@fayz-ai/plugin-financial 0.31.1 → 0.31.2
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.
- package/dist/{FinancialPage-FUTZIECP.js → FinancialPage-QPMREIN4.js} +3 -3
- package/dist/{FinancialPage-FUTZIECP.js.map → FinancialPage-QPMREIN4.js.map} +1 -1
- package/dist/{chunk-D4WRL7ST.js → chunk-ILHSYF6L.js} +158 -151
- package/dist/chunk-ILHSYF6L.js.map +1 -0
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/views/InvoiceFormView.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-D4WRL7ST.js.map +0 -1
|
@@ -3679,174 +3679,181 @@ function InvoiceFormView({ direction, editId, onSaved, focusReceipt = false, fro
|
|
|
3679
3679
|
const canEditItems = !hasPayments && !hasCancelledInstallments && (!isEdit || !!provider.replaceInvoiceItems);
|
|
3680
3680
|
const scheduleSection = (
|
|
3681
3681
|
// Tour anchor: the guided setup points here for the installment schedule.
|
|
3682
|
-
/* @__PURE__ */ jsx("div", { ...tourAnchor("financial.installments"), children: /* @__PURE__ */ jsx(
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
{
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" })
|
|
3760
|
-
) : fonteTravada ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: [formaEscolhida?.name, contaEscolhida?.name].filter(Boolean).join(" \xB7 ") }) : /* @__PURE__ */ jsx(
|
|
3761
|
-
InstallmentSourceFields,
|
|
3682
|
+
/* @__PURE__ */ jsx("div", { ...tourAnchor("financial.installments"), children: /* @__PURE__ */ jsx(
|
|
3683
|
+
OrderFormBlock,
|
|
3684
|
+
{
|
|
3685
|
+
title: t("financial.invoice.paymentSchedule"),
|
|
3686
|
+
actions: isEdit && editId ? /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", type: "button", onClick: () => setAttachmentsOpen(true), children: [
|
|
3687
|
+
/* @__PURE__ */ jsx(Paperclip, { className: "h-3.5 w-3.5" }),
|
|
3688
|
+
" ",
|
|
3689
|
+
t("financial.invoiceForm.attachments"),
|
|
3690
|
+
attachmentCount > 0 ? ` (${attachmentCount})` : ""
|
|
3691
|
+
] }) : void 0,
|
|
3692
|
+
children: /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3693
|
+
hasPayments ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("financial.invoiceForm.scheduleLocked") }) : hasCancelledInstallments ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("financial.invoiceForm.scheduleHasCancelled") }) : !canReschedule ? null : (
|
|
3694
|
+
// Atalhos de parcelamento — 1x, 2x, 3x, 6x, 12x cobrem quase tudo.
|
|
3695
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: [1, 2, 3, 6, 12].map((n) => /* @__PURE__ */ jsxs(
|
|
3696
|
+
Button,
|
|
3697
|
+
{
|
|
3698
|
+
variant: "bare",
|
|
3699
|
+
size: "bare",
|
|
3700
|
+
type: "button",
|
|
3701
|
+
onClick: () => generateInstallments(n),
|
|
3702
|
+
disabled: totalAmount <= 0,
|
|
3703
|
+
className: `rounded-full px-2.5 py-1 text-[10px] font-medium transition-colors disabled:opacity-30 ${installments.length === n ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground hover:bg-muted/80"}`,
|
|
3704
|
+
children: [
|
|
3705
|
+
n,
|
|
3706
|
+
"x"
|
|
3707
|
+
]
|
|
3708
|
+
},
|
|
3709
|
+
n
|
|
3710
|
+
)) })
|
|
3711
|
+
),
|
|
3712
|
+
installments.length > 0 && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: t("financial.invoiceForm.scheduleSourceHint") }),
|
|
3713
|
+
installments.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-xs text-muted-foreground", children: totalAmount <= 0 ? t("financial.invoiceForm.addItemsFirst") : t("financial.invoiceForm.selectInstallments") }) : /* @__PURE__ */ jsx("div", { className: "divide-y rounded border", children: installments.map((inst, i) => {
|
|
3714
|
+
const patch = (next) => {
|
|
3715
|
+
const updated = [...installments];
|
|
3716
|
+
updated[i] = { ...inst, ...next };
|
|
3717
|
+
setInstallments(updated);
|
|
3718
|
+
};
|
|
3719
|
+
const saved = savedMovements[i];
|
|
3720
|
+
const isPaid = saved?.status === "paid";
|
|
3721
|
+
const isPartial = saved?.status === "partial";
|
|
3722
|
+
const lockedAmounts = installments.map((_, n) => {
|
|
3723
|
+
const st = savedMovements[n]?.status;
|
|
3724
|
+
return st === "paid" || st === "partial" || st === "cancelled";
|
|
3725
|
+
});
|
|
3726
|
+
const changeAmount = (value) => {
|
|
3727
|
+
const next = rebalanceInstallments({
|
|
3728
|
+
amounts: installments.map((x) => x.amount),
|
|
3729
|
+
index: i,
|
|
3730
|
+
value,
|
|
3731
|
+
total: scheduleTotal,
|
|
3732
|
+
locked: lockedAmounts,
|
|
3733
|
+
pinned: installments.map((x) => pinnedAmounts.has(x._id))
|
|
3734
|
+
});
|
|
3735
|
+
if (next) {
|
|
3736
|
+
setPinnedAmounts((prev) => new Set(prev).add(inst._id));
|
|
3737
|
+
setInstallments(installments.map((x, n) => ({ ...x, amount: next[n] })));
|
|
3738
|
+
return;
|
|
3739
|
+
}
|
|
3740
|
+
const rest = Math.round((inst.amount - value) * 100) / 100;
|
|
3741
|
+
if (installments.length !== 1 || value <= 0 || rest <= 0) return;
|
|
3742
|
+
const due = /* @__PURE__ */ new Date(`${inst.dueDate}T12:00:00`);
|
|
3743
|
+
due.setMonth(due.getMonth() + 1);
|
|
3744
|
+
setPinnedAmounts((prev) => new Set(prev).add(inst._id));
|
|
3745
|
+
setInstallments([
|
|
3746
|
+
{ ...inst, amount: value },
|
|
3747
|
+
{ _id: fid(), amount: rest, dueDate: due.toISOString().slice(0, 10) }
|
|
3748
|
+
]);
|
|
3749
|
+
};
|
|
3750
|
+
const canChangeAmount = canReschedule && !lockedAmounts[i] && (installments.length === 1 || installments.some((_, n) => n !== i && !lockedAmounts[n]));
|
|
3751
|
+
const canAttach = isEdit ? !!saved && !isPaid : true;
|
|
3752
|
+
const semFonte = Math.abs(inst.amount) < 5e-3 && !isPaid && !isPartial;
|
|
3753
|
+
const fonteTravada = isPaid || isPartial;
|
|
3754
|
+
const formaEscolhida = paymentMethodTypes.find((tp) => tp.id === inst.payMethodTypeId);
|
|
3755
|
+
const contaEscolhida = bankAccounts.find((a) => a.id === inst.payAccountId);
|
|
3756
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3757
|
+
/* @__PURE__ */ jsx(
|
|
3758
|
+
InstallmentRow,
|
|
3762
3759
|
{
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3760
|
+
number: i + 1,
|
|
3761
|
+
amount: money(inst.amount),
|
|
3762
|
+
amountValue: inst.amount,
|
|
3763
|
+
onAmountChange: canChangeAmount ? changeAmount : void 0,
|
|
3764
|
+
status: saved?.status,
|
|
3765
|
+
dueDate: inst.dueDate,
|
|
3766
|
+
onDueDateChange: !hasPayments ? (v) => patch({ dueDate: v }) : void 0,
|
|
3767
|
+
source: semFonte ? (
|
|
3768
|
+
// A zero-value line (gift, 100% discount) has no method to ask for.
|
|
3769
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" })
|
|
3770
|
+
) : fonteTravada ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: [formaEscolhida?.name, contaEscolhida?.name].filter(Boolean).join(" \xB7 ") }) : /* @__PURE__ */ jsx(
|
|
3771
|
+
InstallmentSourceFields,
|
|
3772
|
+
{
|
|
3773
|
+
direction,
|
|
3774
|
+
value: { payMethodTypeId: inst.payMethodTypeId, payAccountId: inst.payAccountId },
|
|
3775
|
+
onChange: (next) => patch(next)
|
|
3776
|
+
}
|
|
3777
|
+
),
|
|
3778
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3779
|
+
canAttach && !isEdit && /* @__PURE__ */ jsx(
|
|
3780
|
+
InstallmentReceiptButton,
|
|
3781
|
+
{
|
|
3782
|
+
attached: !!inst.receiptUrl,
|
|
3783
|
+
pending: !inst.receiptUrl && !!pendingReceipt,
|
|
3784
|
+
title: !inst.receiptUrl && pendingReceipt ? t("financial.receipt.attachRead") : t("financial.quickTx.receiptCapture"),
|
|
3785
|
+
onClick: () => {
|
|
3786
|
+
if (!inst.receiptUrl && pendingReceipt) {
|
|
3787
|
+
patch({ receiptUrl: pendingReceipt });
|
|
3788
|
+
setPendingReceipt(void 0);
|
|
3789
|
+
return;
|
|
3790
|
+
}
|
|
3791
|
+
setReceiptTarget(i);
|
|
3792
|
+
receiptPicker.open();
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
),
|
|
3796
|
+
!isPaid && (saved || !isEdit && !!contactId && items.length > 0 && inst.amount > 0) && /* @__PURE__ */ jsx(
|
|
3797
|
+
InstallmentPayButton,
|
|
3798
|
+
{
|
|
3799
|
+
disabled: saving,
|
|
3800
|
+
onClick: () => {
|
|
3801
|
+
void pagarParcela(i);
|
|
3802
|
+
},
|
|
3803
|
+
children: t(direction === "credit" ? "financial.invoice.receive" : "financial.invoice.pay")
|
|
3804
|
+
}
|
|
3805
|
+
)
|
|
3806
|
+
] })
|
|
3766
3807
|
}
|
|
3767
3808
|
),
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3809
|
+
!isEdit && inst.receiptUrl && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 border-t bg-muted/20 px-3 py-2", children: [
|
|
3810
|
+
/* @__PURE__ */ jsx(
|
|
3811
|
+
"img",
|
|
3771
3812
|
{
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
title: !inst.receiptUrl && pendingReceipt ? t("financial.receipt.attachRead") : t("financial.quickTx.receiptCapture"),
|
|
3776
|
-
onClick: () => {
|
|
3777
|
-
if (isEdit && editId) {
|
|
3778
|
-
setAttachmentsOpen(true);
|
|
3779
|
-
return;
|
|
3780
|
-
}
|
|
3781
|
-
if (!inst.receiptUrl && pendingReceipt) {
|
|
3782
|
-
patch({ receiptUrl: pendingReceipt });
|
|
3783
|
-
setPendingReceipt(void 0);
|
|
3784
|
-
return;
|
|
3785
|
-
}
|
|
3786
|
-
setReceiptTarget(i);
|
|
3787
|
-
receiptPicker.open();
|
|
3788
|
-
}
|
|
3813
|
+
src: inst.receiptUrl,
|
|
3814
|
+
alt: t("financial.quickTx.receipt"),
|
|
3815
|
+
className: "h-8 w-8 shrink-0 rounded border object-cover"
|
|
3789
3816
|
}
|
|
3790
3817
|
),
|
|
3791
|
-
|
|
3792
|
-
|
|
3818
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[10px] font-medium text-success", children: t("financial.invoiceForm.willBePaid") }),
|
|
3819
|
+
/* @__PURE__ */ jsx(
|
|
3820
|
+
Button,
|
|
3793
3821
|
{
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
},
|
|
3798
|
-
|
|
3822
|
+
variant: "bare",
|
|
3823
|
+
size: "bare",
|
|
3824
|
+
type: "button",
|
|
3825
|
+
onClick: () => patch({ receiptUrl: void 0, payMethodTypeId: void 0, payAccountId: void 0 }),
|
|
3826
|
+
"aria-label": t("financial.quickTx.receiptRemove"),
|
|
3827
|
+
className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
3828
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
|
|
3799
3829
|
}
|
|
3800
3830
|
)
|
|
3801
3831
|
] })
|
|
3802
|
-
}
|
|
3803
|
-
),
|
|
3804
|
-
|
|
3805
|
-
/* @__PURE__ */ jsx(
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
}
|
|
3812
|
-
),
|
|
3813
|
-
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[10px] font-medium text-success", children: t("financial.invoiceForm.willBePaid") }),
|
|
3832
|
+
] }, inst._id);
|
|
3833
|
+
}) }),
|
|
3834
|
+
pendingDocs.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: pendingDocs.map((file, idx) => /* @__PURE__ */ jsxs("span", { className: "inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/30 px-2 py-1 text-xs", children: [
|
|
3835
|
+
/* @__PURE__ */ jsx(FileText, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
3836
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: file.name }),
|
|
3837
|
+
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-muted-foreground", children: [
|
|
3838
|
+
"\xB7 ",
|
|
3839
|
+
t("financial.invoiceForm.attachOnSave")
|
|
3840
|
+
] }),
|
|
3814
3841
|
/* @__PURE__ */ jsx(
|
|
3815
3842
|
Button,
|
|
3816
3843
|
{
|
|
3817
3844
|
variant: "bare",
|
|
3818
3845
|
size: "bare",
|
|
3819
3846
|
type: "button",
|
|
3820
|
-
onClick: () =>
|
|
3847
|
+
onClick: () => setPendingDocs((prev) => prev.filter((_, j) => j !== idx)),
|
|
3821
3848
|
"aria-label": t("financial.quickTx.receiptRemove"),
|
|
3822
|
-
className: "flex h-
|
|
3823
|
-
children: /* @__PURE__ */ jsx(X, { className: "h-3
|
|
3849
|
+
className: "font-normal flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
3850
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
3824
3851
|
}
|
|
3825
3852
|
)
|
|
3826
|
-
] })
|
|
3827
|
-
] }
|
|
3828
|
-
}
|
|
3829
|
-
|
|
3830
|
-
/* @__PURE__ */ jsx(FileText, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
3831
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: file.name }),
|
|
3832
|
-
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-muted-foreground", children: [
|
|
3833
|
-
"\xB7 ",
|
|
3834
|
-
t("financial.invoiceForm.attachOnSave")
|
|
3835
|
-
] }),
|
|
3836
|
-
/* @__PURE__ */ jsx(
|
|
3837
|
-
Button,
|
|
3838
|
-
{
|
|
3839
|
-
variant: "bare",
|
|
3840
|
-
size: "bare",
|
|
3841
|
-
type: "button",
|
|
3842
|
-
onClick: () => setPendingDocs((prev) => prev.filter((_, j) => j !== idx)),
|
|
3843
|
-
"aria-label": t("financial.quickTx.receiptRemove"),
|
|
3844
|
-
className: "font-normal flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
3845
|
-
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
3846
|
-
}
|
|
3847
|
-
)
|
|
3848
|
-
] }, `${file.name}-${idx}`)) })
|
|
3849
|
-
] }) }) })
|
|
3853
|
+
] }, `${file.name}-${idx}`)) })
|
|
3854
|
+
] })
|
|
3855
|
+
}
|
|
3856
|
+
) })
|
|
3850
3857
|
);
|
|
3851
3858
|
const contactSection = /* @__PURE__ */ jsx("div", { ...tourAnchor("financial.contact"), children: /* @__PURE__ */ jsxs(OrderFormBlock, { title: direction === "debit" ? t("financial.invoiceForm.payTo") : t("financial.invoiceForm.receiveFrom"), children: [
|
|
3852
3859
|
/* @__PURE__ */ jsx(
|
|
@@ -4265,5 +4272,5 @@ function InvoiceFormView({ direction, editId, onSaved, focusReceipt = false, fro
|
|
|
4265
4272
|
}
|
|
4266
4273
|
|
|
4267
4274
|
export { ACCOUNTS_ROUTE, AccountIcon, BankLogo, BankPicker, CancelInvoicesDialog, FinancialCounterpartySearchSelect, InvoiceAttachmentsModal, InvoiceDetailView, InvoiceFormView, PaymentModal, UnitField, createFinancialCounterpartyLookup, findBrBank, marcarItemParaAbrir, renderAccountAvatar, renderCardChip, useStockedItemTypes, useWritableUnits };
|
|
4268
|
-
//# sourceMappingURL=chunk-
|
|
4269
|
-
//# sourceMappingURL=chunk-
|
|
4275
|
+
//# sourceMappingURL=chunk-ILHSYF6L.js.map
|
|
4276
|
+
//# sourceMappingURL=chunk-ILHSYF6L.js.map
|