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 { Partner } from '../../users/entities/partner.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()
|
||||
export class Transactions extends BaseModel {
|
||||
|
@ -26,7 +28,10 @@ export class Transactions extends BaseModel {
|
|||
@Column()
|
||||
type: typeTransaction;
|
||||
|
||||
@Column()
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
nullable: true,
|
||||
})
|
||||
user: string;
|
||||
|
||||
@Column({
|
||||
|
@ -43,4 +48,6 @@ export class Transactions extends BaseModel {
|
|||
image_prove: string;
|
||||
|
||||
mark_up_price: number;
|
||||
|
||||
userData: UserDetail;
|
||||
}
|
||||
|
|
|
@ -165,16 +165,14 @@ export class TransactionController {
|
|||
@Query('pageSize') pageSize: number,
|
||||
@Request() req,
|
||||
) {
|
||||
const [data, count] =
|
||||
await this.transactionService.getAllDepositReturnToUser(
|
||||
req.user.userId,
|
||||
page,
|
||||
pageSize,
|
||||
);
|
||||
const data = await this.transactionService.getAllDepositReturnToUser(
|
||||
req.user.userId,
|
||||
page,
|
||||
pageSize,
|
||||
);
|
||||
|
||||
return {
|
||||
data,
|
||||
count,
|
||||
...data,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
|
|
|
@ -24,6 +24,8 @@ import { SupplierService } from '../users/supplier/supplier.service';
|
|||
import { ProductHistoryPriceService } from '../product/history-price/history-price.service';
|
||||
import { CommissionService } from '../configurable/commission.service';
|
||||
import { DepositReturnDto } from './dto/deposit_return.dto';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
import { UserDetail } from '../users/entities/user_detail.entity';
|
||||
|
||||
interface JournalEntry {
|
||||
coa_id: string;
|
||||
|
@ -673,6 +675,37 @@ export class TransactionService {
|
|||
page: 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({
|
||||
skip: page * (pageSize || 10),
|
||||
take: pageSize || 10,
|
||||
|
|
Loading…
Reference in New Issue
Block a user