Merge branch 'development' of ssh://git.eigen.co.id:2222/eigen/pos-be into feat/report
commit
26db7d2745
|
@ -12,5 +12,6 @@ COPY env/$env_target /app/.env
|
||||||
COPY --from=builder /app/env/$env_target .env
|
COPY --from=builder /app/env/$env_target .env
|
||||||
COPY --from=builder /app/node_modules ./node_modules
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY --from=builder /app/assets ./assets
|
||||||
COPY --from=builder /app/package.json ./package.json
|
COPY --from=builder /app/package.json ./package.json
|
||||||
CMD ["node", "--max-old-space-size=8192","--max-http-header-size", "512000", "-r", "dotenv/config", "dist/main"]
|
CMD ["node", "--max-old-space-size=8192","--max-http-header-size", "512000", "-r", "dotenv/config", "dist/main"]
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
|
@ -1,20 +1,20 @@
|
||||||
import { InvoiceTempalte } from '../invoice.template';
|
import { InvoiceTemplate } from '../invoice.template';
|
||||||
const PdfPrinter = require('pdfmake');
|
import * as PdfPrinter from 'pdfmake';
|
||||||
const { PassThrough } = require('stream');
|
import { PassThrough } from 'stream';
|
||||||
|
|
||||||
export async function GeneratePdf(transaction, invoiceType, banks) {
|
export async function GeneratePdf(transaction, invoiceType, banks) {
|
||||||
var fonts = {
|
const fonts = {
|
||||||
Roboto: {
|
Roboto: {
|
||||||
normal: './fonts/Roboto-Regular.ttf',
|
normal: './assets/fonts/Roboto-Regular.ttf',
|
||||||
bold: './fonts/Roboto-Medium.ttf',
|
bold: './assets/fonts/Roboto-Medium.ttf',
|
||||||
italics: './fonts/Roboto-Italic.ttf',
|
italics: './assets/fonts/Roboto-Italic.ttf',
|
||||||
bolditalics: './fonts/Roboto-MediumItalic.ttf',
|
bolditalics: './assets/fonts/Roboto-MediumItalic.ttf',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const printer = new PdfPrinter(fonts);
|
const printer = new PdfPrinter(fonts);
|
||||||
|
|
||||||
const docDefinition = InvoiceTempalte(transaction, invoiceType, banks);
|
const docDefinition = InvoiceTemplate(transaction, invoiceType, banks);
|
||||||
|
|
||||||
const createPdfBuffer = (docDefinition) => {
|
const createPdfBuffer = (docDefinition) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -11,12 +11,12 @@ import { InvoiceType } from '../../constants';
|
||||||
import { PaymentMethodEntity } from 'src/modules/transaction/payment-method/domain/entities/payment-method.entity';
|
import { PaymentMethodEntity } from 'src/modules/transaction/payment-method/domain/entities/payment-method.entity';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
export function InvoiceTempalte(
|
export function InvoiceTemplate(
|
||||||
transaction: TransactionEntity,
|
transaction: TransactionEntity,
|
||||||
invoiceType: InvoiceType,
|
invoiceType: InvoiceType,
|
||||||
banks: PaymentMethodEntity[],
|
banks: PaymentMethodEntity[],
|
||||||
) {
|
) {
|
||||||
const filePath = './image/logo.jpeg';
|
const filePath = './assets/image/logo.jpeg';
|
||||||
const imageBase64 = fs.readFileSync(filePath).toString('base64');
|
const imageBase64 = fs.readFileSync(filePath).toString('base64');
|
||||||
const imageUrl = `data:image/png;base64,${imageBase64}`;
|
const imageUrl = `data:image/png;base64,${imageBase64}`;
|
||||||
|
|
||||||
|
@ -52,37 +52,37 @@ export function InvoiceTempalte(
|
||||||
{
|
{
|
||||||
layout: {
|
layout: {
|
||||||
defaultBorder: false,
|
defaultBorder: false,
|
||||||
hLineWidth: function (i, node) {
|
hLineWidth: function () {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
vLineWidth: function (i, node) {
|
vLineWidth: function () {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
hLineColor: function (i, node) {
|
hLineColor: function (i) {
|
||||||
return i === 0 ? '#000000' : '#eaeaea';
|
return i === 0 ? '#000000' : '#eaeaea';
|
||||||
},
|
},
|
||||||
vLineColor: function (i, node) {
|
vLineColor: function () {
|
||||||
return '#eaeaea';
|
return '#eaeaea';
|
||||||
},
|
},
|
||||||
hLineStyle: function (i, node) {
|
hLineStyle: function () {
|
||||||
// if (i === 0 || i === node.table.body.length) {
|
// if (i === 0 || i === node.table.body.length) {
|
||||||
return null;
|
return null;
|
||||||
//}
|
//}
|
||||||
},
|
},
|
||||||
// vLineStyle: function (i, node) { return {dash: { length: 10, space: 4 }}; },
|
// vLineStyle: function (i, node) { return {dash: { length: 10, space: 4 }}; },
|
||||||
paddingLeft: function (i, node) {
|
paddingLeft: function () {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
paddingRight: function (i, node) {
|
paddingRight: function () {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
paddingTop: function (i, node) {
|
paddingTop: function () {
|
||||||
return 3;
|
return 3;
|
||||||
},
|
},
|
||||||
paddingBottom: function (i, node) {
|
paddingBottom: function () {
|
||||||
return 3;
|
return 3;
|
||||||
},
|
},
|
||||||
fillColor: function (rowIndex, node, columnIndex) {
|
fillColor: function () {
|
||||||
return '#fff';
|
return '#fff';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -95,37 +95,37 @@ export function InvoiceTempalte(
|
||||||
{
|
{
|
||||||
layout: {
|
layout: {
|
||||||
defaultBorder: false,
|
defaultBorder: false,
|
||||||
hLineWidth: function (i, node) {
|
hLineWidth: function () {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
vLineWidth: function (i, node) {
|
vLineWidth: function () {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
hLineColor: function (i, node) {
|
hLineColor: function (i) {
|
||||||
return i === 3 ? '#000000' : '#eaeaea';
|
return i === 3 ? '#000000' : '#eaeaea';
|
||||||
},
|
},
|
||||||
vLineColor: function (i, node) {
|
vLineColor: function () {
|
||||||
return '#eaeaea';
|
return '#eaeaea';
|
||||||
},
|
},
|
||||||
hLineStyle: function (i, node) {
|
hLineStyle: function () {
|
||||||
// if (i === 0 || i === node.table.body.length) {
|
// if (i === 0 || i === node.table.body.length) {
|
||||||
return null;
|
return null;
|
||||||
//}
|
//}
|
||||||
},
|
},
|
||||||
// vLineStyle: function (i, node) { return {dash: { length: 10, space: 4 }}; },
|
// vLineStyle: function () { return {dash: { length: 10, space: 4 }}; },
|
||||||
paddingLeft: function (i, node) {
|
paddingLeft: function () {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
paddingRight: function (i, node) {
|
paddingRight: function () {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
paddingTop: function (i, node) {
|
paddingTop: function () {
|
||||||
return 3;
|
return 3;
|
||||||
},
|
},
|
||||||
paddingBottom: function (i, node) {
|
paddingBottom: function (i) {
|
||||||
return i === 2 ? 20 : 3;
|
return i === 2 ? 20 : 3;
|
||||||
},
|
},
|
||||||
fillColor: function (rowIndex, node, columnIndex) {
|
fillColor: function () {
|
||||||
return '#fff';
|
return '#fff';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -145,37 +145,37 @@ export function InvoiceTempalte(
|
||||||
{
|
{
|
||||||
layout: {
|
layout: {
|
||||||
defaultBorder: false,
|
defaultBorder: false,
|
||||||
hLineWidth: function (i, node) {
|
hLineWidth: function () {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
vLineWidth: function (i, node) {
|
vLineWidth: function () {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
hLineColor: function (i, node) {
|
hLineColor: function (i) {
|
||||||
return i === 0 ? '#000000' : '#eaeaea';
|
return i === 0 ? '#000000' : '#eaeaea';
|
||||||
},
|
},
|
||||||
vLineColor: function (i, node) {
|
vLineColor: function () {
|
||||||
return '#eaeaea';
|
return '#eaeaea';
|
||||||
},
|
},
|
||||||
hLineStyle: function (i, node) {
|
hLineStyle: function () {
|
||||||
// if (i === 0 || i === node.table.body.length) {
|
// if (i === 0 || i === node.table.body.length) {
|
||||||
return null;
|
return null;
|
||||||
//}
|
//}
|
||||||
},
|
},
|
||||||
// vLineStyle: function (i, node) { return {dash: { length: 10, space: 4 }}; },
|
// vLineStyle: function () { return {dash: { length: 10, space: 4 }}; },
|
||||||
paddingLeft: function (i, node) {
|
paddingLeft: function () {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
paddingRight: function (i, node) {
|
paddingRight: function () {
|
||||||
return 10;
|
return 10;
|
||||||
},
|
},
|
||||||
paddingTop: function (i, node) {
|
paddingTop: function () {
|
||||||
return 20;
|
return 20;
|
||||||
},
|
},
|
||||||
paddingBottom: function (i, node) {
|
paddingBottom: function () {
|
||||||
return 3;
|
return 3;
|
||||||
},
|
},
|
||||||
fillColor: function (rowIndex, node, columnIndex) {
|
fillColor: function () {
|
||||||
return '#fff';
|
return '#fff';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as nodemailer from 'nodemailer';
|
import * as nodemailer from 'nodemailer';
|
||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as path from 'path';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { TransactionPaymentType } from 'src/modules/transaction/transaction/constants';
|
import { TransactionPaymentType } from 'src/modules/transaction/transaction/constants';
|
||||||
import { InvoiceType } from 'src/modules/configuration/export/constants';
|
import { InvoiceType } from 'src/modules/configuration/export/constants';
|
||||||
|
@ -18,11 +17,7 @@ export async function sendEmail(receivers, invoiceType, attachment?) {
|
||||||
for (const receiver of receivers) {
|
for (const receiver of receivers) {
|
||||||
try {
|
try {
|
||||||
const templateName = getTemplate(receiver.payment_type, invoiceType);
|
const templateName = getTemplate(receiver.payment_type, invoiceType);
|
||||||
let templatePath = path.join(
|
const templatePath = `./assets/email-template/${templateName}.html`;
|
||||||
__dirname,
|
|
||||||
`../email-template/${templateName}.html`,
|
|
||||||
);
|
|
||||||
templatePath = templatePath.replace(/dist/g, 'src');
|
|
||||||
const templateSource = fs.readFileSync(templatePath, 'utf8');
|
const templateSource = fs.readFileSync(templatePath, 'utf8');
|
||||||
|
|
||||||
const template = handlebars.compile(templateSource);
|
const template = handlebars.compile(templateSource);
|
||||||
|
@ -44,7 +39,7 @@ export async function sendEmail(receivers, invoiceType, attachment?) {
|
||||||
|
|
||||||
await new Promise((f) => setTimeout(f, 2000));
|
await new Promise((f) => setTimeout(f, 2000));
|
||||||
|
|
||||||
smtpTransport.sendMail(emailContext, function (err, data) {
|
smtpTransport.sendMail(emailContext, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err, `Error occurs on send to ${receiver.email}`);
|
console.log(err, `Error occurs on send to ${receiver.email}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,8 +9,6 @@ import * as fs from 'fs';
|
||||||
@Public()
|
@Public()
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MailTemplateController {
|
export class MailTemplateController {
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
getTemplate(templateName) {
|
getTemplate(templateName) {
|
||||||
const templatePath = path.join(
|
const templatePath = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
@ -52,6 +50,6 @@ export class MailTemplateController {
|
||||||
|
|
||||||
@Get('refund-request')
|
@Get('refund-request')
|
||||||
async getRefundRequest() {
|
async getRefundRequest() {
|
||||||
return this.getTemplate('refunr-request');
|
return this.getTemplate('refund-request');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
||||||
import { Between, ILike } from 'typeorm';
|
import { Between } from 'typeorm';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import { EMPTY_UUID, STATUS } from 'src/core/strings/constants/base.constants';
|
import { EMPTY_UUID, STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
|
@ -35,7 +35,7 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
||||||
const transactions = await this.dataService.getManyByOptions({
|
const transactions = await this.dataService.getManyByOptions({
|
||||||
where: {
|
where: {
|
||||||
is_recap_transaction: false,
|
is_recap_transaction: false,
|
||||||
paymnet_type: TransactionType.COUNTER,
|
payment_type: TransactionType.COUNTER,
|
||||||
status: STATUS.SETTLED,
|
status: STATUS.SETTLED,
|
||||||
created_at: Between(this.startOfDay, this.endOfDay),
|
created_at: Between(this.startOfDay, this.endOfDay),
|
||||||
},
|
},
|
||||||
|
@ -72,7 +72,7 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
||||||
payment_type_method_id,
|
payment_type_method_id,
|
||||||
} = first_transaction;
|
} = first_transaction;
|
||||||
|
|
||||||
let query = {
|
const query = {
|
||||||
is_recap_transaction: true,
|
is_recap_transaction: true,
|
||||||
created_at: Between(this.startOfDay, this.endOfDay),
|
created_at: Between(this.startOfDay, this.endOfDay),
|
||||||
creator_counter_no: creator_counter_no,
|
creator_counter_no: creator_counter_no,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { FormulaType } from 'src/modules/transaction/sales-price-formula/constan
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||||
import { mappingRevertTransaction } from '../managers/helpers/mapping-transaction.helper';
|
import { mappingRevertTransaction } from '../managers/helpers/mapping-transaction.helper';
|
||||||
|
import { apm } from '../../../../../../core/apm';
|
||||||
|
|
||||||
@EventsHandler(ChangeDocEvent)
|
@EventsHandler(ChangeDocEvent)
|
||||||
export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
||||||
|
@ -77,6 +78,7 @@ export class PosTransactionHandler implements IEventHandler<ChangeDocEvent> {
|
||||||
await this.dataService.create(queryRunner, TransactionModel, data);
|
await this.dataService.create(queryRunner, TransactionModel, data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
apm.captureError(error);
|
||||||
console.log('error handling pos transaction couch');
|
console.log('error handling pos transaction couch');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,8 @@ export class CancelTransactionManager extends BaseUpdateStatusManager<Transactio
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
async beforeProcess(): Promise<void> {
|
||||||
const freeTransaction = this.data.payment_total < 1;
|
|
||||||
Object.assign(this.data, {
|
Object.assign(this.data, {
|
||||||
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
status: STATUS.CANCEL,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import { BatchConfirmDataTransactionManager } from './managers/batch-confirm-dat
|
||||||
import { MidtransService } from 'src/modules/configuration/midtrans/data/services/midtrans.service';
|
import { MidtransService } from 'src/modules/configuration/midtrans/data/services/midtrans.service';
|
||||||
import { PdfMakeManager } from 'src/modules/configuration/export/domain/managers/pdf-make.manager';
|
import { PdfMakeManager } from 'src/modules/configuration/export/domain/managers/pdf-make.manager';
|
||||||
import { PaymentMethodDataService } from 'src/modules/transaction/payment-method/data/services/payment-method-data.service';
|
import { PaymentMethodDataService } from 'src/modules/transaction/payment-method/data/services/payment-method-data.service';
|
||||||
import { InvoiceType } from 'src/modules/configuration/export/constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TransactionDataOrchestrator {
|
export class TransactionDataOrchestrator {
|
||||||
|
|
Loading…
Reference in New Issue