Compare commits
2 Commits
538c081d58
...
595e08459d
| Author | SHA1 | Date | |
|---|---|---|---|
| 595e08459d | |||
| cf7ce088f8 |
@ -4,6 +4,13 @@ import tailwindcss from "@tailwindcss/vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
const appNodeModulesPath = path.resolve(__dirname, "./node_modules");
|
||||
const hmrHost = process.env.VITE_HMR_HOST;
|
||||
const hmrClientPort = process.env.VITE_HMR_CLIENT_PORT
|
||||
? Number(process.env.VITE_HMR_CLIENT_PORT)
|
||||
: undefined;
|
||||
const hmrProtocol = process.env.VITE_HMR_PROTOCOL;
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
build: {
|
||||
@ -13,10 +20,26 @@ export default defineConfig({
|
||||
"process.env": {},
|
||||
},
|
||||
plugins: [react(), tailwindcss()],
|
||||
server: {
|
||||
host: true,
|
||||
hmr:
|
||||
hmrHost || hmrClientPort || hmrProtocol
|
||||
? {
|
||||
host: hmrHost,
|
||||
clientPort: hmrClientPort,
|
||||
protocol: hmrProtocol,
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
resolve: {
|
||||
dedupe: ["react", "react-dom"],
|
||||
dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
react: path.resolve(appNodeModulesPath, "react"),
|
||||
"react-dom": path.resolve(appNodeModulesPath, "react-dom"),
|
||||
"react-dom/client": path.resolve(appNodeModulesPath, "react-dom/client.js"),
|
||||
"react/jsx-runtime": path.resolve(appNodeModulesPath, "react/jsx-runtime.js"),
|
||||
"react/jsx-dev-runtime": path.resolve(appNodeModulesPath, "react/jsx-dev-runtime.js"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { DiscountPercentage } from "@erp/core/api";
|
||||
import { UniqueID } from "@repo/rdx-ddd";
|
||||
import { CurrencyCode, LanguageCode, UniqueID, UtcDate } from "@repo/rdx-ddd";
|
||||
import { Maybe, Result } from "@repo/rdx-utils";
|
||||
|
||||
import { ProformaToIssuedInvoiceConverter } from "./proforma-to-issued-invoice-props-converter";
|
||||
@ -68,3 +68,89 @@ test("toCreateProps no materializa VerifactuRecord ni policy en el converter", (
|
||||
assert.equal(result.isSuccess, true);
|
||||
assert.equal(result.data.verifactu.isNone(), true);
|
||||
});
|
||||
|
||||
test("resolvePaymentTerm normaliza percentage.value cuando llega numérico del catálogo", () => {
|
||||
const converter = new ProformaToIssuedInvoiceConverter();
|
||||
const companyId = UniqueID.generateNewID();
|
||||
const paymentTermId = UniqueID.generateNewID();
|
||||
const invoiceDateResult = UtcDate.createFromISO("2026-08-20");
|
||||
const languageCodeResult = LanguageCode.create("es");
|
||||
const currencyCodeResult = CurrencyCode.create("EUR");
|
||||
const discountResult = DiscountPercentage.create({ value: 0 });
|
||||
|
||||
assert.equal(invoiceDateResult.isSuccess, true);
|
||||
assert.equal(languageCodeResult.isSuccess, true);
|
||||
assert.equal(currencyCodeResult.isSuccess, true);
|
||||
assert.equal(discountResult.isSuccess, true);
|
||||
|
||||
const result = converter["resolvePaymentTerm"]({
|
||||
proforma: {
|
||||
companyId,
|
||||
id: UniqueID.generateNewID(),
|
||||
targetInvoiceSeriesCode: Maybe.none(),
|
||||
operationDate: Maybe.some(invoiceDateResult.data),
|
||||
description: {
|
||||
unwrap: () => "Servicio mensual",
|
||||
},
|
||||
languageCode: languageCodeResult.data,
|
||||
currencyCode: currencyCodeResult.data,
|
||||
notes: Maybe.none(),
|
||||
reference: Maybe.none(),
|
||||
customerId: UniqueID.generateNewID(),
|
||||
totals: () => ({
|
||||
subtotalAmount: {} as never,
|
||||
itemsDiscountAmount: {} as never,
|
||||
globalDiscountAmount: {} as never,
|
||||
totalDiscountAmount: {} as never,
|
||||
taxableAmount: {} as never,
|
||||
ivaAmount: {} as never,
|
||||
recAmount: {} as never,
|
||||
retentionAmount: {} as never,
|
||||
taxesAmount: {} as never,
|
||||
totalAmount: {} as never,
|
||||
}),
|
||||
globalDiscountPercentage: discountResult.data,
|
||||
} as never,
|
||||
paymentMethod: {
|
||||
id: UniqueID.generateNewID(),
|
||||
name: "Transferencia",
|
||||
description: Maybe.none(),
|
||||
},
|
||||
paymentTerm: Maybe.some({
|
||||
id: paymentTermId.toPrimitive(),
|
||||
name: "30 días",
|
||||
description: "Pago estándar",
|
||||
isActive: true,
|
||||
dueRules: [
|
||||
{
|
||||
dueDays: "30",
|
||||
percentage: {
|
||||
value: 10000,
|
||||
scale: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
} as never),
|
||||
taxRegime: {
|
||||
code: "01",
|
||||
description: "Régimen general",
|
||||
},
|
||||
fiscalClassification: {
|
||||
operationQualificationCode: null,
|
||||
exemptionReasonCode: null,
|
||||
},
|
||||
usesVerifactu: false,
|
||||
});
|
||||
|
||||
assert.equal(result.isSuccess, true);
|
||||
assert.equal(result.data.isSome(), true);
|
||||
assert.deepEqual(result.data.unwrap().dueRules, [
|
||||
{
|
||||
dueDays: "30",
|
||||
percentage: {
|
||||
value: "10000",
|
||||
scale: 2,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@ -306,7 +306,7 @@ export class ProformaToIssuedInvoiceConverter implements IProformaToIssuedInvoic
|
||||
dueRules: paymentTerm.dueRules.map((rule) => ({
|
||||
dueDays: rule.dueDays,
|
||||
percentage: {
|
||||
value: rule.percentage.value,
|
||||
value: String(rule.percentage.value),
|
||||
scale: rule.percentage.scale,
|
||||
},
|
||||
})),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user