@spaceinvoices/react-ui 0.4.5 → 0.4.7
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/cli/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/advance-invoices/advance-invoices.hooks.ts +2 -2
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +146 -74
- package/src/components/advance-invoices/create/locales/de.ts +5 -0
- package/src/components/advance-invoices/create/locales/es.ts +5 -0
- package/src/components/advance-invoices/create/locales/fr.ts +5 -0
- package/src/components/advance-invoices/create/locales/hr.ts +5 -0
- package/src/components/advance-invoices/create/locales/it.ts +5 -0
- package/src/components/advance-invoices/create/locales/nl.ts +5 -0
- package/src/components/advance-invoices/create/locales/pl.ts +5 -0
- package/src/components/advance-invoices/create/locales/pt.ts +5 -0
- package/src/components/advance-invoices/create/locales/sl.ts +5 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +5 -5
- package/src/components/credit-notes/create/create-credit-note-form.tsx +138 -72
- package/src/components/credit-notes/create/locales/de.ts +5 -0
- package/src/components/credit-notes/create/locales/es.ts +5 -0
- package/src/components/credit-notes/create/locales/fr.ts +5 -0
- package/src/components/credit-notes/create/locales/hr.ts +5 -0
- package/src/components/credit-notes/create/locales/it.ts +5 -0
- package/src/components/credit-notes/create/locales/nl.ts +5 -0
- package/src/components/credit-notes/create/locales/pl.ts +5 -0
- package/src/components/credit-notes/create/locales/pt.ts +5 -0
- package/src/components/credit-notes/create/locales/sl.ts +5 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +2 -2
- package/src/components/dashboard/collection-rate-card/use-collection-rate.ts +48 -92
- package/src/components/dashboard/invoice-status-chart/use-invoice-status.ts +48 -82
- package/src/components/dashboard/payment-methods-chart/use-payment-methods.ts +22 -31
- package/src/components/dashboard/payment-trend-chart/use-payment-trend.ts +33 -48
- package/src/components/dashboard/revenue-trend-chart/use-revenue-trend.ts +56 -76
- package/src/components/dashboard/shared/index.ts +1 -1
- package/src/components/dashboard/shared/use-revenue-data.ts +106 -182
- package/src/components/dashboard/shared/use-stats-counts.ts +18 -68
- package/src/components/dashboard/shared/use-stats-query.ts +35 -5
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +57 -75
- package/src/components/dashboard/top-customers-chart/use-top-customers.ts +38 -49
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +50 -2
- package/src/components/delivery-notes/create/locales/de.ts +5 -0
- package/src/components/delivery-notes/create/locales/es.ts +5 -0
- package/src/components/delivery-notes/create/locales/fr.ts +5 -0
- package/src/components/delivery-notes/create/locales/hr.ts +5 -0
- package/src/components/delivery-notes/create/locales/it.ts +5 -0
- package/src/components/delivery-notes/create/locales/nl.ts +5 -0
- package/src/components/delivery-notes/create/locales/pl.ts +5 -0
- package/src/components/delivery-notes/create/locales/pt.ts +5 -0
- package/src/components/delivery-notes/create/locales/sl.ts +5 -0
- package/src/components/documents/create/document-details-section.tsx +478 -350
- package/src/components/documents/create/document-recipient-section.tsx +30 -1
- package/src/components/documents/create/live-preview.tsx +15 -28
- package/src/components/documents/create/prepare-document-submission.ts +4 -1
- package/src/components/documents/create/smart-code-insert-button.tsx +6 -0
- package/src/components/documents/create/use-document-customer-form.ts +4 -0
- package/src/components/documents/shared/document-preview-skeleton.tsx +63 -0
- package/src/components/documents/shared/index.ts +1 -0
- package/src/components/documents/view/document-actions-bar.tsx +29 -7
- package/src/components/documents/view/document-details-card.tsx +6 -0
- package/src/components/documents/view/locales/de.ts +1 -0
- package/src/components/documents/view/locales/es.ts +1 -0
- package/src/components/documents/view/locales/fr.ts +1 -0
- package/src/components/documents/view/locales/hr.ts +1 -0
- package/src/components/documents/view/locales/it.ts +1 -0
- package/src/components/documents/view/locales/nl.ts +1 -0
- package/src/components/documents/view/locales/pl.ts +1 -0
- package/src/components/documents/view/locales/pt.ts +1 -0
- package/src/components/documents/view/locales/sl.ts +1 -0
- package/src/components/entities/entity-settings-form/email-template-variables-info.tsx +6 -0
- package/src/components/entities/entity-settings-form/input-with-preview.tsx +2 -145
- package/src/components/entities/entity-settings-form/locales/de.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/es.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/hr.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/pl.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/pt.ts +4 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +4 -0
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +15 -0
- package/src/components/entities/fina-settings-form/fina-settings.hooks.ts +5 -1
- package/src/components/entities/fina-settings-form/locales/de.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/en.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/es.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/fr.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/hr.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/it.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/nl.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/pl.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/pt.ts +3 -0
- package/src/components/entities/fina-settings-form/locales/sl.ts +3 -0
- package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +4 -4
- package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +3 -3
- package/src/components/entities/settings/defaults-settings-form.tsx +38 -1
- package/src/components/entities/settings/tax-rules-settings-form.tsx +32 -15
- package/src/components/estimates/create/create-estimate-form.tsx +46 -4
- package/src/components/estimates/create/locales/de.ts +5 -0
- package/src/components/estimates/create/locales/es.ts +5 -0
- package/src/components/estimates/create/locales/fr.ts +5 -0
- package/src/components/estimates/create/locales/hr.ts +5 -0
- package/src/components/estimates/create/locales/it.ts +5 -0
- package/src/components/estimates/create/locales/nl.ts +5 -0
- package/src/components/estimates/create/locales/pl.ts +5 -0
- package/src/components/estimates/create/locales/pt.ts +5 -0
- package/src/components/estimates/create/locales/sl.ts +5 -0
- package/src/components/invoices/create/create-invoice-form.tsx +258 -96
- package/src/components/invoices/create/locales/de.ts +19 -0
- package/src/components/invoices/create/locales/es.ts +19 -0
- package/src/components/invoices/create/locales/fr.ts +19 -0
- package/src/components/invoices/create/locales/hr.ts +19 -0
- package/src/components/invoices/create/locales/it.ts +19 -0
- package/src/components/invoices/create/locales/nl.ts +19 -0
- package/src/components/invoices/create/locales/pl.ts +19 -0
- package/src/components/invoices/create/locales/pt.ts +19 -0
- package/src/components/invoices/create/locales/sl.ts +19 -0
- package/src/components/invoices/create/prepare-invoice-submission.ts +5 -5
- package/src/components/invoices/invoices.hooks.ts +3 -3
- package/src/components/table/table-pagination.tsx +1 -1
- package/src/components/ui/progress.tsx +27 -0
- package/src/generate-schemas.ts +15 -2
- package/src/generated/schemas/advanceinvoice.ts +4 -0
- package/src/generated/schemas/creditnote.ts +3 -0
- package/src/generated/schemas/customer.ts +2 -0
- package/src/generated/schemas/deliverynote.ts +3 -0
- package/src/generated/schemas/entity.ts +14 -4
- package/src/generated/schemas/entityapikey.ts +19 -0
- package/src/generated/schemas/estimate.ts +4 -0
- package/src/generated/schemas/finasettings.ts +4 -3
- package/src/generated/schemas/index.ts +1 -0
- package/src/generated/schemas/invoice.ts +4 -0
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +17 -11
- package/src/generated/schemas/rendercreditnotepreview_body.ts +17 -11
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +15 -8
- package/src/generated/schemas/renderestimatepreview_body.ts +15 -8
- package/src/generated/schemas/renderinvoicepreview_body.ts +17 -11
- package/src/generated/schemas/startpdfexport_body.ts +12 -5
- package/src/generated/schemas/webhook.ts +4 -0
- package/src/hooks/use-transaction-type-check.ts +152 -0
- package/src/hooks/use-vies-check.ts +7 -131
- package/src/lib/template-variables.tsx +167 -0
- package/src/providers/entities-context.tsx +2 -2
package/cli/dist/index.js
CHANGED
|
@@ -870,7 +870,7 @@ async function list(options = {}) {
|
|
|
870
870
|
|
|
871
871
|
// cli/src/index.ts
|
|
872
872
|
var program = new Command();
|
|
873
|
-
program.name("spaceinvoices-ui").description("CLI for adding Space Invoices React UI components to your project").version("0.4.
|
|
873
|
+
program.name("spaceinvoices-ui").description("CLI for adding Space Invoices React UI components to your project").version("0.4.7");
|
|
874
874
|
program.option("--local <path>", "Use local registry from specified path (for development)");
|
|
875
875
|
program.command("init").description("Initialize Space Invoices UI in your project").option("-y, --yes", "Skip prompts and use defaults").option("-f, --force", "Overwrite existing configuration").option("--cwd <path>", "Working directory (defaults to current directory)").action(async (options) => {
|
|
876
876
|
const globalOpts = program.opts();
|
package/package.json
CHANGED
|
@@ -81,8 +81,8 @@ export function setLastUsedFursCombo(entityId: string, combo: FursCombo): void {
|
|
|
81
81
|
const FINA_ADV_LAST_USED_KEY = "hr:fina:adv:last-used";
|
|
82
82
|
|
|
83
83
|
export type FinaCombo = {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
business_premise_name: string;
|
|
85
|
+
electronic_device_name: string;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export function getLastUsedFinaCombo(entityId: string): FinaCombo | null {
|
|
@@ -13,7 +13,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/ui/c
|
|
|
13
13
|
import type { CreateAdvanceInvoiceSchema } from "@/ui/generated/schemas";
|
|
14
14
|
import { createAdvanceInvoiceSchema } from "@/ui/generated/schemas";
|
|
15
15
|
import { useNextDocumentNumber } from "@/ui/hooks/use-next-document-number";
|
|
16
|
-
import {
|
|
16
|
+
import { useTransactionTypeCheck } from "@/ui/hooks/use-transaction-type-check";
|
|
17
17
|
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
18
18
|
import { createTranslation } from "@/ui/lib/translation";
|
|
19
19
|
import { cn } from "@/ui/lib/utils";
|
|
@@ -21,7 +21,9 @@ import { useEntities } from "@/ui/providers/entities-context";
|
|
|
21
21
|
import { useFormFooterRegistration } from "@/ui/providers/form-footer-context";
|
|
22
22
|
import {
|
|
23
23
|
DocumentDetailsSection,
|
|
24
|
+
DocumentFooterField,
|
|
24
25
|
DocumentNoteField,
|
|
26
|
+
DocumentSignatureField,
|
|
25
27
|
DocumentTaxClauseField,
|
|
26
28
|
} from "../../documents/create/document-details-section";
|
|
27
29
|
import { DocumentItemsSection, type PriceModesMap } from "../../documents/create/document-items-section";
|
|
@@ -107,6 +109,7 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
107
109
|
// Get default note from entity settings (use invoice defaults)
|
|
108
110
|
// Note: Advance invoices don't have payment terms - they are documents requesting payment
|
|
109
111
|
const defaultNote = (activeEntity?.settings as any)?.default_invoice_note || "";
|
|
112
|
+
const defaultFooter = (activeEntity?.settings as any)?.document_footer || "";
|
|
110
113
|
|
|
111
114
|
// ============================================================================
|
|
112
115
|
// FURS Settings & Premises
|
|
@@ -143,8 +146,8 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
143
146
|
const hasFinaPremises = activeFinaPremises.length > 0;
|
|
144
147
|
|
|
145
148
|
// FINA premise/device selection state (no skip - all FINA invoices must be fiscalized)
|
|
146
|
-
const [
|
|
147
|
-
const [
|
|
149
|
+
const [selectedFinaBusinessPremiseName, setSelectedFinaBusinessPremiseName] = useState<string | undefined>();
|
|
150
|
+
const [selectedFinaElectronicDeviceName, setSelectedFinaElectronicDeviceName] = useState<string | undefined>();
|
|
148
151
|
|
|
149
152
|
// UI-only state (not part of API schema)
|
|
150
153
|
const [markAsPaid, setMarkAsPaid] = useState(true);
|
|
@@ -239,22 +242,24 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
239
242
|
|
|
240
243
|
// Get active FINA devices for selected premise
|
|
241
244
|
const activeFinaDevices = useMemo(() => {
|
|
242
|
-
if (!
|
|
243
|
-
const premise = activeFinaPremises.find((p: any) => p.
|
|
245
|
+
if (!selectedFinaBusinessPremiseName) return [];
|
|
246
|
+
const premise = activeFinaPremises.find((p: any) => p.business_premise_name === selectedFinaBusinessPremiseName);
|
|
244
247
|
return premise?.Devices?.filter((d: any) => d.is_active) || [];
|
|
245
|
-
}, [activeFinaPremises,
|
|
248
|
+
}, [activeFinaPremises, selectedFinaBusinessPremiseName]);
|
|
246
249
|
|
|
247
250
|
// Initialize FINA selection from localStorage or first active combo
|
|
248
251
|
useEffect(() => {
|
|
249
|
-
if (!isFinaEnabled || !hasFinaPremises ||
|
|
252
|
+
if (!isFinaEnabled || !hasFinaPremises || selectedFinaBusinessPremiseName) return;
|
|
250
253
|
|
|
251
254
|
const lastUsed = getLastUsedFinaCombo(entityId);
|
|
252
255
|
if (lastUsed) {
|
|
253
|
-
const premise = activeFinaPremises.find((p: any) => p.
|
|
254
|
-
const device = premise?.Devices?.find(
|
|
256
|
+
const premise = activeFinaPremises.find((p: any) => p.business_premise_name === lastUsed.business_premise_name);
|
|
257
|
+
const device = premise?.Devices?.find(
|
|
258
|
+
(d: any) => d.electronic_device_name === lastUsed.electronic_device_name && d.is_active,
|
|
259
|
+
);
|
|
255
260
|
if (premise && device) {
|
|
256
|
-
|
|
257
|
-
|
|
261
|
+
setSelectedFinaBusinessPremiseName(lastUsed.business_premise_name);
|
|
262
|
+
setSelectedFinaElectronicDeviceName(lastUsed.electronic_device_name);
|
|
258
263
|
return;
|
|
259
264
|
}
|
|
260
265
|
}
|
|
@@ -262,25 +267,25 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
262
267
|
const firstPremise = activeFinaPremises[0];
|
|
263
268
|
const firstDevice = firstPremise?.Devices?.find((d: any) => d.is_active);
|
|
264
269
|
if (firstPremise && firstDevice) {
|
|
265
|
-
|
|
266
|
-
|
|
270
|
+
setSelectedFinaBusinessPremiseName(firstPremise.business_premise_name);
|
|
271
|
+
setSelectedFinaElectronicDeviceName(firstDevice.electronic_device_name);
|
|
267
272
|
}
|
|
268
|
-
}, [isFinaEnabled, hasFinaPremises, activeFinaPremises, entityId,
|
|
273
|
+
}, [isFinaEnabled, hasFinaPremises, activeFinaPremises, entityId, selectedFinaBusinessPremiseName]);
|
|
269
274
|
|
|
270
275
|
// When FINA premise changes, select first active device
|
|
271
276
|
useEffect(() => {
|
|
272
|
-
if (!
|
|
273
|
-
const premise = activeFinaPremises.find((p: any) => p.
|
|
277
|
+
if (!selectedFinaBusinessPremiseName) return;
|
|
278
|
+
const premise = activeFinaPremises.find((p: any) => p.business_premise_name === selectedFinaBusinessPremiseName);
|
|
274
279
|
const firstDevice = premise?.Devices?.find((d: any) => d.is_active);
|
|
275
|
-
if (firstDevice &&
|
|
280
|
+
if (firstDevice && selectedFinaElectronicDeviceName !== firstDevice.electronic_device_name) {
|
|
276
281
|
const currentDeviceInPremise = premise?.Devices?.find(
|
|
277
|
-
(d: any) => d.
|
|
282
|
+
(d: any) => d.electronic_device_name === selectedFinaElectronicDeviceName && d.is_active,
|
|
278
283
|
);
|
|
279
284
|
if (!currentDeviceInPremise) {
|
|
280
|
-
|
|
285
|
+
setSelectedFinaElectronicDeviceName(firstDevice.electronic_device_name);
|
|
281
286
|
}
|
|
282
287
|
}
|
|
283
|
-
}, [
|
|
288
|
+
}, [selectedFinaBusinessPremiseName, activeFinaPremises, selectedFinaElectronicDeviceName]);
|
|
284
289
|
|
|
285
290
|
const form = useForm<CreateAdvanceInvoiceFormValues>({
|
|
286
291
|
// Cast resolver to accept extended form type (includes UI-only fields)
|
|
@@ -315,8 +320,10 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
315
320
|
},
|
|
316
321
|
],
|
|
317
322
|
currency_code: initialValues?.currency_code || activeEntity?.currency_code || "EUR",
|
|
323
|
+
reference: (initialValues as any)?.reference ?? "",
|
|
318
324
|
note: initialValues?.note ?? defaultNote,
|
|
319
325
|
tax_clause: "",
|
|
326
|
+
footer: (initialValues as any)?.footer ?? defaultFooter,
|
|
320
327
|
},
|
|
321
328
|
});
|
|
322
329
|
|
|
@@ -339,21 +346,9 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
339
346
|
|
|
340
347
|
// FINA selection ready and active checks
|
|
341
348
|
const isFinaSelectionReady =
|
|
342
|
-
!isFinaEnabled || !hasFinaPremises || (!!
|
|
343
|
-
const isFinaActive =
|
|
344
|
-
|
|
345
|
-
// ============================================================================
|
|
346
|
-
// Next Advance Invoice Number Preview
|
|
347
|
-
// ============================================================================
|
|
348
|
-
const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "advance_invoice", {
|
|
349
|
-
businessPremiseName: isFursActive ? selectedPremiseName : undefined,
|
|
350
|
-
electronicDeviceName: isFursActive ? selectedDeviceName : undefined,
|
|
351
|
-
enabled: !!entityId && !isFursLoading && isFursSelectionReady && !isFinaLoading && isFinaSelectionReady,
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// Overall loading state
|
|
355
|
-
const isFormDataLoading =
|
|
356
|
-
isFursLoading || !isFursSelectionReady || isFinaLoading || !isFinaSelectionReady || isNextNumberLoading;
|
|
349
|
+
!isFinaEnabled || !hasFinaPremises || (!!selectedFinaBusinessPremiseName && !!selectedFinaElectronicDeviceName);
|
|
350
|
+
const isFinaActive =
|
|
351
|
+
isFinaEnabled && hasFinaPremises && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName;
|
|
357
352
|
|
|
358
353
|
// Update header action with FURS and e-SLOG toggle buttons
|
|
359
354
|
useEffect(() => {
|
|
@@ -464,13 +459,6 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
464
459
|
t,
|
|
465
460
|
]);
|
|
466
461
|
|
|
467
|
-
// Pre-fill advance invoice number from preview
|
|
468
|
-
useEffect(() => {
|
|
469
|
-
if (nextNumberData?.number) {
|
|
470
|
-
form.setValue("number", nextNumberData.number);
|
|
471
|
-
}
|
|
472
|
-
}, [nextNumberData?.number, form]);
|
|
473
|
-
|
|
474
462
|
const formValues = useWatch({
|
|
475
463
|
control: form.control,
|
|
476
464
|
});
|
|
@@ -481,20 +469,55 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
481
469
|
const {
|
|
482
470
|
reverseChargeApplies,
|
|
483
471
|
transactionType,
|
|
484
|
-
customerCountryCode: viesCustomerCountryCode,
|
|
485
472
|
isFetching: isViesFetching,
|
|
486
473
|
warning: viesWarning,
|
|
487
|
-
} =
|
|
474
|
+
} = useTransactionTypeCheck({
|
|
488
475
|
issuerCountryCode: activeEntity?.country_code,
|
|
489
476
|
isTaxSubject: activeEntity?.is_tax_subject ?? true,
|
|
490
477
|
customerCountry: formValues.customer?.country,
|
|
491
478
|
customerCountryCode: formValues.customer?.country_code,
|
|
492
479
|
customerTaxNumber: formValues.customer?.tax_number,
|
|
480
|
+
customerIsEndConsumer: (formValues.customer as any)?.is_end_consumer,
|
|
493
481
|
enabled: !!activeEntity,
|
|
494
482
|
});
|
|
495
483
|
|
|
496
|
-
// FINA
|
|
497
|
-
const
|
|
484
|
+
// FINA numbering guard: use FINA numbering for domestic transactions (or all if unified numbering is on)
|
|
485
|
+
const finaUnifiedNumbering = finaSettings?.unified_numbering !== false;
|
|
486
|
+
const useFinaNumbering =
|
|
487
|
+
!!isFinaActive && (finaUnifiedNumbering || transactionType == null || transactionType === "domestic");
|
|
488
|
+
const isFinaNonDomestic = !!isFinaActive && !useFinaNumbering;
|
|
489
|
+
|
|
490
|
+
// ============================================================================
|
|
491
|
+
// Next Advance Invoice Number Preview
|
|
492
|
+
// ============================================================================
|
|
493
|
+
// Use same premise/device params for both FURS and FINA (entity is either one, never both)
|
|
494
|
+
const activePremiseNameForNumber = isFursActive
|
|
495
|
+
? selectedPremiseName
|
|
496
|
+
: useFinaNumbering
|
|
497
|
+
? selectedFinaBusinessPremiseName
|
|
498
|
+
: undefined;
|
|
499
|
+
const activeDeviceNameForNumber = isFursActive
|
|
500
|
+
? selectedDeviceName
|
|
501
|
+
: useFinaNumbering
|
|
502
|
+
? selectedFinaElectronicDeviceName
|
|
503
|
+
: undefined;
|
|
504
|
+
|
|
505
|
+
const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "advance_invoice", {
|
|
506
|
+
businessPremiseName: activePremiseNameForNumber,
|
|
507
|
+
electronicDeviceName: activeDeviceNameForNumber,
|
|
508
|
+
enabled: !!entityId && !isFursLoading && isFursSelectionReady && !isFinaLoading && isFinaSelectionReady,
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
// Overall loading state
|
|
512
|
+
const isFormDataLoading =
|
|
513
|
+
isFursLoading || !isFursSelectionReady || isFinaLoading || !isFinaSelectionReady || isNextNumberLoading;
|
|
514
|
+
|
|
515
|
+
// Pre-fill advance invoice number from preview
|
|
516
|
+
useEffect(() => {
|
|
517
|
+
if (nextNumberData?.number) {
|
|
518
|
+
form.setValue("number", nextNumberData.number);
|
|
519
|
+
}
|
|
520
|
+
}, [nextNumberData?.number, form]);
|
|
498
521
|
|
|
499
522
|
// Auto-populate tax_clause from entity settings when transaction type changes
|
|
500
523
|
const effectiveTransactionType = transactionType ?? "domestic";
|
|
@@ -531,10 +554,10 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
531
554
|
electronic_device_name: selectedDeviceName,
|
|
532
555
|
});
|
|
533
556
|
}
|
|
534
|
-
if (isFinaActive &&
|
|
557
|
+
if (isFinaActive && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName) {
|
|
535
558
|
setLastUsedFinaCombo(entityId, {
|
|
536
|
-
|
|
537
|
-
|
|
559
|
+
business_premise_name: selectedFinaBusinessPremiseName,
|
|
560
|
+
electronic_device_name: selectedFinaElectronicDeviceName,
|
|
538
561
|
});
|
|
539
562
|
}
|
|
540
563
|
onSuccess?.(data);
|
|
@@ -580,8 +603,12 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
580
603
|
|
|
581
604
|
// Build FINA options (skip for drafts; FINA can't be skipped)
|
|
582
605
|
const finaOptions =
|
|
583
|
-
!isDraft &&
|
|
584
|
-
? {
|
|
606
|
+
!isDraft && useFinaNumbering && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName
|
|
607
|
+
? {
|
|
608
|
+
business_premise_name: selectedFinaBusinessPremiseName,
|
|
609
|
+
electronic_device_name: selectedFinaElectronicDeviceName,
|
|
610
|
+
payment_type: paymentTypes[0],
|
|
611
|
+
}
|
|
585
612
|
: undefined;
|
|
586
613
|
|
|
587
614
|
const payload = prepareAdvanceInvoiceSubmission(values, {
|
|
@@ -605,15 +632,14 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
605
632
|
form,
|
|
606
633
|
isEslogAvailable,
|
|
607
634
|
isFursEnabled,
|
|
608
|
-
|
|
609
|
-
isFinaNonDomestic,
|
|
635
|
+
useFinaNumbering,
|
|
610
636
|
markAsPaid,
|
|
611
637
|
originalCustomer,
|
|
612
638
|
paymentTypes,
|
|
613
639
|
selectedDeviceName,
|
|
614
640
|
selectedPremiseName,
|
|
615
|
-
|
|
616
|
-
|
|
641
|
+
selectedFinaBusinessPremiseName,
|
|
642
|
+
selectedFinaElectronicDeviceName,
|
|
617
643
|
showCustomerForm,
|
|
618
644
|
skipFiscalization,
|
|
619
645
|
],
|
|
@@ -645,12 +671,20 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
645
671
|
},
|
|
646
672
|
});
|
|
647
673
|
|
|
648
|
-
// Set default note from entity settings (advance invoices don't have payment terms)
|
|
674
|
+
// Set default note, footer, and signature from entity settings (advance invoices don't have payment terms)
|
|
649
675
|
useEffect(() => {
|
|
650
676
|
const entityDefaultNote = (activeEntity?.settings as any)?.default_invoice_note;
|
|
651
677
|
if (entityDefaultNote && !form.getValues("note")) {
|
|
652
678
|
form.setValue("note", entityDefaultNote);
|
|
653
679
|
}
|
|
680
|
+
const entityDefaultFooter = (activeEntity?.settings as any)?.document_footer;
|
|
681
|
+
if (entityDefaultFooter && !form.getValues("footer")) {
|
|
682
|
+
form.setValue("footer", entityDefaultFooter);
|
|
683
|
+
}
|
|
684
|
+
const entityDefaultSignature = (activeEntity?.settings as any)?.default_document_signature;
|
|
685
|
+
if (entityDefaultSignature && !form.getValues("signature")) {
|
|
686
|
+
form.setValue("signature", entityDefaultSignature);
|
|
687
|
+
}
|
|
654
688
|
}, [activeEntity, form]);
|
|
655
689
|
|
|
656
690
|
// Auto-add tax field for tax subject entities
|
|
@@ -684,7 +718,9 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
684
718
|
customer: formValues.customer,
|
|
685
719
|
items: transformedItems,
|
|
686
720
|
currency_code: formValues.currency_code,
|
|
721
|
+
reference: formValues.reference,
|
|
687
722
|
note: formValues.note,
|
|
723
|
+
signature: formValues.signature,
|
|
688
724
|
};
|
|
689
725
|
onChange(payload);
|
|
690
726
|
}
|
|
@@ -703,16 +739,24 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
703
739
|
<Skeleton className="h-7 w-24" />
|
|
704
740
|
<Skeleton className="h-10 w-full" />
|
|
705
741
|
</div>
|
|
706
|
-
<div className="flex-1 space-y-
|
|
742
|
+
<div className="flex-1 space-y-3">
|
|
707
743
|
<Skeleton className="h-7 w-20" />
|
|
708
|
-
<
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
<
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
744
|
+
<div className="flex items-center gap-3">
|
|
745
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
746
|
+
<Skeleton className="h-10 flex-1" />
|
|
747
|
+
</div>
|
|
748
|
+
<div className="flex items-center gap-3">
|
|
749
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
750
|
+
<Skeleton className="h-10 flex-1" />
|
|
751
|
+
</div>
|
|
752
|
+
<div className="flex items-center gap-3">
|
|
753
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
754
|
+
<Skeleton className="h-10 flex-1" />
|
|
755
|
+
</div>
|
|
756
|
+
<div className="flex items-center gap-3">
|
|
757
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
758
|
+
<Skeleton className="h-10 flex-1" />
|
|
759
|
+
</div>
|
|
716
760
|
<div className="space-y-3 rounded-md border p-4">
|
|
717
761
|
<div className="flex items-center gap-3">
|
|
718
762
|
<Skeleton className="h-4 w-4 rounded" />
|
|
@@ -738,8 +782,6 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
738
782
|
<Skeleton className="h-5 w-12" />
|
|
739
783
|
<Skeleton className="h-24 w-full" />
|
|
740
784
|
</div>
|
|
741
|
-
|
|
742
|
-
<Skeleton className="h-10 w-24" />
|
|
743
785
|
</div>
|
|
744
786
|
);
|
|
745
787
|
}
|
|
@@ -795,14 +837,20 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
795
837
|
: undefined
|
|
796
838
|
}
|
|
797
839
|
finaInline={
|
|
798
|
-
|
|
840
|
+
useFinaNumbering
|
|
799
841
|
? {
|
|
800
|
-
premises: activeFinaPremises.map((p: any) => ({
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
842
|
+
premises: activeFinaPremises.map((p: any) => ({
|
|
843
|
+
id: p.id,
|
|
844
|
+
business_premise_name: p.business_premise_name,
|
|
845
|
+
})),
|
|
846
|
+
devices: activeFinaDevices.map((d: any) => ({
|
|
847
|
+
id: d.id,
|
|
848
|
+
electronic_device_name: d.electronic_device_name,
|
|
849
|
+
})),
|
|
850
|
+
selectedPremise: selectedFinaBusinessPremiseName,
|
|
851
|
+
selectedDevice: selectedFinaElectronicDeviceName,
|
|
852
|
+
onPremiseChange: setSelectedFinaBusinessPremiseName,
|
|
853
|
+
onDeviceChange: setSelectedFinaElectronicDeviceName,
|
|
806
854
|
}
|
|
807
855
|
: undefined
|
|
808
856
|
}
|
|
@@ -864,6 +912,30 @@ export default function CreateAdvanceInvoiceForm({
|
|
|
864
912
|
isTransactionTypeFetching={isViesFetching}
|
|
865
913
|
isFinaNonDomestic={isFinaNonDomestic}
|
|
866
914
|
/>
|
|
915
|
+
|
|
916
|
+
<DocumentSignatureField
|
|
917
|
+
control={form.control}
|
|
918
|
+
t={t}
|
|
919
|
+
entity={activeEntity}
|
|
920
|
+
document={{
|
|
921
|
+
number: formValues.number,
|
|
922
|
+
date: formValues.date,
|
|
923
|
+
currency_code: formValues.currency_code,
|
|
924
|
+
customer: formValues.customer as any,
|
|
925
|
+
}}
|
|
926
|
+
/>
|
|
927
|
+
|
|
928
|
+
<DocumentFooterField
|
|
929
|
+
control={form.control}
|
|
930
|
+
t={t}
|
|
931
|
+
entity={activeEntity}
|
|
932
|
+
document={{
|
|
933
|
+
number: formValues.number,
|
|
934
|
+
date: formValues.date,
|
|
935
|
+
currency_code: formValues.currency_code,
|
|
936
|
+
customer: formValues.customer as any,
|
|
937
|
+
}}
|
|
938
|
+
/>
|
|
867
939
|
</form>
|
|
868
940
|
</Form>
|
|
869
941
|
);
|
|
@@ -30,6 +30,9 @@ export default {
|
|
|
30
30
|
Device: "Gerät",
|
|
31
31
|
"FINA fiscalized invoices always use the current date":
|
|
32
32
|
"FINA-fiskalisierte Dokumente verwenden immer das aktuelle Datum",
|
|
33
|
+
// Signature field
|
|
34
|
+
Signature: "Unterschrift",
|
|
35
|
+
"Add signature text...": "Unterschriftstext hinzufügen...",
|
|
33
36
|
// Separator items
|
|
34
37
|
"Add separator": "Trennzeile hinzufügen",
|
|
35
38
|
"Section header": "Abschnittsüberschrift",
|
|
@@ -45,4 +48,6 @@ export default {
|
|
|
45
48
|
"Diese Rechnung wird nicht fiskalisiert (nicht-inländische Transaktion)",
|
|
46
49
|
"Tax Clause": "Steuerklausel",
|
|
47
50
|
"Add tax clause...": "Steuerklausel hinzufügen...",
|
|
51
|
+
Footer: "Fußzeile",
|
|
52
|
+
"Add document footer...": "Dokumentfußzeile hinzufügen...",
|
|
48
53
|
} as const;
|
|
@@ -30,6 +30,9 @@ export default {
|
|
|
30
30
|
Device: "Dispositivo",
|
|
31
31
|
"FINA fiscalized invoices always use the current date":
|
|
32
32
|
"Los documentos fiscalizados con FINA siempre usan la fecha actual",
|
|
33
|
+
// Signature field
|
|
34
|
+
Signature: "Firma",
|
|
35
|
+
"Add signature text...": "Añadir texto de firma...",
|
|
33
36
|
// Separator items
|
|
34
37
|
"Add separator": "Añadir separador",
|
|
35
38
|
"Section header": "Encabezado de sección",
|
|
@@ -45,4 +48,6 @@ export default {
|
|
|
45
48
|
"Esta factura no será fiscalizada (transacción no nacional)",
|
|
46
49
|
"Tax Clause": "Cláusula fiscal",
|
|
47
50
|
"Add tax clause...": "Agregar cláusula fiscal...",
|
|
51
|
+
Footer: "Pie de página",
|
|
52
|
+
"Add document footer...": "Añadir pie de página del documento...",
|
|
48
53
|
} as const;
|
|
@@ -29,6 +29,9 @@ export default {
|
|
|
29
29
|
Device: "Appareil",
|
|
30
30
|
"FINA fiscalized invoices always use the current date":
|
|
31
31
|
"Les documents fiscalisés FINA utilisent toujours la date actuelle",
|
|
32
|
+
// Signature field
|
|
33
|
+
Signature: "Signature",
|
|
34
|
+
"Add signature text...": "Ajouter un texte de signature...",
|
|
32
35
|
// Separator items
|
|
33
36
|
"Add separator": "Ajouter un séparateur",
|
|
34
37
|
"Section header": "En-tête de section",
|
|
@@ -44,4 +47,6 @@ export default {
|
|
|
44
47
|
"Cette facture ne sera pas fiscalisée (transaction non nationale)",
|
|
45
48
|
"Tax Clause": "Clause fiscale",
|
|
46
49
|
"Add tax clause...": "Ajouter une clause fiscale...",
|
|
50
|
+
Footer: "Pied de page",
|
|
51
|
+
"Add document footer...": "Ajouter un pied de page...",
|
|
47
52
|
} as const;
|
|
@@ -27,6 +27,9 @@ export default {
|
|
|
27
27
|
Premise: "Prostor",
|
|
28
28
|
Device: "Uredaj",
|
|
29
29
|
"FINA fiscalized invoices always use the current date": "FINA fiskalizirani dokumenti uvijek koriste trenutni datum",
|
|
30
|
+
// Signature field
|
|
31
|
+
Signature: "Potpis",
|
|
32
|
+
"Add signature text...": "Dodaj tekst potpisa...",
|
|
30
33
|
// Separator items
|
|
31
34
|
"Add separator": "Dodaj separator",
|
|
32
35
|
"Section header": "Naslov odjeljka",
|
|
@@ -42,4 +45,6 @@ export default {
|
|
|
42
45
|
"Ovaj račun neće biti fiskaliziran (nedomaća transakcija)",
|
|
43
46
|
"Tax Clause": "Porezna klauzula",
|
|
44
47
|
"Add tax clause...": "Dodajte poreznu klauzulu...",
|
|
48
|
+
Footer: "Podnožje",
|
|
49
|
+
"Add document footer...": "Dodajte podnožje dokumenta...",
|
|
45
50
|
} as const;
|
|
@@ -30,6 +30,9 @@ export default {
|
|
|
30
30
|
Device: "Dispositivo",
|
|
31
31
|
"FINA fiscalized invoices always use the current date":
|
|
32
32
|
"I documenti fiscalizzati FINA utilizzano sempre la data corrente",
|
|
33
|
+
// Signature field
|
|
34
|
+
Signature: "Firma",
|
|
35
|
+
"Add signature text...": "Aggiungi testo della firma...",
|
|
33
36
|
// Separator items
|
|
34
37
|
"Add separator": "Aggiungi separatore",
|
|
35
38
|
"Section header": "Intestazione sezione",
|
|
@@ -45,4 +48,6 @@ export default {
|
|
|
45
48
|
"Questa fattura non sarà fiscalizzata (transazione non nazionale)",
|
|
46
49
|
"Tax Clause": "Clausola fiscale",
|
|
47
50
|
"Add tax clause...": "Aggiungi clausola fiscale...",
|
|
51
|
+
Footer: "Piè di pagina",
|
|
52
|
+
"Add document footer...": "Aggiungi piè di pagina del documento...",
|
|
48
53
|
} as const;
|
|
@@ -29,6 +29,9 @@ export default {
|
|
|
29
29
|
Device: "Apparaat",
|
|
30
30
|
"FINA fiscalized invoices always use the current date":
|
|
31
31
|
"FINA-gefiscaliseerde documenten gebruiken altijd de huidige datum",
|
|
32
|
+
// Signature field
|
|
33
|
+
Signature: "Handtekening",
|
|
34
|
+
"Add signature text...": "Handtekeningtekst toevoegen...",
|
|
32
35
|
// Separator items
|
|
33
36
|
"Add separator": "Scheidingslijn toevoegen",
|
|
34
37
|
"Section header": "Sectiekop",
|
|
@@ -44,4 +47,6 @@ export default {
|
|
|
44
47
|
"Deze factuur wordt niet gefiscaliseerd (niet-binnenlandse transactie)",
|
|
45
48
|
"Tax Clause": "Belastingclausule",
|
|
46
49
|
"Add tax clause...": "Belastingclausule toevoegen...",
|
|
50
|
+
Footer: "Voettekst",
|
|
51
|
+
"Add document footer...": "Documentvoettekst toevoegen...",
|
|
47
52
|
} as const;
|
|
@@ -28,6 +28,9 @@ export default {
|
|
|
28
28
|
Premise: "Lokal",
|
|
29
29
|
Device: "Urządzenie",
|
|
30
30
|
"FINA fiscalized invoices always use the current date": "Dokumenty fiskalizowane FINA zawsze używają bieżącej daty",
|
|
31
|
+
// Signature field
|
|
32
|
+
Signature: "Podpis",
|
|
33
|
+
"Add signature text...": "Dodaj tekst podpisu...",
|
|
31
34
|
// Separator items
|
|
32
35
|
"Add separator": "Dodaj separator",
|
|
33
36
|
"Section header": "Nagłówek sekcji",
|
|
@@ -43,4 +46,6 @@ export default {
|
|
|
43
46
|
"Ta faktura nie będzie fiskalizowana (transakcja niekrajowa)",
|
|
44
47
|
"Tax Clause": "Klauzula podatkowa",
|
|
45
48
|
"Add tax clause...": "Dodaj klauzulę podatkową...",
|
|
49
|
+
Footer: "Stopka",
|
|
50
|
+
"Add document footer...": "Dodaj stopkę dokumentu...",
|
|
46
51
|
} as const;
|
|
@@ -29,6 +29,9 @@ export default {
|
|
|
29
29
|
Premise: "Estabelecimento",
|
|
30
30
|
Device: "Dispositivo",
|
|
31
31
|
"FINA fiscalized invoices always use the current date": "Os documentos fiscalizados FINA usam sempre a data atual",
|
|
32
|
+
// Signature field
|
|
33
|
+
Signature: "Assinatura",
|
|
34
|
+
"Add signature text...": "Adicionar texto de assinatura...",
|
|
32
35
|
// Separator items
|
|
33
36
|
"Add separator": "Adicionar separador",
|
|
34
37
|
"Section header": "Cabeçalho da secção",
|
|
@@ -44,4 +47,6 @@ export default {
|
|
|
44
47
|
"Esta fatura não será fiscalizada (transação não nacional)",
|
|
45
48
|
"Tax Clause": "Cláusula fiscal",
|
|
46
49
|
"Add tax clause...": "Adicionar cláusula fiscal...",
|
|
50
|
+
Footer: "Rodapé",
|
|
51
|
+
"Add document footer...": "Adicionar rodapé do documento...",
|
|
47
52
|
} as const;
|
|
@@ -25,6 +25,9 @@ export default {
|
|
|
25
25
|
Premise: "Poslovni prostor",
|
|
26
26
|
Device: "Naprava",
|
|
27
27
|
"FINA fiscalized invoices always use the current date": "FINA fiskalizirani dokumenti vedno uporabijo trenutni datum",
|
|
28
|
+
// Signature field
|
|
29
|
+
Signature: "Podpis",
|
|
30
|
+
"Add signature text...": "Dodaj besedilo podpisa...",
|
|
28
31
|
// Separator items
|
|
29
32
|
"Add separator": "Dodaj ločilnik",
|
|
30
33
|
"Section header": "Naslov razdelka",
|
|
@@ -40,4 +43,6 @@ export default {
|
|
|
40
43
|
"Ta račun ne bo fiskaliziran (nedomača transakcija)",
|
|
41
44
|
"Tax Clause": "Davčna klavzula",
|
|
42
45
|
"Add tax clause...": "Dodajte davčno klavzulo...",
|
|
46
|
+
Footer: "Noga dokumenta",
|
|
47
|
+
"Add document footer...": "Dodajte nogo dokumenta...",
|
|
43
48
|
} as const;
|
|
@@ -9,8 +9,8 @@ type FursData = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
type FinaData = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
business_premise_name?: string;
|
|
13
|
+
electronic_device_name?: string;
|
|
14
14
|
payment_type?: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -71,10 +71,10 @@ export function prepareAdvanceInvoiceSubmission(
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// Add FINA data if provided (FINA can't be skipped - all invoices must be fiscalized)
|
|
74
|
-
if (options.fina?.
|
|
74
|
+
if (options.fina?.business_premise_name && options.fina.electronic_device_name) {
|
|
75
75
|
(payload as any).fina = {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
business_premise_name: options.fina.business_premise_name,
|
|
77
|
+
electronic_device_name: options.fina.electronic_device_name,
|
|
78
78
|
...(options.fina.payment_type && { payment_type: options.fina.payment_type }),
|
|
79
79
|
};
|
|
80
80
|
}
|