@fayz-ai/financial 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ import { createIdempotencyKey } from './chunk-IP5YH4S5.js';
5
5
  import { NAME_AMOUNT_TOLERANCE, matchStatementLines, scorePair } from './chunk-ZFUQBYBG.js';
6
6
  import { emptyStatement, ledgerBalance, buildStatement } from './chunk-HJPUHTI2.js';
7
7
  import { transferLegs } from './chunk-YUNLQYOZ.js';
8
- import { cancellationReason, invoiceTotal, itemsDescription, summarizeInvoiceLines, lineTotal } from './chunk-MUXDSFL5.js';
8
+ import { cancellationReason, invoiceTotal, itemsDescription, summarizeInvoiceLines, attachmentBelongsTo, lineTotal } from './chunk-HU7E2PK7.js';
9
9
  import { paymentFee, ledgerMethod, toLedgerDirection, fromLedgerDirection } from './chunk-4GXBOEI3.js';
10
10
  import { sessionCashFlow } from './chunk-56NQHYL7.js';
11
11
  import { runReconcileAsBill, runReconcileLink } from './chunk-NONT5MVW.js';
@@ -558,13 +558,16 @@ function createSupabaseFinancialProvider() {
558
558
  line.paymentCardInstallments = Number(payment.card_installments) || void 0;
559
559
  }
560
560
  }
561
- const { data: docs } = await pub.from("documents").select("subject_id").eq("subject_type", "financial_invoice").eq("is_active", true).in("subject_id", titulos);
561
+ const { data: docs } = await pub.from("documents").select("subject_id, metadata").eq("subject_type", "financial_invoice").eq("is_active", true).in("subject_id", titulos);
562
562
  const porTitulo = /* @__PURE__ */ new Map();
563
563
  for (const d of docs ?? []) {
564
- porTitulo.set(d.subject_id, (porTitulo.get(d.subject_id) ?? 0) + 1);
564
+ const lista = porTitulo.get(d.subject_id) ?? [];
565
+ lista.push({ installmentNumber: Number(d.metadata?.installment_number) || void 0 });
566
+ porTitulo.set(d.subject_id, lista);
565
567
  }
566
568
  for (const l of linhas) {
567
- l.attachmentCount = porTitulo.get(l.invoiceId ?? l.id) ?? 0;
569
+ const docsDoTitulo = porTitulo.get(l.invoiceId ?? l.id) ?? [];
570
+ l.attachmentCount = docsDoTitulo.filter((a) => attachmentBelongsTo(a, l.installmentNumber ?? 1, l.totalInstallments ?? 1)).length;
568
571
  }
569
572
  }
570
573
  await attachCurrency(pub, linhas);
@@ -2932,5 +2935,5 @@ function createSupabaseFinancialProvider() {
2932
2935
  }
2933
2936
 
2934
2937
  export { createSupabaseFinancialProvider, invoiceLineOrFilter };
2935
- //# sourceMappingURL=chunk-6VYEQG7Y.js.map
2936
- //# sourceMappingURL=chunk-6VYEQG7Y.js.map
2938
+ //# sourceMappingURL=chunk-3REFUWDS.js.map
2939
+ //# sourceMappingURL=chunk-3REFUWDS.js.map