@spaceinvoices/react-ui 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.
- package/cli/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/common/autocomplete.tsx +69 -6
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +124 -285
- package/src/components/advance-invoices/list/list-table.tsx +10 -3
- package/src/components/advance-invoices/list/locales/de.ts +2 -0
- package/src/components/advance-invoices/list/locales/en.ts +1 -0
- package/src/components/advance-invoices/list/locales/es.ts +1 -0
- package/src/components/advance-invoices/list/locales/fr.ts +1 -0
- package/src/components/advance-invoices/list/locales/hr.ts +1 -0
- package/src/components/advance-invoices/list/locales/it.ts +1 -0
- package/src/components/advance-invoices/list/locales/nl.ts +1 -0
- package/src/components/advance-invoices/list/locales/pl.ts +1 -0
- package/src/components/advance-invoices/list/locales/pt.ts +1 -0
- package/src/components/advance-invoices/list/locales/sl.ts +1 -0
- package/src/components/advance-invoices/list/use-advance-invoice-download.ts +1 -12
- package/src/components/credit-notes/create/create-credit-note-form.tsx +116 -238
- package/src/components/credit-notes/list/list-table.tsx +6 -3
- package/src/components/credit-notes/list/use-credit-note-download.ts +1 -12
- package/src/components/customers/customer-autocomplete.tsx +64 -11
- package/src/components/customers/customer-list-table/customer-list-table.tsx +3 -2
- package/src/components/dashboard/collection-rate-card/collection-rate-card.tsx +9 -1
- package/src/components/dashboard/collection-rate-card/locales/bg.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/cs.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/et.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/fi.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/is.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/nb.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/sk.ts +3 -0
- package/src/components/dashboard/collection-rate-card/locales/sv.ts +3 -0
- package/src/components/dashboard/invoice-status-chart/invoice-status-chart.tsx +10 -2
- package/src/components/dashboard/invoice-status-chart/locales/bg.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/cs.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/de.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/es.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/et.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/fi.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/is.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/it.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/nb.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/sk.ts +10 -0
- package/src/components/dashboard/invoice-status-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/invoice-status-chart/locales/sv.ts +10 -0
- package/src/components/dashboard/payment-methods-chart/locales/bg.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/cs.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/et.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/fi.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/is.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/nb.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/sk.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/locales/sv.ts +12 -0
- package/src/components/dashboard/payment-methods-chart/payment-methods-chart.tsx +9 -1
- package/src/components/dashboard/payment-trend-chart/locales/bg.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/cs.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/de.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/es.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/et.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/fi.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/is.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/it.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/nb.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/sk.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/payment-trend-chart/locales/sv.ts +6 -0
- package/src/components/dashboard/payment-trend-chart/payment-trend-chart.tsx +15 -8
- package/src/components/dashboard/revenue-trend-chart/locales/bg.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/cs.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/de.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/es.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/et.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fi.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/fr.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/hr.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/is.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/it.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nb.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/nl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/pt.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sk.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sl.ts +1 -0
- package/src/components/dashboard/revenue-trend-chart/locales/sv.ts +6 -0
- package/src/components/dashboard/revenue-trend-chart/revenue-trend-chart.tsx +15 -8
- package/src/components/dashboard/tax-collected-card/locales.ts +110 -0
- package/src/components/dashboard/tax-collected-card/tax-collected-card.tsx +8 -2
- package/src/components/dashboard/tax-collected-card/use-tax-collected.ts +4 -4
- package/src/components/dashboard/top-customers-chart/locales/bg.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/cs.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/de.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/es.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/et.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/fi.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/fr.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/hr.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/is.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/it.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/nb.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/nl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/pl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/pt.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/sk.ts +7 -0
- package/src/components/dashboard/top-customers-chart/locales/sl.ts +2 -0
- package/src/components/dashboard/top-customers-chart/locales/sv.ts +7 -0
- package/src/components/dashboard/top-customers-chart/top-customers-chart.tsx +23 -12
- package/src/components/delivery-notes/create/create-delivery-note-form.tsx +33 -20
- package/src/components/delivery-notes/list/list-table.tsx +22 -13
- package/src/components/delivery-notes/list/locales/de.ts +2 -0
- package/src/components/delivery-notes/list/locales/en.ts +1 -0
- package/src/components/delivery-notes/list/locales/es.ts +1 -0
- package/src/components/delivery-notes/list/locales/fr.ts +1 -0
- package/src/components/delivery-notes/list/locales/hr.ts +1 -0
- package/src/components/delivery-notes/list/locales/it.ts +1 -0
- package/src/components/delivery-notes/list/locales/nl.ts +1 -0
- package/src/components/delivery-notes/list/locales/pl.ts +1 -0
- package/src/components/delivery-notes/list/locales/pt.ts +1 -0
- package/src/components/delivery-notes/list/locales/sl.ts +1 -0
- package/src/components/delivery-notes/list/use-delivery-note-download.ts +1 -12
- package/src/components/documents/create/document-add-item-form.tsx +28 -16
- package/src/components/documents/create/document-add-item-tax-rate-field.tsx +12 -2
- package/src/components/documents/create/document-items-section.tsx +70 -39
- package/src/components/documents/create/document-recipient-section.tsx +10 -1
- package/src/components/documents/create/live-preview.tsx +113 -15
- package/src/components/documents/create/prepare-document-submission.ts +35 -16
- package/src/components/documents/create/use-document-customer-form.ts +14 -3
- package/src/components/documents/documents.hooks.ts +7 -2
- package/src/components/documents/shared/document-preview-display.tsx +136 -67
- package/src/components/documents/shared/scaled-document-preview.tsx +45 -5
- package/src/components/documents/view/document-actions-bar.tsx +284 -182
- package/src/components/documents/view/document-activities-list.tsx +3 -0
- package/src/components/documents/view/document-payments-list.tsx +3 -0
- package/src/components/documents/view/locales/de.ts +8 -0
- package/src/components/documents/view/locales/es.ts +8 -0
- package/src/components/documents/view/locales/fr.ts +8 -0
- package/src/components/documents/view/locales/hr.ts +8 -0
- package/src/components/documents/view/locales/it.ts +8 -0
- package/src/components/documents/view/locales/nl.ts +8 -0
- package/src/components/documents/view/locales/pl.ts +8 -0
- package/src/components/documents/view/locales/pt.ts +8 -0
- package/src/components/documents/view/locales/sl.ts +8 -0
- package/src/components/documents/view/use-document-download.ts +14 -25
- package/src/components/entities/create-entity-form.tsx +101 -16
- package/src/components/entities/fina-settings-form/fina-operator-required-dialog.tsx +3 -3
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +78 -124
- package/src/components/entities/fina-settings-form/sections/certificate-settings-section.tsx +8 -1
- package/src/components/entities/fina-settings-form/sections/premises-management-section.tsx +14 -2
- package/src/components/entities/fina-settings-form/sections/register-premise-dialog.tsx +7 -2
- package/src/components/entities/furs-settings-form/furs-settings-form.tsx +56 -130
- package/src/components/entities/furs-settings-form/sections/certificate-settings-section.tsx +8 -1
- package/src/components/entities/furs-settings-form/sections/enable-fiscalization-section.tsx +1 -0
- package/src/components/entities/furs-settings-form/sections/general-settings-section.tsx +15 -2
- package/src/components/entities/furs-settings-form/sections/premises-management-section.tsx +20 -3
- package/src/components/entities/furs-settings-form/sections/register-premise-dialog.tsx +38 -12
- package/src/components/entities/settings/eslog-settings-form.tsx +13 -1
- package/src/components/entities/settings/pdf-template-selector/demo-invoice-data.ts +3 -22
- package/src/components/entities/shared/fiscalization-step-flow.ts +77 -0
- package/src/components/entities/shared/fiscalization-step-tabs.tsx +71 -0
- package/src/components/estimates/create/create-estimate-form.tsx +34 -21
- package/src/components/estimates/list/list-table.tsx +23 -14
- package/src/components/estimates/list/locales/de.ts +2 -0
- package/src/components/estimates/list/locales/en.ts +1 -0
- package/src/components/estimates/list/locales/es.ts +1 -0
- package/src/components/estimates/list/locales/fr.ts +1 -0
- package/src/components/estimates/list/locales/hr.ts +1 -0
- package/src/components/estimates/list/locales/it.ts +1 -0
- package/src/components/estimates/list/locales/nl.ts +1 -0
- package/src/components/estimates/list/locales/pl.ts +1 -0
- package/src/components/estimates/list/locales/pt.ts +1 -0
- package/src/components/estimates/list/locales/sl.ts +1 -0
- package/src/components/estimates/list/use-estimate-download.ts +1 -12
- package/src/components/export/document-export-form.tsx +33 -7
- package/src/components/export/sales-per-item-export-form.tsx +23 -7
- package/src/components/invoices/create/create-invoice-form.tsx +295 -329
- package/src/components/invoices/create/prepare-invoice-submission.ts +0 -8
- package/src/components/invoices/list/list-table.tsx +7 -4
- package/src/components/invoices/list/use-invoice-download.ts +1 -11
- package/src/components/invoices/send-email-dialog/locales/de.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/es.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/fr.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/hr.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/it.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/nl.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/pl.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/pt.ts +2 -0
- package/src/components/invoices/send-email-dialog/locales/sl.ts +2 -0
- package/src/components/invoices/send-email-dialog/send-email-dialog.tsx +77 -8
- package/src/components/invoices/view/eslog-info-display.tsx +17 -1
- package/src/components/invoices/view/fiscalization-status-card.tsx +7 -3
- package/src/components/items/item-combobox.tsx +26 -6
- package/src/components/items/item-list-table/item-list-table.tsx +5 -2
- package/src/components/payments/list/list-table.tsx +14 -4
- package/src/components/recurring-invoices/list/list-table.tsx +7 -4
- package/src/components/request-logs/locales.ts +412 -0
- package/src/components/request-logs/request-log-detail.tsx +37 -21
- package/src/components/request-logs/request-log-list-table.tsx +57 -11
- package/src/components/table/data-table.tsx +5 -2
- package/src/components/table/date-cell.tsx +3 -1
- package/src/components/table/filter-bar.tsx +14 -2
- package/src/components/table/hooks/use-table-query.ts +1 -1
- package/src/components/table/locales.ts +1116 -0
- package/src/components/table/search-input.tsx +12 -3
- package/src/components/table/selection-toolbar.tsx +23 -6
- package/src/components/table/table-empty-state.tsx +43 -3
- package/src/components/table/table-no-results.tsx +3 -3
- package/src/components/table/table-pagination.tsx +4 -3
- package/src/components/table/types.ts +1 -0
- package/src/components/tax-reports/index.ts +1 -0
- package/src/components/tax-reports/kir-export-form.tsx +46 -8
- package/src/components/tax-reports/slovenia-tax-profile-step.tsx +191 -0
- package/src/components/tax-reports/slovenia-yearly-export-form.tsx +509 -0
- package/src/components/tax-reports/slovenia-yearly-review-step.tsx +253 -0
- package/src/components/tax-reports/slovenia-yearly-summary.tsx +19 -0
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +3 -2
- package/src/components/ui/sticky-form-footer.tsx +7 -1
- package/src/components/webhook-logs/index.ts +6 -0
- package/src/components/webhook-logs/locales.ts +392 -0
- package/src/components/webhook-logs/webhook-delivery-detail.tsx +255 -0
- package/src/components/webhook-logs/webhook-delivery-list-table.tsx +278 -0
- package/src/components/wl-subscription/index.ts +1 -0
- package/src/components/wl-subscription/locked-feature.tsx +1 -0
- package/src/components/wl-subscription/paywall.tsx +193 -0
- package/src/components/wl-subscription/upgrade-modal.tsx +93 -29
- package/src/generate-schemas.ts +10 -5
- package/src/generated/schemas/customer.ts +2 -0
- package/src/generated/schemas/entity.ts +34 -0
- package/src/generated/schemas/me.ts +20 -1
- package/src/generated/schemas/renderadvanceinvoicepreview_body.ts +40 -34
- package/src/generated/schemas/rendercreditnotepreview_body.ts +42 -36
- package/src/generated/schemas/renderdeliverynotepreview_body.ts +23 -13
- package/src/generated/schemas/renderestimatepreview_body.ts +23 -13
- package/src/generated/schemas/renderinvoicepreview_body.ts +40 -34
- package/src/generated/schemas/sendemail_body.ts +44 -0
- package/src/generated/schemas/startpdfexport_body.ts +91 -1
- package/src/generated/schemas/webhook.ts +10 -0
- package/src/hooks/use-duplicate-document.ts +51 -13
- package/src/hooks/use-eslog-validation.ts +59 -0
- package/src/hooks/use-premise-selection.ts +186 -0
- package/src/lib/browser-cookies.ts +4 -4
- package/src/lib/date-fns-locale.ts +48 -0
- package/src/lib/fiscalization-options.ts +81 -0
- package/src/lib/locale.ts +38 -0
- package/src/lib/template-variables.tsx +1 -1
- package/src/lib/translation.ts +14 -3
- package/src/providers/entities-context.tsx +1 -0
- package/src/providers/entities-provider.tsx +102 -3
- package/src/providers/form-footer-context.tsx +37 -4
- package/src/providers/sdk-provider.tsx +7 -2
- package/src/providers/white-label-provider.tsx +4 -1
- package/src/providers/wl-subscription-provider.tsx +90 -3
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Check, Crown, Sparkles, Zap } from "lucide-react";
|
|
1
|
+
import { Check, Crown, Loader2, Sparkles, Zap } from "lucide-react";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
|
|
3
4
|
import { type GatedFeature, useWLSubscription, type WhiteLabelPlan } from "../../providers/wl-subscription-provider";
|
|
5
|
+
import { Badge } from "../ui/badge";
|
|
4
6
|
import { Button } from "../ui/button";
|
|
5
7
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../ui/dialog";
|
|
8
|
+
import { Switch } from "../ui/switch";
|
|
6
9
|
|
|
7
10
|
type UpgradeModalProps = {
|
|
8
11
|
isOpen: boolean;
|
|
@@ -18,9 +21,13 @@ type UpgradeModalProps = {
|
|
|
18
21
|
*
|
|
19
22
|
* Shows available plans and allows users to upgrade their subscription.
|
|
20
23
|
* Highlights the feature that triggered the modal and which plans include it.
|
|
24
|
+
* Includes monthly/yearly toggle with 20% yearly discount.
|
|
21
25
|
*/
|
|
22
26
|
export function UpgradeModal({ isOpen, onClose, feature, onUpgrade }: UpgradeModalProps) {
|
|
23
|
-
const { plan: currentPlan, availablePlans } = useWLSubscription();
|
|
27
|
+
const { plan: currentPlan, availablePlans, createCheckout } = useWLSubscription();
|
|
28
|
+
const [isRedirecting, setIsRedirecting] = useState<string | null>(null);
|
|
29
|
+
const [checkoutError, setCheckoutError] = useState<string | null>(null);
|
|
30
|
+
const [isYearly, setIsYearly] = useState(false);
|
|
24
31
|
|
|
25
32
|
// Sort plans by display order
|
|
26
33
|
const sortedPlans = [...availablePlans].sort((a, b) => a.display_order - b.display_order);
|
|
@@ -30,13 +37,21 @@ export function UpgradeModal({ isOpen, onClose, feature, onUpgrade }: UpgradeMod
|
|
|
30
37
|
? sortedPlans.find((p) => p.features.length === 0 || p.features.includes(feature))
|
|
31
38
|
: null;
|
|
32
39
|
|
|
33
|
-
const handleUpgrade = (planSlug: string) => {
|
|
40
|
+
const handleUpgrade = async (planSlug: string) => {
|
|
34
41
|
if (onUpgrade) {
|
|
35
42
|
onUpgrade(planSlug);
|
|
36
43
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
setIsRedirecting(planSlug);
|
|
47
|
+
setCheckoutError(null);
|
|
48
|
+
const billingInterval = isYearly ? "yearly" : "monthly";
|
|
49
|
+
const checkoutUrl = await createCheckout(planSlug, billingInterval);
|
|
50
|
+
window.location.href = checkoutUrl;
|
|
51
|
+
} catch (err) {
|
|
52
|
+
setCheckoutError(err instanceof Error ? err.message : "Failed to start checkout");
|
|
53
|
+
setIsRedirecting(null);
|
|
54
|
+
}
|
|
40
55
|
};
|
|
41
56
|
|
|
42
57
|
return (
|
|
@@ -54,17 +69,38 @@ export function UpgradeModal({ isOpen, onClose, feature, onUpgrade }: UpgradeMod
|
|
|
54
69
|
</DialogDescription>
|
|
55
70
|
</DialogHeader>
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
{/* Monthly/Yearly toggle */}
|
|
73
|
+
<div className="flex items-center justify-center gap-3">
|
|
74
|
+
<span className={`text-sm ${!isYearly ? "font-medium" : "text-muted-foreground"}`}>Monthly</span>
|
|
75
|
+
<Switch checked={isYearly} onCheckedChange={setIsYearly} />
|
|
76
|
+
<span className={`text-sm ${isYearly ? "font-medium" : "text-muted-foreground"}`}>Yearly</span>
|
|
77
|
+
{isYearly && (
|
|
78
|
+
<Badge variant="secondary" className="ml-1">
|
|
79
|
+
Save 20%
|
|
80
|
+
</Badge>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
{checkoutError && (
|
|
85
|
+
<p className="rounded-md bg-destructive/10 px-3 py-2 text-destructive text-sm">{checkoutError}</p>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<div className="grid gap-4 py-4 md:grid-cols-2">
|
|
89
|
+
{sortedPlans
|
|
90
|
+
.filter((p) => !p.is_free)
|
|
91
|
+
.map((plan) => (
|
|
92
|
+
<PlanCard
|
|
93
|
+
key={plan.id}
|
|
94
|
+
plan={plan}
|
|
95
|
+
isYearly={isYearly}
|
|
96
|
+
isCurrentPlan={plan.slug === currentPlan?.slug}
|
|
97
|
+
isRecommended={minimumPlanForFeature?.slug === plan.slug}
|
|
98
|
+
highlightFeature={feature}
|
|
99
|
+
isLoading={isRedirecting === plan.slug}
|
|
100
|
+
isDisabled={isRedirecting !== null}
|
|
101
|
+
onSelect={() => handleUpgrade(plan.slug)}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
68
104
|
</div>
|
|
69
105
|
|
|
70
106
|
{sortedPlans.length === 0 && (
|
|
@@ -83,19 +119,30 @@ export function UpgradeModal({ isOpen, onClose, feature, onUpgrade }: UpgradeMod
|
|
|
83
119
|
|
|
84
120
|
type PlanCardProps = {
|
|
85
121
|
plan: WhiteLabelPlan;
|
|
122
|
+
isYearly: boolean;
|
|
86
123
|
isCurrentPlan: boolean;
|
|
87
124
|
isRecommended: boolean;
|
|
88
125
|
highlightFeature?: GatedFeature;
|
|
126
|
+
isLoading?: boolean;
|
|
127
|
+
isDisabled?: boolean;
|
|
89
128
|
onSelect: () => void;
|
|
90
129
|
};
|
|
91
130
|
|
|
92
|
-
function PlanCard({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
131
|
+
function PlanCard({
|
|
132
|
+
plan,
|
|
133
|
+
isYearly,
|
|
134
|
+
isCurrentPlan,
|
|
135
|
+
isRecommended,
|
|
136
|
+
highlightFeature,
|
|
137
|
+
isLoading,
|
|
138
|
+
isDisabled,
|
|
139
|
+
onSelect,
|
|
140
|
+
}: PlanCardProps) {
|
|
141
|
+
const monthlyPrice = plan.base_price_cents ? plan.base_price_cents / 100 : 0;
|
|
142
|
+
const yearlyTotal = Math.round(monthlyPrice * 12 * 0.8 * 100) / 100;
|
|
143
|
+
const yearlyMonthly = Math.round((yearlyTotal / 12) * 100) / 100;
|
|
98
144
|
|
|
145
|
+
const displayPrice = isYearly ? yearlyMonthly : monthlyPrice;
|
|
99
146
|
const documentsLimit = plan.limits?.documents_per_month ?? "Unlimited";
|
|
100
147
|
|
|
101
148
|
return (
|
|
@@ -115,11 +162,13 @@ function PlanCard({ plan, isCurrentPlan, isRecommended, highlightFeature, onSele
|
|
|
115
162
|
<h3 className="font-semibold">{plan.name}</h3>
|
|
116
163
|
</div>
|
|
117
164
|
|
|
118
|
-
<div className="mb-1
|
|
119
|
-
|
|
120
|
-
|
|
165
|
+
<div className="mb-1">
|
|
166
|
+
<span className="font-bold text-2xl">€{displayPrice.toFixed(0)}</span>
|
|
167
|
+
<span className="text-muted-foreground">/mo</span>
|
|
121
168
|
</div>
|
|
122
169
|
|
|
170
|
+
{isYearly && <p className="mb-1 text-muted-foreground text-xs">€{yearlyTotal.toFixed(0)} billed yearly</p>}
|
|
171
|
+
|
|
123
172
|
<p className="mb-4 text-muted-foreground text-sm">{documentsLimit} documents/month</p>
|
|
124
173
|
|
|
125
174
|
<ul className="mb-4 flex-1 space-y-2">
|
|
@@ -141,10 +190,11 @@ function PlanCard({ plan, isCurrentPlan, isRecommended, highlightFeature, onSele
|
|
|
141
190
|
<Button
|
|
142
191
|
variant={isCurrentPlan ? "outline" : isRecommended ? "default" : "secondary"}
|
|
143
192
|
className="w-full"
|
|
144
|
-
disabled={isCurrentPlan}
|
|
193
|
+
disabled={isCurrentPlan || isDisabled}
|
|
145
194
|
onClick={onSelect}
|
|
146
195
|
>
|
|
147
|
-
{
|
|
196
|
+
{isLoading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
|
|
197
|
+
{isCurrentPlan ? "Current Plan" : isLoading ? "Redirecting..." : `Upgrade to ${plan.name}`}
|
|
148
198
|
</Button>
|
|
149
199
|
</div>
|
|
150
200
|
);
|
|
@@ -158,6 +208,8 @@ function PlanIcon({ slug }: { slug: string }) {
|
|
|
158
208
|
switch (slug) {
|
|
159
209
|
case "free":
|
|
160
210
|
return <Zap className="h-5 w-5 text-muted-foreground" />;
|
|
211
|
+
case "basic":
|
|
212
|
+
return <Zap className="h-5 w-5 text-blue-500" />;
|
|
161
213
|
case "starter":
|
|
162
214
|
return <Sparkles className="h-5 w-5 text-blue-500" />;
|
|
163
215
|
case "advanced":
|
|
@@ -178,6 +230,7 @@ function getFeatureDisplayName(feature: GatedFeature): string {
|
|
|
178
230
|
api_access: "API Access",
|
|
179
231
|
webhooks: "Webhooks",
|
|
180
232
|
priority_support: "Priority Support",
|
|
233
|
+
e_invoicing: "E-Invoicing",
|
|
181
234
|
};
|
|
182
235
|
return names[feature] || feature;
|
|
183
236
|
}
|
|
@@ -186,6 +239,16 @@ function getPlanFeatures(slug: string): string[] {
|
|
|
186
239
|
switch (slug) {
|
|
187
240
|
case "free":
|
|
188
241
|
return ["Basic invoicing", "Estimates & quotes", "Customer management", "PDF export"];
|
|
242
|
+
case "basic":
|
|
243
|
+
return [
|
|
244
|
+
"Invoices & estimates",
|
|
245
|
+
"Customer management",
|
|
246
|
+
"PDF export",
|
|
247
|
+
"FURS fiscalization",
|
|
248
|
+
"eSlog export",
|
|
249
|
+
"Recurring invoices",
|
|
250
|
+
"Email sending",
|
|
251
|
+
];
|
|
189
252
|
case "starter":
|
|
190
253
|
return [
|
|
191
254
|
"Everything in Free",
|
|
@@ -197,7 +260,8 @@ function getPlanFeatures(slug: string): string[] {
|
|
|
197
260
|
];
|
|
198
261
|
case "advanced":
|
|
199
262
|
return [
|
|
200
|
-
"Everything in
|
|
263
|
+
"Everything in Basic",
|
|
264
|
+
"All features unlocked",
|
|
201
265
|
"Custom templates",
|
|
202
266
|
"API access",
|
|
203
267
|
"Webhooks",
|
package/src/generate-schemas.ts
CHANGED
|
@@ -27,14 +27,19 @@ async function main() {
|
|
|
27
27
|
await fs.mkdir(GENERATED_DIR, { recursive: true });
|
|
28
28
|
|
|
29
29
|
// Fetch OpenAPI spec from running API and generate schemas
|
|
30
|
-
const API_URL = "http://localhost:3000/openapi.json";
|
|
30
|
+
const API_URL = process.env.OPENAPI_TARGET || "http://localhost:3000/openapi.json";
|
|
31
31
|
const openApiPath = path.resolve(GENERATED_DIR, "openapi.json");
|
|
32
32
|
|
|
33
33
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (/^https?:\/\//.test(API_URL)) {
|
|
35
|
+
const res = await fetch(API_URL);
|
|
36
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
37
|
+
await fs.writeFile(openApiPath, await res.text());
|
|
38
|
+
console.log(`Fetched OpenAPI spec from ${API_URL}`);
|
|
39
|
+
} else {
|
|
40
|
+
await fs.copyFile(API_URL, openApiPath);
|
|
41
|
+
console.log(`Copied OpenAPI spec from ${API_URL}`);
|
|
42
|
+
}
|
|
38
43
|
} catch (_error) {
|
|
39
44
|
console.error(`Failed to fetch OpenAPI spec from ${API_URL}. Is the API running?`);
|
|
40
45
|
process.exit(1);
|
|
@@ -20,6 +20,7 @@ const createCustomerSchemaDefinition = z.object({
|
|
|
20
20
|
country_code: z.union([z.string(), z.null()]).optional(),
|
|
21
21
|
tax_number: z.union([z.string(), z.null()]).optional(),
|
|
22
22
|
company_number: z.union([z.string(), z.null()]).optional(),
|
|
23
|
+
peppol_id: z.union([z.string(), z.null()]).optional(),
|
|
23
24
|
email: z.union([z.string(), z.null()]).optional(),
|
|
24
25
|
is_tax_subject: z.boolean().optional(),
|
|
25
26
|
is_end_consumer: z.union([z.boolean(), z.null()]).optional(),
|
|
@@ -43,6 +44,7 @@ const updateCustomerSchemaDefinition = z
|
|
|
43
44
|
country_code: z.union([z.string(), z.null()]),
|
|
44
45
|
tax_number: z.union([z.string(), z.null()]),
|
|
45
46
|
company_number: z.union([z.string(), z.null()]),
|
|
47
|
+
peppol_id: z.union([z.string(), z.null()]),
|
|
46
48
|
email: z.union([z.string(), z.null()]),
|
|
47
49
|
is_tax_subject: z.boolean(),
|
|
48
50
|
is_end_consumer: z.union([z.boolean(), z.null()]),
|
|
@@ -24,6 +24,7 @@ const createEntitySchemaDefinition = z.object({
|
|
|
24
24
|
tax_number_2: z.union([z.string(), z.null()]).optional(),
|
|
25
25
|
company_number: z.union([z.string(), z.null()]).optional(),
|
|
26
26
|
email: z.union([z.string(), z.null()]).optional(),
|
|
27
|
+
website: z.union([z.string(), z.null()]).optional(),
|
|
27
28
|
environment: z.enum(["live", "sandbox"]).optional(),
|
|
28
29
|
is_tax_subject: z.boolean().optional(),
|
|
29
30
|
is_enabled: z.boolean().optional(),
|
|
@@ -141,6 +142,10 @@ const createEntitySchemaDefinition = z.object({
|
|
|
141
142
|
bank_accounts: z.union([z.array(z.any()), z.null()]),
|
|
142
143
|
eslog_validation_enabled: z.union([z.boolean(), z.null()]),
|
|
143
144
|
delivery_note_hide_prices: z.union([z.boolean(), z.null()]),
|
|
145
|
+
credit_note_negative_values: z.union([z.boolean(), z.null()]),
|
|
146
|
+
receipt_note: z.union([z.string(), z.null()]),
|
|
147
|
+
receipt_footer: z.union([z.string(), z.null()]),
|
|
148
|
+
receipt_signature: z.union([z.string(), z.null()]),
|
|
144
149
|
tax_clause_defaults: z.union([
|
|
145
150
|
z
|
|
146
151
|
.object({
|
|
@@ -155,6 +160,18 @@ const createEntitySchemaDefinition = z.object({
|
|
|
155
160
|
.passthrough(),
|
|
156
161
|
z.null(),
|
|
157
162
|
]),
|
|
163
|
+
e_invoicing: z.union([
|
|
164
|
+
z
|
|
165
|
+
.object({
|
|
166
|
+
enabled: z.boolean().default(false),
|
|
167
|
+
provider: z.literal("flowin").default("flowin"),
|
|
168
|
+
auto_send: z.boolean().default(false),
|
|
169
|
+
default_scheme_id: z.string(),
|
|
170
|
+
})
|
|
171
|
+
.partial()
|
|
172
|
+
.passthrough(),
|
|
173
|
+
z.null(),
|
|
174
|
+
]),
|
|
158
175
|
})
|
|
159
176
|
.partial()
|
|
160
177
|
.passthrough()
|
|
@@ -181,6 +198,7 @@ const patchEntitySchemaDefinition = z
|
|
|
181
198
|
tax_number_2: z.union([z.string(), z.null()]),
|
|
182
199
|
company_number: z.union([z.string(), z.null()]),
|
|
183
200
|
email: z.union([z.string(), z.null()]),
|
|
201
|
+
website: z.union([z.string(), z.null()]),
|
|
184
202
|
is_tax_subject: z.boolean(),
|
|
185
203
|
is_enabled: z.boolean(),
|
|
186
204
|
settings: z
|
|
@@ -297,6 +315,10 @@ const patchEntitySchemaDefinition = z
|
|
|
297
315
|
bank_accounts: z.union([z.array(z.any()), z.null()]),
|
|
298
316
|
eslog_validation_enabled: z.union([z.boolean(), z.null()]),
|
|
299
317
|
delivery_note_hide_prices: z.union([z.boolean(), z.null()]),
|
|
318
|
+
credit_note_negative_values: z.union([z.boolean(), z.null()]),
|
|
319
|
+
receipt_note: z.union([z.string(), z.null()]),
|
|
320
|
+
receipt_footer: z.union([z.string(), z.null()]),
|
|
321
|
+
receipt_signature: z.union([z.string(), z.null()]),
|
|
300
322
|
tax_clause_defaults: z.union([
|
|
301
323
|
z
|
|
302
324
|
.object({
|
|
@@ -311,6 +333,18 @@ const patchEntitySchemaDefinition = z
|
|
|
311
333
|
.passthrough(),
|
|
312
334
|
z.null(),
|
|
313
335
|
]),
|
|
336
|
+
e_invoicing: z.union([
|
|
337
|
+
z
|
|
338
|
+
.object({
|
|
339
|
+
enabled: z.boolean().default(false),
|
|
340
|
+
provider: z.literal("flowin").default("flowin"),
|
|
341
|
+
auto_send: z.boolean().default(false),
|
|
342
|
+
default_scheme_id: z.string(),
|
|
343
|
+
})
|
|
344
|
+
.partial()
|
|
345
|
+
.passthrough(),
|
|
346
|
+
z.null(),
|
|
347
|
+
]),
|
|
314
348
|
})
|
|
315
349
|
.partial()
|
|
316
350
|
.passthrough(),
|
|
@@ -12,7 +12,26 @@ import { z } from 'zod';
|
|
|
12
12
|
const patchMeSchemaDefinition = z
|
|
13
13
|
.object({
|
|
14
14
|
name: z.union([z.string(), z.null()]),
|
|
15
|
-
locale: z.enum([
|
|
15
|
+
locale: z.enum([
|
|
16
|
+
"en",
|
|
17
|
+
"de",
|
|
18
|
+
"sl",
|
|
19
|
+
"it",
|
|
20
|
+
"fr",
|
|
21
|
+
"es",
|
|
22
|
+
"pt",
|
|
23
|
+
"nl",
|
|
24
|
+
"pl",
|
|
25
|
+
"hr",
|
|
26
|
+
"sv",
|
|
27
|
+
"fi",
|
|
28
|
+
"et",
|
|
29
|
+
"bg",
|
|
30
|
+
"cs",
|
|
31
|
+
"sk",
|
|
32
|
+
"nb",
|
|
33
|
+
"is",
|
|
34
|
+
]),
|
|
16
35
|
})
|
|
17
36
|
.partial();
|
|
18
37
|
|
|
@@ -23,6 +23,7 @@ const DocumentEntity = z
|
|
|
23
23
|
tax_number: z.union([z.string(), z.null()]),
|
|
24
24
|
tax_number_2: z.union([z.string(), z.null()]),
|
|
25
25
|
company_number: z.union([z.string(), z.null()]),
|
|
26
|
+
peppol_id: z.union([z.string(), z.null()]),
|
|
26
27
|
is_end_consumer: z.union([z.boolean(), z.null()]),
|
|
27
28
|
bank_account: z.union([
|
|
28
29
|
z
|
|
@@ -30,13 +31,13 @@ const DocumentEntity = z
|
|
|
30
31
|
type: z
|
|
31
32
|
.enum(["iban", "us_domestic", "uk_domestic", "other"])
|
|
32
33
|
.default("iban"),
|
|
33
|
-
name: z.string(),
|
|
34
|
-
bank_name: z.string(),
|
|
35
|
-
iban: z.string(),
|
|
36
|
-
account_number: z.string(),
|
|
37
|
-
bic: z.string(),
|
|
38
|
-
routing_number: z.string(),
|
|
39
|
-
sort_code: z.string(),
|
|
34
|
+
name: z.union([z.string(), z.null()]),
|
|
35
|
+
bank_name: z.union([z.string(), z.null()]),
|
|
36
|
+
iban: z.union([z.string(), z.null()]),
|
|
37
|
+
account_number: z.union([z.string(), z.null()]),
|
|
38
|
+
bic: z.union([z.string(), z.null()]),
|
|
39
|
+
routing_number: z.union([z.string(), z.null()]),
|
|
40
|
+
sort_code: z.union([z.string(), z.null()]),
|
|
40
41
|
})
|
|
41
42
|
.partial()
|
|
42
43
|
.passthrough(),
|
|
@@ -51,7 +52,7 @@ const DocumentEntity = z
|
|
|
51
52
|
const CreateDocumentCustomer = DocumentEntity.and(
|
|
52
53
|
z.union([
|
|
53
54
|
z
|
|
54
|
-
.object({ save_customer: z.boolean().
|
|
55
|
+
.object({ save_customer: z.union([z.boolean(), z.null()]) })
|
|
55
56
|
.partial()
|
|
56
57
|
.passthrough(),
|
|
57
58
|
z.null(),
|
|
@@ -63,28 +64,24 @@ const CreateDocumentCustomer = DocumentEntity.and(
|
|
|
63
64
|
const CreateFinaInvoiceData = z.union([
|
|
64
65
|
z
|
|
65
66
|
.object({
|
|
66
|
-
business_premise_name: z
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"paypal",
|
|
83
|
-
"crypto",
|
|
84
|
-
"coupon",
|
|
85
|
-
"other",
|
|
67
|
+
business_premise_name: z.union([z.string(), z.null()]),
|
|
68
|
+
electronic_device_name: z.union([z.string(), z.null()]),
|
|
69
|
+
operator_oib: z.union([z.string(), z.null()]),
|
|
70
|
+
operator_label: z.union([z.string(), z.null()]),
|
|
71
|
+
payment_type: z.union([
|
|
72
|
+
z.enum([
|
|
73
|
+
"cash",
|
|
74
|
+
"card",
|
|
75
|
+
"online",
|
|
76
|
+
"bank_transfer",
|
|
77
|
+
"paypal",
|
|
78
|
+
"crypto",
|
|
79
|
+
"coupon",
|
|
80
|
+
"other",
|
|
81
|
+
]),
|
|
82
|
+
z.null(),
|
|
86
83
|
]),
|
|
87
|
-
subsequent_submit: z.boolean(),
|
|
84
|
+
subsequent_submit: z.union([z.boolean(), z.null()]),
|
|
88
85
|
})
|
|
89
86
|
.partial(),
|
|
90
87
|
z.null(),
|
|
@@ -121,6 +118,15 @@ const PartialAdvanceInvoicePreview = z.object({
|
|
|
121
118
|
price: z.number(),
|
|
122
119
|
gross_price: z.number(),
|
|
123
120
|
description: z.string(),
|
|
121
|
+
unit: z.string(),
|
|
122
|
+
discounts: z.array(
|
|
123
|
+
z
|
|
124
|
+
.object({
|
|
125
|
+
value: z.number(),
|
|
126
|
+
type: z.enum(["percent", "amount"]).optional(),
|
|
127
|
+
})
|
|
128
|
+
.passthrough()
|
|
129
|
+
),
|
|
124
130
|
taxes: z.array(
|
|
125
131
|
z
|
|
126
132
|
.object({ rate: z.number(), tax_id: z.string() })
|
|
@@ -141,7 +147,7 @@ const PartialAdvanceInvoicePreview = z.object({
|
|
|
141
147
|
// Dependency schema for renderadvanceinvoicepreview_body
|
|
142
148
|
const DocumentItemTax = z
|
|
143
149
|
.object({
|
|
144
|
-
rate: z.number(),
|
|
150
|
+
rate: z.union([z.number(), z.null()]),
|
|
145
151
|
tax_id: z.union([z.string(), z.null()]),
|
|
146
152
|
classification: z.union([z.string(), z.null()]),
|
|
147
153
|
reverse_charge: z.union([z.boolean(), z.null()]),
|
|
@@ -161,17 +167,17 @@ const LineDiscount = z.object({
|
|
|
161
167
|
const CreateDocumentItem = z
|
|
162
168
|
.object({
|
|
163
169
|
type: z.union([z.literal("separator"), z.null()]),
|
|
164
|
-
name: z.string().
|
|
170
|
+
name: z.union([z.string(), z.null()]),
|
|
165
171
|
description: z.union([z.string(), z.null()]),
|
|
166
|
-
price: z.number(),
|
|
172
|
+
price: z.union([z.number(), z.null()]),
|
|
167
173
|
gross_price: z.union([z.number(), z.null()]),
|
|
168
|
-
quantity: z.
|
|
174
|
+
quantity: z.union([z.number(), z.null()]),
|
|
169
175
|
unit: z.union([z.string(), z.null()]),
|
|
170
176
|
taxes: z.array(DocumentItemTax),
|
|
171
177
|
discounts: z.array(LineDiscount).max(5),
|
|
172
178
|
item_id: z.union([z.string(), z.null()]),
|
|
173
179
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]),
|
|
174
|
-
save_item: z.boolean().
|
|
180
|
+
save_item: z.union([z.boolean(), z.null()]),
|
|
175
181
|
})
|
|
176
182
|
.partial();
|
|
177
183
|
|
|
@@ -23,6 +23,7 @@ const DocumentEntity = z
|
|
|
23
23
|
tax_number: z.union([z.string(), z.null()]),
|
|
24
24
|
tax_number_2: z.union([z.string(), z.null()]),
|
|
25
25
|
company_number: z.union([z.string(), z.null()]),
|
|
26
|
+
peppol_id: z.union([z.string(), z.null()]),
|
|
26
27
|
is_end_consumer: z.union([z.boolean(), z.null()]),
|
|
27
28
|
bank_account: z.union([
|
|
28
29
|
z
|
|
@@ -30,13 +31,13 @@ const DocumentEntity = z
|
|
|
30
31
|
type: z
|
|
31
32
|
.enum(["iban", "us_domestic", "uk_domestic", "other"])
|
|
32
33
|
.default("iban"),
|
|
33
|
-
name: z.string(),
|
|
34
|
-
bank_name: z.string(),
|
|
35
|
-
iban: z.string(),
|
|
36
|
-
account_number: z.string(),
|
|
37
|
-
bic: z.string(),
|
|
38
|
-
routing_number: z.string(),
|
|
39
|
-
sort_code: z.string(),
|
|
34
|
+
name: z.union([z.string(), z.null()]),
|
|
35
|
+
bank_name: z.union([z.string(), z.null()]),
|
|
36
|
+
iban: z.union([z.string(), z.null()]),
|
|
37
|
+
account_number: z.union([z.string(), z.null()]),
|
|
38
|
+
bic: z.union([z.string(), z.null()]),
|
|
39
|
+
routing_number: z.union([z.string(), z.null()]),
|
|
40
|
+
sort_code: z.union([z.string(), z.null()]),
|
|
40
41
|
})
|
|
41
42
|
.partial()
|
|
42
43
|
.passthrough(),
|
|
@@ -51,7 +52,7 @@ const DocumentEntity = z
|
|
|
51
52
|
const CreateDocumentCustomer = DocumentEntity.and(
|
|
52
53
|
z.union([
|
|
53
54
|
z
|
|
54
|
-
.object({ save_customer: z.boolean().
|
|
55
|
+
.object({ save_customer: z.union([z.boolean(), z.null()]) })
|
|
55
56
|
.partial()
|
|
56
57
|
.passthrough(),
|
|
57
58
|
z.null(),
|
|
@@ -63,28 +64,24 @@ const CreateDocumentCustomer = DocumentEntity.and(
|
|
|
63
64
|
const CreateFinaInvoiceData = z.union([
|
|
64
65
|
z
|
|
65
66
|
.object({
|
|
66
|
-
business_premise_name: z
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"paypal",
|
|
83
|
-
"crypto",
|
|
84
|
-
"coupon",
|
|
85
|
-
"other",
|
|
67
|
+
business_premise_name: z.union([z.string(), z.null()]),
|
|
68
|
+
electronic_device_name: z.union([z.string(), z.null()]),
|
|
69
|
+
operator_oib: z.union([z.string(), z.null()]),
|
|
70
|
+
operator_label: z.union([z.string(), z.null()]),
|
|
71
|
+
payment_type: z.union([
|
|
72
|
+
z.enum([
|
|
73
|
+
"cash",
|
|
74
|
+
"card",
|
|
75
|
+
"online",
|
|
76
|
+
"bank_transfer",
|
|
77
|
+
"paypal",
|
|
78
|
+
"crypto",
|
|
79
|
+
"coupon",
|
|
80
|
+
"other",
|
|
81
|
+
]),
|
|
82
|
+
z.null(),
|
|
86
83
|
]),
|
|
87
|
-
subsequent_submit: z.boolean(),
|
|
84
|
+
subsequent_submit: z.union([z.boolean(), z.null()]),
|
|
88
85
|
})
|
|
89
86
|
.partial(),
|
|
90
87
|
z.null(),
|
|
@@ -109,9 +106,9 @@ const PartialCreditNotePreview = z.object({
|
|
|
109
106
|
currency_code: z.string().max(3).optional(),
|
|
110
107
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
|
|
111
108
|
reference: z.union([z.string(), z.null()]).optional(),
|
|
112
|
-
date_due: z.union([z.string(), z.null()]).optional(),
|
|
113
109
|
date_service: z.union([z.string(), z.null()]).optional(),
|
|
114
110
|
date_service_to: z.union([z.string(), z.null()]).optional(),
|
|
111
|
+
date_due: z.union([z.string(), z.null()]).optional(),
|
|
115
112
|
items: z
|
|
116
113
|
.array(
|
|
117
114
|
z
|
|
@@ -122,6 +119,15 @@ const PartialCreditNotePreview = z.object({
|
|
|
122
119
|
price: z.number(),
|
|
123
120
|
gross_price: z.number(),
|
|
124
121
|
description: z.string(),
|
|
122
|
+
unit: z.string(),
|
|
123
|
+
discounts: z.array(
|
|
124
|
+
z
|
|
125
|
+
.object({
|
|
126
|
+
value: z.number(),
|
|
127
|
+
type: z.enum(["percent", "amount"]).optional(),
|
|
128
|
+
})
|
|
129
|
+
.passthrough()
|
|
130
|
+
),
|
|
125
131
|
taxes: z.array(
|
|
126
132
|
z
|
|
127
133
|
.object({ rate: z.number(), tax_id: z.string() })
|
|
@@ -142,7 +148,7 @@ const PartialCreditNotePreview = z.object({
|
|
|
142
148
|
// Dependency schema for rendercreditnotepreview_body
|
|
143
149
|
const DocumentItemTax = z
|
|
144
150
|
.object({
|
|
145
|
-
rate: z.number(),
|
|
151
|
+
rate: z.union([z.number(), z.null()]),
|
|
146
152
|
tax_id: z.union([z.string(), z.null()]),
|
|
147
153
|
classification: z.union([z.string(), z.null()]),
|
|
148
154
|
reverse_charge: z.union([z.boolean(), z.null()]),
|
|
@@ -162,17 +168,17 @@ const LineDiscount = z.object({
|
|
|
162
168
|
const CreateDocumentItem = z
|
|
163
169
|
.object({
|
|
164
170
|
type: z.union([z.literal("separator"), z.null()]),
|
|
165
|
-
name: z.string().
|
|
171
|
+
name: z.union([z.string(), z.null()]),
|
|
166
172
|
description: z.union([z.string(), z.null()]),
|
|
167
|
-
price: z.number(),
|
|
173
|
+
price: z.union([z.number(), z.null()]),
|
|
168
174
|
gross_price: z.union([z.number(), z.null()]),
|
|
169
|
-
quantity: z.
|
|
175
|
+
quantity: z.union([z.number(), z.null()]),
|
|
170
176
|
unit: z.union([z.string(), z.null()]),
|
|
171
177
|
taxes: z.array(DocumentItemTax),
|
|
172
178
|
discounts: z.array(LineDiscount).max(5),
|
|
173
179
|
item_id: z.union([z.string(), z.null()]),
|
|
174
180
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]),
|
|
175
|
-
save_item: z.boolean().
|
|
181
|
+
save_item: z.union([z.boolean(), z.null()]),
|
|
176
182
|
})
|
|
177
183
|
.partial();
|
|
178
184
|
|
|
@@ -195,9 +201,9 @@ const CompleteCreditNotePreview = z.object({
|
|
|
195
201
|
currency_code: z.string().max(3).optional(),
|
|
196
202
|
metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
|
|
197
203
|
reference: z.union([z.string(), z.null()]).optional(),
|
|
198
|
-
date_due: z.union([z.string(), z.null()]).optional(),
|
|
199
204
|
date_service: z.union([z.string(), z.null()]).optional(),
|
|
200
205
|
date_service_to: z.union([z.string(), z.null()]).optional(),
|
|
206
|
+
date_due: z.union([z.string(), z.null()]).optional(),
|
|
201
207
|
items: z.array(CreateDocumentItem).min(1),
|
|
202
208
|
fina: CreateFinaInvoiceData.optional(),
|
|
203
209
|
expected_total_with_tax: z.number().gt(0).optional(),
|