Facturas de cliente
This commit is contained in:
parent
e80cc572f9
commit
cec3eba428
@ -31,11 +31,11 @@ export class ListCustomerInvoicesAssembler {
|
|||||||
|
|
||||||
taxes: invoice.taxes,
|
taxes: invoice.taxes,
|
||||||
|
|
||||||
/*subtotal_amount: allAmounts.subtotalAmount.toObjectString(),
|
subtotal_amount: invoice.subtotalAmount.toObjectString(),
|
||||||
discount_amount: allAmounts.discountAmount.toObjectString(),
|
discount_amount: invoice.discountAmount.toObjectString(),
|
||||||
taxable_amount: allAmounts.taxableAmount.toObjectString(),
|
taxable_amount: invoice.taxableAmount.toObjectString(),
|
||||||
taxes_amount: allAmounts.taxesAmount.toObjectString(),
|
taxes_amount: invoice.taxesAmount.toObjectString(),
|
||||||
total_amount: allAmounts.totalAmount.toObjectString(),*/
|
total_amount: invoice.totalAmount.toObjectString(),
|
||||||
|
|
||||||
metadata: {
|
metadata: {
|
||||||
entity: "customer-invoice",
|
entity: "customer-invoice",
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import {
|
|||||||
CustomerInvoiceNumber,
|
CustomerInvoiceNumber,
|
||||||
CustomerInvoiceSerie,
|
CustomerInvoiceSerie,
|
||||||
CustomerInvoiceStatus,
|
CustomerInvoiceStatus,
|
||||||
|
InvoiceAmount,
|
||||||
InvoiceRecipient,
|
InvoiceRecipient,
|
||||||
} from "../../../domain";
|
} from "../../../domain";
|
||||||
import { CustomerInvoiceModel } from "../../sequelize";
|
import { CustomerInvoiceModel } from "../../sequelize";
|
||||||
@ -46,6 +47,12 @@ export type CustomerInvoiceListDTO = {
|
|||||||
taxes: string;
|
taxes: string;
|
||||||
|
|
||||||
discountPercentage: Percentage;
|
discountPercentage: Percentage;
|
||||||
|
|
||||||
|
subtotalAmount: InvoiceAmount;
|
||||||
|
discountAmount: InvoiceAmount;
|
||||||
|
taxableAmount: InvoiceAmount;
|
||||||
|
taxesAmount: InvoiceAmount;
|
||||||
|
totalAmount: InvoiceAmount;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ICustomerInvoiceListMapper
|
export interface ICustomerInvoiceListMapper
|
||||||
@ -109,9 +116,14 @@ export class CustomerInvoiceListMapper
|
|||||||
languageCode: attributes.languageCode!,
|
languageCode: attributes.languageCode!,
|
||||||
currencyCode: attributes.currencyCode!,
|
currencyCode: attributes.currencyCode!,
|
||||||
|
|
||||||
discountPercentage: attributes.discountPercentage!,
|
|
||||||
|
|
||||||
taxes,
|
taxes,
|
||||||
|
|
||||||
|
discountPercentage: attributes.discountPercentage!,
|
||||||
|
subtotalAmount: attributes.subtotalAmount!,
|
||||||
|
discountAmount: attributes.discountAmount!,
|
||||||
|
taxableAmount: attributes.taxableAmount!,
|
||||||
|
taxesAmount: attributes.taxesAmount!,
|
||||||
|
totalAmount: attributes.totalAmount!,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +179,58 @@ export class CustomerInvoiceListMapper
|
|||||||
|
|
||||||
const discountPercentage = extractOrPushError(
|
const discountPercentage = extractOrPushError(
|
||||||
Percentage.create({
|
Percentage.create({
|
||||||
value: raw.discount_amount_scale,
|
value: raw.discount_percentage_value,
|
||||||
scale: raw.discount_percentage_scale,
|
scale: raw.discount_percentage_scale,
|
||||||
}),
|
}),
|
||||||
"discount_percentage_value",
|
"discount_percentage_value",
|
||||||
errors
|
errors
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const subtotalAmount = extractOrPushError(
|
||||||
|
InvoiceAmount.create({
|
||||||
|
value: raw.subtotal_amount_value,
|
||||||
|
currency_code: currencyCode?.code,
|
||||||
|
}),
|
||||||
|
"subtotal_amount_value",
|
||||||
|
errors
|
||||||
|
);
|
||||||
|
|
||||||
|
const discountAmount = extractOrPushError(
|
||||||
|
InvoiceAmount.create({
|
||||||
|
value: raw.discount_amount_value,
|
||||||
|
currency_code: currencyCode?.code,
|
||||||
|
}),
|
||||||
|
"discount_amount_value",
|
||||||
|
errors
|
||||||
|
);
|
||||||
|
|
||||||
|
const taxableAmount = extractOrPushError(
|
||||||
|
InvoiceAmount.create({
|
||||||
|
value: raw.taxable_amount_value,
|
||||||
|
currency_code: currencyCode?.code,
|
||||||
|
}),
|
||||||
|
"taxable_amount_value",
|
||||||
|
errors
|
||||||
|
);
|
||||||
|
|
||||||
|
const taxesAmount = extractOrPushError(
|
||||||
|
InvoiceAmount.create({
|
||||||
|
value: raw.taxes_amount_value,
|
||||||
|
currency_code: currencyCode?.code,
|
||||||
|
}),
|
||||||
|
"taxes_amount_value",
|
||||||
|
errors
|
||||||
|
);
|
||||||
|
|
||||||
|
const totalAmount = extractOrPushError(
|
||||||
|
InvoiceAmount.create({
|
||||||
|
value: raw.total_amount_value,
|
||||||
|
currency_code: currencyCode?.code,
|
||||||
|
}),
|
||||||
|
"total_amount_value",
|
||||||
|
errors
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
invoiceId,
|
invoiceId,
|
||||||
companyId,
|
companyId,
|
||||||
@ -187,6 +244,11 @@ export class CustomerInvoiceListMapper
|
|||||||
languageCode,
|
languageCode,
|
||||||
currencyCode,
|
currencyCode,
|
||||||
discountPercentage,
|
discountPercentage,
|
||||||
|
subtotalAmount,
|
||||||
|
discountAmount,
|
||||||
|
taxableAmount,
|
||||||
|
taxesAmount,
|
||||||
|
totalAmount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ export class MoneyValue extends ValueObject<MoneyValueProps> implements IMoneyVa
|
|||||||
}
|
}
|
||||||
|
|
||||||
get value(): number {
|
get value(): number {
|
||||||
return this.dinero.getAmount() / 10 ** this.dinero.getPrecision(); // ** => Math.pow
|
return this.dinero.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
get currencyCode(): string {
|
get currencyCode(): string {
|
||||||
@ -90,6 +90,10 @@ export class MoneyValue extends ValueObject<MoneyValueProps> implements IMoneyVa
|
|||||||
return this.props;
|
return this.props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get formattedValue(): number {
|
||||||
|
return this.dinero.getAmount() / 10 ** this.dinero.getPrecision(); // ** => Math.pow
|
||||||
|
}
|
||||||
|
|
||||||
/** Reconstruye el VO desde la cadena persistida */
|
/** Reconstruye el VO desde la cadena persistida */
|
||||||
static fromPersistence(value: string): MoneyValue {
|
static fromPersistence(value: string): MoneyValue {
|
||||||
const [currencyCode, amountStr, scaleStr] = value.split(":");
|
const [currencyCode, amountStr, scaleStr] = value.split(":");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user