Private
Public Access
commit parcial: refactor de decorator factura, añadida parcialemnte
funcionalidad de facturas tengo sueño Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
1 parent
3c4bc5c008
commit
42bf987ffc
19 files changed
+525
-37
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { API_URL } from '$lib/env';
|
||||
import { getToken } from '../token';
|
||||
|
||||
export interface ItemFacturaPayload {
|
||||
repuestoId: number;
|
||||
cantidad: number;
|
||||
precioUnitario: number;
|
||||
}
|
||||
|
||||
export interface PagoFacturaPayload {
|
||||
formaDePagoId: number;
|
||||
importe: number;
|
||||
fecha?: string;
|
||||
observacion?: string;
|
||||
}
|
||||
|
||||
export interface CrearFacturaPayload {
|
||||
clienteId: number;
|
||||
almacenId: number;
|
||||
items: ItemFacturaPayload[];
|
||||
descuentoId?: number;
|
||||
pagos?: PagoFacturaPayload[];
|
||||
enviarEmail?: boolean;
|
||||
observacion?: string;
|
||||
}
|
||||
|
||||
export async function crearFactura(payload: CrearFacturaPayload) {
|
||||
try {
|
||||
const req = await fetch(`${API_URL}/facturas/`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${getToken()}` },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
const data = await req.json();
|
||||
if (req.ok) return data;
|
||||
return data.error ?? 'error';
|
||||
} catch {
|
||||
return 'no se pudo alcanzar el servidor';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user