Compare commits
No commits in common. "f0c1410532ab91263d0707423da39f98d6105921" and "13895394b31a2e8c3fb87aa6fee10c9bdcf897b2" have entirely different histories.
f0c1410532
...
13895394b3
|
@ -2,7 +2,6 @@ import { Injectable } from '@nestjs/common';
|
|||
import { EventBus } from '@nestjs/cqrs';
|
||||
import { mappingMidtransTransaction } from '../../domain/usecases/helpers/mapping-transaction.helper';
|
||||
import { Snap } from 'midtrans-client';
|
||||
import { MidtransStatus } from '../../domain/entities/midtrans-callback.event';
|
||||
|
||||
@Injectable()
|
||||
export class MidtransService {
|
||||
|
@ -20,8 +19,8 @@ export class MidtransService {
|
|||
return await this.midtransInstance.transaction.status(orderId);
|
||||
}
|
||||
|
||||
async changeStatus(orderId: string, action: MidtransStatus): Promise<any> {
|
||||
return await this.midtransInstance.transaction[action](orderId);
|
||||
async cancelOrder(orderId: string): Promise<any> {
|
||||
return await this.midtransInstance.transaction.cancel(orderId);
|
||||
}
|
||||
|
||||
async create(body): Promise<any> {
|
||||
|
|
|
@ -6,10 +6,3 @@ export interface IEventMidtrans {
|
|||
id: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export enum MidtransStatus {
|
||||
approve = 'approve',
|
||||
deny = 'deny',
|
||||
cancel = 'cancel',
|
||||
expire = 'expire',
|
||||
}
|
||||
|
|
|
@ -1,21 +1,9 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Injectable,
|
||||
Param,
|
||||
Post,
|
||||
Query,
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common';
|
||||
import { ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
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,
|
||||
MidtransStatus,
|
||||
} from '../domain/entities/midtrans-callback.event';
|
||||
import { MidtransCallbackEvent } from '../domain/entities/midtrans-callback.event';
|
||||
import { MidtransDto } from './dto/midtrans.dto';
|
||||
|
||||
@ApiTags(`midtrans`)
|
||||
|
@ -46,20 +34,14 @@ export class MidtransController {
|
|||
}
|
||||
}
|
||||
|
||||
@Get(':id/change-status')
|
||||
@ApiQuery({ name: 'status', enum: MidtransStatus })
|
||||
async cancel(
|
||||
@Param('id') id: string,
|
||||
@Query('status') status = MidtransStatus.cancel,
|
||||
) {
|
||||
@Get(':id/cancel')
|
||||
async cancel(@Param('id') id: string) {
|
||||
try {
|
||||
return await this.dataService.changeStatus(id, status);
|
||||
const data = await this.dataService.cancelOrder(id);
|
||||
return data;
|
||||
} catch (error) {
|
||||
const data =
|
||||
error.ApiResponse?.status_message ??
|
||||
error.message ??
|
||||
'Gagal update status transaksi';
|
||||
throw new UnprocessableEntityException(data);
|
||||
console.log(error.message);
|
||||
throw new Error('Gagal update status transaksi');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,30 +6,13 @@ import {
|
|||
REPORT_GROUP,
|
||||
} from '../../../constant';
|
||||
import { ReportConfigEntity } from '../../../entities/report-config.entity';
|
||||
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||
|
||||
export default <ReportConfigEntity>{
|
||||
group_name: REPORT_GROUP.transaction_report,
|
||||
unique_name: `${REPORT_GROUP.transaction_report}__income`,
|
||||
label: 'Pendapatan',
|
||||
table_schema: `transactions main
|
||||
LEFT JOIN season_types s_period_type ON s_period_type.id::text = main.season_period_type_id
|
||||
LEFT JOIN refunds refund ON refund.transaction_id = main.id and refund.status != 'cancel'
|
||||
LEFT JOIN vip_codes vip ON vip.id::text = main.discount_code_id::text
|
||||
LEFT JOIN (
|
||||
select item.transaction_id, sum(item.total_hpp) AS total_hpp_item
|
||||
from transaction_items item
|
||||
group by item.transaction_id
|
||||
) item ON item.transaction_id = main.id`,
|
||||
table_schema: 'season_types main',
|
||||
main_table_alias: 'main',
|
||||
whereDefaultConditions: [
|
||||
{
|
||||
column: 'main.status',
|
||||
filter_type: FILTER_TYPE.TEXT_IN_MEMBER,
|
||||
values: [STATUS.SETTLED, STATUS.REFUNDED, STATUS.PROCESS_REFUND],
|
||||
},
|
||||
],
|
||||
defaultOrderBy: [],
|
||||
lowLevelOrderBy: [],
|
||||
filter_period_config: {
|
||||
|
@ -38,291 +21,47 @@ export default <ReportConfigEntity>{
|
|||
|
||||
column_configs: [
|
||||
{
|
||||
column: 'main__settlement_date',
|
||||
query: 'main.settlement_date',
|
||||
label: 'Tanggal Pendapatan',
|
||||
column: 'main__created_at',
|
||||
query: 'main.created_at',
|
||||
label: 'Created Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_TIMESTAMP,
|
||||
date_format: 'DD/MM/YYYY',
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 'main__type',
|
||||
query: 'main.type',
|
||||
label: 'Sumber',
|
||||
column: 'main__updated_at',
|
||||
query: 'main.updated_at',
|
||||
label: 'Updated Date',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
format: DATA_FORMAT.DATE_EPOCH,
|
||||
},
|
||||
{
|
||||
column: 's_period_type__name',
|
||||
query: 's_period_type.name',
|
||||
label: 'Tipe Rate',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__invoice_code',
|
||||
query: 'main.invoice_code',
|
||||
label: 'Kode Booking',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__payment_code',
|
||||
query: 'main.payment_code',
|
||||
label: 'Kode Pembayaran',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__customer_type',
|
||||
query: 'main.customer_type',
|
||||
label: 'Tipe Pelanggan',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__creator_counter_no',
|
||||
query: 'main.creator_counter_no',
|
||||
label: 'No.PoS',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__no_of_group',
|
||||
query: 'main.no_of_group',
|
||||
label: '#Visitor',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'item__total_hpp_item',
|
||||
query: 'item.total_hpp_item',
|
||||
label: 'Total HPP',
|
||||
type: DATA_TYPE.MEASURE,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'main__reconciliation_mdr',
|
||||
query: 'main.reconciliation_mdr',
|
||||
label: 'MDR',
|
||||
type: DATA_TYPE.MEASURE,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'main__payment_total_dpp',
|
||||
query: 'main.payment_total_dpp',
|
||||
label: 'DPP',
|
||||
type: DATA_TYPE.MEASURE,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'main__payment_total_tax',
|
||||
query: 'main.payment_total_tax',
|
||||
label: 'Total Pajak',
|
||||
type: DATA_TYPE.MEASURE,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'main__discount_percentage',
|
||||
query: 'main.discount_percentage',
|
||||
label: 'Diskon (%)',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.NUMBER,
|
||||
},
|
||||
{
|
||||
column: 'main__discount_value',
|
||||
query: 'main.discount_value',
|
||||
label: 'Diskon (IDR)',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'main__payment_total',
|
||||
query: 'main.payment_total',
|
||||
label: 'Total Penjualan',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'refund__refund_date',
|
||||
query: 'refund.refund_date',
|
||||
label: 'Tanggal Pengembalian',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.DATE_TIMESTAMP,
|
||||
date_format: 'DD/MM/YYYY',
|
||||
},
|
||||
{
|
||||
column: 'refund__status',
|
||||
query: 'refund.status',
|
||||
label: 'Status Pengembalian',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'refund__code',
|
||||
query: 'refund.code',
|
||||
label: 'Kode Pengembalian',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'refund__refund_total',
|
||||
query: '(refund.refund_total * -1)',
|
||||
label: 'Total Pengembalian',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'transaction_balance',
|
||||
query: `CASE WHEN refund.id is null THEN main.payment_total ELSE main.payment_total - refund.refund_total END`,
|
||||
label: 'Balance',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.CURRENCY,
|
||||
},
|
||||
{
|
||||
column: 'main__discount_code',
|
||||
query: 'main.discount_code',
|
||||
label: 'Kode Diskon',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'vip__creator_name',
|
||||
query: 'vip.creator_name',
|
||||
label: 'Diberikan Oleh',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__customer_name',
|
||||
query: 'main.customer_name',
|
||||
label: 'Nama Pelanggan',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__customer_description',
|
||||
query: 'main.customer_description',
|
||||
label: 'Deskripsi',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__customer_phone',
|
||||
query: 'main.customer_phone',
|
||||
label: 'Telepon',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__payment_type_method_name',
|
||||
query: 'main.payment_type_method_name',
|
||||
label: 'Bank/Issuer',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__payment_card_information',
|
||||
query: 'main.payment_card_information',
|
||||
label: 'Information',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__creator_name',
|
||||
query: 'main.creator_name',
|
||||
label: 'Penjualan Dibuat Oleh',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__reconciliation_confirm_by',
|
||||
query: 'main.reconciliation_confirm_by',
|
||||
label: 'Direkonsiliasi Oleh',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
{
|
||||
column: 'main__creator_name',
|
||||
query: 'main.creator_name',
|
||||
label: 'Pengembalian Dibuat Oleh',
|
||||
column: 'main__name',
|
||||
query: 'main.name',
|
||||
label: 'Name',
|
||||
type: DATA_TYPE.DIMENSION,
|
||||
format: DATA_FORMAT.TEXT,
|
||||
},
|
||||
],
|
||||
filter_configs: [
|
||||
{
|
||||
filed_label: 'Tanggal Pendapatan',
|
||||
filter_column: 'main__settlement_date',
|
||||
field_type: FILTER_FIELD_TYPE.date_range_picker,
|
||||
filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP,
|
||||
},
|
||||
{
|
||||
filed_label: 'Sumber',
|
||||
filter_column: 'main__type',
|
||||
filed_label: 'Name',
|
||||
filter_column: 'main__name',
|
||||
field_type: FILTER_FIELD_TYPE.select,
|
||||
filter_type: FILTER_TYPE.TEXT_IN_MEMBER,
|
||||
select_custom_options: [...Object.values(TransactionType)],
|
||||
select_data_source_url: '/v1/season-types',
|
||||
select_custom_options: [],
|
||||
select_label_key: 'name',
|
||||
select_value_key: 'name',
|
||||
},
|
||||
{
|
||||
filed_label: 'Tipe Rate',
|
||||
filter_column: 's_period_type__name',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Kode Booking',
|
||||
filter_column: 'main__invoice_code',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Kode Pembayaran',
|
||||
filter_column: 'main__payment_code',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Tipe Pelanggan',
|
||||
filter_column: 'main__customer_type',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'No. PoS',
|
||||
filter_column: 'main__creator_counter_no',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Tanggal Pengembalian',
|
||||
filter_column: 'refund__refund_date',
|
||||
field_type: FILTER_FIELD_TYPE.date_range_picker,
|
||||
filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP,
|
||||
},
|
||||
{
|
||||
filed_label: 'Kode Pengembalian',
|
||||
filter_column: 'refund__code',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Kode Diskon',
|
||||
filter_column: 'main__discount_code',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Nama Pelanggan',
|
||||
filter_column: 'main__customer_name',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
},
|
||||
{
|
||||
filed_label: 'Bank/Issuer',
|
||||
filter_column: 'main__payment_type_method_name',
|
||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||
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',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
@ -11,13 +11,13 @@ import CashierLogReport from './configs/cashier-log';
|
|||
import CashWithdrawalsReport from './configs/cash-withdrawals';
|
||||
|
||||
export const TransactionReportConfig: ReportConfigEntity[] = [
|
||||
IncomeReport,
|
||||
// IncomeReport,
|
||||
// RevenuePerItemReport,
|
||||
// SalesQtyPerItemReport,
|
||||
// VisitorsPerRideReport,
|
||||
// TimePerRideReport,
|
||||
// BookingReport,
|
||||
// RefundsReport,
|
||||
// CashierLogReport,
|
||||
// CashWithdrawalsReport,
|
||||
BookingReport,
|
||||
RefundsReport,
|
||||
CashierLogReport,
|
||||
CashWithdrawalsReport,
|
||||
];
|
||||
|
|
|
@ -39,8 +39,6 @@ export class MidtransCallbackHandler
|
|||
settlement_date: new Date(data.settlement_time),
|
||||
payment_code: await generateInvoiceCodeHelper(this.dataService, 'PMY'),
|
||||
payment_code_reference: data.approval_code,
|
||||
payment_date: data.settlement_time,
|
||||
payment_type_method_name: `Midtrans/${data.payment_type}`,
|
||||
});
|
||||
} else if (['pending'].includes(data['transaction_status'])) {
|
||||
Object.assign(transaction, {
|
||||
|
|
|
@ -175,7 +175,7 @@ export function mappingRevertTransaction(data, type) {
|
|||
item_tenant_share_margin: item.item.tenant?.share_margin ?? null,
|
||||
|
||||
total_price: total_price,
|
||||
total_hpp: Number(item.item.hpp) * Number(item.qty),
|
||||
total_hpp: Number(item.item.item_hpp) * Number(item.qty),
|
||||
total_share_tenant: total_share_tenant,
|
||||
total_profit: total_price - Number(total_share_tenant),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue