Merge branch 'development' of ssh://git.eigen.co.id:2222/eigen/pos-be into feat/report
commit
313843591e
|
@ -0,0 +1,19 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class UpdateDefaultColumnTransaction1720077765890
|
||||||
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'UpdateDefaultColumnTransaction1720077765890';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "transactions" ALTER COLUMN "is_recap_transaction" SET DEFAULT false`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "transactions" ALTER COLUMN "is_recap_transaction" SET DEFAULT true`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||||
|
import { SeasonPeriodEntity } from '../../entities/season-period.entity';
|
||||||
|
import { SelectQueryBuilder } from 'typeorm';
|
||||||
|
import {
|
||||||
|
Param,
|
||||||
|
RelationParam,
|
||||||
|
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CurrentSeasonPeriodManager extends BaseIndexManager<SeasonPeriodEntity> {
|
||||||
|
async prepareData(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeProcess(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async afterProcess(): Promise<void> {
|
||||||
|
Object.assign(this.result, {
|
||||||
|
data: this.result.data.sort((a, b) => a.priority - b.priority)
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
get relations(): RelationParam {
|
||||||
|
return {
|
||||||
|
// relation only join (for query purpose)
|
||||||
|
joinRelations: ['season_type'],
|
||||||
|
|
||||||
|
// relation join and select (relasi yang ingin ditampilkan),
|
||||||
|
selectRelations: [],
|
||||||
|
|
||||||
|
// relation yang hanya ingin dihitung (akan return number)
|
||||||
|
countRelations: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
get selects(): string[] {
|
||||||
|
return [
|
||||||
|
`${ this.tableName }.id`,
|
||||||
|
`${ this.tableName }.priority`,
|
||||||
|
`${ this.tableName }.created_at`,
|
||||||
|
`${ this.tableName }.creator_name`,
|
||||||
|
`${ this.tableName }.editor_name`,
|
||||||
|
`${ this.tableName }.updated_at`,
|
||||||
|
`${ this.tableName }.status`,
|
||||||
|
`${ this.tableName }.start_date`,
|
||||||
|
`${ this.tableName }.end_date`,
|
||||||
|
`${ this.tableName }.days`,
|
||||||
|
`${ this.tableName }.holiday_name`,
|
||||||
|
|
||||||
|
'season_type.id',
|
||||||
|
'season_type.name',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
get specificFilter(): Param[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
cols: `${ this.tableName }.holiday_name`,
|
||||||
|
data: this.filterParam.holiday_names,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
setQueryFilter(
|
||||||
|
queryBuilder: SelectQueryBuilder<SeasonPeriodEntity>,
|
||||||
|
): SelectQueryBuilder<SeasonPeriodEntity> {
|
||||||
|
queryBuilder.andWhere(
|
||||||
|
`${ this.tableName }.start_date BETWEEN :from AND :to`,
|
||||||
|
{
|
||||||
|
from: new Date().toLocaleDateString(),
|
||||||
|
to: new Date().toLocaleDateString(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return queryBuilder;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,9 @@ import { DetailSeasonPeriodManager } from './managers/detail-season-period.manag
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
import { IndexSeasonPeriodeItemManager } from './managers/index-season-period-item.manager';
|
import { IndexSeasonPeriodeItemManager } from './managers/index-season-period-item.manager';
|
||||||
import { ItemRateEntity } from 'src/modules/item-related/item-rate/domain/entities/item-rate.entity';
|
import { ItemRateEntity } from 'src/modules/item-related/item-rate/domain/entities/item-rate.entity';
|
||||||
import { FilterItemRateDto } from 'src/modules/item-related/item-rate/infrastructure/dto/filter-item-rate.dto';
|
|
||||||
import { ItemRateReadService } from 'src/modules/item-related/item-rate/data/services/item-rate-read.service';
|
import { ItemRateReadService } from 'src/modules/item-related/item-rate/data/services/item-rate-read.service';
|
||||||
|
import { CurrentSeasonPeriodManager } from './managers/get-current-period.manager';
|
||||||
|
import { FilterSeasonPeriodDto } from '../../infrastructure/dto/filter-season-period.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SeasonPeriodReadOrchestrator extends BaseReadOrchestrator<SeasonPeriodEntity> {
|
export class SeasonPeriodReadOrchestrator extends BaseReadOrchestrator<SeasonPeriodEntity> {
|
||||||
|
@ -17,6 +18,7 @@ export class SeasonPeriodReadOrchestrator extends BaseReadOrchestrator<SeasonPer
|
||||||
private indexManager: IndexSeasonPeriodManager,
|
private indexManager: IndexSeasonPeriodManager,
|
||||||
private detailManager: DetailSeasonPeriodManager,
|
private detailManager: DetailSeasonPeriodManager,
|
||||||
private indexItemManager: IndexSeasonPeriodeItemManager,
|
private indexItemManager: IndexSeasonPeriodeItemManager,
|
||||||
|
private currentPeriodManager: CurrentSeasonPeriodManager,
|
||||||
private serviceData: SeasonPeriodReadService,
|
private serviceData: SeasonPeriodReadService,
|
||||||
private itemServiceRead: ItemRateReadService,
|
private itemServiceRead: ItemRateReadService,
|
||||||
) {
|
) {
|
||||||
|
@ -37,6 +39,15 @@ export class SeasonPeriodReadOrchestrator extends BaseReadOrchestrator<SeasonPer
|
||||||
return this.detailManager.getResult();
|
return this.detailManager.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async currentPeriod(): Promise<SeasonPeriodEntity> {
|
||||||
|
const params = new FilterSeasonPeriodDto();
|
||||||
|
this.currentPeriodManager.setFilterParam(params);
|
||||||
|
this.currentPeriodManager.setService(this.serviceData, TABLE_NAME.SEASON_PERIOD);
|
||||||
|
await this.currentPeriodManager.execute();
|
||||||
|
const data = this.currentPeriodManager.getResult();
|
||||||
|
return data.data[0]
|
||||||
|
}
|
||||||
|
|
||||||
async indexItem(params): Promise<PaginationResponse<ItemRateEntity>> {
|
async indexItem(params): Promise<PaginationResponse<ItemRateEntity>> {
|
||||||
this.indexItemManager.setFilterParam(params);
|
this.indexItemManager.setFilterParam(params);
|
||||||
this.indexItemManager.setService(
|
this.indexItemManager.setService(
|
||||||
|
|
|
@ -25,6 +25,11 @@ export class SeasonPeriodReadController {
|
||||||
return await this.orchestrator.index(params);
|
return await this.orchestrator.index(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('current-period')
|
||||||
|
async currentPeriod(): Promise<SeasonPeriodEntity> {
|
||||||
|
return await this.orchestrator.currentPeriod();
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
async detail(@Param('id') id: string): Promise<SeasonPeriodEntity> {
|
async detail(@Param('id') id: string): Promise<SeasonPeriodEntity> {
|
||||||
return await this.orchestrator.detail(id);
|
return await this.orchestrator.detail(id);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/it
|
||||||
import { ItemRateReadService } from 'src/modules/item-related/item-rate/data/services/item-rate-read.service';
|
import { ItemRateReadService } from 'src/modules/item-related/item-rate/data/services/item-rate-read.service';
|
||||||
import { SeasonPeriodPriceUpdatedHandler } from './domain/usecases/handlers/season-period-price-updated.handler';
|
import { SeasonPeriodPriceUpdatedHandler } from './domain/usecases/handlers/season-period-price-updated.handler';
|
||||||
import { UpdateSeasonPeriodPriceManager } from './domain/usecases/managers/update-season-period-price.manager';
|
import { UpdateSeasonPeriodPriceManager } from './domain/usecases/managers/update-season-period-price.manager';
|
||||||
|
import { CurrentSeasonPeriodManager } from './domain/usecases/managers/get-current-period.manager';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -57,6 +58,7 @@ import { UpdateSeasonPeriodPriceManager } from './domain/usecases/managers/updat
|
||||||
BatchActiveSeasonPeriodManager,
|
BatchActiveSeasonPeriodManager,
|
||||||
BatchConfirmSeasonPeriodManager,
|
BatchConfirmSeasonPeriodManager,
|
||||||
BatchInactiveSeasonPeriodManager,
|
BatchInactiveSeasonPeriodManager,
|
||||||
|
CurrentSeasonPeriodManager,
|
||||||
|
|
||||||
SeasonPeriodDataService,
|
SeasonPeriodDataService,
|
||||||
SeasonPeriodReadService,
|
SeasonPeriodReadService,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
import { TransactionEntity } from 'src/modules/transaction/transaction/domain/entities/transaction.entity';
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BatchConfirmReconciliationManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
export class BatchConfirmReconciliationManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||||
|
@ -19,7 +20,7 @@ export class BatchConfirmReconciliationManager extends BaseBatchUpdateStatusMana
|
||||||
reconciliation_mdr: this.data.reconciliation_mdr ?? null,
|
reconciliation_mdr: this.data.reconciliation_mdr ?? null,
|
||||||
reconciliation_confirm_by: this.user.name,
|
reconciliation_confirm_by: this.user.name,
|
||||||
reconciliation_confirm_date: new Date().getTime(),
|
reconciliation_confirm_date: new Date().getTime(),
|
||||||
status: this.oldData.status,
|
status: STATUS.SETTLED,
|
||||||
reconciliation_status: this.dataStatus,
|
reconciliation_status: this.dataStatus,
|
||||||
payment_total_net_profit: net_profit,
|
payment_total_net_profit: net_profit,
|
||||||
payment_date: this.data.payment_date,
|
payment_date: this.data.payment_date,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
||||||
|
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
import {
|
import {
|
||||||
EventTopics,
|
EventTopics,
|
||||||
validateRelations,
|
validateRelations,
|
||||||
|
@ -21,7 +22,7 @@ export class ConfirmReconciliationManager extends BaseUpdateStatusManager<Transa
|
||||||
Object.assign(this.data, {
|
Object.assign(this.data, {
|
||||||
reconciliation_confirm_by: this.user.name,
|
reconciliation_confirm_by: this.user.name,
|
||||||
reconciliation_confirm_date: new Date().getTime(),
|
reconciliation_confirm_date: new Date().getTime(),
|
||||||
status: this.oldData.status,
|
status: STATUS.SETTLED,
|
||||||
reconciliation_status: this.dataStatus,
|
reconciliation_status: this.dataStatus,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusManager<TransactionEntity> {
|
||||||
validateData(data: TransactionEntity): Promise<void> {
|
validateData(data: TransactionEntity): Promise<void> {
|
||||||
if (
|
if (
|
||||||
[STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(data.status)
|
![STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(data.status)
|
||||||
) {
|
) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
@ -27,31 +27,9 @@ export class BatchConfirmDataTransactionManager extends BaseBatchUpdateStatusMan
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data.status) {
|
|
||||||
// jika confirm status pending
|
|
||||||
// maka akan kebuat reconsiliasi
|
|
||||||
case STATUS.PENDING:
|
|
||||||
data.reconciliation_status = STATUS.PENDING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// jika confirm status rejected
|
|
||||||
case STATUS.REJECTED:
|
|
||||||
data.reconciliation_status = STATUS.PENDING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// jika confirm status expired
|
|
||||||
case STATUS.EXPIRED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
data.reconciliation_status = STATUS.PENDING;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const freeTransaction = data.payment_total < 1;
|
|
||||||
|
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
status: STATUS.WAITING,
|
||||||
|
reconciliation_status: STATUS.PENDING,
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -24,6 +24,11 @@ export class BatchConfirmTransactionManager extends BaseBatchUpdateStatusManager
|
||||||
error: 'Unprocessable Entity',
|
error: 'Unprocessable Entity',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const freeTransaction = data.payment_total < 1;
|
||||||
|
Object.assign(data, {
|
||||||
|
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ export class ConfirmDataTransactionManager extends BaseUpdateStatusManager<Trans
|
||||||
const old_status = this.oldData.status;
|
const old_status = this.oldData.status;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
[STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(old_status)
|
![STATUS.PENDING, STATUS.REJECTED, STATUS.EXPIRED].includes(old_status)
|
||||||
) {
|
) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
@ -36,29 +36,9 @@ export class ConfirmDataTransactionManager extends BaseUpdateStatusManager<Trans
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (old_status) {
|
|
||||||
// jika confirm status pending
|
|
||||||
// maka akan kebuat reconsiliasi
|
|
||||||
case STATUS.PENDING:
|
|
||||||
this.data.reconciliation_status = STATUS.PENDING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// jika confirm status rejected
|
|
||||||
case STATUS.REJECTED:
|
|
||||||
this.data.reconciliation_status = STATUS.PENDING;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// jika confirm status expired
|
|
||||||
case STATUS.EXPIRED:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
this.data.reconciliation_status = STATUS.PENDING;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const freeTransaction = this.data.payment_total < 1;
|
|
||||||
Object.assign(this.data, {
|
Object.assign(this.data, {
|
||||||
status: freeTransaction ? STATUS.ACTIVE : STATUS.PENDING,
|
status: STATUS.WAITING,
|
||||||
|
reconciliation_status: STATUS.PENDING,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,9 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
||||||
`${this.tableName}.invoice_date`,
|
`${this.tableName}.invoice_date`,
|
||||||
`${this.tableName}.settlement_date`,
|
`${this.tableName}.settlement_date`,
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
|
`${this.tableName}.creator_id`,
|
||||||
`${this.tableName}.creator_name`,
|
`${this.tableName}.creator_name`,
|
||||||
|
`${this.tableName}.updated_at`,
|
||||||
`${this.tableName}.editor_id`,
|
`${this.tableName}.editor_id`,
|
||||||
`${this.tableName}.editor_name`,
|
`${this.tableName}.editor_name`,
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
columnUniques,
|
columnUniques,
|
||||||
validateRelations,
|
validateRelations,
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
} from 'src/core/strings/constants/interface.constants';
|
||||||
|
import { TransactionType } from '../../../constants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UpdateTransactionManager extends BaseUpdateManager<TransactionEntity> {
|
export class UpdateTransactionManager extends BaseUpdateManager<TransactionEntity> {
|
||||||
|
@ -16,6 +17,29 @@ export class UpdateTransactionManager extends BaseUpdateManager<TransactionEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
async beforeProcess(): Promise<void> {
|
||||||
|
Object.assign(this.data, {
|
||||||
|
type: TransactionType.ADMIN,
|
||||||
|
customer_category_id: this.data.customer_category?.id ?? null,
|
||||||
|
customer_category_name: this.data.customer_category?.name ?? null,
|
||||||
|
season_period_id: this.data.season_period?.id ?? null,
|
||||||
|
season_period_name: this.data.season_period?.holiday_name ?? null,
|
||||||
|
season_period_type_id: this.data.season_period?.season_type?.id ?? null,
|
||||||
|
season_period_type_name:
|
||||||
|
this.data.season_period?.season_type?.name ?? null,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.data.items?.map((item) => {
|
||||||
|
Object.assign(item, {
|
||||||
|
item_id: item.item.id,
|
||||||
|
item_name: item.item.name,
|
||||||
|
item_type: item.item.item_type,
|
||||||
|
item_price: item.item.base_price,
|
||||||
|
item_tenant_id: item.item.tenant?.id ?? null,
|
||||||
|
item_tenant_name: item.item.tenant?.id ?? null,
|
||||||
|
item_tenant_percentage: item.item.tenant?.share_margin ?? null,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue