Compare commits
No commits in common. "f4969a837c0cbd0ffff5f6ef83796e279860ee37" and "0df0f30de5e75a5d31758fd24b4a642955170ef5" have entirely different histories.
f4969a837c
...
0df0f30de5
|
@ -6,8 +6,6 @@ JWT_REFRESH_EXPIRES="7d"
|
|||
ENC_KEY="921c83f3b90c92dca4ba9b947f99b4c9"
|
||||
IV="a671a96159e97a4f"
|
||||
|
||||
COUCHDB_CONFIG="http://root:password@172.10.10.2:5970"
|
||||
|
||||
DEFAULT_DB_HOST="postgres"
|
||||
DEFAULT_DB_PORT="5432"
|
||||
DEFAULT_DB_USER="root"
|
||||
|
@ -18,14 +16,4 @@ ELASTIC_APM_ACTIVATE=true
|
|||
ELASTIC_APM_SERVICE_NAME="Skyworld POS"
|
||||
ELASTIC_APM_SERVER_URL="http://172.10.10.10:8200"
|
||||
|
||||
CRON_MIDNIGHT="55 11 * * *"
|
||||
CRON_EVERY_MINUTE="55 11 * * *"
|
||||
CRON_EVERY_HOUR="0 * * * *"
|
||||
|
||||
MIDTRANS_URL=https://app.sandbox.midtrans.com
|
||||
MIDTRANS_PRODUCTION=false
|
||||
MIDTRANS_SERVER_KEY=SB-Mid-server-ITmSD6C0nXfIcmgi4TXm6J7i
|
||||
MIDTRANS_CLIENT_KEY=SB-Mid-client-VFaU_cPL6kh2DKir
|
||||
|
||||
EXPORT_LIMIT_PARTITION=200
|
||||
ASSETS="https://asset.sky.eigen.co.id/"
|
||||
EXPORT_LIMIT_PARTITION=200
|
|
@ -1,31 +0,0 @@
|
|||
PORT="3346"
|
||||
|
||||
JWT_SECRET="ftyYM4t4kjuj/0ixvIrS18gpdvBJw42NnW71GrFrEhcn0alQkkH7TQIHU5MFFJ1e"
|
||||
JWT_EXPIRES="24h"
|
||||
JWT_REFRESH_EXPIRES="7d"
|
||||
ENC_KEY="921c83f3b90c92dca4ba9b947f99b4c9"
|
||||
IV="a671a96159e97a4f"
|
||||
|
||||
COUCHDB_CONFIG="http://root:password@172.10.10.2:5970"
|
||||
|
||||
DEFAULT_DB_HOST="postgres"
|
||||
DEFAULT_DB_PORT="5432"
|
||||
DEFAULT_DB_USER="root"
|
||||
DEFAULT_DB_PASS="password"
|
||||
DEFAULT_DB_NAME="pos"
|
||||
|
||||
ELASTIC_APM_ACTIVATE=true
|
||||
ELASTIC_APM_SERVICE_NAME="Skyworld POS"
|
||||
ELASTIC_APM_SERVER_URL="http://172.10.10.10:8200"
|
||||
|
||||
CRON_MIDNIGHT="55 11 * * *"
|
||||
CRON_EVERY_MINUTE="55 11 * * *"
|
||||
CRON_EVERY_HOUR="0 * * * *"
|
||||
|
||||
MIDTRANS_URL=https://app.midtrans.com
|
||||
MIDTRANS_PRODUCTION=true
|
||||
MIDTRANS_SERVER_KEY=Mid-server-6lA4Nnmov2BSOcwVq1sLSOpC
|
||||
MIDTRANS_CLIENT_KEY=Mid-client-JiPIkIPd_RGooF8U
|
||||
|
||||
EXPORT_LIMIT_PARTITION=200
|
||||
ASSETS="https://asset.sky.eigen.co.id/"
|
|
@ -1,42 +0,0 @@
|
|||
## Formula Calculation
|
||||
|
||||
### Instalation
|
||||
```
|
||||
yarn add mathjs algebra.js
|
||||
```
|
||||
|
||||
|
||||
### Example
|
||||
```ts
|
||||
import * as math from 'mathjs'
|
||||
import { Equation, parse } from 'algebra.js'
|
||||
|
||||
const formula = 'dpp - (dpp*ppn) - (dpp*retribusi) - (dpp*service) - (dpp*ppn3)'
|
||||
const total = '300000'
|
||||
|
||||
const variable = {
|
||||
ppn: 11,
|
||||
retribusi: 5000,
|
||||
service: 5,
|
||||
ppn3: 5000
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
const x1 = math.simplify(formula, variable).toString()
|
||||
console.log('Formula ', x1)
|
||||
const dppFormula = parse(x1)
|
||||
const totalFormula = parse(total)
|
||||
const equation = new Equation(totalFormula, dppFormula)
|
||||
|
||||
console.log(equation.toString())
|
||||
const result = equation.solveFor('dpp').toString()
|
||||
console.log(result)
|
||||
|
||||
const value = math.evaluate(result)
|
||||
console.log(value)
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
```
|
|
@ -37,7 +37,6 @@
|
|||
"@nestjs/schedule": "^4.1.0",
|
||||
"@nestjs/swagger": "^7.3.1",
|
||||
"@nestjs/typeorm": "^10.0.2",
|
||||
"algebra.js": "^0.2.6",
|
||||
"bcrypt": "^5.1.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.1",
|
||||
|
@ -45,8 +44,6 @@
|
|||
"elastic-apm-node": "^4.5.4",
|
||||
"exceljs": "^4.4.0",
|
||||
"googleapis": "^140.0.0",
|
||||
"mathjs": "^13.0.2",
|
||||
"midtrans-client": "^1.3.1",
|
||||
"moment": "^2.30.1",
|
||||
"nano": "^10.1.3",
|
||||
"pg": "^8.11.5",
|
||||
|
|
|
@ -54,7 +54,6 @@ import { ReportExportModule } from './modules/reports/report-export/report-expor
|
|||
import { ReportBookmarkModel } from './modules/reports/shared/models/report-bookmark.model';
|
||||
import { ExportReportHistoryModel } from './modules/reports/shared/models/export-report-history.model';
|
||||
import { CronModule } from './modules/configuration/cron/cron.module';
|
||||
import { MidtransModule } from './modules/configuration/midtrans/midtrans.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -102,7 +101,6 @@ import { MidtransModule } from './modules/configuration/midtrans/midtrans.module
|
|||
CronModule,
|
||||
GoogleCalendarModule,
|
||||
LogModule,
|
||||
MidtransModule,
|
||||
SessionModule,
|
||||
|
||||
// user
|
||||
|
|
|
@ -61,7 +61,7 @@ export class PrivilegeService {
|
|||
}
|
||||
|
||||
async privilegeConfiguration(): Promise<UserPrivilegeConfigurationEntity> {
|
||||
const { module, menu } = this.moduleKey();
|
||||
const { module, menu, sub_menu, section } = this.moduleKey();
|
||||
return await this.repository.findOne({
|
||||
select: ['id', 'view', 'create', 'edit', 'delete', 'cancel', 'confirm'],
|
||||
where: {
|
||||
|
|
|
@ -25,7 +25,7 @@ export abstract class BaseBatchDeleteManager<Entity> extends BaseManager {
|
|||
async process(): Promise<void> {
|
||||
let totalFailed = 0;
|
||||
let totalSuccess = 0;
|
||||
const messages = [];
|
||||
let messages = [];
|
||||
|
||||
for (const id of this.dataIds) {
|
||||
try {
|
||||
|
|
|
@ -29,7 +29,7 @@ export abstract class BaseBatchUpdateStatusManager<Entity> extends BaseManager {
|
|||
async process(): Promise<void> {
|
||||
let totalFailed = 0;
|
||||
let totalSuccess = 0;
|
||||
const messages = [];
|
||||
let messages = [];
|
||||
|
||||
for (const id of this.dataIds) {
|
||||
try {
|
||||
|
|
|
@ -75,21 +75,11 @@ export abstract class BaseCreateManager<Entity> extends BaseManager {
|
|||
|
||||
if (!this.eventTopics.length) return;
|
||||
for (const topic of this.eventTopics) {
|
||||
let data;
|
||||
if (!topic.data) {
|
||||
data = await this.dataService.getOneByOptions({
|
||||
where: {
|
||||
id: this.result['id'],
|
||||
},
|
||||
relations: topic.relations,
|
||||
});
|
||||
}
|
||||
|
||||
this.eventBus.publishAll([
|
||||
new topic.topic({
|
||||
id: data?.['id'] ?? topic?.data?.['id'],
|
||||
id: this.result['id'],
|
||||
old: null,
|
||||
data: data ?? topic.data,
|
||||
data: topic.data,
|
||||
user: this.user,
|
||||
description: '',
|
||||
module: this.tableName,
|
||||
|
|
|
@ -4,9 +4,9 @@ import { BaseDataOrchestrator } from './base-data.orchestrator';
|
|||
export abstract class BaseDataTransactionOrchestrator<
|
||||
Entity,
|
||||
> extends BaseDataOrchestrator<Entity> {
|
||||
abstract active(dataId: string): Promise<string>;
|
||||
abstract confirm(dataId: string): Promise<string>;
|
||||
abstract inactive(dataId: string): Promise<string>;
|
||||
abstract active(dataId: string): Promise<String>;
|
||||
abstract confirm(dataId: string): Promise<String>;
|
||||
abstract inactive(dataId: string): Promise<String>;
|
||||
abstract batchConfirm(dataIds: string[]): Promise<BatchResult>;
|
||||
abstract batchActive(dataIds: string[]): Promise<BatchResult>;
|
||||
abstract batchInactive(dataIds: string[]): Promise<BatchResult>;
|
||||
|
|
|
@ -3,6 +3,6 @@ import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|||
export abstract class BaseDataOrchestrator<Entity> {
|
||||
abstract create(data: Entity): Promise<Entity>;
|
||||
abstract update(dataId: string, data: Entity): Promise<Entity>;
|
||||
abstract delete(dataId: string): Promise<string>;
|
||||
abstract delete(dataId: string): Promise<String>;
|
||||
abstract batchDelete(dataIds: string[]): Promise<BatchResult>;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export interface validateRelations {
|
|||
|
||||
export interface columnUniques {
|
||||
column: string;
|
||||
query?: any;
|
||||
query?: Object;
|
||||
}
|
||||
|
||||
export interface IEvent<Entity = any> {
|
||||
|
|
|
@ -36,7 +36,7 @@ export class {{pascalCase name}}DataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export class {{pascalCase name}}DataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ export class {{pascalCase name}}DataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ export class {{pascalCase name}}DataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orches
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.deleteManager.execute();
|
||||
|
@ -65,7 +65,7 @@ export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orches
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.activeManager.execute();
|
||||
|
@ -82,7 +82,7 @@ export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orches
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.confirmManager.execute();
|
||||
|
@ -99,7 +99,7 @@ export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orches
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(
|
||||
this.serviceData,
|
||||
|
|
|
@ -36,7 +36,7 @@ export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orches
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.{{constantCase name}});
|
||||
await this.deleteManager.execute();
|
||||
|
|
|
@ -1,29 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableTransaction1720436852936 implements MigrationInterface {
|
||||
name = 'UpdateTableTransaction1720436852936';
|
||||
name = 'UpdateTableTransaction1720436852936'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_taxes" ADD "tax_total_value" numeric`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_taxes" DROP COLUMN "taxt_value"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_taxes" ADD "taxt_value" numeric`,
|
||||
);
|
||||
}
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "transaction_taxes" ADD "tax_total_value" numeric`);
|
||||
await queryRunner.query(`ALTER TABLE "transaction_taxes" DROP COLUMN "taxt_value"`);
|
||||
await queryRunner.query(`ALTER TABLE "transaction_taxes" ADD "taxt_value" numeric`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "transaction_taxes" DROP COLUMN "taxt_value"`);
|
||||
await queryRunner.query(`ALTER TABLE "transaction_taxes" ADD "taxt_value" character varying`);
|
||||
await queryRunner.query(`ALTER TABLE "transaction_taxes" DROP COLUMN "tax_total_value"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_taxes" DROP COLUMN "taxt_value"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_taxes" ADD "taxt_value" character varying`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "transaction_taxes" DROP COLUMN "tax_total_value"`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import { PaymentMethodType } from 'src/modules/transaction/payment-method/consta
|
|||
@Controller('v1/constant')
|
||||
@Public(true)
|
||||
export class ConstantController {
|
||||
constructor() {}
|
||||
|
||||
@Get('master-data-status')
|
||||
async masterDataStatus(): Promise<any> {
|
||||
return [STATUS.ACTIVE, STATUS.DRAFT, STATUS.INACTIVE];
|
||||
|
|
|
@ -1 +1 @@
|
|||
export const DatabaseListen = ['transaction', 'vip_code'];
|
||||
export const DatabaseListen = ['transaction'];
|
||||
|
|
|
@ -37,7 +37,6 @@ import { TransactionDataService } from 'src/modules/transaction/transaction/data
|
|||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||
import { TransactionTaxModel } from 'src/modules/transaction/transaction/data/models/transaction-tax.model';
|
||||
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
||||
import { VipCodeCreatedHandler } from './domain/managers/vip-code.handler';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -60,7 +59,6 @@ import { VipCodeCreatedHandler } from './domain/managers/vip-code.handler';
|
|||
BookingDeletedEvent,
|
||||
PaymentMethodDeletedHandler,
|
||||
PaymentMethodUpdatedHandler,
|
||||
VipCodeCreatedHandler,
|
||||
VipCategoryDeletedHandler,
|
||||
VipCategoryUpdatedHandler,
|
||||
SeasonPeriodDeletedHandler,
|
||||
|
|
|
@ -1,32 +1,21 @@
|
|||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DatabaseListen } from '../../constants';
|
||||
import { EventBus } from '@nestjs/cqrs';
|
||||
import { ChangeDocEvent } from '../../domain/events/change-doc.event';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import * as Nano from 'nano';
|
||||
|
||||
@Injectable()
|
||||
export class CouchService {
|
||||
constructor(
|
||||
private eventBus: EventBus,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
|
||||
get nanoInstance() {
|
||||
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
||||
return Nano(couchConfiguration);
|
||||
}
|
||||
constructor(private eventBus: EventBus) {}
|
||||
|
||||
async onModuleInit() {
|
||||
const nano = this.nanoInstance;
|
||||
const nano = require('nano')('http://root:password@172.10.10.2:5970');
|
||||
for (const database of DatabaseListen) {
|
||||
const db = nano.db.use(database);
|
||||
db.changesReader.start({ includeDocs: true }).on('change', (change) => {
|
||||
this.changeDoc(change, database);
|
||||
});
|
||||
|
||||
Logger.log(`start listen database ${database}`, 'CouchService');
|
||||
console.log(`start listen database ${database}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +31,7 @@ export class CouchService {
|
|||
|
||||
public async createDoc(data, database) {
|
||||
try {
|
||||
const nano = this.nanoInstance;
|
||||
const nano = require('nano')('http://root:password@172.10.10.2:5970');
|
||||
const db = nano.use(database);
|
||||
return await db.insert(data);
|
||||
} catch (error) {}
|
||||
|
@ -50,7 +39,7 @@ export class CouchService {
|
|||
|
||||
public async deleteDoc(data, database) {
|
||||
try {
|
||||
const nano = this.nanoInstance;
|
||||
const nano = require('nano')('http://root:password@172.10.10.2:5970');
|
||||
const db = nano.use(database);
|
||||
const result = await db.get(data.id);
|
||||
await db.destroy(data.id, result._rev);
|
||||
|
@ -59,7 +48,7 @@ export class CouchService {
|
|||
|
||||
public async updateDoc(data, database) {
|
||||
try {
|
||||
const nano = this.nanoInstance;
|
||||
const nano = require('nano')('http://root:password@172.10.10.2:5970');
|
||||
const db = nano.use(database);
|
||||
const result = await db.get(data.id);
|
||||
console.log(result, 'dsa');
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||
import { CouchService } from '../../data/services/couch.service';
|
||||
import { VipCodeCreatedEvent } from 'src/modules/transaction/vip-code/domain/entities/event/vip-code-created.event';
|
||||
|
||||
@EventsHandler(VipCodeCreatedEvent)
|
||||
export class VipCodeCreatedHandler
|
||||
implements IEventHandler<VipCodeCreatedEvent>
|
||||
{
|
||||
constructor(private couchService: CouchService) {}
|
||||
|
||||
async handle(event: VipCodeCreatedEvent) {
|
||||
const data = event.data.data;
|
||||
|
||||
await this.couchService.createDoc(
|
||||
{
|
||||
_id: data.id,
|
||||
...data,
|
||||
},
|
||||
'vip_code',
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,28 +1,19 @@
|
|||
import { Body, Controller, Get, Injectable, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Public } from 'src/core/guards';
|
||||
import { Unprotected } from 'src/core/guards';
|
||||
import * as Nano from 'nano';
|
||||
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@ApiTags(`couch`)
|
||||
@Controller('v1/couch')
|
||||
@Public()
|
||||
@Injectable()
|
||||
@Unprotected()
|
||||
export class CouchDataController {
|
||||
constructor(private configService: ConfigService) {}
|
||||
|
||||
get nanoInstance() {
|
||||
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
||||
return Nano(couchConfiguration);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async createDoc(@Body() entity: CreateUserPrivilegeDto) {
|
||||
try {
|
||||
const n = this.nanoInstance;
|
||||
await n.db.create(entity.name);
|
||||
let n = Nano('http://admin:secret@127.0.0.1:5984');
|
||||
let db = await n.db.create(entity.name);
|
||||
} catch (error) {
|
||||
console.log(error, 'dsa');
|
||||
}
|
||||
|
@ -31,17 +22,17 @@ export class CouchDataController {
|
|||
@Post('doc')
|
||||
async createDocs(@Body() entity: CreateUserPrivilegeDto) {
|
||||
try {
|
||||
const nano = this.nanoInstance;
|
||||
const nano = require('nano')('http://admin:secret@127.0.0.1:5984');
|
||||
const people = nano.db.use('string');
|
||||
console.log(await people.info(), entity);
|
||||
// const data = {
|
||||
// id: '1212',
|
||||
// name: 'dsadas',
|
||||
// };
|
||||
console.log(await people.info());
|
||||
const data = {
|
||||
id: '1212',
|
||||
name: 'dsadas',
|
||||
};
|
||||
// await people.insert(data)
|
||||
|
||||
people.changesReader
|
||||
.start({})
|
||||
.start()
|
||||
.on('change', (change) => {
|
||||
console.log(change);
|
||||
})
|
||||
|
@ -62,10 +53,9 @@ export class CouchDataController {
|
|||
@Get()
|
||||
async getDoc() {
|
||||
try {
|
||||
const n = this.nanoInstance;
|
||||
const people = n.db.get('user');
|
||||
let n = Nano('http://admin:secret@127.0.0.1:5984');
|
||||
const people = n.use('string');
|
||||
|
||||
return people;
|
||||
// return people.get();
|
||||
} catch (error) {
|
||||
console.log(error, 'dsa');
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export class CronMidnightEvent {
|
||||
// constructor(public readonly data: {}) {}
|
||||
constructor(public readonly data: {}) {}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ export class MidnightCronManager {
|
|||
|
||||
console.log('Cron Event executed every 00:00 minutes.', now);
|
||||
|
||||
this.eventBus.publishAll([new CronMidnightEvent()]);
|
||||
this.eventBus.publishAll([new CronMidnightEvent({})]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,5 @@ import { ErrorLogService } from '../../data/services/error-log.service';
|
|||
export class RecordErrorLogHandler implements IEventHandler<RecordErrorLog> {
|
||||
constructor(private dataservice: ErrorLogService) {}
|
||||
|
||||
async handle(event: RecordErrorLog) {
|
||||
// TODO: Implement logic here
|
||||
}
|
||||
async handle(event: RecordErrorLog) {}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,5 @@ import { RecordLog } from '../entities/log.event';
|
|||
|
||||
@EventsHandler(RecordLog)
|
||||
export class RecordLogHandler implements IEventHandler<RecordLog> {
|
||||
async handle(event: RecordLog) {
|
||||
// TODO: Implement logic here
|
||||
}
|
||||
async handle(event: RecordLog) {}
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { EventBus } from '@nestjs/cqrs';
|
||||
const midtransClient = require('midtrans-client');
|
||||
|
||||
@Injectable()
|
||||
export class MidtransService {
|
||||
constructor(private eventBus: EventBus) {}
|
||||
|
||||
get midtransInstance() {
|
||||
return new midtransClient.Snap({
|
||||
isProduction: false,
|
||||
serverKey: process.env.MIDTRANS_SERVER_KEY,
|
||||
clientKey: process.env.MIDTRANS_CLIENT_KEY,
|
||||
});
|
||||
}
|
||||
|
||||
async getStatus(orderId: string): Promise<any> {
|
||||
return await this.midtransInstance.transaction.status(orderId);
|
||||
}
|
||||
|
||||
async create(body): Promise<any> {
|
||||
return await this.midtransInstance.createTransaction({
|
||||
transaction_details: {
|
||||
order_id: '123',
|
||||
gross_amount: 10000,
|
||||
},
|
||||
credit_card: {
|
||||
secure: true,
|
||||
},
|
||||
customer_details: {
|
||||
first_name: 'budd',
|
||||
last_name: 'pratama',
|
||||
email: 'budi.pra@mail.com',
|
||||
phone: '0822111111',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
export class MidtransCallbackEvent {
|
||||
constructor(public readonly data: IEventMidtrans) {}
|
||||
}
|
||||
|
||||
export interface IEventMidtrans {
|
||||
id: string;
|
||||
data: any;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class MidtransDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
example: '123',
|
||||
})
|
||||
order_id: string;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
import { Body, Controller, Get, Injectable, Param, Post } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Public } from 'src/core/guards';
|
||||
import { MidtransService } from '../data/services/midtrans.service';
|
||||
import { EventBus } from '@nestjs/cqrs';
|
||||
import { MidtransCallbackEvent } from '../domain/entities/midtrans-callback.event';
|
||||
import { MidtransDto } from './dto/midtrans.dto';
|
||||
|
||||
@ApiTags(`midtrans`)
|
||||
@Controller('v1/midtrans')
|
||||
@Public()
|
||||
@Injectable()
|
||||
export class MidtransController {
|
||||
constructor(
|
||||
private dataService: MidtransService,
|
||||
private eventBus: EventBus,
|
||||
) {}
|
||||
|
||||
@Get(':id/status')
|
||||
async getStatus(@Param('id') id: string) {
|
||||
return await this.dataService.getStatus(id);
|
||||
}
|
||||
|
||||
@Post('callback')
|
||||
async callback(@Body() callback: MidtransDto) {
|
||||
const data = await this.dataService.getStatus(callback?.order_id);
|
||||
this.eventBus.publishAll([
|
||||
new MidtransCallbackEvent({
|
||||
id: data.order_id,
|
||||
data: data,
|
||||
}),
|
||||
]);
|
||||
console.log(`midtrans callback for order ${data.order_id}`);
|
||||
return 'success listen callback';
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import { ConfigModule } from '@nestjs/config';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { MidtransController } from './infrastructure/midtrans.controller';
|
||||
import { MidtransService } from './data/services/midtrans.service';
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(),
|
||||
// TypeOrmModule.forFeature(
|
||||
// [
|
||||
// ],
|
||||
// CONNECTION_NAME.DEFAULT,
|
||||
// ),
|
||||
CqrsModule,
|
||||
],
|
||||
controllers: [MidtransController],
|
||||
providers: [MidtransService],
|
||||
})
|
||||
export class MidtransModule {}
|
|
@ -49,7 +49,7 @@ export class ItemCategoryDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -66,7 +66,7 @@ export class ItemCategoryDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
||||
await this.activeManager.execute();
|
||||
|
@ -83,7 +83,7 @@ export class ItemCategoryDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -100,7 +100,7 @@ export class ItemCategoryDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
||||
await this.inactiveManager.execute();
|
||||
|
|
|
@ -22,9 +22,7 @@ export class CreateItemCategoryManager extends BaseCreateManager<ItemCategoryEnt
|
|||
return;
|
||||
}
|
||||
|
||||
async generateConfig(): Promise<void> {
|
||||
// TODO: Implement logic here
|
||||
}
|
||||
async generateConfig(): Promise<void> {}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
|
|
|
@ -34,7 +34,7 @@ export class ItemCategoryDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class ItemCategoryDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class ItemCategoryDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class ItemCategoryDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export class ItemRateDataOrchestrator extends BaseDataOrchestrator<ItemRateEntit
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.ITEM_RATE);
|
||||
await this.deleteManager.execute();
|
||||
|
|
|
@ -19,7 +19,7 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
|||
|
||||
async afterProcess(): Promise<void> {
|
||||
this.result.data?.map((item) => {
|
||||
const prices = [];
|
||||
let prices = [];
|
||||
for (
|
||||
let d = new Date(this.filterParam.start_date);
|
||||
d <= new Date(this.filterParam.end_date);
|
||||
|
|
|
@ -38,7 +38,7 @@ export class ItemRateDataController {
|
|||
}
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param('id') dataId: string): Promise<string> {
|
||||
// async delete(@Param('id') dataId: string): Promise<String> {
|
||||
// return await this.orchestrator.delete(dataId);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ export class ItemDataOrchestrator extends BaseDataTransactionOrchestrator<ItemEn
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId, tenantId?: string): Promise<string> {
|
||||
async delete(dataId, tenantId?: string): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.ITEM);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -77,7 +77,7 @@ export class ItemDataOrchestrator extends BaseDataTransactionOrchestrator<ItemEn
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId, tenantId?: string): Promise<string> {
|
||||
async active(dataId, tenantId?: string): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.ITEM);
|
||||
await this.activeManager.execute();
|
||||
|
@ -94,7 +94,7 @@ export class ItemDataOrchestrator extends BaseDataTransactionOrchestrator<ItemEn
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId, tenantId?: string): Promise<string> {
|
||||
async confirm(dataId, tenantId?: string): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.ITEM);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -111,7 +111,7 @@ export class ItemDataOrchestrator extends BaseDataTransactionOrchestrator<ItemEn
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId, tenantId?: string): Promise<string> {
|
||||
async inactive(dataId, tenantId?: string): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.ITEM);
|
||||
await this.inactiveManager.execute();
|
||||
|
|
|
@ -34,7 +34,7 @@ export class ItemDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class ItemDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class ItemDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class ItemDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,21 +35,16 @@ export class ReportBookmarkController {
|
|||
return await this.service.getAll(query);
|
||||
}
|
||||
|
||||
// @Get(':id')
|
||||
// async get(@Param('id') id: string) {
|
||||
// return await this.service.getOne(id);
|
||||
// }
|
||||
@Get('id')
|
||||
async get(@Param('id') id: string) {
|
||||
return await this.service.getOne(id);
|
||||
}
|
||||
|
||||
@Get('label-history')
|
||||
async getAllLabelHistory(@Query() query: GetLabelReportBookmarkDto) {
|
||||
return await this.service.getAllLabelHistory(query);
|
||||
}
|
||||
|
||||
@Get('applied')
|
||||
async currentApplied(@Query() query: GetLabelReportBookmarkDto) {
|
||||
return await this.service.getCurrentAppliedBookmark(query);
|
||||
}
|
||||
|
||||
@Put('applied/:id')
|
||||
async applied(@Param('id') id: string) {
|
||||
return await this.service.applied(id);
|
||||
|
|
|
@ -25,11 +25,7 @@ export class ReportBookmarkService extends BaseReportService {
|
|||
|
||||
async create(body: CreateReportBookmarkDto) {
|
||||
const newPayload = this.injectDefaultColumnCreate(body);
|
||||
const result = await this.repo.save(newPayload);
|
||||
if (body.applied) {
|
||||
await this.appliedFalseBookmark(result.id);
|
||||
}
|
||||
return result;
|
||||
return await this.repo.save(newPayload);
|
||||
}
|
||||
|
||||
async getAll(query: GetReportBookmarkDto) {
|
||||
|
@ -96,35 +92,6 @@ export class ReportBookmarkService extends BaseReportService {
|
|||
return newData.map((el) => el.ReportBookmarkModel_label);
|
||||
}
|
||||
|
||||
async getCurrentAppliedBookmark(query: GetLabelReportBookmarkDto) {
|
||||
const modelName = ReportBookmarkModel.name;
|
||||
|
||||
const creator_id = this.getUser().id;
|
||||
const unique_names = query.unique_names;
|
||||
const group_names = query.group_names;
|
||||
const types = query.types;
|
||||
const qb = this.repo
|
||||
.createQueryBuilder(modelName)
|
||||
.where((query) => {
|
||||
if (unique_names) {
|
||||
query.andWhere(`unique_name IN (:...unique_names)`, { unique_names });
|
||||
}
|
||||
if (group_names) {
|
||||
query.andWhere(`group_name IN (:...group_names)`, { group_names });
|
||||
}
|
||||
|
||||
if (types) {
|
||||
query.andWhere(`type IN (:...types)`, { types });
|
||||
}
|
||||
|
||||
query.andWhere(`creator_id = :creator_id`, { creator_id });
|
||||
query.andWhere(`applied = :applied`, { applied: true });
|
||||
})
|
||||
.orderBy(`${modelName}.created_at`, 'DESC');
|
||||
|
||||
return await qb.getMany();
|
||||
}
|
||||
|
||||
async applied(id: string) {
|
||||
await this.repo
|
||||
.createQueryBuilder()
|
||||
|
|
|
@ -98,15 +98,14 @@ export class ReportExportService extends BaseReportService {
|
|||
(_, i) => i * limit,
|
||||
);
|
||||
|
||||
const defaultFileName = fName ?? config.label;
|
||||
const fileName = `${defaultFileName} (${Number(new Date())})`;
|
||||
const fileName = `${fName ?? config.label} (${Number(new Date())})`;
|
||||
|
||||
const exportHistory = {
|
||||
id: undefined,
|
||||
group_name: config.group_name,
|
||||
unique_name: config.unique_name,
|
||||
label: config.label,
|
||||
file_name: defaultFileName,
|
||||
file_name: fName,
|
||||
file_url: null,
|
||||
total_data: totalRow,
|
||||
processing_data: 0,
|
||||
|
@ -144,6 +143,7 @@ export class ReportExportService extends BaseReportService {
|
|||
// Create a new worksheet
|
||||
const reportSheet = workbook.addWorksheet('Report');
|
||||
|
||||
const columnStateIds = columnState.map((i) => i.colId);
|
||||
let configColumns = config.column_configs;
|
||||
const rowGroups = query_model?.rowGroupCols ?? [];
|
||||
|
||||
|
@ -154,11 +154,6 @@ export class ReportExportService extends BaseReportService {
|
|||
});
|
||||
}
|
||||
|
||||
const columnStateIds = [
|
||||
...rowGroups.map((i) => i.id),
|
||||
...columnState.map((i) => i.colId),
|
||||
];
|
||||
|
||||
const newConfigColumn = columnStateIds
|
||||
.map((i) => {
|
||||
const findData = configColumns.find((col) => col.column === i);
|
||||
|
|
|
@ -4,12 +4,11 @@ import { ReportService } from './report.service';
|
|||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ExportReportHistoryModel } from '../shared/models/export-report-history.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { ReportBookmarkModel } from '../shared/models/report-bookmark.model';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature(
|
||||
[ExportReportHistoryModel, ReportBookmarkModel],
|
||||
[ExportReportHistoryModel],
|
||||
CONNECTION_NAME.DEFAULT,
|
||||
),
|
||||
],
|
||||
|
|
|
@ -3,14 +3,13 @@ import { BaseReportService } from '../shared/services/base-report.service';
|
|||
import { GetReportConfigDto } from '../shared/dto/report-config.get.dto';
|
||||
import { GetReportDataDto } from '../shared/dto/report-data.get.dto';
|
||||
import { ReportConfigs } from '../shared/configs';
|
||||
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
|
||||
import { InjectDataSource } from '@nestjs/typeorm';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { ReportConfigEntity } from '../shared/entities/report-config.entity';
|
||||
import { ReportQueryBuilder } from '../shared/helpers';
|
||||
import { DATA_FORMAT, REPORT_BOOKMARK_TYPE } from '../shared/constant';
|
||||
import { DATA_FORMAT } from '../shared/constant';
|
||||
import { roundingCurrency } from '../shared/helpers';
|
||||
import { ReportBookmarkModel } from '../shared/models/report-bookmark.model';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class ReportService extends BaseReportService {
|
||||
|
@ -19,9 +18,6 @@ export class ReportService extends BaseReportService {
|
|||
constructor(
|
||||
@InjectDataSource(CONNECTION_NAME.DEFAULT)
|
||||
private dataSource: DataSource,
|
||||
|
||||
@InjectRepository(ReportBookmarkModel, CONNECTION_NAME.DEFAULT)
|
||||
private bookmarkRepo: Repository<ReportBookmarkModel>,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
@ -39,47 +35,8 @@ export class ReportService extends BaseReportService {
|
|||
unique_names.includes(item.unique_name),
|
||||
);
|
||||
}
|
||||
const groups = Array.from(new Set(configs?.map((item) => item.group_name)));
|
||||
const names = Array.from(new Set(configs?.map((item) => item.unique_name)));
|
||||
|
||||
const modelName = ReportBookmarkModel.name;
|
||||
const creator_id = this.getUser().id;
|
||||
|
||||
const bookmarkConfigs = await this.bookmarkRepo
|
||||
.createQueryBuilder(modelName)
|
||||
.where((query) => {
|
||||
if (names.length > 0) {
|
||||
query.andWhere(`group_name IN (:...groups)`, { groups });
|
||||
}
|
||||
if (groups.length > 0) {
|
||||
query.andWhere(`unique_name IN (:...names)`, { names });
|
||||
}
|
||||
|
||||
query.andWhere(`creator_id = :creator_id`, { creator_id });
|
||||
query.andWhere(`applied = :applied`, { applied: true });
|
||||
})
|
||||
.getMany();
|
||||
|
||||
return configs.map((item) => {
|
||||
const active_filter = bookmarkConfigs.find(
|
||||
(conf) =>
|
||||
conf.group_name === item.group_name &&
|
||||
conf.unique_name === item.unique_name &&
|
||||
conf.type === REPORT_BOOKMARK_TYPE.FILTER_TABLE,
|
||||
);
|
||||
|
||||
const active_table_config = bookmarkConfigs.find(
|
||||
(conf) =>
|
||||
conf.group_name === item.group_name &&
|
||||
conf.unique_name === item.unique_name &&
|
||||
conf.type === REPORT_BOOKMARK_TYPE.TABLE_CONFIG,
|
||||
);
|
||||
return {
|
||||
...item,
|
||||
active_filter: active_filter ?? {},
|
||||
active_table_config: active_table_config ?? {},
|
||||
};
|
||||
});
|
||||
return configs;
|
||||
}
|
||||
|
||||
getReportConfigByUniqueName(group_name, unique_name): ReportConfigEntity {
|
||||
|
|
|
@ -2,9 +2,9 @@ import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
|||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__refunds`,
|
||||
label: 'Pengembalian',
|
||||
group_name: REPORT_GROUP.general_report,
|
||||
unique_name: `${REPORT_GROUP.general_report}__sample`,
|
||||
label: 'Sample General Report ',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
|
@ -0,0 +1,5 @@
|
|||
import { ReportConfigEntity } from '../../entities/report-config.entity';
|
||||
|
||||
import SampleReport from './configs/sample.report';
|
||||
|
||||
export const GeneralReportConfig: ReportConfigEntity[] = [SampleReport];
|
|
@ -1,8 +1,8 @@
|
|||
import { ReportConfigEntity } from '../entities/report-config.entity';
|
||||
import { TransactionReportConfig } from './transaction-report';
|
||||
import { GeneralReportConfig } from './general-report';
|
||||
import { TenantReportConfig } from './tenant-report';
|
||||
|
||||
export const ReportConfigs: ReportConfigEntity[] = [
|
||||
...TransactionReportConfig,
|
||||
...GeneralReportConfig,
|
||||
...TenantReportConfig,
|
||||
];
|
||||
|
|
|
@ -4,7 +4,7 @@ import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
|||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.tenant_report,
|
||||
unique_name: `${REPORT_GROUP.tenant_report}__sample`,
|
||||
label: 'Sample Tenant Report',
|
||||
label: 'Sample Tenant Report ',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__booking`,
|
||||
label: 'Pemesanan',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__cash_withdrawals`,
|
||||
label: 'Penarikan Kas',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__cashier_log`,
|
||||
label: 'Kasir Log',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,67 +0,0 @@
|
|||
import {
|
||||
DATA_FORMAT,
|
||||
DATA_TYPE,
|
||||
FILTER_FIELD_TYPE,
|
||||
FILTER_TYPE,
|
||||
REPORT_GROUP,
|
||||
} from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__income`,
|
||||
label: 'Pendapatan',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [
|
||||
{
|
||||
filed_label: 'Name',
|
||||
filter_column: 'main__name',
|
||||
field_type: FILTER_FIELD_TYPE.select,
|
||||
filter_type: FILTER_TYPE.TEXT_IN_MEMBER,
|
||||
select_data_source_url: '/v1/season-types',
|
||||
select_custom_options: [],
|
||||
select_label_key: 'name',
|
||||
select_value_key: 'name',
|
||||
},
|
||||
{
|
||||
filed_label: 'Status',
|
||||
filter_column: 'main__status',
|
||||
field_type: FILTER_FIELD_TYPE.input_text,
|
||||
filter_type: FILTER_TYPE.TEXT_EQUAL,
|
||||
// select_data_source_url: '/v1/season-types',
|
||||
// select_custom_options: [],
|
||||
// select_label_key: 'code',
|
||||
// select_value_key: 'code',
|
||||
},
|
||||
],
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__revenue_per_item`,
|
||||
label: 'Pendapatan per Item',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__sales_qty_per_item`,
|
||||
label: 'Qty Penjualan per Item',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__time_per_ride`,
|
||||
label: 'Waktu per Wahana',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
import { DATA_FORMAT, DATA_TYPE, REPORT_GROUP } from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__visitors_per_ride`,
|
||||
label: 'Pengunjung per Wahana',
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
hidden: true,
|
||||
},
|
||||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [],
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
import { ReportConfigEntity } from '../../entities/report-config.entity';
|
||||
|
||||
import IncomeReport from './configs/income';
|
||||
import RevenuePerItemReport from './configs/revenue-per-item';
|
||||
import SalesQtyPerItemReport from './configs/sales-qty-per-item';
|
||||
import VisitorsPerRideReport from './configs/visitors-per-ride';
|
||||
import TimePerRideReport from './configs/time-per-ride';
|
||||
import BookingReport from './configs/booking';
|
||||
import RefundsReport from './configs/refunds';
|
||||
import CashierLogReport from './configs/cashier-log';
|
||||
import CashWithdrawalsReport from './configs/cash-withdrawals';
|
||||
|
||||
export const TransactionReportConfig: ReportConfigEntity[] = [
|
||||
IncomeReport,
|
||||
RevenuePerItemReport,
|
||||
SalesQtyPerItemReport,
|
||||
VisitorsPerRideReport,
|
||||
TimePerRideReport,
|
||||
BookingReport,
|
||||
RefundsReport,
|
||||
CashierLogReport,
|
||||
CashWithdrawalsReport,
|
||||
];
|
|
@ -1,6 +1,6 @@
|
|||
export enum REPORT_GROUP {
|
||||
// PATTERN => MODULE__MENU__SUB_MENU
|
||||
// EXAMPLE:
|
||||
transaction_report = 'transaction_report',
|
||||
general_report = 'general_report',
|
||||
tenant_report = 'tenant_report',
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export class GetReportDataDto {
|
|||
@ApiProperty({
|
||||
name: 'group_name',
|
||||
required: true,
|
||||
default: REPORT_GROUP.transaction_report,
|
||||
default: REPORT_GROUP.general_report,
|
||||
})
|
||||
@IsString()
|
||||
group_name: string;
|
||||
|
@ -15,7 +15,7 @@ export class GetReportDataDto {
|
|||
@ApiProperty({
|
||||
name: 'unique_name',
|
||||
required: true,
|
||||
default: `${REPORT_GROUP.transaction_report}__sample`,
|
||||
default: `${REPORT_GROUP.general_report}__sample`,
|
||||
})
|
||||
@IsString()
|
||||
unique_name: string;
|
||||
|
|
|
@ -8,9 +8,8 @@ export class CreateReportExportDto extends GetReportDataDto {
|
|||
@IsString()
|
||||
time_zone: string;
|
||||
|
||||
@ApiProperty({ name: 'file_name', required: false })
|
||||
@ApiProperty({ name: 'file_name', required: true })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
file_name?: string;
|
||||
|
||||
@ApiProperty({
|
||||
|
|
|
@ -360,10 +360,8 @@ export class ReportQueryBuilder {
|
|||
});
|
||||
}
|
||||
|
||||
const tableWhereConditions = [...whereCondition, ...whereParts].filter(
|
||||
Boolean,
|
||||
);
|
||||
const defaultWhereConditions = defaultWhereOptions.filter(Boolean);
|
||||
const tableWhereConditions = [...whereCondition, ...whereParts];
|
||||
const defaultWhereConditions = defaultWhereOptions;
|
||||
|
||||
if (tableWhereConditions.length > 0) {
|
||||
return `WHERE (${
|
||||
|
|
|
@ -21,7 +21,7 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
|||
=> akan tetapi dapat ditindih oleh season period 2024-08-15, 2024-08-28 days [Sabtu, Senin] (karena ini naik prio menjadi priority 2)
|
||||
*/
|
||||
const query = dataService.getRepository().createQueryBuilder('data');
|
||||
let priority = 3;
|
||||
let priority: number = 3;
|
||||
// libur / specific date
|
||||
if (
|
||||
data.holidays?.length > 0 ||
|
||||
|
|
|
@ -60,7 +60,7 @@ export class SeasonPeriodDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.updatePriceManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -77,7 +77,7 @@ export class SeasonPeriodDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
await this.activeManager.execute();
|
||||
|
@ -94,7 +94,7 @@ export class SeasonPeriodDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -111,7 +111,7 @@ export class SeasonPeriodDataOrchestrator extends BaseDataTransactionOrchestrato
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||
await this.inactiveManager.execute();
|
||||
|
|
|
@ -44,7 +44,7 @@ export class SeasonPeriodDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class SeasonPeriodDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ export class SeasonPeriodDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ export class SeasonPeriodDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export type FilterSeasonTypeEntity = BaseFilterEntity;
|
||||
export interface FilterSeasonTypeEntity extends BaseFilterEntity {}
|
||||
|
|
|
@ -48,7 +48,7 @@ export class SeasonTypeDataOrchestrator extends BaseDataTransactionOrchestrator<
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -65,7 +65,7 @@ export class SeasonTypeDataOrchestrator extends BaseDataTransactionOrchestrator<
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
|
||||
await this.activeManager.execute();
|
||||
|
@ -82,7 +82,7 @@ export class SeasonTypeDataOrchestrator extends BaseDataTransactionOrchestrator<
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -99,7 +99,7 @@ export class SeasonTypeDataOrchestrator extends BaseDataTransactionOrchestrator<
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
|
||||
await this.inactiveManager.execute();
|
||||
|
|
|
@ -34,7 +34,7 @@ export class SeasonTypeDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class SeasonTypeDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class SeasonTypeDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class SeasonTypeDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ export class PaymentMethodDataOrchestrator extends BaseDataTransactionOrchestrat
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -65,7 +65,7 @@ export class PaymentMethodDataOrchestrator extends BaseDataTransactionOrchestrat
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.activeManager.execute();
|
||||
|
@ -82,7 +82,7 @@ export class PaymentMethodDataOrchestrator extends BaseDataTransactionOrchestrat
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -99,7 +99,7 @@ export class PaymentMethodDataOrchestrator extends BaseDataTransactionOrchestrat
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(
|
||||
this.serviceData,
|
||||
|
|
|
@ -34,7 +34,7 @@ export class PaymentMethodDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class PaymentMethodDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class PaymentMethodDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class PaymentMethodDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
|||
|
||||
@Injectable()
|
||||
export class BatchConfirmReconciliationManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||
async validateData(data: TransactionEntity): Promise<void> {
|
||||
validateData(data: TransactionEntity): Promise<void> {
|
||||
const net_profit = data.reconciliation_mdr
|
||||
? Number(this.data.payment_total) - Number(this.data.reconciliation_mdr)
|
||||
: null;
|
||||
|
|
|
@ -45,7 +45,6 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
|
|||
`${this.tableName}.reconciliation_confirm_by`,
|
||||
|
||||
`${this.tableName}.customer_name`,
|
||||
`${this.tableName}.creator_counter_no`,
|
||||
|
||||
`${this.tableName}.payment_type`,
|
||||
`${this.tableName}.payment_type_method_id`,
|
||||
|
|
|
@ -39,7 +39,7 @@ export class ReconciliationDataOrchestrator {
|
|||
return this.recapManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.CONFIRMED);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -56,7 +56,7 @@ export class ReconciliationDataOrchestrator {
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async cancel(dataId): Promise<string> {
|
||||
async cancel(dataId): Promise<String> {
|
||||
this.cancelManager.setData(dataId, STATUS.REJECTED);
|
||||
this.cancelManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
||||
await this.cancelManager.execute();
|
||||
|
|
|
@ -34,12 +34,12 @@ export class ReconciliationDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
@Patch(':id/cancel')
|
||||
async cancel(@Param('id') dataId: string): Promise<string> {
|
||||
async cancel(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.cancel(dataId);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import { BatchCancelReconciliationManager } from './domain/usecases/managers/bat
|
|||
import { BatchConfirmReconciliationManager } from './domain/usecases/managers/batch-confirm-reconciliation.manager';
|
||||
import { RecapReconciliationManager } from './domain/usecases/managers/recap-reconciliation.manager';
|
||||
import { RecapPosTransactionHandler } from './domain/usecases/handlers/recap-pos-transaction.handler';
|
||||
import { SalesPriceFormulaDataService } from '../sales-price-formula/data/services/sales-price-formula-data.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
|
|
@ -50,7 +50,7 @@ export class TaxDataOrchestrator extends BaseDataTransactionOrchestrator<TaxEnti
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(
|
||||
this.serviceData,
|
||||
|
@ -72,7 +72,7 @@ export class TaxDataOrchestrator extends BaseDataTransactionOrchestrator<TaxEnti
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||
await this.activeManager.execute();
|
||||
|
@ -86,7 +86,7 @@ export class TaxDataOrchestrator extends BaseDataTransactionOrchestrator<TaxEnti
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.TAX);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -100,7 +100,7 @@ export class TaxDataOrchestrator extends BaseDataTransactionOrchestrator<TaxEnti
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(
|
||||
this.serviceData,
|
||||
|
|
|
@ -34,7 +34,7 @@ export class TaxDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class TaxDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class TaxDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class TaxDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event';
|
||||
import { SalesPriceFormulaDataService } from 'src/modules/transaction/sales-price-formula/data/services/sales-price-formula-data.service';
|
||||
import { TaxDataService } from 'src/modules/transaction/tax/data/services/tax-data.service';
|
||||
import { FormulaType } from 'src/modules/transaction/sales-price-formula/constants';
|
||||
import * as math from 'mathjs';
|
||||
import { Equation, parse } from 'algebra.js';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
import { TransactionDataService } from '../../../data/services/transaction-data.service';
|
||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||
|
||||
@EventsHandler(TransactionChangeStatusEvent)
|
||||
export class SettledTransactionHandler
|
||||
implements IEventHandler<TransactionChangeStatusEvent>
|
||||
{
|
||||
constructor(
|
||||
private formulaService: SalesPriceFormulaDataService,
|
||||
private taxService: TaxDataService,
|
||||
private dataService: TransactionDataService,
|
||||
) {}
|
||||
|
||||
async handle(event: TransactionChangeStatusEvent) {
|
||||
const old_data = event.data.old;
|
||||
const data = event.data.data;
|
||||
|
||||
if (
|
||||
old_data.status == data.status ||
|
||||
![STATUS.ACTIVE, STATUS.SETTLED].includes(data.status)
|
||||
)
|
||||
return;
|
||||
|
||||
const profit_formula = await this.formulaService.getOneByOptions({
|
||||
where: {
|
||||
type: FormulaType.PROFIT_SHARE,
|
||||
},
|
||||
});
|
||||
|
||||
const sales_price = await this.formulaService.getOneByOptions({
|
||||
where: {
|
||||
type: FormulaType.SALES_PRICE,
|
||||
},
|
||||
});
|
||||
|
||||
const taxes = await this.taxService.getManyByOptions({
|
||||
where: {
|
||||
status: STATUS.ACTIVE,
|
||||
},
|
||||
});
|
||||
|
||||
const queryRunner = this.dataService
|
||||
.getRepository()
|
||||
.manager.connection.createQueryRunner();
|
||||
|
||||
// const profit_share_value = this.calculateFormula(profit_formula.formula_string, taxes, data.payment_total_net_profit ?? 0);
|
||||
// const sale_price_value = this.calculateFormula(sales_price.formula_string, taxes, data.payment_total_net_profit ?? 0);
|
||||
|
||||
Object.assign(data, {
|
||||
profit_share_formula: profit_formula.formula_string,
|
||||
sales_price_formula: sales_price.formula_string,
|
||||
});
|
||||
|
||||
await this.dataService.create(queryRunner, TransactionModel, data);
|
||||
}
|
||||
|
||||
calculateFormula(formula, taxes, total) {
|
||||
const regex = /([a-zA-Z0-9_]+)/g;
|
||||
const variable = {};
|
||||
|
||||
const matches: string[] = formula.match(regex);
|
||||
const uniqueMatches = new Set(matches);
|
||||
const keys = Array.from(uniqueMatches).filter((key) => key != 'dpp');
|
||||
|
||||
for (const key of keys) {
|
||||
const keyData = taxes.find((tax) => tax.name == key);
|
||||
variable[key] = keyData.value / 100;
|
||||
}
|
||||
|
||||
try {
|
||||
const x1 = math.simplify(formula, variable).toString();
|
||||
console.log('Formula ', x1);
|
||||
const dppFormula = parse(x1);
|
||||
const totalFormula = parse(total.toString());
|
||||
const equation = new Equation(totalFormula, dppFormula);
|
||||
|
||||
console.log(equation.toString());
|
||||
const result = equation.solveFor('dpp').toString();
|
||||
console.log(result);
|
||||
|
||||
const value = math.evaluate(result);
|
||||
console.log(value);
|
||||
return value;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { TransactionEntity } from '../../entities/transaction.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class ActiveTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
|
||||
getResult(): string {
|
||||
return `Success active data ${this.result.invoice_code}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TransactionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TransactionChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { TransactionEntity } from '../../entities/transaction.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchActiveTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||
validateData(data: TransactionEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TransactionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TransactionChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
|||
|
||||
@Injectable()
|
||||
export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||
async validateData(data: TransactionEntity): Promise<void> {
|
||||
validateData(data: TransactionEntity): Promise<void> {
|
||||
if (data.status != STATUS.DRAFT) {
|
||||
throw new UnprocessableEntityException({
|
||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
||||
import { TransactionEntity } from '../../entities/transaction.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event';
|
||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BatchInactiveTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||
validateData(data: TransactionEntity): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TransactionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TransactionChangeStatusEvent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
getResult(): BatchResult {
|
||||
return this.result;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
|||
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
||||
|
||||
export function mappingTransaction(data) {
|
||||
let payment_type_bank: any = null;
|
||||
let payment_type_bank;
|
||||
const season_period = {
|
||||
id: data.season_period_id,
|
||||
holiday_name: data.season_period_name,
|
||||
|
@ -12,7 +12,7 @@ export function mappingTransaction(data) {
|
|||
},
|
||||
};
|
||||
|
||||
if (data.payment_type_method_id || data.payment_type_method_name) {
|
||||
if (data.payment_type_method_id) {
|
||||
payment_type_bank = {
|
||||
id: data.payment_type_method_id,
|
||||
issuer_name: data.payment_type_method_name,
|
||||
|
@ -93,17 +93,12 @@ export function mappingRevertTransaction(data, type) {
|
|||
|
||||
Object.assign(data, {
|
||||
type: type,
|
||||
payment_total_net_profit: data.payment_total,
|
||||
customer_category_id: data.customer_category?.id ?? null,
|
||||
customer_category_name: data.customer_category?.name ?? null,
|
||||
season_period_id: data.season_period?.id ?? null,
|
||||
season_period_name: data.season_period?.holiday_name ?? null,
|
||||
season_period_type_id: data.season_period?.season_type?.id ?? null,
|
||||
season_period_type_name: data.season_period?.season_type?.name ?? null,
|
||||
payment_type_method_id: data.payment_type_method?.id,
|
||||
payment_type_method_number: data.payment_type_method?.account_number,
|
||||
payment_type_method_name: data.payment_type_method?.issuer_name,
|
||||
payment_type_method_qr: data.payment_type_method?.qr_image,
|
||||
});
|
||||
|
||||
data.items?.map((item) => {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||
import { TransactionEntity } from '../../entities/transaction.entity';
|
||||
import {
|
||||
EventTopics,
|
||||
validateRelations,
|
||||
} from 'src/core/strings/constants/interface.constants';
|
||||
import { TransactionModel } from '../../../data/models/transaction.model';
|
||||
import { TransactionChangeStatusEvent } from '../../entities/event/transaction-change-status.event';
|
||||
|
||||
@Injectable()
|
||||
export class InactiveTransactionManager extends BaseUpdateStatusManager<TransactionEntity> {
|
||||
getResult(): string {
|
||||
return `Success inactive data ${this.result.invoice_code}`;
|
||||
}
|
||||
|
||||
async validateProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
get entityTarget(): any {
|
||||
return TransactionModel;
|
||||
}
|
||||
|
||||
get eventTopics(): EventTopics[] {
|
||||
return [
|
||||
{
|
||||
topic: TransactionChangeStatusEvent,
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ export class TransactionDataOrchestrator {
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -62,7 +62,7 @@ export class TransactionDataOrchestrator {
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async cancel(dataId): Promise<string> {
|
||||
async cancel(dataId): Promise<String> {
|
||||
this.cancelManager.setData(dataId, STATUS.CANCEL);
|
||||
this.cancelManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
||||
await this.cancelManager.execute();
|
||||
|
@ -79,7 +79,7 @@ export class TransactionDataOrchestrator {
|
|||
return this.batchCancelManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -96,7 +96,7 @@ export class TransactionDataOrchestrator {
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async confirmData(dataId): Promise<string> {
|
||||
async confirmData(dataId): Promise<String> {
|
||||
this.confirmDataManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmDataManager.setService(
|
||||
this.serviceData,
|
||||
|
|
|
@ -34,7 +34,7 @@ export class TransactionDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm-data')
|
||||
async confirmData(@Param('id') dataId: string): Promise<string> {
|
||||
async confirmData(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirmData(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class TransactionDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class TransactionDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/cancel')
|
||||
async cancel(@Param('id') dataId: string): Promise<string> {
|
||||
async cancel(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.cancel(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class TransactionDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import { TaxDataService } from '../tax/data/services/tax-data.service';
|
|||
import { SalesPriceFormulaDataService } from '../sales-price-formula/data/services/sales-price-formula-data.service';
|
||||
import { SalesPriceFormulaModel } from '../sales-price-formula/data/models/sales-price-formula.model';
|
||||
import { TaxModel } from '../tax/data/models/tax.model';
|
||||
import { SettledTransactionHandler } from './domain/usecases/handlers/settled-transaction.handler';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -49,7 +48,6 @@ import { SettledTransactionHandler } from './domain/usecases/handlers/settled-tr
|
|||
controllers: [TransactionDataController, TransactionReadController],
|
||||
providers: [
|
||||
PosTransactionHandler,
|
||||
SettledTransactionHandler,
|
||||
|
||||
IndexTransactionManager,
|
||||
DetailTransactionManager,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export type FilterVipCategoryEntity = BaseFilterEntity;
|
||||
export interface FilterVipCategoryEntity extends BaseFilterEntity {}
|
||||
|
|
|
@ -19,9 +19,7 @@ export class CreateVipCategoryManager extends BaseCreateManager<VipCategoryEntit
|
|||
return;
|
||||
}
|
||||
|
||||
async generateConfig(): Promise<void> {
|
||||
// TODO: Implement logic here
|
||||
}
|
||||
async generateConfig(): Promise<void> {}
|
||||
|
||||
get validateRelations(): validateRelations[] {
|
||||
return [];
|
||||
|
|
|
@ -49,7 +49,7 @@ export class VipCategoryDataOrchestrator extends BaseDataTransactionOrchestrator
|
|||
return this.updateManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -66,7 +66,7 @@ export class VipCategoryDataOrchestrator extends BaseDataTransactionOrchestrator
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
await this.activeManager.execute();
|
||||
|
@ -83,7 +83,7 @@ export class VipCategoryDataOrchestrator extends BaseDataTransactionOrchestrator
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -100,7 +100,7 @@ export class VipCategoryDataOrchestrator extends BaseDataTransactionOrchestrator
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.VIP_CATEGORY);
|
||||
await this.inactiveManager.execute();
|
||||
|
|
|
@ -34,7 +34,7 @@ export class VipCategoryDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ export class VipCategoryDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class VipCategoryDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export class VipCategoryDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export type FilterVipCodeEntity = BaseFilterEntity;
|
||||
export interface FilterVipCodeEntity extends BaseFilterEntity {}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
||||
import { ChangeDocEvent } from 'src/modules/configuration/couch/domain/events/change-doc.event';
|
||||
import { VipCodeDataService } from '../../../data/services/vip-code-data.service';
|
||||
import { VipCodeModel } from '../../../data/models/vip-code.model';
|
||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
||||
|
||||
@EventsHandler(ChangeDocEvent)
|
||||
export class CreateVipCodeHandler implements IEventHandler<ChangeDocEvent> {
|
||||
constructor(
|
||||
private dataService: VipCodeDataService,
|
||||
private couchService: CouchService,
|
||||
) {}
|
||||
|
||||
async handle(event: ChangeDocEvent) {
|
||||
const database = event.data.database;
|
||||
const data = event.data.data;
|
||||
|
||||
if (database != 'vip_code') return;
|
||||
|
||||
const queryRunner = this.dataService
|
||||
.getRepository()
|
||||
.manager.connection.createQueryRunner();
|
||||
|
||||
// jika delete
|
||||
if (data._deleted ?? false) {
|
||||
} else {
|
||||
const dataMapped = {
|
||||
...data,
|
||||
id: data._id ?? data.id,
|
||||
vip_category_id: data.vip_category?._id ?? data.vip_category?.id,
|
||||
};
|
||||
|
||||
try {
|
||||
await this.dataService.create(queryRunner, VipCodeModel, dataMapped);
|
||||
} catch (error) {
|
||||
await this.couchService.createDoc(data, 'error_vip_code');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ export class CreateVipCodeManager extends BaseCreateManager<VipCodeEntity> {
|
|||
return [
|
||||
{
|
||||
topic: VipCodeCreatedEvent,
|
||||
relations: ['vip_category'],
|
||||
data: this.data,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export class VipCodeDataOrchestrator extends BaseDataOrchestrator<VipCodeEntity>
|
|||
update(dataId: string, data: VipCodeEntity): Promise<VipCodeEntity> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
delete(dataId: string): Promise<string> {
|
||||
delete(dataId: string): Promise<String> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
batchDelete(dataIds: string[]): Promise<BatchResult> {
|
||||
|
|
|
@ -19,7 +19,7 @@ export class VipCodeDataController {
|
|||
}
|
||||
|
||||
@Post('generate-code')
|
||||
async generateCOde(): Promise<string> {
|
||||
async generateCOde(): Promise<String> {
|
||||
return await this.orchestrator.generateCode();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ export class VipCodeDataController {
|
|||
// }
|
||||
|
||||
// @Delete(':id')
|
||||
// async delete(@Param('id') dataId: string): Promise<string> {
|
||||
// async delete(@Param('id') dataId: string): Promise<String> {
|
||||
// return await this.orchestrator.delete(dataId);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import { CqrsModule } from '@nestjs/cqrs';
|
|||
import { IndexVipCodeManager } from './domain/usecases/managers/index-vip-code.manager';
|
||||
import { VipCodeModel } from './data/models/vip-code.model';
|
||||
import { GenerateVipCodeManager } from './domain/usecases/managers/geneate-vip-code.manager';
|
||||
import { CreateVipCodeHandler } from './domain/usecases/handlers/create-vip-code.handler';
|
||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -24,13 +22,10 @@ import { CouchService } from 'src/modules/configuration/couch/data/services/couc
|
|||
],
|
||||
controllers: [VipCodeDataController, VipCodeReadController],
|
||||
providers: [
|
||||
CreateVipCodeHandler,
|
||||
|
||||
IndexVipCodeManager,
|
||||
CreateVipCodeManager,
|
||||
GenerateVipCodeManager,
|
||||
|
||||
CouchService,
|
||||
VipCodeDataService,
|
||||
VipCodeReadService,
|
||||
|
||||
|
|
|
@ -30,9 +30,7 @@ export class CreateTenantManager extends BaseCreateManager<UserEntity> {
|
|||
return;
|
||||
}
|
||||
|
||||
async generateConfig(): Promise<void> {
|
||||
// TODO: Implement logic here
|
||||
}
|
||||
async generateConfig(): Promise<void> {}
|
||||
|
||||
get uniqueColumns(): columnUniques[] {
|
||||
return [
|
||||
|
|
|
@ -58,7 +58,7 @@ export class TenantDataOrchestrator extends BaseDataTransactionOrchestrator<User
|
|||
return this.updatePasswordManager.getResult();
|
||||
}
|
||||
|
||||
async delete(dataId): Promise<string> {
|
||||
async delete(dataId): Promise<String> {
|
||||
this.deleteManager.setData(dataId);
|
||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.TENANT);
|
||||
await this.deleteManager.execute();
|
||||
|
@ -72,7 +72,7 @@ export class TenantDataOrchestrator extends BaseDataTransactionOrchestrator<User
|
|||
return this.batchDeleteManager.getResult();
|
||||
}
|
||||
|
||||
async active(dataId): Promise<string> {
|
||||
async active(dataId): Promise<String> {
|
||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.activeManager.setService(this.serviceData, TABLE_NAME.TENANT);
|
||||
await this.activeManager.execute();
|
||||
|
@ -86,7 +86,7 @@ export class TenantDataOrchestrator extends BaseDataTransactionOrchestrator<User
|
|||
return this.batchActiveManager.getResult();
|
||||
}
|
||||
|
||||
async confirm(dataId): Promise<string> {
|
||||
async confirm(dataId): Promise<String> {
|
||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.TENANT);
|
||||
await this.confirmManager.execute();
|
||||
|
@ -100,7 +100,7 @@ export class TenantDataOrchestrator extends BaseDataTransactionOrchestrator<User
|
|||
return this.batchConfirmManager.getResult();
|
||||
}
|
||||
|
||||
async inactive(dataId): Promise<string> {
|
||||
async inactive(dataId): Promise<String> {
|
||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.TENANT);
|
||||
await this.inactiveManager.execute();
|
||||
|
|
|
@ -36,7 +36,7 @@ export class TenantDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/active')
|
||||
async active(@Param('id') dataId: string): Promise<string> {
|
||||
async active(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.active(dataId);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ export class TenantDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/confirm')
|
||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||
async confirm(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.confirm(dataId);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ export class TenantDataController {
|
|||
}
|
||||
|
||||
@Patch(':id/inactive')
|
||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
||||
async inactive(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.inactive(dataId);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ export class TenantDataController {
|
|||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') dataId: string): Promise<string> {
|
||||
async delete(@Param('id') dataId: string): Promise<String> {
|
||||
return await this.orchestrator.delete(dataId);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue