feat(web): asiento con indicador, folio, referencias 1 a 3 (cabecera y línea), cuenta/socio y vencimiento por línea
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8bbd05d07b
commit
eb84d73719
4 files changed
+60
-6
No files matched your search
@@ -5,7 +5,7 @@ const round2 = (n: number): number => Math.round((n + Number.EPSILON) * 100) / 1
|
||||
const has = (v: unknown): boolean => !(v === null || v === undefined || (typeof v === 'string' && v.trim() === ''));
|
||||
|
||||
/** Campos de la línea que se envían a SAP además de la cuenta y los importes. */
|
||||
export const JOURNAL_LINE_TEXT_FIELDS = ['LineMemo', 'CostingCode', 'CostingCode2', 'CostingCode3', 'CostingCode4', 'CostingCode5', 'ProjectCode'] as const;
|
||||
export const JOURNAL_LINE_TEXT_FIELDS = ['ShortName', 'DueDate', 'Reference1', 'Reference2', 'AdditionalReference', 'LineMemo', 'CostingCode', 'CostingCode2', 'CostingCode3', 'CostingCode4', 'CostingCode5', 'ProjectCode'] as const;
|
||||
|
||||
export interface JournalDraft {
|
||||
referenceDate: string;
|
||||
@@ -15,6 +15,11 @@ export interface JournalDraft {
|
||||
memo: string;
|
||||
reference: string;
|
||||
reference2: string;
|
||||
reference3: string;
|
||||
indicator: string;
|
||||
folioPrefix: string;
|
||||
/** Se edita como texto; SAP lo espera como número. */
|
||||
folioNumber: string;
|
||||
lines: Row[];
|
||||
}
|
||||
|
||||
@@ -38,6 +43,7 @@ export function journalTotals(lines: readonly Row[]): JournalTotals {
|
||||
export function validateJournal(d: JournalDraft): string[] {
|
||||
const errors: string[] = [];
|
||||
if (!has(d.referenceDate)) errors.push('Indique la fecha de contabilización.');
|
||||
if (!/^\d*$/.test(d.folioNumber.trim())) errors.push('El número de folio debe ser numérico.');
|
||||
const lines = d.lines.filter((l) => !isBlank(l));
|
||||
if (lines.length < 2) errors.push('Un asiento necesita al menos dos líneas.');
|
||||
lines.forEach((l, i) => {
|
||||
@@ -62,6 +68,10 @@ export function journalPayload(d: JournalDraft): Row {
|
||||
if (has(d.memo)) body['Memo'] = d.memo;
|
||||
if (has(d.reference)) body['Reference'] = d.reference;
|
||||
if (has(d.reference2)) body['Reference2'] = d.reference2;
|
||||
if (has(d.reference3)) body['Reference3'] = d.reference3;
|
||||
if (has(d.indicator)) body['Indicator'] = d.indicator;
|
||||
if (has(d.folioPrefix)) body['FolioPrefixString'] = d.folioPrefix.trim();
|
||||
if (has(d.folioNumber)) body['FolioNumber'] = Number(d.folioNumber);
|
||||
body['JournalEntryLines'] = d.lines
|
||||
.filter((l) => !isBlank(l))
|
||||
.map((l) => {
|
||||
|
||||
Reference in new issue
Block a user