mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
refactor(nestjs): landed cost
This commit is contained in:
@@ -7,32 +7,45 @@ import {
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
||||
import { AllocateBillLandedCostDto } from './dtos/AllocateBillLandedCost.dto';
|
||||
import { AllocateLandedCostService } from './commands/AllocateLandedCost.service';
|
||||
import { BillAllocatedLandedCostTransactions } from './commands/BillAllocatedLandedCostTransactions.service';
|
||||
import { RevertAllocatedLandedCost } from './commands/RevertAllocatedLandedCost.service';
|
||||
import { LandedCostTranasctions } from './commands/LandedCostTransactions.service';
|
||||
import { LandedCostTransactionsQueryDto } from './dtos/LandedCostTransactionsQuery.dto';
|
||||
|
||||
@ApiTags('Landed Cost')
|
||||
@Controller('landed-cost')
|
||||
export class BillAllocateLandedCostController {
|
||||
constructor(
|
||||
private allocateLandedCost: AllocateLandedCostService,
|
||||
private billAllocatedCostTransactions: BillAllocatedLandedCostTransactions,
|
||||
private revertAllocatedLandedCost: RevertAllocatedLandedCost,
|
||||
private landedCostTranasctions: LandedCostTranasctions,
|
||||
private landedCostTransactions: LandedCostTranasctions,
|
||||
) {}
|
||||
|
||||
@Get('/transactions')
|
||||
@ApiOperation({ summary: 'Get landed cost transactions' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'List of landed cost transactions.',
|
||||
})
|
||||
async getLandedCostTransactions(
|
||||
@Query('transaction_type') transactionType: string,
|
||||
@Query() query: LandedCostTransactionsQueryDto,
|
||||
) {
|
||||
const transactions =
|
||||
await this.landedCostTranasctions.getLandedCostTransactions(transactionType);
|
||||
await this.landedCostTransactions.getLandedCostTransactions(query);
|
||||
|
||||
return transactions;
|
||||
}
|
||||
|
||||
@Post('/bills/:billId/allocate')
|
||||
@ApiOperation({ summary: 'Allocate landed cost to bill items' })
|
||||
@ApiResponse({
|
||||
status: 201,
|
||||
description: 'Landed cost allocated successfully.',
|
||||
})
|
||||
public async calculateLandedCost(
|
||||
@Param('billId') billId: number,
|
||||
@Body() landedCostDTO: AllocateBillLandedCostDto,
|
||||
@@ -48,37 +61,37 @@ export class BillAllocateLandedCostController {
|
||||
}
|
||||
|
||||
@Delete('/:allocatedLandedCostId')
|
||||
@ApiOperation({ summary: 'Delete allocated landed cost' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Allocated landed cost deleted successfully.',
|
||||
})
|
||||
public async deleteAllocatedLandedCost(
|
||||
@Param('allocatedLandedCostId') allocatedLandedCostId: number,
|
||||
) {
|
||||
await this.revertAllocatedLandedCost.deleteAllocatedLandedCost(
|
||||
allocatedLandedCostId,
|
||||
);
|
||||
|
||||
return {
|
||||
id: allocatedLandedCostId,
|
||||
message: 'The allocated landed cost are delete successfully.',
|
||||
};
|
||||
}
|
||||
|
||||
public async listLandedCosts(
|
||||
) {
|
||||
const transactions =
|
||||
await this.landedCostTranasctions.getLandedCostTransactions(query);
|
||||
|
||||
return transactions;
|
||||
};
|
||||
|
||||
@Get('/bills/:billId/transactions')
|
||||
@ApiOperation({ summary: 'Get bill landed cost transactions' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'List of bill landed cost transactions.',
|
||||
})
|
||||
async getBillLandedCostTransactions(@Param('billId') billId: number) {
|
||||
const transactions =
|
||||
const data =
|
||||
await this.billAllocatedCostTransactions.getBillLandedCostTransactions(
|
||||
billId,
|
||||
);
|
||||
|
||||
return {
|
||||
billId,
|
||||
transactions,
|
||||
data,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user