Merge branch 'development' into 'devops-staging'
Development See merge request empatnusabangsa/ppob/ppob-backend!56
This commit is contained in:
commit
8b05ffd936
|
@ -14,6 +14,8 @@ import { BaseModel } from '../../config/basemodel.entity';
|
||||||
import { statusTransaction, typeTransaction } from '../../helper/enum-list';
|
import { statusTransaction, typeTransaction } from '../../helper/enum-list';
|
||||||
import { Partner } from '../../users/entities/partner.entity';
|
import { Partner } from '../../users/entities/partner.entity';
|
||||||
import { ProductHistoryPrice } from '../../product/entities/product-history-price.entity';
|
import { ProductHistoryPrice } from '../../product/entities/product-history-price.entity';
|
||||||
|
import { User } from '../../users/entities/user.entity';
|
||||||
|
import { UserDetail } from '../../users/entities/user_detail.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Transactions extends BaseModel {
|
export class Transactions extends BaseModel {
|
||||||
|
@ -26,7 +28,10 @@ export class Transactions extends BaseModel {
|
||||||
@Column()
|
@Column()
|
||||||
type: typeTransaction;
|
type: typeTransaction;
|
||||||
|
|
||||||
@Column()
|
@Column({
|
||||||
|
type: 'uuid',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
user: string;
|
user: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
@ -43,4 +48,6 @@ export class Transactions extends BaseModel {
|
||||||
image_prove: string;
|
image_prove: string;
|
||||||
|
|
||||||
mark_up_price: number;
|
mark_up_price: number;
|
||||||
|
|
||||||
|
userData: UserDetail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,16 +165,14 @@ export class TransactionController {
|
||||||
@Query('pageSize') pageSize: number,
|
@Query('pageSize') pageSize: number,
|
||||||
@Request() req,
|
@Request() req,
|
||||||
) {
|
) {
|
||||||
const [data, count] =
|
const data = await this.transactionService.getAllDepositReturnToUser(
|
||||||
await this.transactionService.getAllDepositReturnToUser(
|
req.user.userId,
|
||||||
req.user.userId,
|
page,
|
||||||
page,
|
pageSize,
|
||||||
pageSize,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
...data,
|
||||||
count,
|
|
||||||
statusCode: HttpStatus.OK,
|
statusCode: HttpStatus.OK,
|
||||||
message: 'success',
|
message: 'success',
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,6 +24,8 @@ import { SupplierService } from '../users/supplier/supplier.service';
|
||||||
import { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
import { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
||||||
import { CommissionService } from '../configurable/commission.service';
|
import { CommissionService } from '../configurable/commission.service';
|
||||||
import { DepositReturnDto } from './dto/deposit_return.dto';
|
import { DepositReturnDto } from './dto/deposit_return.dto';
|
||||||
|
import { User } from '../users/entities/user.entity';
|
||||||
|
import { UserDetail } from '../users/entities/user_detail.entity';
|
||||||
|
|
||||||
interface JournalEntry {
|
interface JournalEntry {
|
||||||
coa_id: string;
|
coa_id: string;
|
||||||
|
@ -673,6 +675,37 @@ export class TransactionService {
|
||||||
page: number,
|
page: number,
|
||||||
pageSize?: number,
|
pageSize?: number,
|
||||||
) {
|
) {
|
||||||
|
const baseQuery = this.transactionRepository
|
||||||
|
.createQueryBuilder('transaction')
|
||||||
|
.where('transaction.user_destination = :id and transaction.type = 3', {
|
||||||
|
id: user,
|
||||||
|
})
|
||||||
|
.leftJoinAndMapOne(
|
||||||
|
'transaction.userData',
|
||||||
|
UserDetail,
|
||||||
|
'userData',
|
||||||
|
'userData.user = transaction.user',
|
||||||
|
)
|
||||||
|
.select('transaction.id', 'id')
|
||||||
|
.addSelect([
|
||||||
|
'transaction.created_at',
|
||||||
|
'image_prove',
|
||||||
|
'amount',
|
||||||
|
'status',
|
||||||
|
'userData.name',
|
||||||
|
]);
|
||||||
|
|
||||||
|
const data = await baseQuery
|
||||||
|
.offset(page * (pageSize || 10))
|
||||||
|
.limit(pageSize || 10)
|
||||||
|
.getRawMany();
|
||||||
|
|
||||||
|
const totalData = await baseQuery.getCount();
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
count: totalData,
|
||||||
|
};
|
||||||
return this.transactionRepository.findAndCount({
|
return this.transactionRepository.findAndCount({
|
||||||
skip: page * (pageSize || 10),
|
skip: page * (pageSize || 10),
|
||||||
take: pageSize || 10,
|
take: pageSize || 10,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user