diff --git a/src/modules/reports/shared/configs/transaction-report/configs/income.ts b/src/modules/reports/shared/configs/transaction-report/configs/income.ts index 551b235..d2752f6 100644 --- a/src/modules/reports/shared/configs/transaction-report/configs/income.ts +++ b/src/modules/reports/shared/configs/transaction-report/configs/income.ts @@ -6,13 +6,30 @@ 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 { group_name: REPORT_GROUP.transaction_report, unique_name: `${REPORT_GROUP.transaction_report}__income`, label: 'Pendapatan', - table_schema: 'season_types main', + 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`, 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: { @@ -21,47 +38,291 @@ export default { column_configs: [ { - column: 'main__created_at', - query: 'main.created_at', - label: 'Created Date', + column: 'main__settlement_date', + query: 'main.settlement_date', + label: 'Tanggal Pendapatan', type: DATA_TYPE.DIMENSION, - format: DATA_FORMAT.DATE_EPOCH, + format: DATA_FORMAT.DATE_TIMESTAMP, + date_format: 'DD/MM/YYYY', }, { - column: 'main__updated_at', - query: 'main.updated_at', - label: 'Updated Date', + column: 'main__type', + query: 'main.type', + label: 'Sumber', type: DATA_TYPE.DIMENSION, - format: DATA_FORMAT.DATE_EPOCH, + format: DATA_FORMAT.TEXT, }, { - column: 'main__name', - query: 'main.name', - label: 'Name', + 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', 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: '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: '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', + filed_label: 'Sumber', + filter_column: 'main__type', + field_type: FILTER_FIELD_TYPE.select, + filter_type: FILTER_TYPE.TEXT_IN_MEMBER, + select_custom_options: [...Object.values(TransactionType)], + }, + { + 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, }, ], }; diff --git a/src/modules/reports/shared/configs/transaction-report/index.ts b/src/modules/reports/shared/configs/transaction-report/index.ts index 8acd1d7..a51f33b 100644 --- a/src/modules/reports/shared/configs/transaction-report/index.ts +++ b/src/modules/reports/shared/configs/transaction-report/index.ts @@ -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, ]; diff --git a/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts b/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts index 1cc9f7a..487ef24 100644 --- a/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts +++ b/src/modules/transaction/transaction/domain/usecases/managers/helpers/mapping-transaction.helper.ts @@ -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.item_hpp) * Number(item.qty), + total_hpp: Number(item.item.hpp) * Number(item.qty), total_share_tenant: total_share_tenant, total_profit: total_price - Number(total_share_tenant), });