diff --git a/modules/catalogs/src/api/infrastructure/tax-regimes/persistence/sequelize/models/sequelize-tax-regime.model.ts b/modules/catalogs/src/api/infrastructure/tax-regimes/persistence/sequelize/models/sequelize-tax-regime.model.ts index 07fdf017..0aefd1de 100644 --- a/modules/catalogs/src/api/infrastructure/tax-regimes/persistence/sequelize/models/sequelize-tax-regime.model.ts +++ b/modules/catalogs/src/api/infrastructure/tax-regimes/persistence/sequelize/models/sequelize-tax-regime.model.ts @@ -39,10 +39,10 @@ export default (database: Sequelize) => { code: { type: DataTypes.STRING(2), allowNull: false, - unique: true, + unique: false, }, description: { - type: DataTypes.STRING, + type: DataTypes.STRING(500), allowNull: false, }, is_active: { @@ -71,8 +71,8 @@ export default (database: Sequelize) => { indexes: [ { - name: "idx_tax_regimes_code", - fields: ["code", "deleted_at"], + name: "idx_tax_regimes_company_id_code", + fields: ["company_id", "code", "deletedAt"], unique: true, }, ], diff --git a/modules/customer-invoices/src/api/application/proformas/services/assemblers/proforma-full-read-model.assembler.ts b/modules/customer-invoices/src/api/application/proformas/services/assemblers/proforma-full-read-model.assembler.ts index 5d843313..38e7b97e 100644 --- a/modules/customer-invoices/src/api/application/proformas/services/assemblers/proforma-full-read-model.assembler.ts +++ b/modules/customer-invoices/src/api/application/proformas/services/assemblers/proforma-full-read-model.assembler.ts @@ -4,10 +4,10 @@ import { Maybe, Result } from "@repo/rdx-utils"; import type { Proforma } from "../../../../domain"; import type { - ProformaFullReadModel, - ProformaPaymentMethodReadModel, - ProformaTaxRegimeFullReadModel, -} from "../../models"; + InvocieTaxRegimeFullReadModel, + InvoicePaymentMethodReadModel, +} from "../../../common/models"; +import type { ProformaFullReadModel } from "../../models"; export interface IProformaFullReadModelAssembler { assemble(params: { @@ -62,7 +62,7 @@ export class ProformaFullReadModelAssembler implements IProformaFullReadModelAss companyId: UniqueID; proforma: Proforma; transaction?: unknown; - }): Promise, Error>> { + }): Promise, Error>> { if (params.proforma.paymentMethodId.isNone()) { return Result.ok(Maybe.none()); } @@ -82,7 +82,7 @@ export class ProformaFullReadModelAssembler implements IProformaFullReadModelAss if (result.data.isNone()) { return Result.ok( Maybe.some({ - id: paymentMethodId.toString(), + id: paymentMethodId, name: "", description: Maybe.none(), }) @@ -93,7 +93,7 @@ export class ProformaFullReadModelAssembler implements IProformaFullReadModelAss return Result.ok( Maybe.some({ - id: paymentMethod.id.toString(), + id: paymentMethod.id, name: paymentMethod.name.toString(), description: paymentMethod.description ?? null, }) @@ -104,7 +104,7 @@ export class ProformaFullReadModelAssembler implements IProformaFullReadModelAss companyId: UniqueID; proforma: Proforma; transaction?: unknown; - }): Promise, Error>> { + }): Promise, Error>> { if (params.proforma.taxRegimeCode.isNone()) { return Result.ok(Maybe.none()); } diff --git a/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts b/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts index c933c06d..eba9594f 100644 --- a/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts +++ b/modules/customer-invoices/src/api/application/proformas/services/proforma-updater.ts @@ -77,6 +77,8 @@ export class ProformaUpdater implements IProformaUpdater { }): Promise> { const { patch, companyId, currentInvoiceDate } = params; + console.log(patch); + if (patch.taxRegimeCode !== undefined) { const taxRegimeResult = await this.deps.taxResolver.ensureTaxRegimeByCode({ companyId, diff --git a/modules/customer-invoices/src/api/application/proformas/snapshot-builders/full/proforma-full-snapshot-builder.ts b/modules/customer-invoices/src/api/application/proformas/snapshot-builders/full/proforma-full-snapshot-builder.ts index 11442c33..296e09a5 100644 --- a/modules/customer-invoices/src/api/application/proformas/snapshot-builders/full/proforma-full-snapshot-builder.ts +++ b/modules/customer-invoices/src/api/application/proformas/snapshot-builders/full/proforma-full-snapshot-builder.ts @@ -1,5 +1,5 @@ import type { ISnapshotBuilder } from "@erp/core/api"; -import { maybeToNullable } from "@repo/rdx-ddd"; +import { maybeToEmptyString, maybeToNullable } from "@repo/rdx-ddd"; import type { GetProformaByIdResponseDTO } from "../../../../../common"; import type { ProformaFullReadModel } from "../../models"; @@ -21,7 +21,7 @@ export class ProformaFullSnapshotBuilder implements IProformaFullSnapshotBuilder ) {} toOutput(source: ProformaFullReadModel): ProformaFullSnapshot { - const { proforma } = source; + const { proforma, paymentMethod, taxRegime } = source; const calculationContext = { languageCode: proforma.languageCode, @@ -58,19 +58,16 @@ export class ProformaFullSnapshotBuilder implements IProformaFullSnapshotBuilder linked_invoice_id: maybeToNullable(proforma.linkedInvoiceId, (value) => value.toString()), - /*payment_method: { - id: source.paymentMethod., - name: value.name, - description: maybeToNullable(value.description, (description) => description), - }, + payment_method: maybeToNullable(paymentMethod, (paymentMethod) => ({ + id: paymentMethod.id.toString(), + name: paymentMethod.name, + description: maybeToEmptyString(paymentMethod.description), + })), + + tax_regime: maybeToNullable(taxRegime, (taxRegime) => taxRegime), payment_term: null, - tax_regime: { - code: value.code, - description: maybeToNullable(value.description, (description) => description), - },*/ - subtotal_amount: allTotals.subtotalAmount.toObjectString(), items_discount_amount: allTotals.itemsDiscountAmount.toObjectString(), diff --git a/modules/customer-invoices/src/api/infrastructure/common/persistence/sequelize/models/customer-invoice.model.ts b/modules/customer-invoices/src/api/infrastructure/common/persistence/sequelize/models/customer-invoice.model.ts index ed1d01fb..927c2336 100644 --- a/modules/customer-invoices/src/api/infrastructure/common/persistence/sequelize/models/customer-invoice.model.ts +++ b/modules/customer-invoices/src/api/infrastructure/common/persistence/sequelize/models/customer-invoice.model.ts @@ -315,7 +315,7 @@ export default (database: Sequelize) => { }, tax_regime_code: { - type: DataTypes.STRING(), + type: DataTypes.STRING(2), allowNull: true, }, diff --git a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-taxes-card.tsx b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-taxes-card.tsx index 80d9f321..a5670bb1 100644 --- a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-taxes-card.tsx +++ b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-taxes-card.tsx @@ -17,7 +17,7 @@ import { SelectTrigger, SelectValue, } from "@repo/shadcn-ui/components"; -import { FileText } from "lucide-react"; +import { LandmarkIcon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; @@ -29,7 +29,7 @@ export const ProformaTaxesCard = () => {
-
diff --git a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-tax-editor.tsx b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-tax-editor.tsx index 01a56a24..75064661 100644 --- a/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-tax-editor.tsx +++ b/modules/customer-invoices/src/web/proformas/update/ui/editors/proforma-update-tax-editor.tsx @@ -7,7 +7,7 @@ import { } from "@repo/rdx-ui/components"; import { PercentageHelper } from "@repo/rdx-utils"; import { Separator } from "@repo/shadcn-ui/components"; -import { ReceiptTextIcon } from "lucide-react"; +import { LandmarkIcon } from "lucide-react"; import { useTranslation } from "../../../../i18n"; import { @@ -45,7 +45,7 @@ export const ProformaUpdateTaxEditor = ({ "Configuración fiscal de la proforma" )} disabled={disabled} - icon={} + icon={} title={t("form_groups.proformas.taxes.title", "Impuestos y retenciones")} >