@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
|
@@ -9,7 +9,7 @@ import { Form } from "@/ui/components/ui/form";
|
|
|
9
9
|
import { Skeleton } from "@/ui/components/ui/skeleton";
|
|
10
10
|
import { createCreditNoteSchema } from "@/ui/generated/schemas";
|
|
11
11
|
import { useNextDocumentNumber } from "@/ui/hooks/use-next-document-number";
|
|
12
|
-
import {
|
|
12
|
+
import { useTransactionTypeCheck } from "@/ui/hooks/use-transaction-type-check";
|
|
13
13
|
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
14
14
|
import { createTranslation } from "@/ui/lib/translation";
|
|
15
15
|
import { useEntities } from "@/ui/providers/entities-context";
|
|
@@ -17,8 +17,10 @@ import { useFormFooterRegistration } from "@/ui/providers/form-footer-context";
|
|
|
17
17
|
import { CUSTOMERS_CACHE_KEY } from "../../customers/customers.hooks";
|
|
18
18
|
import {
|
|
19
19
|
DocumentDetailsSection,
|
|
20
|
+
DocumentFooterField,
|
|
20
21
|
DocumentNoteField,
|
|
21
22
|
DocumentPaymentTermsField,
|
|
23
|
+
DocumentSignatureField,
|
|
22
24
|
DocumentTaxClauseField,
|
|
23
25
|
} from "../../documents/create/document-details-section";
|
|
24
26
|
import { DocumentItemsSection, type PriceModesMap } from "../../documents/create/document-items-section";
|
|
@@ -130,8 +132,8 @@ export default function CreateCreditNoteForm({
|
|
|
130
132
|
const hasFinaPremises = activeFinaPremises.length > 0;
|
|
131
133
|
|
|
132
134
|
// FINA premise/device selection state (no skip - all FINA credit notes must be fiscalized)
|
|
133
|
-
const [
|
|
134
|
-
const [
|
|
135
|
+
const [selectedFinaBusinessPremiseName, setSelectedFinaBusinessPremiseName] = useState<string | undefined>();
|
|
136
|
+
const [selectedFinaElectronicDeviceName, setSelectedFinaElectronicDeviceName] = useState<string | undefined>();
|
|
135
137
|
|
|
136
138
|
// UI-only state (not part of API schema)
|
|
137
139
|
const [markAsPaid, setMarkAsPaid] = useState(false);
|
|
@@ -201,22 +203,24 @@ export default function CreateCreditNoteForm({
|
|
|
201
203
|
|
|
202
204
|
// Get active FINA devices for selected premise
|
|
203
205
|
const activeFinaDevices = useMemo(() => {
|
|
204
|
-
if (!
|
|
205
|
-
const premise = activeFinaPremises.find((p: any) => p.
|
|
206
|
+
if (!selectedFinaBusinessPremiseName) return [];
|
|
207
|
+
const premise = activeFinaPremises.find((p: any) => p.business_premise_name === selectedFinaBusinessPremiseName);
|
|
206
208
|
return premise?.Devices?.filter((d: any) => d.is_active) || [];
|
|
207
|
-
}, [activeFinaPremises,
|
|
209
|
+
}, [activeFinaPremises, selectedFinaBusinessPremiseName]);
|
|
208
210
|
|
|
209
211
|
// Initialize FINA selection from localStorage or first active combo
|
|
210
212
|
useEffect(() => {
|
|
211
|
-
if (!isFinaEnabled || !hasFinaPremises ||
|
|
213
|
+
if (!isFinaEnabled || !hasFinaPremises || selectedFinaBusinessPremiseName) return;
|
|
212
214
|
|
|
213
215
|
const lastUsed = getLastUsedFinaCombo(entityId);
|
|
214
216
|
if (lastUsed) {
|
|
215
|
-
const premise = activeFinaPremises.find((p: any) => p.
|
|
216
|
-
const device = premise?.Devices?.find(
|
|
217
|
+
const premise = activeFinaPremises.find((p: any) => p.business_premise_name === lastUsed.business_premise_name);
|
|
218
|
+
const device = premise?.Devices?.find(
|
|
219
|
+
(d: any) => d.electronic_device_name === lastUsed.electronic_device_name && d.is_active,
|
|
220
|
+
);
|
|
217
221
|
if (premise && device) {
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
setSelectedFinaBusinessPremiseName(lastUsed.business_premise_name);
|
|
223
|
+
setSelectedFinaElectronicDeviceName(lastUsed.electronic_device_name);
|
|
220
224
|
return;
|
|
221
225
|
}
|
|
222
226
|
}
|
|
@@ -224,48 +228,37 @@ export default function CreateCreditNoteForm({
|
|
|
224
228
|
const firstPremise = activeFinaPremises[0];
|
|
225
229
|
const firstDevice = firstPremise?.Devices?.find((d: any) => d.is_active);
|
|
226
230
|
if (firstPremise && firstDevice) {
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
setSelectedFinaBusinessPremiseName(firstPremise.business_premise_name);
|
|
232
|
+
setSelectedFinaElectronicDeviceName(firstDevice.electronic_device_name);
|
|
229
233
|
}
|
|
230
|
-
}, [isFinaEnabled, hasFinaPremises, activeFinaPremises, entityId,
|
|
234
|
+
}, [isFinaEnabled, hasFinaPremises, activeFinaPremises, entityId, selectedFinaBusinessPremiseName]);
|
|
231
235
|
|
|
232
236
|
// When FINA premise changes, select first active device
|
|
233
237
|
useEffect(() => {
|
|
234
|
-
if (!
|
|
235
|
-
const premise = activeFinaPremises.find((p: any) => p.
|
|
238
|
+
if (!selectedFinaBusinessPremiseName) return;
|
|
239
|
+
const premise = activeFinaPremises.find((p: any) => p.business_premise_name === selectedFinaBusinessPremiseName);
|
|
236
240
|
const firstDevice = premise?.Devices?.find((d: any) => d.is_active);
|
|
237
|
-
if (firstDevice &&
|
|
241
|
+
if (firstDevice && selectedFinaElectronicDeviceName !== firstDevice.electronic_device_name) {
|
|
238
242
|
const currentDeviceInPremise = premise?.Devices?.find(
|
|
239
|
-
(d: any) => d.
|
|
243
|
+
(d: any) => d.electronic_device_name === selectedFinaElectronicDeviceName && d.is_active,
|
|
240
244
|
);
|
|
241
245
|
if (!currentDeviceInPremise) {
|
|
242
|
-
|
|
246
|
+
setSelectedFinaElectronicDeviceName(firstDevice.electronic_device_name);
|
|
243
247
|
}
|
|
244
248
|
}
|
|
245
|
-
}, [
|
|
249
|
+
}, [selectedFinaBusinessPremiseName, activeFinaPremises, selectedFinaElectronicDeviceName]);
|
|
246
250
|
|
|
247
251
|
// FINA selection ready and active checks
|
|
248
252
|
const isFinaSelectionReady =
|
|
249
|
-
!isFinaEnabled || !hasFinaPremises || (!!
|
|
250
|
-
const isFinaActive =
|
|
251
|
-
|
|
252
|
-
// ============================================================================
|
|
253
|
-
// Next Credit Note Number Preview
|
|
254
|
-
// ============================================================================
|
|
255
|
-
const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "credit_note", {
|
|
256
|
-
businessPremiseName: isFursActive ? selectedPremiseName : undefined,
|
|
257
|
-
electronicDeviceName: isFursActive ? selectedDeviceName : undefined,
|
|
258
|
-
enabled: !!entityId && !isFursLoading && isFursSelectionReady && !isFinaLoading && isFinaSelectionReady,
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
// Overall loading state
|
|
262
|
-
const isFormDataLoading =
|
|
263
|
-
isFursLoading || !isFursSelectionReady || isFinaLoading || !isFinaSelectionReady || isNextNumberLoading;
|
|
253
|
+
!isFinaEnabled || !hasFinaPremises || (!!selectedFinaBusinessPremiseName && !!selectedFinaElectronicDeviceName);
|
|
254
|
+
const isFinaActive =
|
|
255
|
+
isFinaEnabled && hasFinaPremises && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName;
|
|
264
256
|
|
|
265
257
|
// No header action for credit notes - FINA can't be skipped
|
|
266
258
|
|
|
267
|
-
// Get default payment terms from entity settings
|
|
259
|
+
// Get default payment terms and footer from entity settings
|
|
268
260
|
const defaultPaymentTerms = (activeEntity?.settings as any)?.default_credit_note_payment_terms || "";
|
|
261
|
+
const defaultFooter = (activeEntity?.settings as any)?.document_footer || "";
|
|
269
262
|
|
|
270
263
|
const form = useForm<CreateCreditNoteFormValues>({
|
|
271
264
|
// Cast resolver to accept extended form type (includes UI-only fields)
|
|
@@ -300,9 +293,11 @@ export default function CreateCreditNoteForm({
|
|
|
300
293
|
},
|
|
301
294
|
],
|
|
302
295
|
currency_code: initialValues?.currency_code || activeEntity?.currency_code || "EUR",
|
|
296
|
+
reference: (initialValues as any)?.reference ?? "",
|
|
303
297
|
note: initialValues?.note ?? "",
|
|
304
298
|
tax_clause: (initialValues as any)?.tax_clause ?? "",
|
|
305
299
|
payment_terms: initialValues?.payment_terms ?? defaultPaymentTerms,
|
|
300
|
+
footer: (initialValues as any)?.footer ?? defaultFooter,
|
|
306
301
|
},
|
|
307
302
|
});
|
|
308
303
|
|
|
@@ -316,20 +311,48 @@ export default function CreateCreditNoteForm({
|
|
|
316
311
|
const {
|
|
317
312
|
reverseChargeApplies,
|
|
318
313
|
transactionType,
|
|
319
|
-
customerCountryCode: viesCustomerCountryCode,
|
|
320
314
|
isFetching: isViesFetching,
|
|
321
315
|
warning: viesWarning,
|
|
322
|
-
} =
|
|
316
|
+
} = useTransactionTypeCheck({
|
|
323
317
|
issuerCountryCode: activeEntity?.country_code,
|
|
324
318
|
isTaxSubject: activeEntity?.is_tax_subject ?? true,
|
|
325
319
|
customerCountry: formValues.customer?.country,
|
|
326
320
|
customerCountryCode: formValues.customer?.country_code,
|
|
327
321
|
customerTaxNumber: formValues.customer?.tax_number,
|
|
322
|
+
customerIsEndConsumer: (formValues.customer as any)?.is_end_consumer,
|
|
328
323
|
enabled: !!activeEntity,
|
|
329
324
|
});
|
|
330
325
|
|
|
331
|
-
// FINA
|
|
332
|
-
const
|
|
326
|
+
// FINA numbering guard: use FINA numbering for domestic transactions (or all if unified numbering is on)
|
|
327
|
+
const finaUnifiedNumbering = finaSettings?.unified_numbering !== false;
|
|
328
|
+
const useFinaNumbering =
|
|
329
|
+
!!isFinaActive && (finaUnifiedNumbering || transactionType == null || transactionType === "domestic");
|
|
330
|
+
const isFinaNonDomestic = !!isFinaActive && !useFinaNumbering;
|
|
331
|
+
|
|
332
|
+
// ============================================================================
|
|
333
|
+
// Next Credit Note Number Preview
|
|
334
|
+
// ============================================================================
|
|
335
|
+
// Use same premise/device params for both FURS and FINA (entity is either one, never both)
|
|
336
|
+
const activePremiseNameForNumber = isFursActive
|
|
337
|
+
? selectedPremiseName
|
|
338
|
+
: useFinaNumbering
|
|
339
|
+
? selectedFinaBusinessPremiseName
|
|
340
|
+
: undefined;
|
|
341
|
+
const activeDeviceNameForNumber = isFursActive
|
|
342
|
+
? selectedDeviceName
|
|
343
|
+
: useFinaNumbering
|
|
344
|
+
? selectedFinaElectronicDeviceName
|
|
345
|
+
: undefined;
|
|
346
|
+
|
|
347
|
+
const { data: nextNumberData, isLoading: isNextNumberLoading } = useNextDocumentNumber(entityId, "credit_note", {
|
|
348
|
+
businessPremiseName: activePremiseNameForNumber,
|
|
349
|
+
electronicDeviceName: activeDeviceNameForNumber,
|
|
350
|
+
enabled: !!entityId && !isFursLoading && isFursSelectionReady && !isFinaLoading && isFinaSelectionReady,
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Overall loading state
|
|
354
|
+
const isFormDataLoading =
|
|
355
|
+
isFursLoading || !isFursSelectionReady || isFinaLoading || !isFinaSelectionReady || isNextNumberLoading;
|
|
333
356
|
|
|
334
357
|
// Auto-populate tax_clause from entity settings when transaction type changes
|
|
335
358
|
const effectiveTransactionType = transactionType ?? "domestic";
|
|
@@ -374,10 +397,10 @@ export default function CreateCreditNoteForm({
|
|
|
374
397
|
});
|
|
375
398
|
}
|
|
376
399
|
// Save FINA combo to localStorage on successful creation
|
|
377
|
-
if (isFinaActive &&
|
|
400
|
+
if (isFinaActive && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName) {
|
|
378
401
|
setLastUsedFinaCombo(entityId, {
|
|
379
|
-
|
|
380
|
-
|
|
402
|
+
business_premise_name: selectedFinaBusinessPremiseName,
|
|
403
|
+
electronic_device_name: selectedFinaElectronicDeviceName,
|
|
381
404
|
});
|
|
382
405
|
}
|
|
383
406
|
// Invalidate customers cache when a customer was created/linked
|
|
@@ -400,8 +423,12 @@ export default function CreateCreditNoteForm({
|
|
|
400
423
|
|
|
401
424
|
// Build FINA options (skip for drafts; FINA can't be skipped)
|
|
402
425
|
const finaOptions =
|
|
403
|
-
!isDraft &&
|
|
404
|
-
? {
|
|
426
|
+
!isDraft && useFinaNumbering && selectedFinaBusinessPremiseName && selectedFinaElectronicDeviceName
|
|
427
|
+
? {
|
|
428
|
+
business_premise_name: selectedFinaBusinessPremiseName,
|
|
429
|
+
electronic_device_name: selectedFinaElectronicDeviceName,
|
|
430
|
+
payment_type: paymentTypes[0],
|
|
431
|
+
}
|
|
405
432
|
: undefined;
|
|
406
433
|
|
|
407
434
|
const payload = prepareDocumentSubmission(values, {
|
|
@@ -429,14 +456,13 @@ export default function CreateCreditNoteForm({
|
|
|
429
456
|
[
|
|
430
457
|
createCreditNote,
|
|
431
458
|
isFursEnabled,
|
|
432
|
-
|
|
433
|
-
isFinaNonDomestic,
|
|
459
|
+
useFinaNumbering,
|
|
434
460
|
markAsPaid,
|
|
435
461
|
originalCustomer,
|
|
436
462
|
paymentTypes,
|
|
437
463
|
selectedDeviceName,
|
|
438
|
-
|
|
439
|
-
|
|
464
|
+
selectedFinaElectronicDeviceName,
|
|
465
|
+
selectedFinaBusinessPremiseName,
|
|
440
466
|
selectedPremiseName,
|
|
441
467
|
showCustomerForm,
|
|
442
468
|
],
|
|
@@ -478,6 +504,14 @@ export default function CreateCreditNoteForm({
|
|
|
478
504
|
if (entityDefaultPaymentTerms && !form.getValues("payment_terms")) {
|
|
479
505
|
form.setValue("payment_terms", entityDefaultPaymentTerms);
|
|
480
506
|
}
|
|
507
|
+
const entityDefaultFooter = (activeEntity?.settings as any)?.document_footer;
|
|
508
|
+
if (entityDefaultFooter && !form.getValues("footer")) {
|
|
509
|
+
form.setValue("footer", entityDefaultFooter);
|
|
510
|
+
}
|
|
511
|
+
const entityDefaultSignature = (activeEntity?.settings as any)?.default_document_signature;
|
|
512
|
+
if (entityDefaultSignature && !form.getValues("signature")) {
|
|
513
|
+
form.setValue("signature", entityDefaultSignature);
|
|
514
|
+
}
|
|
481
515
|
}, [activeEntity, form]);
|
|
482
516
|
|
|
483
517
|
// Auto-add tax field for tax subject entities
|
|
@@ -512,8 +546,10 @@ export default function CreateCreditNoteForm({
|
|
|
512
546
|
customer: formValues.customer,
|
|
513
547
|
items: transformedItems,
|
|
514
548
|
currency_code: formValues.currency_code,
|
|
549
|
+
reference: formValues.reference,
|
|
515
550
|
note: formValues.note,
|
|
516
551
|
payment_terms: formValues.payment_terms,
|
|
552
|
+
signature: formValues.signature,
|
|
517
553
|
};
|
|
518
554
|
onChange(payload);
|
|
519
555
|
}
|
|
@@ -532,21 +568,23 @@ export default function CreateCreditNoteForm({
|
|
|
532
568
|
<Skeleton className="h-7 w-24" />
|
|
533
569
|
<Skeleton className="h-10 w-full" />
|
|
534
570
|
</div>
|
|
535
|
-
<div className="flex-1 space-y-
|
|
571
|
+
<div className="flex-1 space-y-3">
|
|
536
572
|
<Skeleton className="h-7 w-20" />
|
|
537
|
-
<
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
<
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
<div className="
|
|
546
|
-
<
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
573
|
+
<div className="flex items-center gap-3">
|
|
574
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
575
|
+
<Skeleton className="h-10 flex-1" />
|
|
576
|
+
</div>
|
|
577
|
+
<div className="flex items-center gap-3">
|
|
578
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
579
|
+
<Skeleton className="h-10 flex-1" />
|
|
580
|
+
</div>
|
|
581
|
+
<div className="flex items-center gap-3">
|
|
582
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
583
|
+
<Skeleton className="h-10 flex-1" />
|
|
584
|
+
</div>
|
|
585
|
+
<div className="flex items-center gap-3">
|
|
586
|
+
<Skeleton className="h-5 w-[6.5rem] shrink-0" />
|
|
587
|
+
<Skeleton className="h-10 flex-1" />
|
|
550
588
|
</div>
|
|
551
589
|
</div>
|
|
552
590
|
</div>
|
|
@@ -567,8 +605,6 @@ export default function CreateCreditNoteForm({
|
|
|
567
605
|
<Skeleton className="h-5 w-12" />
|
|
568
606
|
<Skeleton className="h-24 w-full" />
|
|
569
607
|
</div>
|
|
570
|
-
|
|
571
|
-
<Skeleton className="h-10 w-24" />
|
|
572
608
|
</div>
|
|
573
609
|
);
|
|
574
610
|
}
|
|
@@ -605,14 +641,20 @@ export default function CreateCreditNoteForm({
|
|
|
605
641
|
: undefined
|
|
606
642
|
}
|
|
607
643
|
finaInline={
|
|
608
|
-
|
|
644
|
+
useFinaNumbering
|
|
609
645
|
? {
|
|
610
|
-
premises: activeFinaPremises.map((p: any) => ({
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
646
|
+
premises: activeFinaPremises.map((p: any) => ({
|
|
647
|
+
id: p.id,
|
|
648
|
+
business_premise_name: p.business_premise_name,
|
|
649
|
+
})),
|
|
650
|
+
devices: activeFinaDevices.map((d: any) => ({
|
|
651
|
+
id: d.id,
|
|
652
|
+
electronic_device_name: d.electronic_device_name,
|
|
653
|
+
})),
|
|
654
|
+
selectedPremise: selectedFinaBusinessPremiseName,
|
|
655
|
+
selectedDevice: selectedFinaElectronicDeviceName,
|
|
656
|
+
onPremiseChange: setSelectedFinaBusinessPremiseName,
|
|
657
|
+
onDeviceChange: setSelectedFinaElectronicDeviceName,
|
|
616
658
|
}
|
|
617
659
|
: undefined
|
|
618
660
|
}
|
|
@@ -685,6 +727,30 @@ export default function CreateCreditNoteForm({
|
|
|
685
727
|
customer: formValues.customer as any,
|
|
686
728
|
}}
|
|
687
729
|
/>
|
|
730
|
+
|
|
731
|
+
<DocumentSignatureField
|
|
732
|
+
control={form.control}
|
|
733
|
+
t={t}
|
|
734
|
+
entity={activeEntity}
|
|
735
|
+
document={{
|
|
736
|
+
number: formValues.number,
|
|
737
|
+
date: formValues.date,
|
|
738
|
+
currency_code: formValues.currency_code,
|
|
739
|
+
customer: formValues.customer as any,
|
|
740
|
+
}}
|
|
741
|
+
/>
|
|
742
|
+
|
|
743
|
+
<DocumentFooterField
|
|
744
|
+
control={form.control}
|
|
745
|
+
t={t}
|
|
746
|
+
entity={activeEntity}
|
|
747
|
+
document={{
|
|
748
|
+
number: formValues.number,
|
|
749
|
+
date: formValues.date,
|
|
750
|
+
currency_code: formValues.currency_code,
|
|
751
|
+
customer: formValues.customer as any,
|
|
752
|
+
}}
|
|
753
|
+
/>
|
|
688
754
|
</form>
|
|
689
755
|
</Form>
|
|
690
756
|
);
|
|
@@ -39,6 +39,9 @@ export default {
|
|
|
39
39
|
"Insert variable": "Variable einfügen",
|
|
40
40
|
"Add payment instructions, terms, or other notes...":
|
|
41
41
|
"Zahlungsanweisungen, Bedingungen oder andere Notizen hinzufügen...",
|
|
42
|
+
// Signature field
|
|
43
|
+
Signature: "Unterschrift",
|
|
44
|
+
"Add signature text...": "Unterschriftstext hinzufügen...",
|
|
42
45
|
// Payment terms field
|
|
43
46
|
"Payment Terms": "Zahlungsbedingungen",
|
|
44
47
|
"Add payment terms...": "Zahlungsbedingungen hinzufügen...",
|
|
@@ -91,5 +94,7 @@ export default {
|
|
|
91
94
|
"Diese Rechnung wird nicht fiskalisiert (nicht-inländische Transaktion)",
|
|
92
95
|
"Tax Clause": "Steuerklausel",
|
|
93
96
|
"Add tax clause...": "Steuerklausel hinzufügen...",
|
|
97
|
+
Footer: "Fußzeile",
|
|
98
|
+
"Add document footer...": "Dokumentfußzeile hinzufügen...",
|
|
94
99
|
"Reverse charge - tax exempt EU B2B sale": "Umkehrung der Steuerschuldnerschaft - steuerbefreiter EU B2B Verkauf",
|
|
95
100
|
} as const;
|
|
@@ -38,6 +38,9 @@ export default {
|
|
|
38
38
|
Note: "Nota",
|
|
39
39
|
"Insert variable": "Insertar variable",
|
|
40
40
|
"Add payment instructions, terms, or other notes...": "Agregue instrucciones de pago, terminos u otras notas...",
|
|
41
|
+
// Signature field
|
|
42
|
+
Signature: "Firma",
|
|
43
|
+
"Add signature text...": "Añadir texto de firma...",
|
|
41
44
|
// Payment terms field
|
|
42
45
|
"Payment Terms": "Terminos de pago",
|
|
43
46
|
"Add payment terms...": "Agregue terminos de pago...",
|
|
@@ -90,5 +93,7 @@ export default {
|
|
|
90
93
|
"Esta factura no será fiscalizada (transacción no nacional)",
|
|
91
94
|
"Tax Clause": "Cláusula fiscal",
|
|
92
95
|
"Add tax clause...": "Agregar cláusula fiscal...",
|
|
96
|
+
Footer: "Pie de página",
|
|
97
|
+
"Add document footer...": "Añadir pie de página del documento...",
|
|
93
98
|
"Reverse charge - tax exempt EU B2B sale": "Inversión del sujeto pasivo - venta EU B2B exenta de impuestos",
|
|
94
99
|
} as const;
|
|
@@ -39,6 +39,9 @@ export default {
|
|
|
39
39
|
"Insert variable": "Inserer une variable",
|
|
40
40
|
"Add payment instructions, terms, or other notes...":
|
|
41
41
|
"Ajoutez des instructions de paiement, des conditions ou d'autres notes...",
|
|
42
|
+
// Signature field
|
|
43
|
+
Signature: "Signature",
|
|
44
|
+
"Add signature text...": "Ajouter un texte de signature...",
|
|
42
45
|
// Payment terms field
|
|
43
46
|
"Payment Terms": "Conditions de paiement",
|
|
44
47
|
"Add payment terms...": "Ajoutez des conditions de paiement...",
|
|
@@ -90,5 +93,7 @@ export default {
|
|
|
90
93
|
"Cette facture ne sera pas fiscalisée (transaction non nationale)",
|
|
91
94
|
"Tax Clause": "Clause fiscale",
|
|
92
95
|
"Add tax clause...": "Ajouter une clause fiscale...",
|
|
96
|
+
Footer: "Pied de page",
|
|
97
|
+
"Add document footer...": "Ajouter un pied de page...",
|
|
93
98
|
"Reverse charge - tax exempt EU B2B sale": "Autoliquidation - vente B2B UE exonérée de taxe",
|
|
94
99
|
} as const;
|
|
@@ -38,6 +38,9 @@ export default {
|
|
|
38
38
|
Note: "Napomena",
|
|
39
39
|
"Insert variable": "Umetni varijablu",
|
|
40
40
|
"Add payment instructions, terms, or other notes...": "Dodajte upute za placanje, uvjete ili druge napomene...",
|
|
41
|
+
// Signature field
|
|
42
|
+
Signature: "Potpis",
|
|
43
|
+
"Add signature text...": "Dodaj tekst potpisa...",
|
|
41
44
|
// Payment terms field
|
|
42
45
|
"Payment Terms": "Uvjeti placanja",
|
|
43
46
|
"Add payment terms...": "Dodajte uvjete placanja...",
|
|
@@ -88,5 +91,7 @@ export default {
|
|
|
88
91
|
"Ovaj račun neće biti fiskaliziran (nedomaća transakcija)",
|
|
89
92
|
"Tax Clause": "Porezna klauzula",
|
|
90
93
|
"Add tax clause...": "Dodajte poreznu klauzulu...",
|
|
94
|
+
Footer: "Podnožje",
|
|
95
|
+
"Add document footer...": "Dodajte podnožje dokumenta...",
|
|
91
96
|
"Reverse charge - tax exempt EU B2B sale": "Prijenos porezne obveze - porezno oslobođena EU B2B prodaja",
|
|
92
97
|
} as const;
|
|
@@ -38,6 +38,9 @@ export default {
|
|
|
38
38
|
Note: "Nota",
|
|
39
39
|
"Insert variable": "Inserisci variabile",
|
|
40
40
|
"Add payment instructions, terms, or other notes...": "Aggiungi istruzioni di pagamento, termini o altre note...",
|
|
41
|
+
// Signature field
|
|
42
|
+
Signature: "Firma",
|
|
43
|
+
"Add signature text...": "Aggiungi testo della firma...",
|
|
41
44
|
// Payment terms field
|
|
42
45
|
"Payment Terms": "Termini di pagamento",
|
|
43
46
|
"Add payment terms...": "Aggiungi termini di pagamento...",
|
|
@@ -91,5 +94,7 @@ export default {
|
|
|
91
94
|
"Questa fattura non sarà fiscalizzata (transazione non nazionale)",
|
|
92
95
|
"Tax Clause": "Clausola fiscale",
|
|
93
96
|
"Add tax clause...": "Aggiungi clausola fiscale...",
|
|
97
|
+
Footer: "Piè di pagina",
|
|
98
|
+
"Add document footer...": "Aggiungi piè di pagina del documento...",
|
|
94
99
|
"Reverse charge - tax exempt EU B2B sale": "Inversione contabile - vendita B2B UE esente da imposta",
|
|
95
100
|
} as const;
|
|
@@ -39,6 +39,9 @@ export default {
|
|
|
39
39
|
"Insert variable": "Variabele invoegen",
|
|
40
40
|
"Add payment instructions, terms, or other notes...":
|
|
41
41
|
"Voeg betalingsinstructies, voorwaarden of andere opmerkingen toe...",
|
|
42
|
+
// Signature field
|
|
43
|
+
Signature: "Handtekening",
|
|
44
|
+
"Add signature text...": "Handtekeningtekst toevoegen...",
|
|
42
45
|
// Payment terms field
|
|
43
46
|
"Payment Terms": "Betalingsvoorwaarden",
|
|
44
47
|
"Add payment terms...": "Voeg betalingsvoorwaarden toe...",
|
|
@@ -90,5 +93,7 @@ export default {
|
|
|
90
93
|
"Deze factuur wordt niet gefiscaliseerd (niet-binnenlandse transactie)",
|
|
91
94
|
"Tax Clause": "Belastingclausule",
|
|
92
95
|
"Add tax clause...": "Belastingclausule toevoegen...",
|
|
96
|
+
Footer: "Voettekst",
|
|
97
|
+
"Add document footer...": "Documentvoettekst toevoegen...",
|
|
93
98
|
"Reverse charge - tax exempt EU B2B sale": "Verlegging - belastingvrijgestelde EU B2B verkoop",
|
|
94
99
|
} as const;
|
|
@@ -38,6 +38,9 @@ export default {
|
|
|
38
38
|
Note: "Notatka",
|
|
39
39
|
"Insert variable": "Wstaw zmienna",
|
|
40
40
|
"Add payment instructions, terms, or other notes...": "Dodaj instrukcje platnosci, warunki lub inne uwagi...",
|
|
41
|
+
// Signature field
|
|
42
|
+
Signature: "Podpis",
|
|
43
|
+
"Add signature text...": "Dodaj tekst podpisu...",
|
|
41
44
|
// Payment terms field
|
|
42
45
|
"Payment Terms": "Warunki platnosci",
|
|
43
46
|
"Add payment terms...": "Dodaj warunki platnosci...",
|
|
@@ -88,5 +91,7 @@ export default {
|
|
|
88
91
|
"Ta faktura nie będzie fiskalizowana (transakcja niekrajowa)",
|
|
89
92
|
"Tax Clause": "Klauzula podatkowa",
|
|
90
93
|
"Add tax clause...": "Dodaj klauzulę podatkową...",
|
|
94
|
+
Footer: "Stopka",
|
|
95
|
+
"Add document footer...": "Dodaj stopkę dokumentu...",
|
|
91
96
|
"Reverse charge - tax exempt EU B2B sale": "Odwrotne obciążenie - zwolniona z podatku sprzedaż EU B2B",
|
|
92
97
|
} as const;
|
|
@@ -38,6 +38,9 @@ export default {
|
|
|
38
38
|
Note: "Nota",
|
|
39
39
|
"Insert variable": "Inserir variavel",
|
|
40
40
|
"Add payment instructions, terms, or other notes...": "Adicione instrucoes de pagamento, termos ou outras notas...",
|
|
41
|
+
// Signature field
|
|
42
|
+
Signature: "Assinatura",
|
|
43
|
+
"Add signature text...": "Adicionar texto de assinatura...",
|
|
41
44
|
// Payment terms field
|
|
42
45
|
"Payment Terms": "Condicoes de pagamento",
|
|
43
46
|
"Add payment terms...": "Adicione condicoes de pagamento...",
|
|
@@ -88,5 +91,7 @@ export default {
|
|
|
88
91
|
"Esta fatura não será fiscalizada (transação não nacional)",
|
|
89
92
|
"Tax Clause": "Cláusula fiscal",
|
|
90
93
|
"Add tax clause...": "Adicionar cláusula fiscal...",
|
|
94
|
+
Footer: "Rodapé",
|
|
95
|
+
"Add document footer...": "Adicionar rodapé do documento...",
|
|
91
96
|
"Reverse charge - tax exempt EU B2B sale": "Autoliquidação - venda B2B UE isenta de imposto",
|
|
92
97
|
} as const;
|
|
@@ -37,6 +37,9 @@ export default {
|
|
|
37
37
|
Note: "Opomba",
|
|
38
38
|
"Insert variable": "Vstavi spremenljivko",
|
|
39
39
|
"Add payment instructions, terms, or other notes...": "Dodajte navodila za plačilo, pogoje ali druge opombe...",
|
|
40
|
+
// Signature field
|
|
41
|
+
Signature: "Podpis",
|
|
42
|
+
"Add signature text...": "Dodaj besedilo podpisa...",
|
|
40
43
|
// Payment terms field
|
|
41
44
|
"Payment Terms": "Plačilni pogoji",
|
|
42
45
|
"Add payment terms...": "Dodajte plačilne pogoje...",
|
|
@@ -87,5 +90,7 @@ export default {
|
|
|
87
90
|
"Ta račun ne bo fiskaliziran (nedomača transakcija)",
|
|
88
91
|
"Tax Clause": "Davčna klavzula",
|
|
89
92
|
"Add tax clause...": "Dodajte davčno klavzulo...",
|
|
93
|
+
Footer: "Noga dokumenta",
|
|
94
|
+
"Add document footer...": "Dodajte nogo dokumenta...",
|
|
90
95
|
"Reverse charge - tax exempt EU B2B sale": "Obrnjena davčna obveznost - davka oproščena EU B2B prodaja",
|
|
91
96
|
} as const;
|
|
@@ -58,8 +58,8 @@ export function setLastUsedFursCombo(entityId: string, combo: FursCombo): void {
|
|
|
58
58
|
const FINA_CN_LAST_USED_KEY = "hr:fina:cn:last-used";
|
|
59
59
|
|
|
60
60
|
export type FinaCombo = {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
business_premise_name: string;
|
|
62
|
+
electronic_device_name: string;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export function getLastUsedFinaCombo(entityId: string): FinaCombo | null {
|