fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+52 -4
View File
@@ -1,4 +1,52 @@
import type {Acquisition} from './iva-acquisitions.ts';
export function beverageParcel(row:Acquisition):string{return JSON.stringify([row.field==='11'?'customs':row.supplier.trim().toLocaleLowerCase(),row.documentRef.trim().toLocaleLowerCase(),row.documentDate,row.documentLine.trim()]);}
type Claim={source:{parcel:string;origin:string}|null;stage:string;decision:string;receipts:unknown[]};
export function beverageParcelReserved(d:Record<string,unknown>,row:Acquisition):boolean{const store=JSON.parse(String(d.modelo_a_snapshot||'{}')),map=store.ivaBeverageRestitutions as Record<string,{rows:Claim[];result?:{inputs:Claim[]};history?:Array<{inputs:Claim[]}>}>|undefined;return Object.entries(map??{}).some(([scope,b])=>[...b.rows,...[...(b.history??[]),...(b.result?[b.result]:[])].flatMap(c=>c.inputs)].some(r=>r.source&&(scope===String(d.context_opportunity||'general')||r.source.origin==='effective')&&r.source.origin===row.origin&&r.source.parcel===beverageParcel(row)&&(r.stage==='submitted'||r.decision!=='pending'||r.receipts.length>0)));}
import { inputText } from './input-text.ts';
import type { Acquisition } from './iva-acquisitions.ts';
export function beverageParcel(row: Acquisition): string {
return JSON.stringify([
row.field === '11'
? 'customs'
: row.supplier.trim().toLocaleLowerCase(),
row.documentRef.trim().toLocaleLowerCase(),
row.documentDate,
row.documentLine.trim(),
]);
}
type Claim = {
source: { parcel: string; origin: string } | null;
stage: string;
decision: string;
receipts: unknown[];
};
export function beverageParcelReserved(
d: Record<string, unknown>,
row: Acquisition,
): boolean {
const store = JSON.parse(inputText(d.modelo_a_snapshot || '{}')),
map = store.ivaBeverageRestitutions as
| Record<
string,
{
rows: Claim[];
result?: { inputs: Claim[] };
history?: Array<{ inputs: Claim[] }>;
}
>
| undefined;
return Object.entries(map ?? {}).some(([scope, b]) =>
[
...b.rows,
...[...(b.history ?? []), ...(b.result ? [b.result] : [])].flatMap(
(c) => c.inputs,
),
].some(
(r) =>
r.source &&
(scope === inputText(d.context_opportunity || 'general') ||
r.source.origin === 'effective') &&
r.source.origin === row.origin &&
r.source.parcel === beverageParcel(row) &&
(r.stage === 'submitted' ||
r.decision !== 'pending' ||
r.receipts.length > 0),
),
);
}