Compare commits
No commits in common. "822cfe606a2dff1ae28008b7ee534d4623d2db93" and "1d9cdfe8e6c66338f0761f40f11c6d434664c224" have entirely different histories.
822cfe606a
...
1d9cdfe8e6
|
@ -106,7 +106,6 @@ import { OtpVerificationModule } from './modules/configuration/otp-verification/
|
||||||
import { OtpVerificationModel } from './modules/configuration/otp-verification/data/models/otp-verification.model';
|
import { OtpVerificationModel } from './modules/configuration/otp-verification/data/models/otp-verification.model';
|
||||||
import { OtpVerifierModel } from './modules/configuration/otp-verification/data/models/otp-verifier.model';
|
import { OtpVerifierModel } from './modules/configuration/otp-verification/data/models/otp-verifier.model';
|
||||||
import { RescheduleVerificationModel } from './modules/booking-online/order/data/models/reschedule-verification.model';
|
import { RescheduleVerificationModel } from './modules/booking-online/order/data/models/reschedule-verification.model';
|
||||||
import { OtpCheckerGuard } from './core/guards/domain/otp-checker.guard';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -247,8 +246,6 @@ import { OtpCheckerGuard } from './core/guards/domain/otp-checker.guard';
|
||||||
providers: [
|
providers: [
|
||||||
AuthService,
|
AuthService,
|
||||||
PrivilegeService,
|
PrivilegeService,
|
||||||
OtpCheckerGuard,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By default all request from client will protect by JWT
|
* By default all request from client will protect by JWT
|
||||||
* if there is some endpoint/function that does'nt require authentication
|
* if there is some endpoint/function that does'nt require authentication
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
import {
|
|
||||||
CanActivate,
|
|
||||||
ExecutionContext,
|
|
||||||
Injectable,
|
|
||||||
UnprocessableEntityException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { InjectDataSource } from '@nestjs/typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { OtpVerificationModel } from 'src/modules/configuration/otp-verification/data/models/otp-verification.model';
|
|
||||||
import { OtpVerificationEntity } from 'src/modules/configuration/otp-verification/domain/entities/otp-verification.entity';
|
|
||||||
import { DataSource } from 'typeorm';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class OtpCheckerGuard implements CanActivate {
|
|
||||||
constructor(
|
|
||||||
@InjectDataSource(CONNECTION_NAME.DEFAULT)
|
|
||||||
protected readonly dataSource: DataSource,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
get otpRepository() {
|
|
||||||
return this.dataSource.getRepository(OtpVerificationModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
||||||
const request = context.switchToHttp().getRequest();
|
|
||||||
const verificationCode = request.headers['x-verification-code'];
|
|
||||||
console.log({ verificationCode });
|
|
||||||
|
|
||||||
if (verificationCode) {
|
|
||||||
const decoded = Buffer.from(verificationCode, 'base64').toString('ascii');
|
|
||||||
const [dataIdentity, otpCode] = decoded.split('|');
|
|
||||||
|
|
||||||
let otpData: OtpVerificationEntity;
|
|
||||||
|
|
||||||
otpData = await this.otpRepository.findOne({
|
|
||||||
where: {
|
|
||||||
otp_code: otpCode,
|
|
||||||
target_id: dataIdentity,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!otpData) {
|
|
||||||
otpData = await this.otpRepository.findOne({
|
|
||||||
where: {
|
|
||||||
otp_code: otpCode,
|
|
||||||
reference: dataIdentity,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (otpData && otpData?.verified_at) return true;
|
|
||||||
console.log({ dataIdentity, otpCode, otpData });
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnprocessableEntityException('OTP not verified.');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
||||||
import { TransactionTaxModel } from 'src/modules/transaction/transaction/data/models/transaction-tax.model';
|
import { TransactionTaxModel } from 'src/modules/transaction/transaction/data/models/transaction-tax.model';
|
||||||
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
|
@ -19,7 +19,6 @@ import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
CouchModule,
|
|
||||||
],
|
],
|
||||||
controllers: [GoogleCalendarController],
|
controllers: [GoogleCalendarController],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { TransactionDataService } from 'src/modules/transaction/transaction/data
|
||||||
import { PaymentTransactionHandler } from './domain/handlers/payment-transaction.handler';
|
import { PaymentTransactionHandler } from './domain/handlers/payment-transaction.handler';
|
||||||
import { MailTemplateController } from './infrastructure/mail.controller';
|
import { MailTemplateController } from './infrastructure/mail.controller';
|
||||||
import { PdfMakeManager } from '../export/domain/managers/pdf-make.manager';
|
import { PdfMakeManager } from '../export/domain/managers/pdf-make.manager';
|
||||||
import { CouchModule } from '../couch/couch.module';
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
|
@ -19,7 +19,6 @@ import { CouchModule } from '../couch/couch.module';
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
CouchModule,
|
|
||||||
],
|
],
|
||||||
controllers: [MailTemplateController],
|
controllers: [MailTemplateController],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
OtpVerifierCreateDto,
|
OtpVerifierCreateDto,
|
||||||
OtpVerifyDto,
|
OtpVerifyDto,
|
||||||
} from './dto/otp-verification.dto';
|
} from './dto/otp-verification.dto';
|
||||||
import { OtpAuthGuard } from './guards/otp-auth.guard';
|
import { OtpAuthGuard } from './guards/otp-auth-guard';
|
||||||
import { OtpVerifierService } from '../data/services/otp-verifier.service';
|
import { OtpVerifierService } from '../data/services/otp-verifier.service';
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.OTP_VERIFICATIONS.split('-').join(' ')} - data`)
|
@ApiTags(`${MODULE_NAME.OTP_VERIFICATIONS.split('-').join(' ')} - data`)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
} from './infrastructure/otp-verification-data.controller';
|
} from './infrastructure/otp-verification-data.controller';
|
||||||
import { OtpVerificationService } from './data/services/otp-verification.service';
|
import { OtpVerificationService } from './data/services/otp-verification.service';
|
||||||
import { OtpVerifierModel } from './data/models/otp-verifier.model';
|
import { OtpVerifierModel } from './data/models/otp-verifier.model';
|
||||||
import { OtpAuthGuard } from './infrastructure/guards/otp-auth.guard';
|
import { OtpAuthGuard } from './infrastructure/guards/otp-auth-guard';
|
||||||
|
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
import { JwtModule } from '@nestjs/jwt';
|
||||||
import { JWT_EXPIRED } from 'src/core/sessions/constants';
|
import { JWT_EXPIRED } from 'src/core/sessions/constants';
|
||||||
|
|
|
@ -39,7 +39,7 @@ import { ItemQueueModel } from '../item-related/item-queue/data/models/item-queu
|
||||||
import { QueueTimeFormula } from './domain/usecases/formula/queue-time.formula';
|
import { QueueTimeFormula } from './domain/usecases/formula/queue-time.formula';
|
||||||
import { QueueJobController } from './infrastructure/controllers/queue-job.controller';
|
import { QueueJobController } from './infrastructure/controllers/queue-job.controller';
|
||||||
import { GenerateQueueManager } from './domain/usecases/generate-queue.manager';
|
import { GenerateQueueManager } from './domain/usecases/generate-queue.manager';
|
||||||
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
|
@ -57,7 +57,6 @@ import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
CouchModule,
|
|
||||||
],
|
],
|
||||||
controllers: [QueueController, QueueAdminController, QueueJobController],
|
controllers: [QueueController, QueueAdminController, QueueJobController],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -19,13 +19,13 @@ import { BatchCancelReconciliationManager } from './domain/usecases/managers/bat
|
||||||
import { BatchConfirmReconciliationManager } from './domain/usecases/managers/batch-confirm-reconciliation.manager';
|
import { BatchConfirmReconciliationManager } from './domain/usecases/managers/batch-confirm-reconciliation.manager';
|
||||||
import { RecapReconciliationManager } from './domain/usecases/managers/recap-reconciliation.manager';
|
import { RecapReconciliationManager } from './domain/usecases/managers/recap-reconciliation.manager';
|
||||||
import { RecapPosTransactionHandler } from './domain/usecases/handlers/recap-pos-transaction.handler';
|
import { RecapPosTransactionHandler } from './domain/usecases/handlers/recap-pos-transaction.handler';
|
||||||
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
import { SalesPriceFormulaDataService } from '../sales-price-formula/data/services/sales-price-formula-data.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
TypeOrmModule.forFeature([TransactionModel], CONNECTION_NAME.DEFAULT),
|
TypeOrmModule.forFeature([TransactionModel], CONNECTION_NAME.DEFAULT),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
CouchModule,
|
|
||||||
],
|
],
|
||||||
controllers: [ReconciliationDataController, ReconciliationReadController],
|
controllers: [ReconciliationDataController, ReconciliationReadController],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { CancelRefundManager } from './domain/usecases/managers/cancel-refund.ma
|
||||||
import { RefundItemModel } from './data/models/refund-item.model';
|
import { RefundItemModel } from './data/models/refund-item.model';
|
||||||
import { TransactionDataService } from '../transaction/data/services/transaction-data.service';
|
import { TransactionDataService } from '../transaction/data/services/transaction-data.service';
|
||||||
import { TransactionModel } from '../transaction/data/models/transaction.model';
|
import { TransactionModel } from '../transaction/data/models/transaction.model';
|
||||||
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
|
@ -32,7 +32,6 @@ import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
CouchModule,
|
|
||||||
],
|
],
|
||||||
controllers: [RefundDataController, RefundReadController],
|
controllers: [RefundDataController, RefundReadController],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -4,14 +4,12 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { TransactionModel } from '../models/transaction.model';
|
import { TransactionModel } from '../models/transaction.model';
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TransactionDataService extends BaseDataService<TransactionModel> {
|
export class TransactionDataService extends BaseDataService<TransactionModel> {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(TransactionModel, CONNECTION_NAME.DEFAULT)
|
@InjectRepository(TransactionModel, CONNECTION_NAME.DEFAULT)
|
||||||
private repo: Repository<TransactionModel>,
|
private repo: Repository<TransactionModel>,
|
||||||
private couchService: CouchService,
|
|
||||||
) {
|
) {
|
||||||
super(repo);
|
super(repo);
|
||||||
}
|
}
|
||||||
|
@ -22,14 +20,4 @@ export class TransactionDataService extends BaseDataService<TransactionModel> {
|
||||||
where: { id: booking_id },
|
where: { id: booking_id },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveTransactionToCouch(transaction) {
|
|
||||||
const id = transaction.id ?? transaction._id;
|
|
||||||
const couchData = await this.couchService.getDoc(id, 'transaction');
|
|
||||||
if (!couchData) {
|
|
||||||
await this.couchService.createDoc(transaction, 'transaction');
|
|
||||||
} else {
|
|
||||||
await this.couchService.updateDoc(transaction, 'transaction');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,64 +30,4 @@ export class TransactionReadService extends BaseReadService<TransactionEntity> {
|
||||||
|
|
||||||
return transactions;
|
return transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSummary(posId: string, startDate: string) {
|
|
||||||
const query = `select payment_type_counter, payment_type_method_name, sum(payment_total) payment_total, sum(payment_total_pay) payment_total_pay
|
|
||||||
from transactions t
|
|
||||||
where 1=1
|
|
||||||
and t.creator_counter_no IN (${posId})
|
|
||||||
and invoice_date = '${startDate}'
|
|
||||||
and status = 'settled'
|
|
||||||
group by payment_type_counter, payment_type_method_name;`;
|
|
||||||
const transactions = await this.repo.query(query);
|
|
||||||
|
|
||||||
const qtyQuery = `select ti.item_id, ti.item_name, sum(ti.qty) total_qty, count(ti.item_name), sum(ti.qty), string_agg(distinct ti.item_price::text, '') price,
|
|
||||||
sum(payment_total) payment_total, sum(payment_total_pay) payment_total_pay
|
|
||||||
from transactions t
|
|
||||||
inner join transaction_items ti on t.id = ti.transaction_id
|
|
||||||
where t.creator_counter_no IN (${posId})
|
|
||||||
and invoice_date = '${startDate}'
|
|
||||||
and t.status = 'settled'
|
|
||||||
group by ti.item_name, ti.item_id`;
|
|
||||||
const qtyTransactions = await this.repo.query(qtyQuery);
|
|
||||||
|
|
||||||
const totalSalesQuery = `select sum(payment_total) payment_total
|
|
||||||
from transactions t
|
|
||||||
where 1=1
|
|
||||||
and t.creator_counter_no IN (${posId})
|
|
||||||
and invoice_date = '${startDate}'
|
|
||||||
and status = 'settled'`;
|
|
||||||
const totalSales = await this.repo.query(totalSalesQuery);
|
|
||||||
|
|
||||||
return {
|
|
||||||
payment: transactions,
|
|
||||||
qty: qtyTransactions,
|
|
||||||
totalSales: totalSales?.[0]?.payment_total ?? 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async getLastTransactionByPos(
|
|
||||||
posId: string,
|
|
||||||
): Promise<TransactionEntity | null> {
|
|
||||||
const transaction = await this.repo.findOne({
|
|
||||||
select: [
|
|
||||||
'id',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
'status',
|
|
||||||
'invoice_code',
|
|
||||||
'creator_counter_no',
|
|
||||||
'invoice_date',
|
|
||||||
'payment_total',
|
|
||||||
],
|
|
||||||
where: {
|
|
||||||
creator_counter_no: parseInt(posId),
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
created_at: 'DESC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return transaction;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,10 +141,4 @@ export class TransactionDataOrchestrator {
|
||||||
await this.batchConfirmDataManager.execute();
|
await this.batchConfirmDataManager.execute();
|
||||||
return this.batchConfirmDataManager.getResult();
|
return this.batchConfirmDataManager.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveTransactionToCouch(transaction: any[]) {
|
|
||||||
for (const t of transaction) {
|
|
||||||
await this.serviceData.saveTransactionToCouch(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@ import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrat
|
||||||
import { DetailTransactionManager } from './managers/detail-transaction.manager';
|
import { DetailTransactionManager } from './managers/detail-transaction.manager';
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
import { PriceCalculator } from './calculator/price.calculator';
|
import { PriceCalculator } from './calculator/price.calculator';
|
||||||
import { In } from 'typeorm';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TransactionReadOrchestrator extends BaseReadOrchestrator<TransactionEntity> {
|
export class TransactionReadOrchestrator extends BaseReadOrchestrator<TransactionEntity> {
|
||||||
|
@ -28,16 +26,6 @@ export class TransactionReadOrchestrator extends BaseReadOrchestrator<Transactio
|
||||||
return this.indexManager.getResult();
|
return this.indexManager.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
async summary(posId: string) {
|
|
||||||
const today = moment().format('YYYY-MM-DD');
|
|
||||||
const summary = await this.serviceData.getSummary(posId, today);
|
|
||||||
const lastTransaction = await this.serviceData.getLastTransactionByPos(
|
|
||||||
posId,
|
|
||||||
);
|
|
||||||
|
|
||||||
return { summary, lastTransaction };
|
|
||||||
}
|
|
||||||
|
|
||||||
async detail(dataId: string): Promise<TransactionEntity> {
|
async detail(dataId: string): Promise<TransactionEntity> {
|
||||||
this.detailManager.setData(dataId);
|
this.detailManager.setData(dataId);
|
||||||
this.detailManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
this.detailManager.setService(this.serviceData, TABLE_NAME.TRANSACTION);
|
||||||
|
@ -62,24 +50,17 @@ export class TransactionReadOrchestrator extends BaseReadOrchestrator<Transactio
|
||||||
transaction.payment_total_dpp = price.dpp_value;
|
transaction.payment_total_dpp = price.dpp_value;
|
||||||
transaction.payment_total_share = price.other.total_profit_share;
|
transaction.payment_total_share = price.other.total_profit_share;
|
||||||
transaction.payment_total_tax = price.other.payment_total_tax;
|
transaction.payment_total_tax = price.other.payment_total_tax;
|
||||||
console.log(transaction.id);
|
console.log({ price }, transaction.payment_total);
|
||||||
await this.serviceData.getRepository().save(transaction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ids = [];
|
|
||||||
|
|
||||||
async calculatePrice(): Promise<void> {
|
async calculatePrice(): Promise<void> {
|
||||||
const transactions = await this.serviceData.getManyByOptions({
|
const transactions = await this.serviceData.getManyByOptions({
|
||||||
where: {
|
where: {
|
||||||
// is_recap_transaction: false,
|
is_recap_transaction: false,
|
||||||
id: In(this.ids),
|
|
||||||
},
|
},
|
||||||
relations: ['items', 'items.bundling_items'],
|
relations: ['items', 'items.bundling_items'],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(transactions.length);
|
|
||||||
// return;
|
|
||||||
|
|
||||||
for (const transaction of transactions) {
|
for (const transaction of transactions) {
|
||||||
try {
|
try {
|
||||||
const price = await this.calculator.calculate(transaction);
|
const price = await this.calculator.calculate(transaction);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
|
@ -8,19 +7,17 @@ import {
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
Res,
|
Res,
|
||||||
UseGuards,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import { TransactionDataOrchestrator } from '../domain/usecases/transaction-data.orchestrator';
|
import { TransactionDataOrchestrator } from '../domain/usecases/transaction-data.orchestrator';
|
||||||
import { TransactionDto } from './dto/transaction.dto';
|
import { TransactionDto } from './dto/transaction.dto';
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
import { ApiBearerAuth, ApiBody, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { TransactionEntity } from '../domain/entities/transaction.entity';
|
import { TransactionEntity } from '../domain/entities/transaction.entity';
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
||||||
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
||||||
import { Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { DownloadPdfDto } from './dto/donwload-pdf.dto';
|
import { DownloadPdfDto } from './dto/donwload-pdf.dto';
|
||||||
import { OtpAuthGuard } from 'src/modules/configuration/otp-verification/infrastructure/guards/otp-auth.guard';
|
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.TRANSACTION.split('-').join(' ')} - data`)
|
@ApiTags(`${MODULE_NAME.TRANSACTION.split('-').join(' ')} - data`)
|
||||||
@Controller(`v1/${MODULE_NAME.TRANSACTION}`)
|
@Controller(`v1/${MODULE_NAME.TRANSACTION}`)
|
||||||
|
@ -94,29 +91,4 @@ export class TransactionDataController {
|
||||||
async delete(@Param('id') dataId: string): Promise<string> {
|
async delete(@Param('id') dataId: string): Promise<string> {
|
||||||
return await this.orchestrator.delete(dataId);
|
return await this.orchestrator.delete(dataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('save-to-couch')
|
|
||||||
@ApiBody({
|
|
||||||
schema: {
|
|
||||||
type: 'array',
|
|
||||||
items: {
|
|
||||||
type: 'object',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@Public(true)
|
|
||||||
// @UseGuards(OtpAuthGuard)
|
|
||||||
async saveToCouch(@Body() body: any[]) {
|
|
||||||
try {
|
|
||||||
await this.orchestrator.saveTransactionToCouch(body);
|
|
||||||
return {
|
|
||||||
message: 'Success',
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
throw new BadRequestException({
|
|
||||||
message: error.message,
|
|
||||||
error: error.stack,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,6 @@ export class TransactionReadController {
|
||||||
return await this.orchestrator.detail(id);
|
return await this.orchestrator.detail(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public(true)
|
|
||||||
@Get('summary/:posId')
|
|
||||||
async summary(@Param('posId') posId: string) {
|
|
||||||
return await this.orchestrator.summary(posId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Public(true)
|
@Public(true)
|
||||||
@Get('dummy/:id')
|
@Get('dummy/:id')
|
||||||
async calculate(@Param('id') id: string): Promise<string> {
|
async calculate(@Param('id') id: string): Promise<string> {
|
||||||
|
|
|
@ -47,9 +47,6 @@ import { TransactionDemographyModel } from './data/models/transaction-demography
|
||||||
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 { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
import { CouchModule } from 'src/modules/configuration/couch/couch.module';
|
||||||
import { JWT_EXPIRED } from 'src/core/sessions/constants';
|
|
||||||
import { JWT_SECRET } from 'src/core/sessions/constants';
|
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
exports: [
|
exports: [
|
||||||
|
@ -59,10 +56,6 @@ import { JwtModule } from '@nestjs/jwt';
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
JwtModule.register({
|
|
||||||
secret: JWT_SECRET,
|
|
||||||
signOptions: { expiresIn: JWT_EXPIRED },
|
|
||||||
}),
|
|
||||||
TypeOrmModule.forFeature(
|
TypeOrmModule.forFeature(
|
||||||
[
|
[
|
||||||
TransactionModel,
|
TransactionModel,
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Post,
|
Post,
|
||||||
Put,
|
Put,
|
||||||
UseGuards,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { UserDataOrchestrator } from '../domain/usecases/user-data.orchestrator';
|
import { UserDataOrchestrator } from '../domain/usecases/user-data.orchestrator';
|
||||||
import { UserDto } from './dto/user.dto';
|
import { UserDto } from './dto/user.dto';
|
||||||
|
@ -18,7 +17,6 @@ import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto'
|
||||||
import { Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
import { UpdateUserDto } from './dto/update-user.dto';
|
||||||
import { UpdatePasswordUserDto } from './dto/update-password-user.dto';
|
import { UpdatePasswordUserDto } from './dto/update-password-user.dto';
|
||||||
import { OtpCheckerGuard } from 'src/core/guards/domain/otp-checker.guard';
|
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.USER.split('-').join(' ')} - data`)
|
@ApiTags(`${MODULE_NAME.USER.split('-').join(' ')} - data`)
|
||||||
@Controller(`v1/${MODULE_NAME.USER}`)
|
@Controller(`v1/${MODULE_NAME.USER}`)
|
||||||
|
@ -38,23 +36,25 @@ export class UserDataController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id/active')
|
@Patch(':id/active')
|
||||||
@UseGuards(OtpCheckerGuard)
|
// TODO => simpan OTP update yang disikim dari request ini
|
||||||
async active(@Param('id') dataId: string): Promise<string> {
|
async active(@Param('id') dataId: string): Promise<string> {
|
||||||
return await this.orchestrator.active(dataId);
|
return await this.orchestrator.active(dataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('/batch-active')
|
@Put('/batch-active')
|
||||||
|
// TODO => simpan OTP update yang disikim dari request ini
|
||||||
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
return await this.orchestrator.batchActive(body.ids);
|
return await this.orchestrator.batchActive(body.ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id/confirm')
|
@Patch(':id/confirm')
|
||||||
@UseGuards(OtpCheckerGuard)
|
// TODO => simpan OTP update yang disikim dari request ini
|
||||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
async confirm(@Param('id') dataId: string): Promise<string> {
|
||||||
return await this.orchestrator.confirm(dataId);
|
return await this.orchestrator.confirm(dataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('/batch-confirm')
|
@Put('/batch-confirm')
|
||||||
|
// TODO => simpan OTP update yang disikim dari request ini
|
||||||
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
||||||
return await this.orchestrator.batchConfirm(body.ids);
|
return await this.orchestrator.batchConfirm(body.ids);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue