Enhance invoice and item processing with balance tracking features
- Added `company_id` to `ClientProviderAddress` and `ClientProviderPrograms` for better association. - Updated `_process_with_discharge` to simplify invoice review by removing redundant parameters. - Improved `pre_validators` to ensure address validation checks for existence before accessing country. - Enhanced balance comparison logic in `compare_balances` by tracking consumed quantities. - Modified `fill_available_balances` to reflect invoice status changes from 'UNPROCESSED' to 'PENDING'. - Introduced `get_lines_with_balance` method in `ItemService` to fetch invoice lines with available balance. - Added new API endpoint to retrieve import invoice lines with balance information. - Updated frontend components to display available balances and improve user experience in invoice selection.
This commit is contained in:
@@ -299,5 +299,52 @@ export const itemsApi = {
|
||||
company_id: companyId.toString()
|
||||
});
|
||||
return api.delete(`/v1/a76/items/${itemId}/?${params.toString()}`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Lista las líneas de una factura de importación con su saldo disponible.
|
||||
* Solo las líneas con has_balance = true tienen mercancía disponible para descarga.
|
||||
*
|
||||
* @param invoiceId - ID de la factura de importación
|
||||
* @param companyId - ID de la empresa
|
||||
* @param asOfDate - Fecha corte opcional (ISO: "YYYY-MM-DD").
|
||||
* Pasa la fecha de la factura de exportación para que
|
||||
* los consumos futuros no se descuenten del saldo.
|
||||
*/
|
||||
listByInvoiceWithBalance: (
|
||||
invoiceId: number,
|
||||
companyId: number,
|
||||
asOfDate?: string
|
||||
) => {
|
||||
const params = new URLSearchParams({ company_id: companyId.toString() });
|
||||
if (asOfDate) params.append('as_of_date', asOfDate);
|
||||
return api.get<ImportLineWithBalance[]>(
|
||||
`/v1/a76/items/invoice/${invoiceId}/items-with-balance?${params.toString()}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export interface ImportLineWithBalance {
|
||||
id: number;
|
||||
line_number: number;
|
||||
// Invoice info
|
||||
invoice_number?: string;
|
||||
invoice_date?: string;
|
||||
invoice_status?: string;
|
||||
// Part / class
|
||||
part_number?: string;
|
||||
class_code?: string;
|
||||
description_spanish?: string;
|
||||
unit_of_measure_code?: string;
|
||||
// Quantities
|
||||
quantity?: number;
|
||||
quantity_returned_temp?: number;
|
||||
quantity_returned?: number;
|
||||
// Balance
|
||||
available_balance: number;
|
||||
has_balance: boolean;
|
||||
// FA / subitem
|
||||
is_subitem?: boolean;
|
||||
contains_subitems?: boolean;
|
||||
subitem_count?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user