@spaceinvoices/react-ui 0.4.3 → 0.4.4
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 +18 -2
- package/src/components/advance-invoices/create/create-advance-invoice-form.tsx +0 -1
- package/src/components/advance-invoices/create/locales/de.ts +2 -0
- package/src/components/advance-invoices/create/locales/es.ts +2 -0
- package/src/components/advance-invoices/create/locales/fr.ts +2 -0
- package/src/components/advance-invoices/create/locales/hr.ts +1 -0
- package/src/components/advance-invoices/create/locales/it.ts +2 -0
- package/src/components/advance-invoices/create/locales/nl.ts +2 -0
- package/src/components/advance-invoices/create/locales/pl.ts +1 -0
- package/src/components/advance-invoices/create/locales/pt.ts +1 -0
- package/src/components/advance-invoices/create/locales/sl.ts +1 -0
- package/src/components/advance-invoices/create/prepare-advance-invoice-submission.ts +0 -1
- package/src/components/advance-invoices/list/list-table.tsx +80 -50
- package/src/components/advance-invoices/list/locales/de.ts +5 -0
- package/src/components/advance-invoices/list/locales/en.ts +4 -0
- package/src/components/advance-invoices/list/locales/es.ts +5 -0
- package/src/components/advance-invoices/list/locales/fr.ts +5 -0
- package/src/components/advance-invoices/list/locales/hr.ts +5 -0
- package/src/components/advance-invoices/list/locales/it.ts +5 -0
- package/src/components/advance-invoices/list/locales/nl.ts +5 -0
- package/src/components/advance-invoices/list/locales/pl.ts +5 -0
- package/src/components/advance-invoices/list/locales/pt.ts +5 -0
- package/src/components/advance-invoices/list/locales/sl.ts +5 -0
- package/src/components/credit-notes/create/create-credit-note-form.tsx +114 -3
- package/src/components/credit-notes/create/locales/de.ts +2 -0
- package/src/components/credit-notes/create/locales/es.ts +2 -0
- package/src/components/credit-notes/create/locales/fr.ts +2 -0
- package/src/components/credit-notes/create/locales/hr.ts +1 -0
- package/src/components/credit-notes/create/locales/it.ts +2 -0
- package/src/components/credit-notes/create/locales/nl.ts +2 -0
- package/src/components/credit-notes/create/locales/pl.ts +1 -0
- package/src/components/credit-notes/create/locales/pt.ts +1 -0
- package/src/components/credit-notes/create/locales/sl.ts +1 -0
- package/src/components/credit-notes/credit-notes.hooks.ts +30 -0
- package/src/components/credit-notes/list/list-table.tsx +77 -30
- package/src/components/credit-notes/list/locales/de.ts +5 -0
- package/src/components/credit-notes/list/locales/en.ts +4 -0
- package/src/components/credit-notes/list/locales/es.ts +5 -0
- package/src/components/credit-notes/list/locales/fr.ts +5 -0
- package/src/components/credit-notes/list/locales/hr.ts +5 -0
- package/src/components/credit-notes/list/locales/it.ts +5 -0
- package/src/components/credit-notes/list/locales/nl.ts +5 -0
- package/src/components/credit-notes/list/locales/pl.ts +5 -0
- package/src/components/credit-notes/list/locales/pt.ts +5 -0
- package/src/components/credit-notes/list/locales/sl.ts +5 -0
- package/src/components/customers/customer-list-table/customer-list-table.tsx +0 -3
- package/src/components/customers/customer-list-table/locales/de.ts +1 -0
- package/src/components/customers/customer-list-table/locales/es.ts +1 -0
- package/src/components/customers/customer-list-table/locales/fr.ts +1 -0
- package/src/components/customers/customer-list-table/locales/hr.ts +1 -0
- package/src/components/customers/customer-list-table/locales/it.ts +1 -0
- package/src/components/customers/customer-list-table/locales/nl.ts +1 -0
- package/src/components/customers/customer-list-table/locales/pl.ts +1 -0
- package/src/components/customers/customer-list-table/locales/pt.ts +1 -0
- package/src/components/customers/customer-list-table/locales/sl.ts +1 -0
- package/src/components/delivery-notes/list/list-row-actions.tsx +20 -1
- package/src/components/delivery-notes/list/list-table.tsx +41 -8
- package/src/components/delivery-notes/list/locales/de.ts +4 -0
- package/src/components/delivery-notes/list/locales/en.ts +2 -0
- package/src/components/delivery-notes/list/locales/es.ts +4 -0
- package/src/components/delivery-notes/list/locales/fr.ts +4 -0
- package/src/components/delivery-notes/list/locales/hr.ts +4 -0
- package/src/components/delivery-notes/list/locales/it.ts +4 -0
- package/src/components/delivery-notes/list/locales/nl.ts +4 -0
- package/src/components/delivery-notes/list/locales/pl.ts +4 -0
- package/src/components/delivery-notes/list/locales/pt.ts +4 -0
- package/src/components/delivery-notes/list/locales/sl.ts +4 -0
- package/src/components/documents/create/document-details-section.tsx +41 -27
- package/src/components/documents/create/linked-documents-info.tsx +82 -0
- package/src/components/documents/create/live-preview.tsx +1 -1
- package/src/components/documents/types.ts +2 -2
- package/src/components/documents/view/document-activities-list.tsx +65 -47
- package/src/components/documents/view/document-details-card.tsx +99 -74
- package/src/components/documents/view/document-payments-list.tsx +99 -65
- package/src/components/documents/view/document-relations-list.tsx +43 -28
- package/src/components/documents/view/document-sidebar.tsx +151 -0
- package/src/components/documents/view/index.ts +2 -0
- package/src/components/documents/view/locales/de.ts +2 -0
- package/src/components/documents/view/locales/es.ts +2 -0
- package/src/components/documents/view/locales/fr.ts +2 -0
- package/src/components/documents/view/locales/hr.ts +2 -0
- package/src/components/documents/view/locales/it.ts +2 -0
- package/src/components/documents/view/locales/nl.ts +2 -0
- package/src/components/documents/view/locales/pl.ts +2 -0
- package/src/components/documents/view/locales/pt.ts +2 -0
- package/src/components/documents/view/locales/sl.ts +2 -0
- package/src/components/documents/view/use-document-download.ts +3 -2
- package/src/components/entities/create-entity-form.tsx +165 -13
- package/src/components/entities/entity-settings-form/entity-settings-form.tsx +101 -1
- package/src/components/entities/entity-settings-form/locales/de.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/es.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/fr.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/hr.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/it.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/nl.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/pl.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/pt.ts +9 -0
- package/src/components/entities/entity-settings-form/locales/sl.ts +9 -0
- package/src/components/entities/fina-settings-form/fina-settings-form.tsx +6 -6
- package/src/components/entities/fina-settings-form/locales/de.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/en.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/es.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/fr.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/hr.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/it.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/nl.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/pl.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/pt.ts +2 -2
- package/src/components/entities/fina-settings-form/locales/sl.ts +2 -2
- package/src/components/entities/furs-settings-form/locales/en.ts +0 -1
- package/src/components/entities/settings/pdf-template-selector/locales/de.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/locales/es.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/locales/fr.ts +4 -1
- package/src/components/entities/settings/pdf-template-selector/locales/hr.ts +4 -1
- package/src/components/entities/settings/pdf-template-selector/locales/it.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/locales/nl.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/locales/pl.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/locales/pt.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/locales/sl.ts +3 -1
- package/src/components/entities/settings/pdf-template-selector/pdf-template-cards.tsx +1 -0
- package/src/components/estimates/create/create-estimate-form.tsx +29 -2
- package/src/components/estimates/list/list-table.tsx +3 -6
- package/src/components/estimates/list/locales/de.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/export/document-export-form.tsx +9 -2
- package/src/components/export/index.ts +2 -0
- package/src/components/export/sales-per-item-export-form.tsx +223 -0
- package/src/components/invoices/create/create-invoice-form.tsx +48 -1
- package/src/components/invoices/create/locales/de.ts +11 -0
- package/src/components/invoices/create/locales/es.ts +11 -0
- package/src/components/invoices/create/locales/fr.ts +11 -0
- package/src/components/invoices/create/locales/hr.ts +10 -0
- package/src/components/invoices/create/locales/it.ts +11 -0
- package/src/components/invoices/create/locales/nl.ts +11 -0
- package/src/components/invoices/create/locales/pl.ts +10 -0
- package/src/components/invoices/create/locales/pt.ts +10 -0
- package/src/components/invoices/create/locales/sl.ts +10 -0
- package/src/components/invoices/invoices-furs.hooks.ts +4 -1
- package/src/components/invoices/list/list-table.tsx +77 -31
- package/src/components/invoices/list/locales/de.ts +5 -0
- package/src/components/invoices/list/locales/en.ts +4 -0
- package/src/components/invoices/list/locales/es.ts +5 -0
- package/src/components/invoices/list/locales/fr.ts +5 -0
- package/src/components/invoices/list/locales/hr.ts +5 -0
- package/src/components/invoices/list/locales/it.ts +5 -0
- package/src/components/invoices/list/locales/nl.ts +5 -0
- package/src/components/invoices/list/locales/pl.ts +5 -0
- package/src/components/invoices/list/locales/pt.ts +5 -0
- package/src/components/invoices/list/locales/sl.ts +5 -0
- package/src/components/invoices/view/fiscalization-status-card.tsx +42 -24
- package/src/components/items/item-combobox.tsx +5 -3
- package/src/components/items/item-list-table/item-list-header.tsx +4 -17
- package/src/components/items/item-list-table/item-list-table.tsx +3 -3
- package/src/components/items/item-list-table/locales/de.ts +1 -0
- package/src/components/items/item-list-table/locales/es.ts +1 -0
- package/src/components/items/item-list-table/locales/fr.ts +1 -0
- package/src/components/items/item-list-table/locales/hr.ts +1 -0
- package/src/components/items/item-list-table/locales/it.ts +1 -0
- package/src/components/items/item-list-table/locales/nl.ts +1 -0
- package/src/components/items/item-list-table/locales/pl.ts +1 -0
- package/src/components/items/item-list-table/locales/pt.ts +1 -0
- package/src/components/items/item-list-table/locales/sl.ts +1 -0
- package/src/components/payments/list/list-table.tsx +0 -4
- package/src/components/payments/list/locales/de.ts +1 -0
- package/src/components/payments/list/locales/es.ts +1 -0
- package/src/components/payments/list/locales/fr.ts +1 -0
- package/src/components/payments/list/locales/hr.ts +1 -0
- package/src/components/payments/list/locales/it.ts +1 -0
- package/src/components/payments/list/locales/nl.ts +1 -0
- package/src/components/payments/list/locales/pl.ts +1 -0
- package/src/components/payments/list/locales/pt.ts +1 -0
- package/src/components/payments/list/locales/sl.ts +1 -0
- package/src/components/recurring-invoices/list/list-table.tsx +0 -7
- package/src/components/recurring-invoices/list/locales/de.ts +1 -0
- package/src/components/recurring-invoices/list/locales/es.ts +1 -0
- package/src/components/recurring-invoices/list/locales/fr.ts +1 -0
- package/src/components/recurring-invoices/list/locales/hr.ts +1 -0
- package/src/components/recurring-invoices/list/locales/it.ts +1 -0
- package/src/components/recurring-invoices/list/locales/nl.ts +1 -0
- package/src/components/recurring-invoices/list/locales/pl.ts +1 -0
- package/src/components/recurring-invoices/list/locales/pt.ts +1 -0
- package/src/components/recurring-invoices/list/locales/sl.ts +1 -0
- package/src/components/request-logs/request-log-list-table.tsx +0 -3
- package/src/components/table/README.md +14 -121
- package/src/components/table/data-table.tsx +22 -37
- package/src/components/table/hooks/use-table-state.ts +3 -27
- package/src/components/table/index.ts +0 -2
- package/src/components/table/selection-toolbar.tsx +35 -1
- package/src/components/table/table-empty-state.tsx +6 -3
- package/src/components/table/table-no-results.tsx +10 -5
- package/src/components/table/types.ts +0 -5
- package/src/components/taxes/tax-list-table/locales/de.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/es.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/fr.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/hr.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/it.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/nl.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/pl.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/pt.ts +1 -0
- package/src/components/taxes/tax-list-table/locales/sl.ts +1 -0
- package/src/components/taxes/tax-list-table/tax-list-header.tsx +3 -14
- package/src/components/taxes/tax-list-table/tax-list-table.tsx +3 -3
- package/src/components/ui/popover.tsx +3 -1
- package/src/components/ui/tooltip.tsx +3 -1
- package/src/generated/schemas/index.ts +1 -1
- package/src/hooks/use-duplicate-document.ts +40 -5
- package/src/lib/fiscalization.ts +12 -0
- package/src/lib/schemas/advance-invoice.ts +0 -1
- package/src/components/table/sortable-header.tsx +0 -56
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AdvanceInvoice,
|
|
3
|
+
CreditNote,
|
|
4
|
+
DeliveryNote,
|
|
5
|
+
DocumentRelation,
|
|
6
|
+
Estimate,
|
|
7
|
+
Invoice,
|
|
8
|
+
Payment,
|
|
9
|
+
} from "@spaceinvoices/js-sdk";
|
|
10
|
+
import { Card, CardContent } from "@/ui/components/ui/card";
|
|
11
|
+
import { Separator } from "@/ui/components/ui/separator";
|
|
12
|
+
import type { ComponentTranslationProps } from "@/ui/lib/translation";
|
|
13
|
+
import { FiscalizationStatusCard } from "../../invoices/view/fiscalization-status-card";
|
|
14
|
+
import { DocumentActivitiesList } from "./document-activities-list";
|
|
15
|
+
import { DocumentDetailsCard } from "./document-details-card";
|
|
16
|
+
import { DocumentPaymentsList } from "./document-payments-list";
|
|
17
|
+
import { DocumentRelationsList } from "./document-relations-list";
|
|
18
|
+
|
|
19
|
+
type Document = Invoice | Estimate | CreditNote | AdvanceInvoice | DeliveryNote;
|
|
20
|
+
type DocumentType = "invoice" | "estimate" | "credit_note" | "advance_invoice" | "delivery_note";
|
|
21
|
+
|
|
22
|
+
interface DocumentSidebarProps extends ComponentTranslationProps {
|
|
23
|
+
document: Document;
|
|
24
|
+
documentType: DocumentType;
|
|
25
|
+
entityId: string;
|
|
26
|
+
locale?: string;
|
|
27
|
+
currentUserId?: string;
|
|
28
|
+
/** Show payments section */
|
|
29
|
+
showPayments?: boolean;
|
|
30
|
+
onAddPayment?: () => void;
|
|
31
|
+
onEditPayment?: (payment: Payment) => void;
|
|
32
|
+
onPaymentDeleteSuccess?: () => void;
|
|
33
|
+
onPaymentDeleteError?: (error: string) => void;
|
|
34
|
+
/** Navigate to a related document */
|
|
35
|
+
onNavigateRelation?: (documentId: string) => void;
|
|
36
|
+
/** FURS fiscalization */
|
|
37
|
+
showFurs?: boolean;
|
|
38
|
+
fursFiscalizationData?: any;
|
|
39
|
+
/** FINA fiscalization */
|
|
40
|
+
showFina?: boolean;
|
|
41
|
+
finaFiscalizationData?: any;
|
|
42
|
+
onRetryFiscalization?: () => void;
|
|
43
|
+
isRetryingFiscalization?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function DocumentSidebar({
|
|
47
|
+
document,
|
|
48
|
+
documentType,
|
|
49
|
+
entityId,
|
|
50
|
+
locale = "en",
|
|
51
|
+
currentUserId,
|
|
52
|
+
showPayments,
|
|
53
|
+
onAddPayment,
|
|
54
|
+
onEditPayment,
|
|
55
|
+
onPaymentDeleteSuccess,
|
|
56
|
+
onPaymentDeleteError,
|
|
57
|
+
onNavigateRelation,
|
|
58
|
+
showFurs,
|
|
59
|
+
fursFiscalizationData,
|
|
60
|
+
showFina,
|
|
61
|
+
finaFiscalizationData,
|
|
62
|
+
onRetryFiscalization,
|
|
63
|
+
isRetryingFiscalization,
|
|
64
|
+
...i18nProps
|
|
65
|
+
}: DocumentSidebarProps) {
|
|
66
|
+
const documentRelations = (document as unknown as { document_relations?: DocumentRelation[] }).document_relations;
|
|
67
|
+
const hasRelations = documentRelations && documentRelations.length > 0;
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Card size="sm">
|
|
71
|
+
<CardContent className="space-y-5">
|
|
72
|
+
<DocumentDetailsCard
|
|
73
|
+
variant="inline"
|
|
74
|
+
document={document}
|
|
75
|
+
documentType={documentType}
|
|
76
|
+
locale={locale}
|
|
77
|
+
{...i18nProps}
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
{showPayments && (
|
|
81
|
+
<>
|
|
82
|
+
<Separator />
|
|
83
|
+
<DocumentPaymentsList
|
|
84
|
+
variant="inline"
|
|
85
|
+
documentId={document.id}
|
|
86
|
+
documentType={documentType as "invoice" | "credit_note" | "advance_invoice"}
|
|
87
|
+
entityId={entityId}
|
|
88
|
+
currencyCode={document.currency_code}
|
|
89
|
+
locale={locale}
|
|
90
|
+
onAddPayment={onAddPayment}
|
|
91
|
+
onEditPayment={onEditPayment}
|
|
92
|
+
onDeleteSuccess={onPaymentDeleteSuccess}
|
|
93
|
+
onDeleteError={onPaymentDeleteError}
|
|
94
|
+
{...i18nProps}
|
|
95
|
+
/>
|
|
96
|
+
</>
|
|
97
|
+
)}
|
|
98
|
+
|
|
99
|
+
{hasRelations && (
|
|
100
|
+
<>
|
|
101
|
+
<Separator />
|
|
102
|
+
<DocumentRelationsList
|
|
103
|
+
variant="inline"
|
|
104
|
+
documentId={document.id}
|
|
105
|
+
documentRelations={documentRelations}
|
|
106
|
+
locale={locale}
|
|
107
|
+
onNavigate={onNavigateRelation}
|
|
108
|
+
{...i18nProps}
|
|
109
|
+
/>
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
|
|
113
|
+
<Separator />
|
|
114
|
+
<DocumentActivitiesList
|
|
115
|
+
variant="inline"
|
|
116
|
+
documentId={document.id}
|
|
117
|
+
entityId={entityId}
|
|
118
|
+
currentUserId={currentUserId}
|
|
119
|
+
locale={locale}
|
|
120
|
+
{...i18nProps}
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
{(showFurs || showFina) && (
|
|
124
|
+
<>
|
|
125
|
+
<Separator />
|
|
126
|
+
{showFurs && (
|
|
127
|
+
<FiscalizationStatusCard
|
|
128
|
+
variant="inline"
|
|
129
|
+
fiscalizationType="furs"
|
|
130
|
+
fiscalizationData={fursFiscalizationData}
|
|
131
|
+
onRetry={onRetryFiscalization}
|
|
132
|
+
isRetrying={isRetryingFiscalization}
|
|
133
|
+
locale={locale}
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
{showFina && (
|
|
137
|
+
<FiscalizationStatusCard
|
|
138
|
+
variant="inline"
|
|
139
|
+
fiscalizationType="fina"
|
|
140
|
+
fiscalizationData={finaFiscalizationData}
|
|
141
|
+
onRetry={onRetryFiscalization}
|
|
142
|
+
isRetrying={isRetryingFiscalization}
|
|
143
|
+
locale={locale}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
</>
|
|
147
|
+
)}
|
|
148
|
+
</CardContent>
|
|
149
|
+
</Card>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
@@ -2,4 +2,6 @@ export { DocumentActionsBar } from "./document-actions-bar";
|
|
|
2
2
|
export { DocumentActivitiesList } from "./document-activities-list";
|
|
3
3
|
export { DocumentDetailsCard } from "./document-details-card";
|
|
4
4
|
export { DocumentPaymentsList } from "./document-payments-list";
|
|
5
|
+
export { DocumentRelationsList } from "./document-relations-list";
|
|
6
|
+
export { DocumentSidebar } from "./document-sidebar";
|
|
5
7
|
export { useDocumentDownload } from "./use-document-download";
|
|
@@ -20,10 +20,12 @@ export default {
|
|
|
20
20
|
"Duplicate estimate": "Angebot duplizieren",
|
|
21
21
|
"Duplicate credit_note": "Gutschrift duplizieren",
|
|
22
22
|
"Duplicate advance_invoice": "Anzahlungsrechnung duplizieren",
|
|
23
|
+
"Duplicate delivery_note": "Lieferschein duplizieren",
|
|
23
24
|
"Create invoice": "Rechnung erstellen",
|
|
24
25
|
"Create estimate": "Angebot erstellen",
|
|
25
26
|
"Create credit_note": "Gutschrift erstellen",
|
|
26
27
|
"Create advance_invoice": "Anzahlungsrechnung erstellen",
|
|
28
|
+
"Create delivery_note": "Lieferschein erstellen",
|
|
27
29
|
|
|
28
30
|
// Details card
|
|
29
31
|
Details: "Details",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Duplicar presupuesto",
|
|
20
20
|
"Duplicate credit_note": "Duplicar nota de crédito",
|
|
21
21
|
"Duplicate advance_invoice": "Duplicar factura anticipada",
|
|
22
|
+
"Duplicate delivery_note": "Duplicar albarán",
|
|
22
23
|
"Create invoice": "Crear factura",
|
|
23
24
|
"Create estimate": "Crear presupuesto",
|
|
24
25
|
"Create credit_note": "Crear nota de crédito",
|
|
25
26
|
"Create advance_invoice": "Crear factura anticipada",
|
|
27
|
+
"Create delivery_note": "Crear albarán",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Detalles",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Dupliquer le devis",
|
|
20
20
|
"Duplicate credit_note": "Dupliquer l'avoir",
|
|
21
21
|
"Duplicate advance_invoice": "Dupliquer la facture d'acompte",
|
|
22
|
+
"Duplicate delivery_note": "Dupliquer le bon de livraison",
|
|
22
23
|
"Create invoice": "Créer une facture",
|
|
23
24
|
"Create estimate": "Créer un devis",
|
|
24
25
|
"Create credit_note": "Créer un avoir",
|
|
25
26
|
"Create advance_invoice": "Créer une facture d'acompte",
|
|
27
|
+
"Create delivery_note": "Créer un bon de livraison",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Détails",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Dupliciraj ponudu",
|
|
20
20
|
"Duplicate credit_note": "Dupliciraj knjižno odobrenje",
|
|
21
21
|
"Duplicate advance_invoice": "Dupliciraj avansni račun",
|
|
22
|
+
"Duplicate delivery_note": "Dupliciraj otpremnicu",
|
|
22
23
|
"Create invoice": "Stvori račun",
|
|
23
24
|
"Create estimate": "Stvori ponudu",
|
|
24
25
|
"Create credit_note": "Stvori knjižno odobrenje",
|
|
25
26
|
"Create advance_invoice": "Stvori avansni račun",
|
|
27
|
+
"Create delivery_note": "Stvori otpremnicu",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Pojedinosti",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Duplica preventivo",
|
|
20
20
|
"Duplicate credit_note": "Duplica nota di credito",
|
|
21
21
|
"Duplicate advance_invoice": "Duplica fattura di acconto",
|
|
22
|
+
"Duplicate delivery_note": "Duplica bolla di consegna",
|
|
22
23
|
"Create invoice": "Crea fattura",
|
|
23
24
|
"Create estimate": "Crea preventivo",
|
|
24
25
|
"Create credit_note": "Crea nota di credito",
|
|
25
26
|
"Create advance_invoice": "Crea fattura di acconto",
|
|
27
|
+
"Create delivery_note": "Crea bolla di consegna",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Dettagli",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Offerte dupliceren",
|
|
20
20
|
"Duplicate credit_note": "Creditnota dupliceren",
|
|
21
21
|
"Duplicate advance_invoice": "Voorschotfactuur dupliceren",
|
|
22
|
+
"Duplicate delivery_note": "Afleverbon dupliceren",
|
|
22
23
|
"Create invoice": "Factuur aanmaken",
|
|
23
24
|
"Create estimate": "Offerte aanmaken",
|
|
24
25
|
"Create credit_note": "Creditnota aanmaken",
|
|
25
26
|
"Create advance_invoice": "Voorschotfactuur aanmaken",
|
|
27
|
+
"Create delivery_note": "Afleverbon aanmaken",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Details",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Duplikuj kosztorys",
|
|
20
20
|
"Duplicate credit_note": "Duplikuj notę kredytową",
|
|
21
21
|
"Duplicate advance_invoice": "Duplikuj fakturę zaliczkową",
|
|
22
|
+
"Duplicate delivery_note": "Duplikuj dowód dostawy",
|
|
22
23
|
"Create invoice": "Utwórz fakturę",
|
|
23
24
|
"Create estimate": "Utwórz kosztorys",
|
|
24
25
|
"Create credit_note": "Utwórz notę kredytową",
|
|
25
26
|
"Create advance_invoice": "Utwórz fakturę zaliczkową",
|
|
27
|
+
"Create delivery_note": "Utwórz dowód dostawy",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Szczegóły",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Duplicar orçamento",
|
|
20
20
|
"Duplicate credit_note": "Duplicar nota de crédito",
|
|
21
21
|
"Duplicate advance_invoice": "Duplicar fatura antecipada",
|
|
22
|
+
"Duplicate delivery_note": "Duplicar guia de remessa",
|
|
22
23
|
"Create invoice": "Criar fatura",
|
|
23
24
|
"Create estimate": "Criar orçamento",
|
|
24
25
|
"Create credit_note": "Criar nota de crédito",
|
|
25
26
|
"Create advance_invoice": "Criar fatura antecipada",
|
|
27
|
+
"Create delivery_note": "Criar guia de remessa",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Detalhes",
|
|
@@ -19,10 +19,12 @@ export default {
|
|
|
19
19
|
"Duplicate estimate": "Podvoji predračun",
|
|
20
20
|
"Duplicate credit_note": "Podvoji dobropis",
|
|
21
21
|
"Duplicate advance_invoice": "Podvoji avansni račun",
|
|
22
|
+
"Duplicate delivery_note": "Podvoji dobavnico",
|
|
22
23
|
"Create invoice": "Ustvari račun",
|
|
23
24
|
"Create estimate": "Ustvari predračun",
|
|
24
25
|
"Create credit_note": "Ustvari dobropis",
|
|
25
26
|
"Create advance_invoice": "Ustvari avansni račun",
|
|
27
|
+
"Create delivery_note": "Ustvari dobavnico",
|
|
26
28
|
|
|
27
29
|
// Details card
|
|
28
30
|
Details: "Podrobnosti",
|
|
@@ -38,7 +38,7 @@ export function useDocumentDownload({
|
|
|
38
38
|
/**
|
|
39
39
|
* Download PDF in specified locale
|
|
40
40
|
*/
|
|
41
|
-
const downloadPdf = async (document: Document, documentType: DocumentType,
|
|
41
|
+
const downloadPdf = async (document: Document, documentType: DocumentType, locale: string) => {
|
|
42
42
|
if (!sdk || !activeEntity?.id) {
|
|
43
43
|
onDownloadError?.("Download failed");
|
|
44
44
|
return;
|
|
@@ -51,7 +51,8 @@ export function useDocumentDownload({
|
|
|
51
51
|
// SDK signature: renderPdf(id, params?, SDKMethodOptions?)
|
|
52
52
|
// entity_id goes in SDKMethodOptions (last arg), not params
|
|
53
53
|
// Note: renderPdf is on invoices module but works with any document ID via /documents/{id}/pdf
|
|
54
|
-
const
|
|
54
|
+
const params = locale ? { locale } : {};
|
|
55
|
+
const blob = await sdk.invoices.renderPdf(document.id, params, { entity_id: activeEntity.id });
|
|
55
56
|
const downloadUrl = window.URL.createObjectURL(blob);
|
|
56
57
|
const link = window.document.createElement("a");
|
|
57
58
|
link.href = downloadUrl;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2
|
-
import type { CreateEntityRequest, Entity } from "@spaceinvoices/js-sdk";
|
|
2
|
+
import type { CompanyRegistryResult, CreateEntityRequest, Entity } from "@spaceinvoices/js-sdk";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
4
|
import type { Resolver } from "react-hook-form";
|
|
4
5
|
import { useForm } from "react-hook-form";
|
|
6
|
+
import { Autocomplete } from "@/ui/common/autocomplete";
|
|
7
|
+
import { useCompanyRegistrySearch, useIsCountrySupported } from "@/ui/components/company-registry";
|
|
5
8
|
import { FormInput } from "@/ui/components/form";
|
|
6
9
|
import { Button } from "@/ui/components/ui/button";
|
|
7
|
-
import {
|
|
10
|
+
import { Checkbox } from "@/ui/components/ui/checkbox";
|
|
11
|
+
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/ui/components/ui/form";
|
|
8
12
|
import { type CreateEntitySchema, createEntitySchema } from "@/ui/generated/schemas";
|
|
9
13
|
|
|
10
14
|
import ButtonLoader from "../button-loader";
|
|
@@ -16,6 +20,8 @@ export type CreateEntityFormProps = {
|
|
|
16
20
|
accountId?: string;
|
|
17
21
|
environment?: string;
|
|
18
22
|
defaultName?: string;
|
|
23
|
+
countryCode?: string;
|
|
24
|
+
locale?: string;
|
|
19
25
|
defaultValues?: Partial<CreateEntitySchema>;
|
|
20
26
|
onSuccess?: (data: Entity) => void;
|
|
21
27
|
onError?: (error: unknown) => void;
|
|
@@ -29,12 +35,44 @@ export function CreateEntityForm({
|
|
|
29
35
|
accountId,
|
|
30
36
|
environment,
|
|
31
37
|
defaultName,
|
|
38
|
+
countryCode,
|
|
39
|
+
locale = "en",
|
|
32
40
|
defaultValues: extraDefaults,
|
|
33
41
|
onSuccess,
|
|
34
42
|
onError,
|
|
35
43
|
}: CreateEntityFormProps) {
|
|
36
44
|
const translate = (key: string) => t(namespace ? `${namespace}.${key}` : key);
|
|
37
45
|
|
|
46
|
+
const countryName = countryCode ? new Intl.DisplayNames([locale], { type: "region" }).of(countryCode) : undefined;
|
|
47
|
+
|
|
48
|
+
// Track whether the country code is still valid (cleared when user edits country name)
|
|
49
|
+
const [activeCountryCode, setActiveCountryCode] = useState<string | undefined>(countryCode);
|
|
50
|
+
const autoFilledCountryRef = useRef(countryName);
|
|
51
|
+
|
|
52
|
+
// Company registry autocomplete state
|
|
53
|
+
const [nameSearch, setNameSearch] = useState("");
|
|
54
|
+
const { isSupported: isRegistrySupported } = useIsCountrySupported(activeCountryCode || "");
|
|
55
|
+
const { data: searchData, isLoading: isSearching } = useCompanyRegistrySearch(activeCountryCode || "", nameSearch);
|
|
56
|
+
const companies = searchData?.data || [];
|
|
57
|
+
|
|
58
|
+
const showAutocomplete = !!activeCountryCode && isRegistrySupported;
|
|
59
|
+
|
|
60
|
+
const nameOptions = companies.map((company) => {
|
|
61
|
+
const addressParts = [company.address, company.city].filter(Boolean);
|
|
62
|
+
const address = addressParts.join(", ");
|
|
63
|
+
return {
|
|
64
|
+
value: company.id,
|
|
65
|
+
label: (
|
|
66
|
+
<div className="flex flex-col overflow-hidden py-1">
|
|
67
|
+
<span className="truncate font-medium">{company.name}</span>
|
|
68
|
+
{address && <span className="truncate text-muted-foreground text-xs">{address}</span>}
|
|
69
|
+
{company.tax_number && <span className="truncate text-muted-foreground text-xs">{company.tax_number}</span>}
|
|
70
|
+
</div>
|
|
71
|
+
),
|
|
72
|
+
company,
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
38
76
|
const form = useForm<CreateEntitySchema>({
|
|
39
77
|
resolver: zodResolver(createEntitySchema) as Resolver<CreateEntitySchema>,
|
|
40
78
|
defaultValues: {
|
|
@@ -44,9 +82,11 @@ export function CreateEntityForm({
|
|
|
44
82
|
post_code: "",
|
|
45
83
|
city: "",
|
|
46
84
|
state: "",
|
|
47
|
-
country: "",
|
|
85
|
+
country: countryName || "",
|
|
86
|
+
country_code: countryCode || "",
|
|
48
87
|
tax_number: "",
|
|
49
88
|
company_number: "",
|
|
89
|
+
is_tax_subject: true,
|
|
50
90
|
environment: environment as "live" | "sandbox" | undefined,
|
|
51
91
|
...extraDefaults,
|
|
52
92
|
// defaultName takes priority over extraDefaults.name if provided
|
|
@@ -54,6 +94,26 @@ export function CreateEntityForm({
|
|
|
54
94
|
},
|
|
55
95
|
});
|
|
56
96
|
|
|
97
|
+
// Watch country field — clear activeCountryCode when user edits away from auto-filled value
|
|
98
|
+
const countryValue = form.watch("country");
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (countryValue !== autoFilledCountryRef.current) {
|
|
101
|
+
setActiveCountryCode(undefined);
|
|
102
|
+
} else {
|
|
103
|
+
setActiveCountryCode(countryCode);
|
|
104
|
+
}
|
|
105
|
+
}, [countryValue, countryCode]);
|
|
106
|
+
|
|
107
|
+
const handleCompanySelect = (company: CompanyRegistryResult) => {
|
|
108
|
+
form.setValue("name", company.name);
|
|
109
|
+
if (company.address) form.setValue("address", company.address);
|
|
110
|
+
if (company.post_code) form.setValue("post_code", company.post_code);
|
|
111
|
+
if (company.city) form.setValue("city", company.city);
|
|
112
|
+
if (company.tax_number) form.setValue("tax_number", company.tax_number);
|
|
113
|
+
if (company.registration_number) form.setValue("company_number", company.registration_number);
|
|
114
|
+
setNameSearch("");
|
|
115
|
+
};
|
|
116
|
+
|
|
57
117
|
// Wrap onSuccess to reset form only after successful mutation
|
|
58
118
|
const handleSuccess = (data: Entity) => {
|
|
59
119
|
form.reset();
|
|
@@ -84,30 +144,122 @@ export function CreateEntityForm({
|
|
|
84
144
|
}
|
|
85
145
|
};
|
|
86
146
|
|
|
147
|
+
const nameValue = form.watch("name");
|
|
148
|
+
|
|
87
149
|
return (
|
|
88
150
|
<Form {...form}>
|
|
89
151
|
<form onSubmit={form.handleSubmit(onSubmit as any)} className="space-y-4">
|
|
90
|
-
|
|
152
|
+
{showAutocomplete ? (
|
|
153
|
+
<FormField
|
|
154
|
+
control={form.control}
|
|
155
|
+
name="name"
|
|
156
|
+
render={({ field }) => (
|
|
157
|
+
<FormItem>
|
|
158
|
+
<FormLabel>
|
|
159
|
+
{translate("name")}
|
|
160
|
+
<span className="ml-1 text-red-500">*</span>
|
|
161
|
+
</FormLabel>
|
|
162
|
+
<FormControl>
|
|
163
|
+
<Autocomplete
|
|
164
|
+
searchValue={nameSearch}
|
|
165
|
+
onSearch={(v) => {
|
|
166
|
+
setNameSearch(v);
|
|
167
|
+
field.onChange(v || undefined);
|
|
168
|
+
}}
|
|
169
|
+
displayValue={nameValue || ""}
|
|
170
|
+
options={nameOptions}
|
|
171
|
+
onValueChange={(selectedId) => {
|
|
172
|
+
const option = nameOptions.find((o) => o.value === selectedId);
|
|
173
|
+
if (option?.company) {
|
|
174
|
+
handleCompanySelect(option.company);
|
|
175
|
+
}
|
|
176
|
+
}}
|
|
177
|
+
onBlur={() => {
|
|
178
|
+
setNameSearch("");
|
|
179
|
+
}}
|
|
180
|
+
placeholder={translate("name")}
|
|
181
|
+
loading={isSearching}
|
|
182
|
+
emptyText={nameSearch.length < 2 ? translate("search-hint") : translate("no-results")}
|
|
183
|
+
/>
|
|
184
|
+
</FormControl>
|
|
185
|
+
<FormMessage />
|
|
186
|
+
</FormItem>
|
|
187
|
+
)}
|
|
188
|
+
/>
|
|
189
|
+
) : (
|
|
190
|
+
<FormInput
|
|
191
|
+
control={form.control}
|
|
192
|
+
name="name"
|
|
193
|
+
label={translate("name")}
|
|
194
|
+
placeholder={translate("name")}
|
|
195
|
+
required
|
|
196
|
+
/>
|
|
197
|
+
)}
|
|
91
198
|
|
|
92
|
-
<FormInput
|
|
199
|
+
<FormInput
|
|
200
|
+
control={form.control}
|
|
201
|
+
name="country"
|
|
202
|
+
label={translate("country")}
|
|
203
|
+
placeholder={translate("country")}
|
|
204
|
+
required
|
|
205
|
+
/>
|
|
93
206
|
|
|
94
|
-
<FormInput
|
|
207
|
+
<FormInput
|
|
208
|
+
control={form.control}
|
|
209
|
+
name="address"
|
|
210
|
+
label={translate("address")}
|
|
211
|
+
placeholder={translate("address")}
|
|
212
|
+
/>
|
|
95
213
|
|
|
96
|
-
<FormInput
|
|
214
|
+
<FormInput
|
|
215
|
+
control={form.control}
|
|
216
|
+
name="address_2"
|
|
217
|
+
label={translate("address-2")}
|
|
218
|
+
placeholder={translate("address-2")}
|
|
219
|
+
/>
|
|
97
220
|
|
|
98
221
|
<div className="grid grid-cols-2 gap-4">
|
|
99
|
-
<FormInput
|
|
100
|
-
|
|
222
|
+
<FormInput
|
|
223
|
+
control={form.control}
|
|
224
|
+
name="post_code"
|
|
225
|
+
label={translate("post-code")}
|
|
226
|
+
placeholder={translate("post-code")}
|
|
227
|
+
/>
|
|
228
|
+
<FormInput control={form.control} name="city" label={translate("city")} placeholder={translate("city")} />
|
|
101
229
|
</div>
|
|
102
230
|
|
|
103
|
-
<FormInput control={form.control} name="state" label="
|
|
231
|
+
<FormInput control={form.control} name="state" label={translate("state")} placeholder={translate("state")} />
|
|
104
232
|
|
|
105
|
-
<
|
|
233
|
+
<div className="grid grid-cols-[1fr_auto] items-end gap-4">
|
|
234
|
+
<FormInput
|
|
235
|
+
control={form.control}
|
|
236
|
+
name="tax_number"
|
|
237
|
+
label={translate("tax-number")}
|
|
238
|
+
placeholder={translate("tax-number")}
|
|
239
|
+
/>
|
|
240
|
+
<FormField
|
|
241
|
+
control={form.control}
|
|
242
|
+
name="is_tax_subject"
|
|
243
|
+
render={({ field }) => (
|
|
244
|
+
<FormItem className="flex flex-row items-center space-x-2 space-y-0 pb-2">
|
|
245
|
+
<FormControl>
|
|
246
|
+
<Checkbox checked={field.value} onCheckedChange={field.onChange} />
|
|
247
|
+
</FormControl>
|
|
248
|
+
<FormLabel className="font-normal">{translate("is-tax-subject")}</FormLabel>
|
|
249
|
+
</FormItem>
|
|
250
|
+
)}
|
|
251
|
+
/>
|
|
252
|
+
</div>
|
|
106
253
|
|
|
107
|
-
<FormInput
|
|
254
|
+
<FormInput
|
|
255
|
+
control={form.control}
|
|
256
|
+
name="company_number"
|
|
257
|
+
label={translate("company-number")}
|
|
258
|
+
placeholder={translate("company-number")}
|
|
259
|
+
/>
|
|
108
260
|
|
|
109
261
|
<Button type="submit" className="w-full cursor-pointer" disabled={isPending} aria-busy={isPending}>
|
|
110
|
-
{isPending ? <ButtonLoader /> : "
|
|
262
|
+
{isPending ? <ButtonLoader /> : translate("submit")}
|
|
111
263
|
</Button>
|
|
112
264
|
</form>
|
|
113
265
|
</Form>
|