Merge branch 'development' into 'devops-staging'
add: get History Deposit See merge request empatnusabangsa/ppob/ppob-backend!47
This commit is contained in:
commit
395db6e537
|
@ -48,7 +48,7 @@ export class TransactionController {
|
||||||
@Request() req,
|
@Request() req,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
data: await this.transactionService.addPartnerSaldo(
|
data: await this.transactionService.addSupplierSaldo(
|
||||||
addSaldoSupplier,
|
addSaldoSupplier,
|
||||||
req.user,
|
req.user,
|
||||||
),
|
),
|
||||||
|
@ -88,7 +88,7 @@ export class TransactionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('history')
|
@Get('history')
|
||||||
async findByCategories(
|
async getHistoryTransactionUser(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
@Query('pageSize') pageSize: number,
|
@Query('pageSize') pageSize: number,
|
||||||
@Request() req,
|
@Request() req,
|
||||||
|
@ -106,6 +106,27 @@ export class TransactionController {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('history-deposit')
|
||||||
|
async getHistoryDepositUser(
|
||||||
|
@Query('page') page: number,
|
||||||
|
@Query('pageSize') pageSize: number,
|
||||||
|
@Query('user-destination') userDestination: string,
|
||||||
|
@Request() req,
|
||||||
|
) {
|
||||||
|
const data = await this.transactionService.topUpHistoryByUser(
|
||||||
|
page,
|
||||||
|
req.user.userId,
|
||||||
|
userDestination,
|
||||||
|
pageSize,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
statusCode: HttpStatus.OK,
|
||||||
|
message: 'success',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Get('deposit-return')
|
@Get('deposit-return')
|
||||||
async findDepositReturn(
|
async findDepositReturn(
|
||||||
@Query('page') page: number,
|
@Query('page') page: number,
|
||||||
|
|
|
@ -10,7 +10,12 @@ import { CoaService } from './coa.service';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import { uniq } from 'lodash';
|
import { uniq } from 'lodash';
|
||||||
import { Decimal } from 'decimal.js';
|
import { Decimal } from 'decimal.js';
|
||||||
import { balanceType, coaType, statusTransaction, typeTransaction } from '../helper/enum-list';
|
import {
|
||||||
|
balanceType,
|
||||||
|
coaType,
|
||||||
|
statusTransaction,
|
||||||
|
typeTransaction,
|
||||||
|
} from '../helper/enum-list';
|
||||||
import { ProductService } from '../product/product.service';
|
import { ProductService } from '../product/product.service';
|
||||||
import { CreateJournalDto } from './dto/create-journal.dto';
|
import { CreateJournalDto } from './dto/create-journal.dto';
|
||||||
import { UsersService } from 'src/users/users.service';
|
import { UsersService } from 'src/users/users.service';
|
||||||
|
@ -44,7 +49,7 @@ export class TransactionService {
|
||||||
private connection: Connection,
|
private connection: Connection,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async addPartnerSaldo(addSaldoSupplier: AddSaldoSupplier, currentUser: any) {
|
async addSupplierSaldo(addSaldoSupplier: AddSaldoSupplier, currentUser: any) {
|
||||||
const supplier = await this.supplierService.findByCode(
|
const supplier = await this.supplierService.findByCode(
|
||||||
addSaldoSupplier.supplier,
|
addSaldoSupplier.supplier,
|
||||||
);
|
);
|
||||||
|
@ -137,6 +142,7 @@ export class TransactionService {
|
||||||
const coaBudget = await this.coaService.findByName(
|
const coaBudget = await this.coaService.findByName(
|
||||||
`${coaType[coaType.BUDGET]}-${supplier.code}`,
|
`${coaType[coaType.BUDGET]}-${supplier.code}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (coaBudget.amount < distributeTransactionDto.amount) {
|
if (coaBudget.amount < distributeTransactionDto.amount) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
{
|
{
|
||||||
|
@ -146,6 +152,7 @@ export class TransactionService {
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const coaContraBudget = await this.coaService.findByName(
|
const coaContraBudget = await this.coaService.findByName(
|
||||||
`${coaType[coaType.CONTRA_BUDGET]}-${supplier.code}`,
|
`${coaType[coaType.CONTRA_BUDGET]}-${supplier.code}`,
|
||||||
);
|
);
|
||||||
|
@ -318,8 +325,12 @@ export class TransactionService {
|
||||||
userData,
|
userData,
|
||||||
);
|
);
|
||||||
profit = supervisorData
|
profit = supervisorData
|
||||||
.map((item) => item.credit)
|
.map((item) => {
|
||||||
.reduce((prev, curr) => prev + curr, 0);
|
return item.credit;
|
||||||
|
})
|
||||||
|
.reduce((prev, curr) => {
|
||||||
|
return prev + curr;
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//GET COA
|
//GET COA
|
||||||
|
@ -585,6 +596,36 @@ export class TransactionService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async topUpHistoryByUser(
|
||||||
|
page: number,
|
||||||
|
user: string,
|
||||||
|
destinationUser: string,
|
||||||
|
pageSize?: number,
|
||||||
|
) {
|
||||||
|
const baseQuery = this.transactionRepository
|
||||||
|
.createQueryBuilder('transaction')
|
||||||
|
.where(
|
||||||
|
'transaction.user = :id and transaction.type = 0 and transaction.user_destination = :destinationId',
|
||||||
|
{
|
||||||
|
id: user,
|
||||||
|
destinationId: destinationUser,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.select(['id', 'created_at as transaction_date', 'amount']);
|
||||||
|
|
||||||
|
const data = await baseQuery
|
||||||
|
.offset(page * (pageSize || 10))
|
||||||
|
.limit(pageSize || 10)
|
||||||
|
.getRawMany();
|
||||||
|
|
||||||
|
const totalData = await baseQuery.getCount();
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
count: totalData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async findApprovalDepositReturn(id: string) {
|
async findApprovalDepositReturn(id: string) {
|
||||||
try {
|
try {
|
||||||
return await this.transactionRepository.findOneOrFail({
|
return await this.transactionRepository.findOneOrFail({
|
||||||
|
@ -668,6 +709,7 @@ export class TransactionService {
|
||||||
const commissionValue = await this.commissionService.findOne(
|
const commissionValue = await this.commissionService.findOne(
|
||||||
it.roles.id,
|
it.roles.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
coa_id: coaAccount.id,
|
coa_id: coaAccount.id,
|
||||||
credit: (totalPrice * commissionValue.commission) / 100,
|
credit: (totalPrice * commissionValue.commission) / 100,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user