feat: Enhance invoice item management with detailed line item structure
- Introduced nested interfaces for line items including customs, financials, quantities, descriptions, and references. - Updated Item interface to include lines as an array of LineItem. - Modified invoice top fields to handle pedimento ID and auto-assign values from the invoice. - Enhanced item configuration component to manage line item properties and descriptions. - Updated main data, packages section, summary section, and other components to bind new line item properties. - Implemented normalization of numeric values when editing items to ensure consistent data types. - Adjusted save invoice logic to accommodate new line item structure and compliance data.
This commit is contained in:
@@ -11,9 +11,9 @@ export type TransportType = 'none' | 'transport' | 'box' | 'licence plates' | 't
|
||||
|
||||
export interface InvoiceComplianceMx {
|
||||
invoice_id?: number;
|
||||
pedimento?: string | null;
|
||||
pedimento_code?: string | null;
|
||||
pedimento_k1?: string | null;
|
||||
pedimento_id?: number | null;
|
||||
pedimento_r1?: number | null;
|
||||
pedimento_k1?: number | null;
|
||||
remesa?: number | null;
|
||||
aduana?: string | null;
|
||||
port_of_entry?: string | null;
|
||||
@@ -24,7 +24,7 @@ export interface InvoiceComplianceMx {
|
||||
sold_to_header?: string | null;
|
||||
sold_to_id?: number | null;
|
||||
shipped_to_header?: string | null;
|
||||
shipped_to_id?: string | null;
|
||||
shipped_to_id?: number | null;
|
||||
shipped_by_header?: string | null;
|
||||
shipped_by_id?: number | null;
|
||||
customs_broker_id?: number | null;
|
||||
|
||||
@@ -6,6 +6,115 @@ import { api } from '$lib/api';
|
||||
|
||||
// --- Interfaces ---
|
||||
|
||||
// --- Nested Interfaces for Line Items ---
|
||||
|
||||
export interface LineCustoms {
|
||||
id?: number;
|
||||
line_item_id?: number;
|
||||
fraction?: string;
|
||||
fraction_type?: string;
|
||||
american_fraction?: string;
|
||||
origin_country?: string;
|
||||
destination_country?: string;
|
||||
advalorem?: string;
|
||||
advalorem_american?: number; // Backend: Decimal
|
||||
sector?: string;
|
||||
}
|
||||
|
||||
export interface LineFinancials {
|
||||
id?: number;
|
||||
line_item_id?: number;
|
||||
// Costs
|
||||
unit_cost_usd?: number;
|
||||
unit_cost_mxn?: number;
|
||||
unit_cost_capture?: number;
|
||||
unit_cost_commercial_usd?: number;
|
||||
|
||||
// Values
|
||||
value_usd?: number;
|
||||
value_mxn?: number;
|
||||
value_returned_usd?: number;
|
||||
value_returned_mxn?: number;
|
||||
customs_value_usd?: number;
|
||||
}
|
||||
|
||||
export interface LineQuantities {
|
||||
id?: number;
|
||||
line_item_id?: number;
|
||||
quantity?: number;
|
||||
unit_of_measure?: string;
|
||||
|
||||
// Special quantities
|
||||
quantity_temp_export?: number;
|
||||
quantity_returned?: number;
|
||||
|
||||
// Weight
|
||||
net_weight?: number;
|
||||
gross_weight?: number;
|
||||
|
||||
// Packaging
|
||||
package_key?: string;
|
||||
package_quantity?: number;
|
||||
package_description?: string;
|
||||
}
|
||||
|
||||
export interface LineDescriptions {
|
||||
id?: number;
|
||||
line_item_id?: number;
|
||||
description_spanish?: string;
|
||||
description_english?: string;
|
||||
extra_description?: string;
|
||||
additional_info_spanish?: string;
|
||||
brand?: string;
|
||||
model?: string;
|
||||
has_serial?: boolean;
|
||||
}
|
||||
|
||||
export interface LineReferences {
|
||||
id?: number;
|
||||
line_item_id?: number;
|
||||
serie_id?: number;
|
||||
}
|
||||
|
||||
export interface LineItem {
|
||||
id?: number;
|
||||
item_id?: number;
|
||||
line_number: number;
|
||||
|
||||
// Identification
|
||||
part_number?: string;
|
||||
component_part_number?: string;
|
||||
class_code?: string;
|
||||
identifier?: string;
|
||||
|
||||
// Unit of Measure
|
||||
unit_of_measure?: string;
|
||||
alternate_unit?: string;
|
||||
|
||||
// Permits
|
||||
permit_number?: string;
|
||||
page_line?: string;
|
||||
has_certificate?: boolean;
|
||||
certificate_number?: string;
|
||||
|
||||
// Flags
|
||||
is_subitem?: boolean;
|
||||
includes_subitems?: boolean;
|
||||
tax_payment?: boolean;
|
||||
|
||||
// Payment
|
||||
payment_method?: string;
|
||||
igi_amount?: number;
|
||||
|
||||
|
||||
// Nested relations (Singular names to match backend Pydantic models)
|
||||
customs?: LineCustoms;
|
||||
financial?: LineFinancials;
|
||||
quantity?: LineQuantities;
|
||||
description?: LineDescriptions;
|
||||
reference?: LineReferences;
|
||||
}
|
||||
|
||||
export interface Item {
|
||||
id?: number;
|
||||
invoice_id: number;
|
||||
@@ -18,6 +127,8 @@ export interface Item {
|
||||
location?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
|
||||
lines?: LineItem[];
|
||||
}
|
||||
|
||||
export interface ItemListResponse {
|
||||
@@ -36,6 +147,7 @@ export interface CreateItemData {
|
||||
rectification?: number;
|
||||
warehouse?: string;
|
||||
location?: string;
|
||||
lines?: LineItem[];
|
||||
}
|
||||
|
||||
export interface UpdateItemData {
|
||||
@@ -46,6 +158,7 @@ export interface UpdateItemData {
|
||||
rectification?: boolean;
|
||||
warehouse?: string;
|
||||
location?: string;
|
||||
lines?: LineItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user