Compare commits
12 Commits
e401a1bf4c
...
b08325a53c
Author | SHA1 | Date |
---|---|---|
|
b08325a53c | |
|
a1f7108bc5 | |
|
2e4d5df17a | |
|
4fcd852d8d | |
|
0f05656ca2 | |
|
0bec3c6590 | |
|
8eee99fce5 | |
|
239e2d778a | |
|
cc01b23e2a | |
|
0b502188af | |
|
e38fbc65bd | |
|
0e47b99ca7 |
|
@ -24,8 +24,11 @@ CRON_EVERY_HOUR="0 * * * *"
|
||||||
|
|
||||||
EMAIL_HOST=smtp.gmail.com
|
EMAIL_HOST=smtp.gmail.com
|
||||||
EMAIL_POST=465
|
EMAIL_POST=465
|
||||||
EMAIL_USER=developer@eigen.co.id
|
EMAIL_USER=weplayground.app@gmail.com
|
||||||
EMAIL_TOKEN=bitqkbkzjzfywxqx
|
EMAIL_TOKEN=sonvvwiukhsevtmv
|
||||||
|
|
||||||
|
// nama email yang akan muncul ke user sebagai pengirim
|
||||||
|
EMAIL_SENDER=no-reply@eigen.co.id
|
||||||
|
|
||||||
MIDTRANS_URL=https://app.sandbox.midtrans.com
|
MIDTRANS_URL=https://app.sandbox.midtrans.com
|
||||||
MIDTRANS_PRODUCTION=false
|
MIDTRANS_PRODUCTION=false
|
||||||
|
|
|
@ -145,7 +145,6 @@ export const PrivilegePOSConstant = [
|
||||||
actions: [
|
actions: [
|
||||||
PrivilegeAction.VIEW,
|
PrivilegeAction.VIEW,
|
||||||
PrivilegeAction.CREATE,
|
PrivilegeAction.CREATE,
|
||||||
PrivilegeAction.DELETE,
|
|
||||||
PrivilegeAction.EDIT,
|
PrivilegeAction.EDIT,
|
||||||
PrivilegeAction.CANCEL,
|
PrivilegeAction.CANCEL,
|
||||||
],
|
],
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class UpdateTypeColumnItemTable1722587128195
|
||||||
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'UpdateTypeColumnItemTable1722587128195';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "sales_margin"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" ADD "sales_margin" numeric`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "sales_margin"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "items" ADD "sales_margin" integer`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class UpdateTableTransaction1722595038215 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableTransaction1722595038215';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TYPE "public"."transactions_payment_type_counter_enum" AS ENUM('midtrans', 'bank transfer', 'qris', 'counter', 'cash', 'credit card', 'debit', 'e-money')`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "transactions" ADD "payment_type_counter" "public"."transactions_payment_type_counter_enum"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "transactions" DROP COLUMN "payment_type_counter"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`DROP TYPE "public"."transactions_payment_type_counter_enum"`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,8 +38,11 @@ export class BookingHandler
|
||||||
const old_data = event.data.old;
|
const old_data = event.data.old;
|
||||||
const data = event.data.data;
|
const data = event.data.data;
|
||||||
|
|
||||||
if (data.payment_type != TransactionPaymentType.COUNTER) return;
|
if (
|
||||||
|
data.payment_type == TransactionPaymentType.COUNTER ||
|
||||||
|
([STATUS.ACTIVE, STATUS.SETTLED].includes(data.status) &&
|
||||||
|
data.payment_type != TransactionPaymentType.COUNTER)
|
||||||
|
) {
|
||||||
const booking = await this.bookingService.getOneByOptions({
|
const booking = await this.bookingService.getOneByOptions({
|
||||||
where: {
|
where: {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
|
@ -50,8 +53,9 @@ export class BookingHandler
|
||||||
mappingTransaction(booking);
|
mappingTransaction(booking);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
old_data?.status != data.status &&
|
(old_data?.status != data.status ||
|
||||||
[STATUS.PENDING, STATUS.ACTIVE].includes(data.status)
|
data.payment_type != TransactionPaymentType.COUNTER) &&
|
||||||
|
[STATUS.PENDING, STATUS.ACTIVE, STATUS.SETTLED].includes(data.status)
|
||||||
) {
|
) {
|
||||||
await this.couchService.createDoc(
|
await this.couchService.createDoc(
|
||||||
{
|
{
|
||||||
|
@ -70,4 +74,5 @@ export class BookingHandler
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,12 @@ export async function CreateEventCalendarHelper(
|
||||||
|
|
||||||
function mappingData(transaction) {
|
function mappingData(transaction) {
|
||||||
return {
|
return {
|
||||||
summary: transaction.invoice_code,
|
summary: transaction.customer_name ?? transaction.invoice_code,
|
||||||
description: `Booking for invoice ${transaction.invoice_code}`,
|
description: `<b>Booking for invoice ${
|
||||||
|
transaction.invoice_code
|
||||||
|
}</b><p>List Items :</p><ul>${transaction.items.map(
|
||||||
|
(item) => `<li>${item.item_name}</li>`,
|
||||||
|
)}</ul>`,
|
||||||
start: {
|
start: {
|
||||||
dateTime: new Date(transaction.booking_date).toISOString(),
|
dateTime: new Date(transaction.booking_date).toISOString(),
|
||||||
timeZone: 'Asia/Jakarta',
|
timeZone: 'Asia/Jakarta',
|
||||||
|
|
|
@ -20,9 +20,9 @@ export async function sendEmail(receivers, subject) {
|
||||||
if (receiver.payment_type == TransactionPaymentType.MIDTRANS)
|
if (receiver.payment_type == TransactionPaymentType.MIDTRANS)
|
||||||
templateName = 'payment-confirmation-midtrans';
|
templateName = 'payment-confirmation-midtrans';
|
||||||
|
|
||||||
let templatePath = path.resolve(
|
let templatePath = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
`../email-template/${ templateName }.html`,
|
`../email-template/${templateName}.html`,
|
||||||
);
|
);
|
||||||
templatePath = templatePath.replace(/dist/g, 'src');
|
templatePath = templatePath.replace(/dist/g, 'src');
|
||||||
const templateSource = fs.readFileSync(templatePath, 'utf8');
|
const templateSource = fs.readFileSync(templatePath, 'utf8');
|
||||||
|
@ -31,7 +31,7 @@ export async function sendEmail(receivers, subject) {
|
||||||
const htmlToSend = template(receiver);
|
const htmlToSend = template(receiver);
|
||||||
|
|
||||||
const emailContext = {
|
const emailContext = {
|
||||||
from: 'no-reply@eigen.co.id',
|
from: process.env.EMAIL_SENDER ?? 'no-reply@weplayground.app',
|
||||||
to: receiver.email,
|
to: receiver.email,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
html: htmlToSend,
|
html: htmlToSend,
|
||||||
|
@ -42,13 +42,13 @@ export async function sendEmail(receivers, subject) {
|
||||||
|
|
||||||
smtpTransport.sendMail(emailContext, function (err, data) {
|
smtpTransport.sendMail(emailContext, function (err, data) {
|
||||||
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 {
|
||||||
console.log(`Email sent to ${ receiver.email }`);
|
console.log(`Email sent to ${receiver.email}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error, `Error occurs on send to ${ receiver.email }`)
|
console.log(error, `Error occurs on send to ${receiver.email}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
import { Controller, Get, Injectable } from '@nestjs/common';
|
||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import { Public } from 'src/core/guards';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
@ApiTags(`email templates`)
|
||||||
|
@Controller('v1/email-templates')
|
||||||
|
@Public()
|
||||||
|
@Injectable()
|
||||||
|
export class MailTemplateController {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
getTemplate(templateName) {
|
||||||
|
const templatePath = path.join(
|
||||||
|
__dirname,
|
||||||
|
'../../../../../',
|
||||||
|
`src/modules/configuration/mail/domain/email-template/${templateName}.html`,
|
||||||
|
);
|
||||||
|
return fs.readFileSync(templatePath, 'utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('date-change')
|
||||||
|
async getDateChange() {
|
||||||
|
return this.getTemplate('change-date');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('invoice')
|
||||||
|
async getBookingInvoice() {
|
||||||
|
return this.getTemplate('invoice');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('payment-confirmation-bank')
|
||||||
|
async getPaymentConfirmation() {
|
||||||
|
return this.getTemplate('payment-confirmation-bank');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('payment-confirmation-midtrans')
|
||||||
|
async getPaymentConfirmationMidtrans() {
|
||||||
|
return this.getTemplate('payment-confirmation-midtrans');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('invoice-expired')
|
||||||
|
async getInvoiceExpired() {
|
||||||
|
return this.getTemplate('invoice-expired');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('refund-confirmation')
|
||||||
|
async getRefundConfirmation() {
|
||||||
|
return this.getTemplate('refund-confirmation');
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('refund-request')
|
||||||
|
async getRefundRequest() {
|
||||||
|
return this.getTemplate('refunr-request');
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
import { TransactionDataService } from 'src/modules/transaction/transaction/data/services/transaction-data.service';
|
import { TransactionDataService } from 'src/modules/transaction/transaction/data/services/transaction-data.service';
|
||||||
import { PaymentTransactionHandler } from './domain/handlers/payment-transaction.handler';
|
import { PaymentTransactionHandler } from './domain/handlers/payment-transaction.handler';
|
||||||
|
import { MailTemplateController } from './infrastructure/mail.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -18,7 +19,7 @@ import { PaymentTransactionHandler } from './domain/handlers/payment-transaction
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
],
|
],
|
||||||
controllers: [],
|
controllers: [MailTemplateController],
|
||||||
providers: [
|
providers: [
|
||||||
PaymentTransactionHandler,
|
PaymentTransactionHandler,
|
||||||
PaymentMethodDataService,
|
PaymentMethodDataService,
|
||||||
|
|
|
@ -18,7 +18,20 @@ export class MidtransController {
|
||||||
|
|
||||||
@Get(':id/status')
|
@Get(':id/status')
|
||||||
async getStatus(@Param('id') id: string) {
|
async getStatus(@Param('id') id: string) {
|
||||||
return await this.dataService.getStatus(id);
|
try {
|
||||||
|
const data = await this.dataService.getStatus(id);
|
||||||
|
this.eventBus.publishAll([
|
||||||
|
new MidtransCallbackEvent({
|
||||||
|
id: id,
|
||||||
|
data: data,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return 'Berhasil update status transaksi';
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error.message);
|
||||||
|
throw new Error('Gagal update status transaksi');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('callback')
|
@Post('callback')
|
||||||
|
|
|
@ -32,7 +32,10 @@ export class SeasonPeriodHolidayHandler
|
||||||
const rate = new ItemRateModel();
|
const rate = new ItemRateModel();
|
||||||
rate.item_id = event.data.id;
|
rate.item_id = event.data.id;
|
||||||
rate.season_period_id = season.id;
|
rate.season_period_id = season.id;
|
||||||
rate.price = event.data.data.total_price ?? event.data.data.base_price;
|
rate.price =
|
||||||
|
Number(event.data.data.total_price) != 0
|
||||||
|
? event.data.data.total_price
|
||||||
|
: event.data.data.base_price;
|
||||||
|
|
||||||
rates.push(rate);
|
rates.push(rate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class ItemModel
|
||||||
@Column('bigint', { name: 'hpp', nullable: true })
|
@Column('bigint', { name: 'hpp', nullable: true })
|
||||||
hpp: number;
|
hpp: number;
|
||||||
|
|
||||||
@Column('int', { name: 'sales_margin', nullable: true })
|
@Column('decimal', { name: 'sales_margin', nullable: true })
|
||||||
sales_margin: number;
|
sales_margin: number;
|
||||||
|
|
||||||
@Column('bigint', { name: 'total_price', nullable: true })
|
@Column('bigint', { name: 'total_price', nullable: true })
|
||||||
|
|
|
@ -36,7 +36,12 @@ export class ActiveItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
||||||
{
|
{
|
||||||
relation: 'tenant',
|
relation: 'tenant',
|
||||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
message: `Gagal! Belum ada item yang aktif`,
|
message: `Gagal! tenant tidak aktif`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'bundling_items',
|
||||||
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
|
message: `Gagal! Terdapat item yang belum aktif`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,7 @@ import {
|
||||||
import { ItemModel } from '../../../data/models/item.model';
|
import { ItemModel } from '../../../data/models/item.model';
|
||||||
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
import { ItemChangeStatusEvent } from '../../entities/event/item-change-status.event';
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
import {
|
import { Injectable } from '@nestjs/common';
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
UnprocessableEntityException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -33,7 +29,12 @@ export class BatchActiveItemManager extends BaseBatchUpdateStatusManager<ItemEnt
|
||||||
{
|
{
|
||||||
relation: 'tenant',
|
relation: 'tenant',
|
||||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
message: `Gagal! Belum ada item yang aktif`,
|
message: `Gagal! tenant tidak aktif`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'bundling_items',
|
||||||
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
|
message: `Gagal! Terdapat item yang belum aktif`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,12 @@ export class BatchConfirmItemManager extends BaseBatchUpdateStatusManager<ItemEn
|
||||||
{
|
{
|
||||||
relation: 'tenant',
|
relation: 'tenant',
|
||||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
message: `Gagal! Belum ada item yang aktif`,
|
message: `Gagal! tenant tidak aktif`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'bundling_items',
|
||||||
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
|
message: `Gagal! Terdapat item yang belum aktif`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,12 @@ export class ConfirmItemManager extends BaseUpdateStatusManager<ItemEntity> {
|
||||||
{
|
{
|
||||||
relation: 'tenant',
|
relation: 'tenant',
|
||||||
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
message: `Gagal! Belum ada item yang aktif`,
|
message: `Gagal! tenant tidak aktif`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
relation: 'bundling_items',
|
||||||
|
singleQuery: ['status', '!=', STATUS.ACTIVE],
|
||||||
|
message: `Gagal! Terdapat item yang belum aktif`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { HttpStatus, UnprocessableEntityException } from '@nestjs/common';
|
import { HttpStatus, UnprocessableEntityException } from '@nestjs/common';
|
||||||
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
|
import { In } from 'typeorm';
|
||||||
|
|
||||||
export async function validateRelation(dataService, id) {
|
export async function validateRelation(dataService, id) {
|
||||||
const haveRelation = await dataService.getOneByOptions({
|
const haveRelation = await dataService.getOneByOptions({
|
||||||
where: {
|
where: {
|
||||||
|
status: In([STATUS.ACTIVE]),
|
||||||
bundling_items: {
|
bundling_items: {
|
||||||
id: id,
|
id: id,
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,6 +36,7 @@ export class DetailReconciliationManager extends BaseDetailManager<TransactionEn
|
||||||
`${this.tableName}.reconciliation_mdr`,
|
`${this.tableName}.reconciliation_mdr`,
|
||||||
|
|
||||||
`${this.tableName}.payment_type`,
|
`${this.tableName}.payment_type`,
|
||||||
|
`${this.tableName}.payment_type_counter`,
|
||||||
`${this.tableName}.payment_type_method_id`,
|
`${this.tableName}.payment_type_method_id`,
|
||||||
`${this.tableName}.payment_type_method_name`,
|
`${this.tableName}.payment_type_method_name`,
|
||||||
`${this.tableName}.payment_type_method_number`,
|
`${this.tableName}.payment_type_method_number`,
|
||||||
|
|
|
@ -51,6 +51,7 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
|
||||||
`${this.tableName}.invoice_code`,
|
`${this.tableName}.invoice_code`,
|
||||||
`${this.tableName}.booking_date`,
|
`${this.tableName}.booking_date`,
|
||||||
`${this.tableName}.payment_type`,
|
`${this.tableName}.payment_type`,
|
||||||
|
`${this.tableName}.payment_type_counter`,
|
||||||
`${this.tableName}.payment_type_method_id`,
|
`${this.tableName}.payment_type_method_id`,
|
||||||
`${this.tableName}.payment_type_method_name`,
|
`${this.tableName}.payment_type_method_name`,
|
||||||
`${this.tableName}.payment_type_method_number`,
|
`${this.tableName}.payment_type_method_number`,
|
||||||
|
|
|
@ -35,27 +35,24 @@ 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,
|
||||||
type: TransactionType.COUNTER,
|
paymnet_type: TransactionType.COUNTER,
|
||||||
status: STATUS.SETTLED,
|
status: STATUS.SETTLED,
|
||||||
created_at: Between(this.startOfDay, this.endOfDay),
|
created_at: Between(this.startOfDay, this.endOfDay),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const payCounserTransactions = await this.dataService.getManyByOptions({
|
|
||||||
where: {
|
|
||||||
is_recap_transaction: false,
|
|
||||||
payment_code: ILike('%SLS%'),
|
|
||||||
status: STATUS.SETTLED,
|
|
||||||
created_at: Between(this.startOfDay, this.endOfDay),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
transactions.push(...payCounserTransactions);
|
|
||||||
|
|
||||||
for (const transaction of transactions) {
|
for (const transaction of transactions) {
|
||||||
const { creator_counter_no, payment_type, payment_type_method_id } =
|
const {
|
||||||
transaction;
|
creator_counter_no,
|
||||||
|
payment_type_counter,
|
||||||
|
payment_type_method_id,
|
||||||
|
} = transaction;
|
||||||
const group_by =
|
const group_by =
|
||||||
creator_counter_no + '-' + payment_type + '-' + payment_type_method_id;
|
creator_counter_no +
|
||||||
|
'-' +
|
||||||
|
payment_type_counter +
|
||||||
|
'-' +
|
||||||
|
payment_type_method_id;
|
||||||
if (!this.recapTransactions[group_by]) {
|
if (!this.recapTransactions[group_by]) {
|
||||||
this.recapTransactions[group_by] = [];
|
this.recapTransactions[group_by] = [];
|
||||||
}
|
}
|
||||||
|
@ -69,17 +66,20 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
||||||
const total_recap = Object.keys(this.recapTransactions);
|
const total_recap = Object.keys(this.recapTransactions);
|
||||||
for (const recap of total_recap) {
|
for (const recap of total_recap) {
|
||||||
const first_transaction = this.recapTransactions[recap][0];
|
const first_transaction = this.recapTransactions[recap][0];
|
||||||
const { creator_counter_no, payment_type, payment_type_method_id } =
|
const {
|
||||||
first_transaction;
|
creator_counter_no,
|
||||||
|
payment_type_counter,
|
||||||
|
payment_type_method_id,
|
||||||
|
} = first_transaction;
|
||||||
|
|
||||||
let query = {
|
let 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,
|
||||||
payment_type: payment_type,
|
payment_type: payment_type_counter,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (payment_type != 'cash')
|
if (payment_type_counter != 'cash')
|
||||||
query['payment_type_method_id'] = payment_type_method_id ?? EMPTY_UUID;
|
query['payment_type_method_id'] = payment_type_method_id ?? EMPTY_UUID;
|
||||||
|
|
||||||
const exist = await this.dataService.getOneByOptions({
|
const exist = await this.dataService.getOneByOptions({
|
||||||
|
@ -110,7 +110,8 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
|
||||||
booking_date: new Date(),
|
booking_date: new Date(),
|
||||||
payment_date: new Date(),
|
payment_date: new Date(),
|
||||||
creator_counter_no: first_transaction.creator_counter_no,
|
creator_counter_no: first_transaction.creator_counter_no,
|
||||||
payment_type: first_transaction.payment_type,
|
payment_type: first_transaction.payment_type_counter,
|
||||||
|
payment_type_counter: first_transaction.payment_type_counter,
|
||||||
payment_type_method_id: first_transaction.payment_type_method_id,
|
payment_type_method_id: first_transaction.payment_type_method_id,
|
||||||
payment_type_method_number:
|
payment_type_method_number:
|
||||||
first_transaction.payment_type_method_number,
|
first_transaction.payment_type_method_number,
|
||||||
|
|
|
@ -12,25 +12,10 @@ import {
|
||||||
columnUniques,
|
columnUniques,
|
||||||
validateRelations,
|
validateRelations,
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UpdateRefundManager extends BaseUpdateManager<RefundEntity> {
|
export class UpdateRefundManager extends BaseUpdateManager<RefundEntity> {
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
const transaction = await this.dataServiceFirstOpt.getOneByOptions({
|
|
||||||
where: {
|
|
||||||
id: this.data.transaction.id,
|
|
||||||
status: STATUS.SETTLED,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!transaction) {
|
|
||||||
throw new UnprocessableEntityException({
|
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
||||||
message: `Gagal! hanya pemesanan dengan status ${STATUS.SETTLED} yang dapat dikembalikan`,
|
|
||||||
error: 'Unprocessable Entity',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,13 @@ export class TransactionModel
|
||||||
})
|
})
|
||||||
payment_type: TransactionPaymentType;
|
payment_type: TransactionPaymentType;
|
||||||
|
|
||||||
|
@Column('enum', {
|
||||||
|
name: 'payment_type_counter',
|
||||||
|
enum: TransactionPaymentType,
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
payment_type_counter: TransactionPaymentType;
|
||||||
|
|
||||||
@Column('varchar', { name: 'payment_code', nullable: true })
|
@Column('varchar', { name: 'payment_code', nullable: true })
|
||||||
payment_code: string;
|
payment_code: string;
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ export interface TransactionEntity extends BaseStatusEntity {
|
||||||
|
|
||||||
// payment data
|
// payment data
|
||||||
payment_type: TransactionPaymentType;
|
payment_type: TransactionPaymentType;
|
||||||
|
payment_type_counter: TransactionPaymentType;
|
||||||
payment_type_method_id: string;
|
payment_type_method_id: string;
|
||||||
payment_type_method_name: string;
|
payment_type_method_name: string;
|
||||||
payment_type_method_number: string;
|
payment_type_method_number: string;
|
||||||
|
|
|
@ -37,8 +37,7 @@ export class SettledTransactionHandler
|
||||||
relations: ['items'],
|
relations: ['items'],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!settled || !oldSettled) return;
|
if (settled || oldSettled) {
|
||||||
|
|
||||||
const queryRunner = this.dataService
|
const queryRunner = this.dataService
|
||||||
.getRepository()
|
.getRepository()
|
||||||
.manager.connection.createQueryRunner();
|
.manager.connection.createQueryRunner();
|
||||||
|
@ -69,6 +68,7 @@ export class SettledTransactionHandler
|
||||||
data.payment_total_net_profit ?? 0,
|
data.payment_total_net_profit ?? 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(data, 'dsa');
|
||||||
const google_calendar = await CreateEventCalendarHelper(data);
|
const google_calendar = await CreateEventCalendarHelper(data);
|
||||||
|
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
|
@ -80,6 +80,7 @@ export class SettledTransactionHandler
|
||||||
calendar_link: google_calendar?.htmlLink,
|
calendar_link: google_calendar?.htmlLink,
|
||||||
});
|
});
|
||||||
} else if (oldSettled) {
|
} else if (oldSettled) {
|
||||||
|
console.log(data, 'data oldSettled');
|
||||||
const google_calendar = await CreateEventCalendarHelper(data);
|
const google_calendar = await CreateEventCalendarHelper(data);
|
||||||
|
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
|
@ -90,4 +91,5 @@ export class SettledTransactionHandler
|
||||||
|
|
||||||
await this.dataService.create(queryRunner, TransactionModel, data);
|
await this.dataService.create(queryRunner, TransactionModel, data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { TransactionChangeStatusEvent } from '../../entities/event/transaction-c
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ActiveTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
|
export class ActiveTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
|
||||||
getResult(): string {
|
getResult(): string {
|
||||||
return `Success active data ${this.result.invoice_code}`;
|
return `Success ${this.dataStatus} data ${this.result.invoice_code}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
|
|
|
@ -16,11 +16,11 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CancelTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
|
export class CancelTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
|
||||||
getResult(): string {
|
getResult(): string {
|
||||||
return `Success active data ${this.result.invoice_code}`;
|
return `Success ${this.dataStatus} data ${this.result.invoice_code}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
if (![STATUS.EXPIRED, STATUS.PENDING].includes(this.data.status)) {
|
if (![STATUS.EXPIRED, STATUS.PENDING].includes(this.oldData.status)) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
message: `Gagal! hanya tranksaksi dengan status ${STATUS.PENDING} dan ${STATUS.EXPIRED} yang dapat di${this.dataStatus}`,
|
message: `Gagal! hanya tranksaksi dengan status ${STATUS.PENDING} dan ${STATUS.EXPIRED} yang dapat di${this.dataStatus}`,
|
||||||
|
|
|
@ -67,6 +67,7 @@ export class DetailTransactionManager extends BaseDetailManager<TransactionEntit
|
||||||
`${this.tableName}.discount_value`,
|
`${this.tableName}.discount_value`,
|
||||||
|
|
||||||
`${this.tableName}.payment_type`,
|
`${this.tableName}.payment_type`,
|
||||||
|
`${this.tableName}.payment_type_counter`,
|
||||||
`${this.tableName}.payment_date`,
|
`${this.tableName}.payment_date`,
|
||||||
`${this.tableName}.payment_total_pay`,
|
`${this.tableName}.payment_total_pay`,
|
||||||
`${this.tableName}.payment_type_method_id`,
|
`${this.tableName}.payment_type_method_id`,
|
||||||
|
|
|
@ -98,6 +98,7 @@ export function mappingRevertTransaction(data, type) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
|
type: type,
|
||||||
creator_id: data.pos_admin?.id,
|
creator_id: data.pos_admin?.id,
|
||||||
creator_name: data.pos_admin?.name,
|
creator_name: data.pos_admin?.name,
|
||||||
invoice_code: data.code,
|
invoice_code: data.code,
|
||||||
|
@ -107,11 +108,11 @@ export function mappingRevertTransaction(data, type) {
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
id: data.booking_id ?? data._id,
|
id: data.booking_id ?? data._id,
|
||||||
creator_counter_no: Number(data.pos_number),
|
creator_counter_no: Number(data.pos_number),
|
||||||
status: STATUS.SETTLED,
|
|
||||||
settlement_date: new Date(data.created_at),
|
settlement_date: new Date(data.created_at),
|
||||||
payment_date: new Date(data.created_at),
|
payment_date: new Date(data.created_at),
|
||||||
invoice_date: new Date(data.created_at),
|
invoice_date: new Date(data.created_at),
|
||||||
payment_type:
|
payment_type: TransactionPaymentType.COUNTER,
|
||||||
|
payment_type_counter:
|
||||||
data.payment_type == 'cc'
|
data.payment_type == 'cc'
|
||||||
? TransactionPaymentType.CC
|
? TransactionPaymentType.CC
|
||||||
: data.payment_type,
|
: data.payment_type,
|
||||||
|
@ -122,13 +123,12 @@ export function mappingRevertTransaction(data, type) {
|
||||||
discount_percentage: data.discount_code?.discount,
|
discount_percentage: data.discount_code?.discount,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Object.assign(data, {
|
Object.assign(data, {
|
||||||
// payment_type:
|
type: type,
|
||||||
// })
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
type: type,
|
|
||||||
payment_total_net_profit: data.payment_total,
|
payment_total_net_profit: data.payment_total,
|
||||||
customer_category_id: data.customer_category?.id ?? null,
|
customer_category_id: data.customer_category?.id ?? null,
|
||||||
customer_category_name: data.customer_category?.name ?? null,
|
customer_category_name: data.customer_category?.name ?? null,
|
||||||
|
|
|
@ -75,6 +75,7 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
||||||
`${this.tableName}.payment_code`,
|
`${this.tableName}.payment_code`,
|
||||||
`${this.tableName}.payment_card_information`,
|
`${this.tableName}.payment_card_information`,
|
||||||
`${this.tableName}.payment_type`,
|
`${this.tableName}.payment_type`,
|
||||||
|
`${this.tableName}.payment_type_counter`,
|
||||||
`${this.tableName}.payment_date`,
|
`${this.tableName}.payment_date`,
|
||||||
`${this.tableName}.payment_total_pay`,
|
`${this.tableName}.payment_total_pay`,
|
||||||
`${this.tableName}.payment_type_method_id`,
|
`${this.tableName}.payment_type_method_id`,
|
||||||
|
|
Loading…
Reference in New Issue