import { type DocumentLayout, FIELDS, blankLine, commentsOnly, descriptionColumn, itemColumn, quantityColumn, today, warehouseColumn, } from '../document-layouts'; /** Solicitud de compra: solicitante (usuario de SAP), fecha requerida y, por línea, proveedor sugerido. */ export const purchaseRequestLayout: DocumentLayout = { lines: { key: 'DocumentLines', fields: ['ItemCode', 'ItemDescription', 'Quantity', 'UoMEntry', 'WarehouseCode', 'LineVendor'], base: false }, header: { left: [FIELDS.requester], right: [FIELDS.docNum, FIELDS.docDate, FIELDS.requiredDate] }, footer: commentsOnly, columns: [ itemColumn, descriptionColumn, quantityColumn, warehouseColumn, { key: 'LineVendor', title: 'Proveedor', width: '130px', mono: true, lookup: { config: { title: 'Proveedores', resource: 'BusinessPartners', baseFilter: `CardType eq 'cSupplier'`, orderby: 'CardCode', columns: [ { key: 'CardCode', title: 'Código', width: '130px', mono: true }, { key: 'CardName', title: 'Nombre' }, ], }, apply: (bp, line) => ({ ...line, LineVendor: bp['CardCode'] }), }, }, ], newHeader: () => ({ DocDate: today(), RequriedDate: today() }), newLine: blankLine, // El solicitante es un usuario de SAP (`ReqType` 12). beforeCreate: (h) => (h['Requester'] ? { ...h, ReqType: 12 } : h), requiredLine: [], };