Compare commits

..

No commits in common. "ac3ee266b994b130b0f033777e73aaca42f70965" and "b716c75a2cb25c46e95280cf5cd641a361c96bc1" have entirely different histories.

6 changed files with 31 additions and 98 deletions

View File

@ -43,20 +43,11 @@ export class BatchCancelReconciliationManager extends BaseBatchUpdateStatusManag
payment_date: this.data.payment_date,
});
// FIXME => VALIDATION GUARD CANCEL FOR RECONCILIATION FROM CASHIER
if (data.is_recap_transaction) {
// throw new UnprocessableEntityException({
// statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
// message: `Gagagl! tidak dapat batalkan data rekap`,
// error: 'Unprocessable Entity',
// });
Object.assign(this.data, {
reconciliation_confirm_by: null,
reconciliation_confirm_date: null,
reconciliation_status: STATUS.PENDING,
payment_code: null,
settlement_date: null,
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Gagagl! tidak dapat batalkan data rekap`,
error: 'Unprocessable Entity',
});
}

View File

@ -37,39 +37,26 @@ export class CancelReconciliationManager extends BaseUpdateStatusManager<Transac
error: 'Unprocessable Entity',
});
} else if (this.data.is_recap_transaction) {
// FIXME => VALIDATION GUARD CANCEL FOR RECONCILIATION FROM CASHIER
// throw new UnprocessableEntityException({
// statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
// message: `Gagagl! tidak dapat batalkan data rekap`,
// error: 'Unprocessable Entity',
// });
throw new UnprocessableEntityException({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: `Gagagl! tidak dapat batalkan data rekap`,
error: 'Unprocessable Entity',
});
}
return;
}
async beforeProcess(): Promise<void> {
if (this.data.is_recap_transaction) {
Object.assign(this.data, {
reconciliation_confirm_by: null,
reconciliation_confirm_date: null,
reconciliation_status: STATUS.PENDING,
payment_code: null,
settlement_date: null,
});
} else {
Object.assign(this.data, {
reconciliation_mdr: this.data.reconciliation_mdr ?? null,
reconciliation_confirm_by: this.user.name,
reconciliation_confirm_date: new Date().getTime(),
status: this.dataStatus,
reconciliation_status: this.dataStatus,
payment_date: this.data.payment_date,
settlement_date:
this.dataStatus === STATUS.REJECTED
? null
: this.data.settlement_date,
});
}
Object.assign(this.data, {
reconciliation_mdr: this.data.reconciliation_mdr ?? null,
reconciliation_confirm_by: this.user.name,
reconciliation_confirm_date: new Date().getTime(),
status: this.dataStatus,
reconciliation_status: this.dataStatus,
payment_date: this.data.payment_date,
settlement_date:
this.dataStatus === STATUS.REJECTED ? null : this.data.settlement_date,
});
return;
}

View File

@ -8,18 +8,12 @@ import { Between, IsNull, MoreThan, Not } from 'typeorm';
import * as _ from 'lodash';
import * as moment from 'moment';
import { EMPTY_UUID, STATUS } from 'src/core/strings/constants/base.constants';
import { RecapReconciliationDto } from '../../../infrastructure/dto/recap.dto';
@Injectable()
export class RecapReconciliationManager extends BaseCustomManager<TransactionEntity> {
private recapTransactions = {};
private bodyFilter: any;
private paymentDate: string;
setBodyFilter(body: RecapReconciliationDto) {
this.bodyFilter = body;
this.paymentDate = body.payment_date;
}
private startOfDay = moment().startOf('day').valueOf();
private endOfDay = moment().endOf('day').valueOf();
get entityTarget(): any {
return TransactionModel;
@ -43,7 +37,7 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
is_recap_transaction: false,
payment_type: TransactionType.COUNTER,
status: STATUS.SETTLED,
payment_date: this.paymentDate,
created_at: Between(this.startOfDay, this.endOfDay),
payment_type_counter: Not(IsNull()),
payment_total: MoreThan(0),
},
@ -54,17 +48,13 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
creator_counter_no,
payment_type_counter,
payment_type_method_id,
payment_date,
} = transaction;
const group_by =
creator_counter_no +
'-' +
payment_type_counter +
'-' +
payment_type_method_id +
'_' +
payment_date;
payment_type_method_id;
if (!this.recapTransactions[group_by]) {
this.recapTransactions[group_by] = [];
}
@ -76,20 +66,17 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
async process(): Promise<void> {
const total_recap = Object.keys(this.recapTransactions);
for (const recap of total_recap) {
const first_transaction = this.recapTransactions[recap][0];
const {
creator_counter_no,
payment_type_counter,
payment_type_method_id,
payment_date,
} = first_transaction;
const query = {
is_recap_transaction: true,
payment_date: payment_date,
created_at: Between(this.startOfDay, this.endOfDay),
creator_counter_no: creator_counter_no,
payment_type: payment_type_counter,
};
@ -107,30 +94,9 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
);
if (exist) {
if (parseFloat(exist.payment_total) !== total) {
const newTotal = total;
const newTotalNet =
total - parseFloat(exist.reconciliation_mdr ?? '0');
Object.assign(exist, {
payment_total: newTotal,
payment_total_net_profit: newTotalNet,
//RESET STATUS TO PENDING
reconciliation_confirm_by: null,
reconciliation_confirm_date: null,
reconciliation_status: STATUS.PENDING,
payment_code: null,
settlement_date: null,
});
} else {
Object.assign(exist, {
payment_total: total,
payment_total_net_profit: total,
});
}
Object.assign(exist, {
payment_total: total,
payment_total_net_profit: total,
editor_id: this.user.id,
editor_name: this.user.name,
updated_at: new Date().getTime(),
@ -143,8 +109,8 @@ export class RecapReconciliationManager extends BaseCustomManager<TransactionEnt
reconciliation_status: STATUS.PENDING,
status: STATUS.SETTLED,
type: TransactionType.COUNTER,
booking_date: payment_date,
payment_date: payment_date,
booking_date: new Date(),
payment_date: new Date(),
creator_counter_no: first_transaction.creator_counter_no,
payment_type: first_transaction.payment_type_counter,
payment_type_counter: first_transaction.payment_type_counter,

View File

@ -11,7 +11,6 @@ import { TransactionEntity } from 'src/modules/transaction/transaction/domain/en
import { TransactionDataService } from 'src/modules/transaction/transaction/data/services/transaction-data.service';
import { RecapReconciliationManager } from './managers/recap-reconciliation.manager';
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
import { RecapReconciliationDto } from '../../infrastructure/dto/recap.dto';
@Injectable()
export class ReconciliationDataOrchestrator {
@ -32,10 +31,9 @@ export class ReconciliationDataOrchestrator {
return this.updateManager.getResult();
}
async recap(body: RecapReconciliationDto) {
async recap() {
const data = new TransactionModel();
this.recapManager.setData(data);
this.recapManager.setBodyFilter(body);
this.recapManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
await this.recapManager.execute();
return this.recapManager.getResult();

View File

@ -1,8 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString } from 'class-validator';
export class RecapReconciliationDto {
@ApiProperty({ required: true, type: String })
@IsString()
payment_date: string;
}

View File

@ -15,7 +15,6 @@ import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto'
import { Public } from 'src/core/guards';
import { TransactionEntity } from '../../transaction/domain/entities/transaction.entity';
import { UpdateReconciliationDto } from './dto/reconciliation.dto';
import { RecapReconciliationDto } from './dto/recap.dto';
@ApiTags(`${MODULE_NAME.RECONCILIATION.split('-').join(' ')} - data`)
@Controller(`v1/${MODULE_NAME.RECONCILIATION}`)
@ -25,8 +24,8 @@ export class ReconciliationDataController {
constructor(private orchestrator: ReconciliationDataOrchestrator) {}
@Post('/recap-transaction')
async recap(@Body() body: RecapReconciliationDto): Promise<any> {
return await this.orchestrator.recap(body);
async recap(): Promise<any> {
return await this.orchestrator.recap();
}
@Put('/batch-confirm')