fix(invoices): simplify operation type handling in invoice payload and server load
This commit is contained in:
@@ -110,9 +110,7 @@ function buildInvoicePayload(formData: FormDataSet): CreateInvoiceData | UpdateI
|
||||
const payload: any = {
|
||||
// Datos generales desde InvoiceTopFieldsFormData
|
||||
system: 'fixed_asset',
|
||||
operation_type: InvoiceTopFieldsFormData?.operation_type !== null && InvoiceTopFieldsFormData?.operation_type !== undefined
|
||||
? (InvoiceTopFieldsFormData.operation_type === 1 ? 'exp' : 'imp') as OperationType
|
||||
: undefined,
|
||||
operation_type: InvoiceTopFieldsFormData?.operation_type || undefined,
|
||||
invoice_type: InvoiceTopFieldsFormData?.invoice_type || undefined,
|
||||
document_type: generalFormData?.document_type || undefined,
|
||||
invoice_number: InvoiceTopFieldsFormData?.invoice_number || undefined,
|
||||
|
||||
@@ -427,11 +427,6 @@
|
||||
|
||||
function handleCreateClick() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const operationType = params.get('operation_type');
|
||||
if (operationType) {
|
||||
const operationTypeNumber = operationType === 'exp' ? 1 : 2;
|
||||
params.set('operation_type', operationTypeNumber.toString());
|
||||
}
|
||||
|
||||
const queryString = params.toString();
|
||||
const url = queryString
|
||||
|
||||
@@ -20,13 +20,10 @@ export const load: PageServerLoad = async ({ params, cookies, fetch, url }) => {
|
||||
const operationTypeParam = url.searchParams.get('operation_type');
|
||||
const invoiceTypeParam = url.searchParams.get('invoice_type');
|
||||
|
||||
// Parsear operation_type de forma segura
|
||||
let parsedOperationType: number | null = null;
|
||||
if (operationTypeParam) {
|
||||
const parsed = parseInt(operationTypeParam, 10);
|
||||
if (!isNaN(parsed)) {
|
||||
parsedOperationType = parsed;
|
||||
}
|
||||
// Validar que operation_type sea 'exp' o 'imp'
|
||||
let parsedOperationType: string | null = null;
|
||||
if (operationTypeParam && (operationTypeParam === 'exp' || operationTypeParam === 'imp')) {
|
||||
parsedOperationType = operationTypeParam;
|
||||
}
|
||||
|
||||
// Cargar datos de referencia necesarios
|
||||
|
||||
Reference in New Issue
Block a user