Compare commits
9 Commits
1.5.0-prod
...
production
Author | SHA1 | Date |
---|---|---|
|
2201071c68 | |
|
027025935c | |
|
10cd1a711e | |
|
bad4b2ea56 | |
|
35919b91f7 | |
|
8afbe33c01 | |
|
f2d7ea80d2 | |
|
b18a834129 | |
|
928e2e7648 |
|
@ -100,7 +100,7 @@ export class CouchService {
|
||||||
public async totalTodayTransactions(database = 'transaction') {
|
public async totalTodayTransactions(database = 'transaction') {
|
||||||
try {
|
try {
|
||||||
const nano = this.nanoInstance;
|
const nano = this.nanoInstance;
|
||||||
const db = nano.use(database);
|
const db = nano.use<any>(database);
|
||||||
|
|
||||||
// Get today's start timestamp (midnight)
|
// Get today's start timestamp (midnight)
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
@ -116,10 +116,14 @@ export class CouchService {
|
||||||
|
|
||||||
const result = await db.find({
|
const result = await db.find({
|
||||||
selector: selector,
|
selector: selector,
|
||||||
fields: ['_id'],
|
fields: ['_id', 'payment_total_pay'],
|
||||||
|
limit: 10000,
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.docs.length;
|
return result.docs.reduce(
|
||||||
|
(sum, doc) => sum + (doc.payment_total_pay || 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
apm.captureError(error);
|
apm.captureError(error);
|
||||||
|
|
|
@ -42,9 +42,16 @@ export default <ReportConfigEntity>{
|
||||||
},
|
},
|
||||||
|
|
||||||
column_configs: [
|
column_configs: [
|
||||||
|
// {
|
||||||
|
// column: 'main__payment_date',
|
||||||
|
// query: `to_char(main.payment_date, 'DD-MM-YYYY')`,
|
||||||
|
// label: 'Tgl. Pendapatan',
|
||||||
|
// type: DATA_TYPE.DIMENSION,
|
||||||
|
// format: DATA_FORMAT.TEXT,
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
column: 'main__payment_date',
|
column: 'main__payment_date',
|
||||||
query: `to_char(main.payment_date, 'DD-MM-YYYY')`,
|
query: `to_char(cast(to_timestamp(main.created_at/1000) as date),'DD-MM-YYYY')`,
|
||||||
label: 'Tgl. Pendapatan',
|
label: 'Tgl. Pendapatan',
|
||||||
type: DATA_TYPE.DIMENSION,
|
type: DATA_TYPE.DIMENSION,
|
||||||
format: DATA_FORMAT.TEXT,
|
format: DATA_FORMAT.TEXT,
|
||||||
|
@ -282,15 +289,22 @@ export default <ReportConfigEntity>{
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
filter_configs: [
|
filter_configs: [
|
||||||
|
// {
|
||||||
|
// filed_label: 'Tgl. Pembatalan',
|
||||||
|
// filter_column: 'main__payment_date',
|
||||||
|
// field_type: FILTER_FIELD_TYPE.date_range_picker,
|
||||||
|
// filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP,
|
||||||
|
// // date_format: 'DD-MM-YYYY',
|
||||||
|
// date_format: 'YYYY-MM-DD',
|
||||||
|
// },
|
||||||
|
|
||||||
{
|
{
|
||||||
filed_label: 'Tgl. Pembatalan',
|
filed_label: 'Tgl. Pembatalan',
|
||||||
filter_column: 'main__payment_date',
|
filter_column: 'main__payment_date',
|
||||||
field_type: FILTER_FIELD_TYPE.date_range_picker,
|
field_type: FILTER_FIELD_TYPE.date_range_picker,
|
||||||
filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP,
|
filter_type: FILTER_TYPE.DATE_IN_RANGE_TIMESTAMP,
|
||||||
// date_format: 'DD-MM-YYYY',
|
date_format: 'DD-MM-YYYY',
|
||||||
date_format: 'YYYY-MM-DD',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
filed_label: 'Sumber',
|
filed_label: 'Sumber',
|
||||||
filter_column: 'main__type',
|
filter_column: 'main__type',
|
||||||
|
@ -392,8 +406,9 @@ export default <ReportConfigEntity>{
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
customQueryColumn(column) {
|
customQueryColumn(column) {
|
||||||
if (column === 'main__payment_date') return 'main.payment_date';
|
// if (column === 'main__payment_date') return 'main.payment_date';
|
||||||
else if (column === 'refund__refund_date') return 'refund.refund_date';
|
// else if (column === 'refund__refund_date') return 'refund.refund_date';
|
||||||
|
if (column === 'refund__refund_date') return 'refund.refund_date';
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -255,7 +255,14 @@ export default <ReportConfigEntity>{
|
||||||
{
|
{
|
||||||
column: 'main__payment_card_information',
|
column: 'main__payment_card_information',
|
||||||
query: 'main.payment_card_information',
|
query: 'main.payment_card_information',
|
||||||
label: 'Information',
|
label: 'Card Information',
|
||||||
|
type: DATA_TYPE.DIMENSION,
|
||||||
|
format: DATA_FORMAT.TEXT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
column: 'main__payment_code_reference',
|
||||||
|
query: 'main.payment_code_reference',
|
||||||
|
label: 'Payment Reference',
|
||||||
type: DATA_TYPE.DIMENSION,
|
type: DATA_TYPE.DIMENSION,
|
||||||
format: DATA_FORMAT.TEXT,
|
format: DATA_FORMAT.TEXT,
|
||||||
},
|
},
|
||||||
|
@ -334,6 +341,18 @@ export default <ReportConfigEntity>{
|
||||||
field_type: FILTER_FIELD_TYPE.input_tag,
|
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||||
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
filter_type: FILTER_TYPE.TEXT_MULTIPLE_CONTAINS,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
filed_label: 'Card Information',
|
||||||
|
filter_column: 'main__payment_card_information',
|
||||||
|
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||||
|
filter_type: FILTER_TYPE.TEXT_IN_MEMBER,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filed_label: 'Payment Reference',
|
||||||
|
filter_column: 'main__payment_code_reference',
|
||||||
|
field_type: FILTER_FIELD_TYPE.input_tag,
|
||||||
|
filter_type: FILTER_TYPE.TEXT_IN_MEMBER,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
filed_label: 'Tgl. Pengembalian',
|
filed_label: 'Tgl. Pengembalian',
|
||||||
filter_column: 'refund__refund_date',
|
filter_column: 'refund__refund_date',
|
||||||
|
|
|
@ -14,12 +14,13 @@ import {
|
||||||
TransactionSettingModel,
|
TransactionSettingModel,
|
||||||
} from '../models/sales-price-formula.model';
|
} from '../models/sales-price-formula.model';
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { MoreThan, Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { FormulaType } from '../../constants';
|
import { FormulaType } from '../../constants';
|
||||||
import { TaxModel } from 'src/modules/transaction/tax/data/models/tax.model';
|
import { TaxModel } from 'src/modules/transaction/tax/data/models/tax.model';
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
||||||
|
import { TransactionType } from 'src/modules/transaction/transaction/constants';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SalesPriceFormulaDataService extends BaseDataService<SalesPriceFormulaEntity> {
|
export class SalesPriceFormulaDataService extends BaseDataService<SalesPriceFormulaEntity> {
|
||||||
|
@ -67,11 +68,17 @@ export class SalesPriceFormulaDataService extends BaseDataService<SalesPriceForm
|
||||||
|
|
||||||
const todayTimestamp = today.getTime();
|
const todayTimestamp = today.getTime();
|
||||||
|
|
||||||
const totalTransactions = await this.transaction.count({
|
const totalTransactions = parseInt(
|
||||||
where: {
|
await this.transaction
|
||||||
created_at: MoreThan(todayTimestamp),
|
.createQueryBuilder('transaction')
|
||||||
},
|
.select('SUM(transaction.payment_total_pay)', 'sum')
|
||||||
});
|
.where('transaction.created_at > :timestamp', {
|
||||||
|
timestamp: todayTimestamp,
|
||||||
|
})
|
||||||
|
.andWhere('transaction.type = :type', { type: TransactionType.COUNTER })
|
||||||
|
.getRawOne()
|
||||||
|
.then((result) => result.sum || 0),
|
||||||
|
);
|
||||||
|
|
||||||
const couchTransaction = await this.couchService.totalTodayTransactions();
|
const couchTransaction = await this.couchService.totalTodayTransactions();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { TaxModel } from '../tax/data/models/tax.model';
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
||||||
import { UpdateTransactionSettingManager } from './domain/usecases/managers/update-transaction-setting.manager';
|
import { UpdateTransactionSettingManager } from './domain/usecases/managers/update-transaction-setting.manager';
|
||||||
import { TransactionModel } from '../transaction/data/models/transaction.model';
|
import { TransactionModel } from '../transaction/data/models/transaction.model';
|
||||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
|
@ -40,6 +40,7 @@ import { CouchService } from 'src/modules/configuration/couch/data/services/couc
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
|
CouchModule,
|
||||||
],
|
],
|
||||||
controllers: [
|
controllers: [
|
||||||
SalesPriceFormulaDataController,
|
SalesPriceFormulaDataController,
|
||||||
|
@ -57,7 +58,6 @@ import { CouchService } from 'src/modules/configuration/couch/data/services/couc
|
||||||
|
|
||||||
SalesPriceFormulaDataOrchestrator,
|
SalesPriceFormulaDataOrchestrator,
|
||||||
SalesPriceFormulaReadOrchestrator,
|
SalesPriceFormulaReadOrchestrator,
|
||||||
CouchService,
|
|
||||||
],
|
],
|
||||||
exports: [SalesPriceFormulaDataService, SalesPriceFormulaReadService],
|
exports: [SalesPriceFormulaDataService, SalesPriceFormulaReadService],
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,7 +46,7 @@ import { PaymentMethodModel } from '../payment-method/data/models/payment-method
|
||||||
import { TransactionDemographyModel } from './data/models/transaction-demography.model';
|
import { TransactionDemographyModel } from './data/models/transaction-demography.model';
|
||||||
import { PriceCalculator } from './domain/usecases/calculator/price.calculator';
|
import { PriceCalculator } from './domain/usecases/calculator/price.calculator';
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
||||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
exports: [TransactionReadService],
|
exports: [TransactionReadService],
|
||||||
|
@ -70,6 +70,7 @@ import { CouchService } from 'src/modules/configuration/couch/data/services/couc
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
|
CouchModule,
|
||||||
],
|
],
|
||||||
controllers: [TransactionDataController, TransactionReadController],
|
controllers: [TransactionDataController, TransactionReadController],
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -101,8 +102,6 @@ import { CouchService } from 'src/modules/configuration/couch/data/services/couc
|
||||||
|
|
||||||
TransactionDataOrchestrator,
|
TransactionDataOrchestrator,
|
||||||
TransactionReadOrchestrator,
|
TransactionReadOrchestrator,
|
||||||
|
|
||||||
CouchService,
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class TransactionModule {}
|
export class TransactionModule {}
|
||||||
|
|
Loading…
Reference in New Issue