.
This commit is contained in:
parent
3a0262cbf7
commit
e5fbad0915
@ -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,
|
||||
},
|
||||
],
|
||||
|
||||
@ -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<Result<Maybe<ProformaPaymentMethodReadModel>, Error>> {
|
||||
}): Promise<Result<Maybe<InvoicePaymentMethodReadModel>, 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<Result<Maybe<ProformaTaxRegimeFullReadModel>, Error>> {
|
||||
}): Promise<Result<Maybe<InvocieTaxRegimeFullReadModel>, Error>> {
|
||||
if (params.proforma.taxRegimeCode.isNone()) {
|
||||
return Result.ok(Maybe.none());
|
||||
}
|
||||
|
||||
@ -77,6 +77,8 @@ export class ProformaUpdater implements IProformaUpdater {
|
||||
}): Promise<Result<ProformaPatchProps, Error>> {
|
||||
const { patch, companyId, currentInvoiceDate } = params;
|
||||
|
||||
console.log(patch);
|
||||
|
||||
if (patch.taxRegimeCode !== undefined) {
|
||||
const taxRegimeResult = await this.deps.taxResolver.ensureTaxRegimeByCode({
|
||||
companyId,
|
||||
|
||||
@ -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(),
|
||||
|
||||
|
||||
@ -315,7 +315,7 @@ export default (database: Sequelize) => {
|
||||
},
|
||||
|
||||
tax_regime_code: {
|
||||
type: DataTypes.STRING(),
|
||||
type: DataTypes.STRING(2),
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
|
||||
@ -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 = () => {
|
||||
<CardHeader className="px-6 pb-7 pt-3">
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="flex size-12 shrink-0 items-center justify-center rounded-lg bg-primary-50 text-primary-600">
|
||||
<FileText aria-hidden="true" className="size-5" />
|
||||
<LandmarkIcon aria-hidden="true" className="size-5" />
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
|
||||
@ -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={<ReceiptTextIcon className="size-5" />}
|
||||
icon={<LandmarkIcon className="size-5" />}
|
||||
title={t("form_groups.proformas.taxes.title", "Impuestos y retenciones")}
|
||||
>
|
||||
<FormSectionGrid>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user