feat: solicitudes de compra como documento de marketing (solicitante, válido hasta, fecha necesaria, proveedor y fecha por línea) y API de usuarios con campos limitados
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a3bd976bbd
commit
c1f2cea1e1
19 files changed
+342
-62
No files matched your search
@@ -1,53 +1,54 @@
|
||||
import {
|
||||
type DocumentLayout,
|
||||
FIELDS,
|
||||
blankLine,
|
||||
commentsOnly,
|
||||
descriptionColumn,
|
||||
itemColumn,
|
||||
quantityColumn,
|
||||
today,
|
||||
warehouseColumn,
|
||||
} from '../document-layouts';
|
||||
import { type DocumentLayout, marketingLayout } from '../document-layouts';
|
||||
import type { GridColumn } from '../../../shared/grid/grid.types';
|
||||
import { ANALYTIC_COLUMNS, lineFieldsOf } from '../line-columns';
|
||||
import { ANALYTIC_COLUMNS, LINE_COLUMNS } from '../line-columns';
|
||||
|
||||
/** Solicitud de compra: solicitante (usuario de SAP), fecha requerida y, por línea, proveedor sugerido. */
|
||||
const purchaseRequestColumns: readonly GridColumn[] = [
|
||||
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'] }),
|
||||
/** Proveedor sugerido de la línea (`LineVendor`). */
|
||||
const vendorColumn: GridColumn = {
|
||||
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'] }),
|
||||
},
|
||||
};
|
||||
|
||||
/** Fecha en que se necesita lo pedido en la línea (`RequiredDate`). */
|
||||
const requiredDateColumn: GridColumn = { key: 'RequiredDate', title: 'Fecha necesaria', type: 'date', width: '135px' };
|
||||
|
||||
/** Las columnas de la solicitud de compra, en el orden de SAP: artículo, descripción, proveedor, fecha, cantidad, precio, descuento, impuesto, total y almacén. */
|
||||
const requestColumns: readonly GridColumn[] = [
|
||||
LINE_COLUMNS.item,
|
||||
LINE_COLUMNS.description,
|
||||
vendorColumn,
|
||||
requiredDateColumn,
|
||||
{ ...LINE_COLUMNS.quantity, title: 'Cantidad necesaria' },
|
||||
{ ...LINE_COLUMNS.price, title: 'Precio info' },
|
||||
LINE_COLUMNS.discount,
|
||||
LINE_COLUMNS.tax,
|
||||
LINE_COLUMNS.total,
|
||||
LINE_COLUMNS.warehouse,
|
||||
...ANALYTIC_COLUMNS,
|
||||
];
|
||||
|
||||
export const purchaseRequestLayout: DocumentLayout = {
|
||||
lines: { key: 'DocumentLines', fields: [...lineFieldsOf(purchaseRequestColumns), 'UoMEntry'], base: false },
|
||||
header: { left: [FIELDS.requester, FIELDS.indicator, FIELDS.project], right: [FIELDS.docNumber, FIELDS.docDate, FIELDS.requiredDate] },
|
||||
footer: commentsOnly,
|
||||
columns: purchaseRequestColumns,
|
||||
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: [],
|
||||
};
|
||||
/**
|
||||
* Solicitud de compra: un documento de marketing sin socio de negocio. Lleva al solicitante (usuario de SAP), «Válido
|
||||
* hasta» y la fecha necesaria; sus líneas llevan el proveedor sugerido y la fecha en que se necesita cada una.
|
||||
*/
|
||||
export const purchaseRequestLayout: DocumentLayout = marketingLayout({
|
||||
partnerLabel: 'Solicitante',
|
||||
taxResource: 'SalesTaxCodes',
|
||||
uom: 'purchase',
|
||||
requester: true,
|
||||
lineColumns: requestColumns,
|
||||
});
|
||||
Reference in new issue
Block a user