Facturas de cliente y Veri*Factu
This commit is contained in:
parent
0f4619dd06
commit
50dd4103b2
@ -20,7 +20,7 @@ Este módulo es para **facturas de cliente (Customer Invoices)** y debe cumplir
|
|||||||
|
|
||||||
La entidad `CustomerInvoice` tendrá:
|
La entidad `CustomerInvoice` tendrá:
|
||||||
- `id`: UUID (ValueObject `UniqueID`)
|
- `id`: UUID (ValueObject `UniqueID`)
|
||||||
- `status`: string (ValueObject) (`Draft`, `Emitted`, `Sent`, `Rejected`)
|
- `status`: string (ValueObject) (`Draft`, `Issued`, `Sent`, `Rejected`)
|
||||||
- `invoiceNumber`: string (ValueObject )
|
- `invoiceNumber`: string (ValueObject )
|
||||||
- `invoiceSeries`: string (ValueObject )
|
- `invoiceSeries`: string (ValueObject )
|
||||||
- `customerId`: UUID (ValueObject)
|
- `customerId`: UUID (ValueObject)
|
||||||
|
|||||||
@ -282,7 +282,7 @@ export class CustomerInvoice
|
|||||||
return CustomerInvoice.create(
|
return CustomerInvoice.create(
|
||||||
{
|
{
|
||||||
...this.props,
|
...this.props,
|
||||||
status: CustomerInvoiceStatus.createEmitted(),
|
status: CustomerInvoiceStatus.createIssued(),
|
||||||
isProforma: false,
|
isProforma: false,
|
||||||
invoiceNumber: Maybe.some(newInvoiceNumber),
|
invoiceNumber: Maybe.some(newInvoiceNumber),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,17 +10,17 @@ export enum INVOICE_STATUS {
|
|||||||
SENT = "sent", // <- Proforma
|
SENT = "sent", // <- Proforma
|
||||||
APPROVED = "approved", // <- Proforma
|
APPROVED = "approved", // <- Proforma
|
||||||
REJECTED = "rejected", // <- Proforma
|
REJECTED = "rejected", // <- Proforma
|
||||||
EMITTED = "emitted", // <- Factura y enviada a Veri*Factu
|
ISSUED = "issued", // <- Factura y enviada a Veri*Factu
|
||||||
}
|
}
|
||||||
export class CustomerInvoiceStatus extends ValueObject<ICustomerInvoiceStatusProps> {
|
export class CustomerInvoiceStatus extends ValueObject<ICustomerInvoiceStatusProps> {
|
||||||
private static readonly ALLOWED_STATUSES = ["draft", "sent", "approved", "rejected", "emitted"];
|
private static readonly ALLOWED_STATUSES = ["draft", "sent", "approved", "rejected", "issued"];
|
||||||
private static readonly FIELD = "invoiceStatus";
|
private static readonly FIELD = "invoiceStatus";
|
||||||
private static readonly ERROR_CODE = "INVALID_INVOICE_STATUS";
|
private static readonly ERROR_CODE = "INVALID_INVOICE_STATUS";
|
||||||
|
|
||||||
private static readonly TRANSITIONS: Record<string, string[]> = {
|
private static readonly TRANSITIONS: Record<string, string[]> = {
|
||||||
draft: [INVOICE_STATUS.SENT],
|
draft: [INVOICE_STATUS.SENT],
|
||||||
sent: [INVOICE_STATUS.APPROVED, INVOICE_STATUS.REJECTED],
|
sent: [INVOICE_STATUS.APPROVED, INVOICE_STATUS.REJECTED],
|
||||||
approved: [INVOICE_STATUS.EMITTED],
|
approved: [INVOICE_STATUS.ISSUED],
|
||||||
rejected: [INVOICE_STATUS.DRAFT],
|
rejected: [INVOICE_STATUS.DRAFT],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ export class CustomerInvoiceStatus extends ValueObject<ICustomerInvoiceStatusPro
|
|||||||
? CustomerInvoiceStatus.createRejected()
|
? CustomerInvoiceStatus.createRejected()
|
||||||
: value === "sent"
|
: value === "sent"
|
||||||
? CustomerInvoiceStatus.createSent()
|
? CustomerInvoiceStatus.createSent()
|
||||||
: value === "emitted"
|
: value === "issued"
|
||||||
? CustomerInvoiceStatus.createEmitted()
|
? CustomerInvoiceStatus.createIssued()
|
||||||
: value === "approved"
|
: value === "approved"
|
||||||
? CustomerInvoiceStatus.createApproved()
|
? CustomerInvoiceStatus.createApproved()
|
||||||
: CustomerInvoiceStatus.createDraft()
|
: CustomerInvoiceStatus.createDraft()
|
||||||
@ -53,8 +53,8 @@ export class CustomerInvoiceStatus extends ValueObject<ICustomerInvoiceStatusPro
|
|||||||
return new CustomerInvoiceStatus({ value: INVOICE_STATUS.DRAFT });
|
return new CustomerInvoiceStatus({ value: INVOICE_STATUS.DRAFT });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createEmitted(): CustomerInvoiceStatus {
|
public static createIssued(): CustomerInvoiceStatus {
|
||||||
return new CustomerInvoiceStatus({ value: INVOICE_STATUS.EMITTED });
|
return new CustomerInvoiceStatus({ value: INVOICE_STATUS.ISSUED });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createSent(): CustomerInvoiceStatus {
|
public static createSent(): CustomerInvoiceStatus {
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
"catalog": {
|
"catalog": {
|
||||||
"status": {
|
"status": {
|
||||||
"draft": "Draft",
|
"draft": "Draft",
|
||||||
"emitted": "Emitted",
|
"issued": "Issued",
|
||||||
"sent": "Sent",
|
"sent": "Sent",
|
||||||
"received": "Received",
|
"received": "Received",
|
||||||
"rejected": "Rejected"
|
"rejected": "Rejected"
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
"catalog": {
|
"catalog": {
|
||||||
"status": {
|
"status": {
|
||||||
"draft": "Borrador",
|
"draft": "Borrador",
|
||||||
"emitted": "Emitida",
|
"issued": "Emitida",
|
||||||
"sent": "Enviada",
|
"sent": "Enviada",
|
||||||
"received": "Recibida",
|
"received": "Recibida",
|
||||||
"rejected": "Rechazada"
|
"rejected": "Rechazada"
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { cn } from "@repo/shadcn-ui/lib/utils";
|
|||||||
import { forwardRef } from "react";
|
import { forwardRef } from "react";
|
||||||
import { useTranslation } from "../i18n";
|
import { useTranslation } from "../i18n";
|
||||||
|
|
||||||
export type CustomerInvoiceStatus = "draft" | "emitted" | "sent" | "received" | "rejected";
|
export type CustomerInvoiceStatus = "draft" | "issued" | "sent" | "received" | "rejected";
|
||||||
|
|
||||||
export type CustomerInvoiceStatusBadgeProps = {
|
export type CustomerInvoiceStatusBadgeProps = {
|
||||||
status: string; // permitir cualquier valor
|
status: string; // permitir cualquier valor
|
||||||
@ -16,7 +16,7 @@ const statusColorConfig: Record<CustomerInvoiceStatus, { badge: string; dot: str
|
|||||||
"bg-gray-600/10 dark:bg-gray-600/20 hover:bg-gray-600/10 text-gray-500 border-gray-600/60",
|
"bg-gray-600/10 dark:bg-gray-600/20 hover:bg-gray-600/10 text-gray-500 border-gray-600/60",
|
||||||
dot: "bg-gray-500",
|
dot: "bg-gray-500",
|
||||||
},
|
},
|
||||||
emitted: {
|
issued: {
|
||||||
badge:
|
badge:
|
||||||
"bg-amber-600/10 dark:bg-amber-600/20 hover:bg-amber-600/10 text-amber-500 border-amber-600/60",
|
"bg-amber-600/10 dark:bg-amber-600/20 hover:bg-amber-600/10 text-amber-500 border-amber-600/60",
|
||||||
dot: "bg-amber-500",
|
dot: "bg-amber-500",
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export class VerifactuRecordEstado extends ValueObject<IVerifactuRecordEstadoPro
|
|||||||
private static readonly TRANSITIONS: Record<string, string[]> = {
|
private static readonly TRANSITIONS: Record<string, string[]> = {
|
||||||
draft: [INVOICE_STATUS.SENT],
|
draft: [INVOICE_STATUS.SENT],
|
||||||
sent: [INVOICE_STATUS.APPROVED, INVOICE_STATUS.REJECTED],
|
sent: [INVOICE_STATUS.APPROVED, INVOICE_STATUS.REJECTED],
|
||||||
approved: [INVOICE_STATUS.EMITTED],
|
approved: [INVOICE_STATUS.ISSUED],
|
||||||
rejected: [INVOICE_STATUS.DRAFT],
|
rejected: [INVOICE_STATUS.DRAFT],
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user