mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix: landed cost dialog
This commit is contained in:
@@ -25,7 +25,7 @@ export class BillAllocateLandedCostController {
|
||||
private billAllocatedCostTransactions: BillAllocatedLandedCostTransactions,
|
||||
private revertAllocatedLandedCost: RevertAllocatedLandedCost,
|
||||
private landedCostTransactions: LandedCostTranasctions,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
@Get('/transactions')
|
||||
@ApiOperation({ summary: 'Get landed cost transactions' })
|
||||
|
||||
@@ -21,7 +21,7 @@ export class BillAllocatedLandedCostTransactions {
|
||||
private readonly billLandedCostModel: TenantModelProxy<
|
||||
typeof BillLandedCost
|
||||
>,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Retrieve the bill associated landed cost transactions.
|
||||
@@ -77,6 +77,13 @@ export class BillAllocatedLandedCostTransactions {
|
||||
transaction.fromTransactionType,
|
||||
transaction,
|
||||
);
|
||||
const allocationMethodFormattedKey = transaction.allocationMethodFormatted;
|
||||
const allocationMethodFormatted = allocationMethodFormattedKey
|
||||
? this.i18nService.t(allocationMethodFormattedKey, {
|
||||
defaultValue: allocationMethodFormattedKey,
|
||||
})
|
||||
: '';
|
||||
|
||||
return {
|
||||
formattedAmount: formatNumber(transaction.amount, {
|
||||
currencyCode: transaction.currencyCode,
|
||||
@@ -84,12 +91,14 @@ export class BillAllocatedLandedCostTransactions {
|
||||
...omit(transaction, [
|
||||
'allocatedFromBillEntry',
|
||||
'allocatedFromExpenseEntry',
|
||||
'allocationMethodFormatted',
|
||||
]),
|
||||
name,
|
||||
description,
|
||||
formattedLocalAmount: formatNumber(transaction.localAmount, {
|
||||
currencyCode: 'USD',
|
||||
}),
|
||||
allocationMethodFormatted,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import { LandedCostTransactionsQueryDto } from '../dtos/LandedCostTransactionsQu
|
||||
|
||||
@Injectable()
|
||||
export class LandedCostTranasctions {
|
||||
constructor(private readonly transactionLandedCost: TransactionLandedCost) {}
|
||||
constructor(private readonly transactionLandedCost: TransactionLandedCost) { }
|
||||
|
||||
/**
|
||||
* Retrieve the landed costs based on the given query.
|
||||
@@ -45,8 +45,8 @@ export class LandedCostTranasctions {
|
||||
)(transactionType);
|
||||
|
||||
return pipe(
|
||||
this.transformLandedCostTransactions,
|
||||
R.map(transformLandedCost),
|
||||
this.transformLandedCostTransactions,
|
||||
)(transactions);
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ export class LandedCostTranasctions {
|
||||
const entries = R.map<
|
||||
ILandedCostTransactionEntry,
|
||||
ILandedCostTransactionEntryDOJO
|
||||
>(transformLandedCostEntry)(transaction.entries);
|
||||
>(transformLandedCostEntry)(transaction.entries ?? []);
|
||||
|
||||
return {
|
||||
...transaction,
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
IsOptional,
|
||||
IsArray,
|
||||
ValidateNested,
|
||||
IsDecimal,
|
||||
IsString,
|
||||
IsNumber,
|
||||
} from 'class-validator';
|
||||
@@ -17,8 +16,9 @@ export class AllocateBillLandedCostItemDto {
|
||||
@ToNumber()
|
||||
entryId: number;
|
||||
|
||||
@IsDecimal()
|
||||
cost: string; // Use string for IsDecimal, or use @IsNumber() if you want a number
|
||||
@IsNumber()
|
||||
@ToNumber()
|
||||
cost: number;
|
||||
}
|
||||
|
||||
export class AllocateBillLandedCostDto {
|
||||
|
||||
@@ -60,8 +60,8 @@ export class BillLandedCost extends BaseModel {
|
||||
const allocationMethod = lowerCase(this.allocationMethod);
|
||||
|
||||
const keyLabelsPairs = {
|
||||
value: 'allocation_method.value.label',
|
||||
quantity: 'allocation_method.quantity.label',
|
||||
value: 'bill.allocation_method.value',
|
||||
quantity: 'bill.allocation_method.quantity',
|
||||
};
|
||||
return keyLabelsPairs[allocationMethod] || '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user