@fast-white-cat/integration-ksef-direct 0.1.0
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/README.md +36 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/integration_ksef_direct/acl.js +13 -0
- package/dist/modules/integration_ksef_direct/acl.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/documents/[id].js +92 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/documents/[id].js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/documents.js +105 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/documents.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/health.js +158 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/health.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/received-documents/[id].js +86 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/received-documents/[id].js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/received-documents.js +112 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/received-documents.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/seller-info.js +54 -0
- package/dist/modules/integration_ksef_direct/api/get/integration-ksef-direct/seller-info.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/documents/[id]/send.js +64 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/documents/[id]/send.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/documents.js +104 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/documents.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/invoice-numbers.js +41 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/invoice-numbers.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/received-documents/fetch.js +172 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/received-documents/fetch.js.map +7 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/received-documents/sync.js +80 -0
- package/dist/modules/integration_ksef_direct/api/post/integration-ksef-direct/received-documents/sync.js.map +7 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/new/page.js +441 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/new/page.js.map +7 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/new/page.meta.js +8 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/new/page.meta.js.map +7 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/page.js +193 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/page.js.map +7 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/received-documents/page.js +314 -0
- package/dist/modules/integration_ksef_direct/backend/integration-ksef-direct/received-documents/page.js.map +7 -0
- package/dist/modules/integration_ksef_direct/backend/page.js +154 -0
- package/dist/modules/integration_ksef_direct/backend/page.js.map +7 -0
- package/dist/modules/integration_ksef_direct/commands/create-ksef-direct-document.js +80 -0
- package/dist/modules/integration_ksef_direct/commands/create-ksef-direct-document.js.map +7 -0
- package/dist/modules/integration_ksef_direct/commands/enqueue-ksef-direct-document.js +43 -0
- package/dist/modules/integration_ksef_direct/commands/enqueue-ksef-direct-document.js.map +7 -0
- package/dist/modules/integration_ksef_direct/data/entities.js +224 -0
- package/dist/modules/integration_ksef_direct/data/entities.js.map +7 -0
- package/dist/modules/integration_ksef_direct/data/validators.js +103 -0
- package/dist/modules/integration_ksef_direct/data/validators.js.map +7 -0
- package/dist/modules/integration_ksef_direct/di.js +11 -0
- package/dist/modules/integration_ksef_direct/di.js.map +7 -0
- package/dist/modules/integration_ksef_direct/events.js +21 -0
- package/dist/modules/integration_ksef_direct/events.js.map +7 -0
- package/dist/modules/integration_ksef_direct/index.js +10 -0
- package/dist/modules/integration_ksef_direct/index.js.map +7 -0
- package/dist/modules/integration_ksef_direct/integration.js +56 -0
- package/dist/modules/integration_ksef_direct/integration.js.map +7 -0
- package/dist/modules/integration_ksef_direct/lib/health.js +32 -0
- package/dist/modules/integration_ksef_direct/lib/health.js.map +7 -0
- package/dist/modules/integration_ksef_direct/lib/invoiceNumberFormat.js +23 -0
- package/dist/modules/integration_ksef_direct/lib/invoiceNumberFormat.js.map +7 -0
- package/dist/modules/integration_ksef_direct/lib/ksefClient.js +523 -0
- package/dist/modules/integration_ksef_direct/lib/ksefClient.js.map +7 -0
- package/dist/modules/integration_ksef_direct/lib/ksefCrypto.js +103 -0
- package/dist/modules/integration_ksef_direct/lib/ksefCrypto.js.map +7 -0
- package/dist/modules/integration_ksef_direct/lib/ksefFa2Xml.js +123 -0
- package/dist/modules/integration_ksef_direct/lib/ksefFa2Xml.js.map +7 -0
- package/dist/modules/integration_ksef_direct/lib/ksefXmlParser.js +76 -0
- package/dist/modules/integration_ksef_direct/lib/ksefXmlParser.js.map +7 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260519210000_integration_ksef_direct.js +15 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260519210000_integration_ksef_direct.js.map +7 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260520120000_ksef_direct_documents.js +17 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260520120000_ksef_direct_documents.js.map +7 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260520220000_ksef_direct_send_queue.js +15 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260520220000_ksef_direct_send_queue.js.map +7 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260520230000_ksef_direct_seller_per_document.js +17 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260520230000_ksef_direct_seller_per_document.js.map +7 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260521120000_ksef_direct_received_documents.js +16 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260521120000_ksef_direct_received_documents.js.map +7 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260521130000_ksef_received_download_urls.js +15 -0
- package/dist/modules/integration_ksef_direct/migrations/Migration20260521130000_ksef_received_download_urls.js.map +7 -0
- package/dist/modules/integration_ksef_direct/setup.js +11 -0
- package/dist/modules/integration_ksef_direct/setup.js.map +7 -0
- package/dist/modules/integration_ksef_direct/subscribers/auto-enqueue-ksef-document.js +19 -0
- package/dist/modules/integration_ksef_direct/subscribers/auto-enqueue-ksef-document.js.map +7 -0
- package/dist/modules/integration_ksef_direct/workers/check-ksef-document-status.js +103 -0
- package/dist/modules/integration_ksef_direct/workers/check-ksef-document-status.js.map +7 -0
- package/dist/modules/integration_ksef_direct/workers/send-ksef-document.js +104 -0
- package/dist/modules/integration_ksef_direct/workers/send-ksef-document.js.map +7 -0
- package/dist/modules/integration_ksef_direct/workers/sync-received-documents.js +137 -0
- package/dist/modules/integration_ksef_direct/workers/sync-received-documents.js.map +7 -0
- package/dist/types/declarations.d.js +1 -0
- package/dist/types/declarations.d.js.map +7 -0
- package/package.json +98 -0
- package/src/index.ts +1 -0
- package/src/modules/integration_ksef_direct/__tests__/invoiceNumberFormat.test.ts +42 -0
- package/src/modules/integration_ksef_direct/__tests__/ksefFa2Xml.test.ts +407 -0
- package/src/modules/integration_ksef_direct/__tests__/ksefXmlParser.test.ts +230 -0
- package/src/modules/integration_ksef_direct/acl.ts +9 -0
- package/src/modules/integration_ksef_direct/api/get/integration-ksef-direct/documents/[id].ts +94 -0
- package/src/modules/integration_ksef_direct/api/get/integration-ksef-direct/documents.ts +111 -0
- package/src/modules/integration_ksef_direct/api/get/integration-ksef-direct/health.ts +194 -0
- package/src/modules/integration_ksef_direct/api/get/integration-ksef-direct/received-documents/[id].ts +88 -0
- package/src/modules/integration_ksef_direct/api/get/integration-ksef-direct/received-documents.ts +119 -0
- package/src/modules/integration_ksef_direct/api/get/integration-ksef-direct/seller-info.ts +62 -0
- package/src/modules/integration_ksef_direct/api/post/integration-ksef-direct/documents/[id]/send.ts +64 -0
- package/src/modules/integration_ksef_direct/api/post/integration-ksef-direct/documents.ts +109 -0
- package/src/modules/integration_ksef_direct/api/post/integration-ksef-direct/invoice-numbers.ts +40 -0
- package/src/modules/integration_ksef_direct/api/post/integration-ksef-direct/received-documents/fetch.ts +185 -0
- package/src/modules/integration_ksef_direct/api/post/integration-ksef-direct/received-documents/sync.ts +86 -0
- package/src/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/new/page.meta.ts +4 -0
- package/src/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/new/page.tsx +470 -0
- package/src/modules/integration_ksef_direct/backend/integration-ksef-direct/documents/page.tsx +233 -0
- package/src/modules/integration_ksef_direct/backend/integration-ksef-direct/received-documents/page.tsx +415 -0
- package/src/modules/integration_ksef_direct/backend/page.tsx +183 -0
- package/src/modules/integration_ksef_direct/commands/create-ksef-direct-document.ts +93 -0
- package/src/modules/integration_ksef_direct/commands/enqueue-ksef-direct-document.ts +57 -0
- package/src/modules/integration_ksef_direct/data/entities.ts +195 -0
- package/src/modules/integration_ksef_direct/data/validators.ts +115 -0
- package/src/modules/integration_ksef_direct/di.ts +9 -0
- package/src/modules/integration_ksef_direct/events.ts +18 -0
- package/src/modules/integration_ksef_direct/i18n/en.json +115 -0
- package/src/modules/integration_ksef_direct/i18n/pl.json +115 -0
- package/src/modules/integration_ksef_direct/index.ts +6 -0
- package/src/modules/integration_ksef_direct/integration.ts +54 -0
- package/src/modules/integration_ksef_direct/lib/health.ts +43 -0
- package/src/modules/integration_ksef_direct/lib/invoiceNumberFormat.ts +23 -0
- package/src/modules/integration_ksef_direct/lib/ksefClient.ts +668 -0
- package/src/modules/integration_ksef_direct/lib/ksefCrypto.ts +138 -0
- package/src/modules/integration_ksef_direct/lib/ksefFa2Xml.ts +147 -0
- package/src/modules/integration_ksef_direct/lib/ksefXmlParser.ts +97 -0
- package/src/modules/integration_ksef_direct/migrations/.snapshot-open-mercato.json +1028 -0
- package/src/modules/integration_ksef_direct/migrations/Migration20260519210000_integration_ksef_direct.ts +15 -0
- package/src/modules/integration_ksef_direct/migrations/Migration20260520120000_ksef_direct_documents.ts +17 -0
- package/src/modules/integration_ksef_direct/migrations/Migration20260520220000_ksef_direct_send_queue.ts +15 -0
- package/src/modules/integration_ksef_direct/migrations/Migration20260520230000_ksef_direct_seller_per_document.ts +17 -0
- package/src/modules/integration_ksef_direct/migrations/Migration20260521120000_ksef_direct_received_documents.ts +16 -0
- package/src/modules/integration_ksef_direct/migrations/Migration20260521130000_ksef_received_download_urls.ts +15 -0
- package/src/modules/integration_ksef_direct/setup.ts +9 -0
- package/src/modules/integration_ksef_direct/subscribers/auto-enqueue-ksef-document.ts +21 -0
- package/src/modules/integration_ksef_direct/workers/check-ksef-document-status.ts +129 -0
- package/src/modules/integration_ksef_direct/workers/send-ksef-document.ts +137 -0
- package/src/modules/integration_ksef_direct/workers/sync-received-documents.ts +171 -0
- package/src/types/declarations.d.ts +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/integration_ksef_direct/backend/integration-ksef-direct/received-documents/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Copy, Search } from 'lucide-react'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { StatusBadge } from '@open-mercato/ui/primitives/status-badge'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@open-mercato/ui/primitives/dialog'\nimport { FormField } from '@open-mercato/ui/primitives/form-field'\nimport { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\n\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport const pageMetadata = {\n requireAuth: true,\n requireFeatures: ['integration_ksef_direct.received_documents.view'],\n pageTitleKey: 'integration_ksef_direct.received_documents.title',\n}\n\nconst PAGE_SIZE = 50\n\ntype ReceivedDocumentRow = {\n id: string\n ksefReferenceNumber: string\n invoiceNumber: string | null\n sellerNip: string | null\n sellerName: string | null\n issueDate: string | null\n currency: string | null\n grossAmount: string | null\n status: string\n errorMessage: string | null\n syncedAt: string | null\n createdAt: string\n}\n\ntype ReceivedDocumentDetail = ReceivedDocumentRow & {\n netAmount: string | null\n vatAmount: string | null\n rawXml: string | null\n updatedAt: string\n}\n\ntype ApiResponse = {\n items: ReceivedDocumentRow[]\n total: number\n page: number\n pageSize: number\n}\n\nconst STATUS_VARIANT: Record<string, 'warning' | 'success' | 'error'> = {\n pending_download: 'warning',\n downloaded: 'success',\n failed: 'error',\n}\n\n// \u2500\u2500\u2500 Detail Modal \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction DetailModal({\n documentId,\n onClose,\n}: {\n documentId: string\n onClose: () => void\n}) {\n const t = useT()\n const [doc, setDoc] = React.useState<ReceivedDocumentDetail | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [copied, setCopied] = React.useState(false)\n\n React.useEffect(() => {\n let cancelled = false\n setLoading(true)\n apiCall<ReceivedDocumentDetail>(`/api/integration-ksef-direct/received-documents/${documentId}`)\n .then((res) => {\n if (!cancelled && res.ok && res.result) setDoc(res.result)\n })\n .catch(() => {})\n .finally(() => { if (!cancelled) setLoading(false) })\n return () => { cancelled = true }\n }, [documentId])\n\n React.useEffect(() => {\n const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() }\n window.addEventListener('keydown', handler)\n return () => window.removeEventListener('keydown', handler)\n }, [onClose])\n\n async function handleCopy() {\n if (!doc?.rawXml) return\n try {\n await navigator.clipboard.writeText(doc.rawXml)\n setCopied(true)\n setTimeout(() => setCopied(false), 2000)\n } catch {}\n }\n\n return (\n <Dialog open onOpenChange={(open: boolean) => { if (!open) onClose() }}>\n <DialogContent className=\"max-w-3xl max-h-[90vh] flex flex-col\">\n <DialogHeader>\n <DialogTitle>\n {doc?.invoiceNumber ?? doc?.ksefReferenceNumber ?? t('integration_ksef_direct.received_documents.title', 'Received Document')}\n </DialogTitle>\n </DialogHeader>\n\n {loading && (\n <p className=\"text-sm text-muted-foreground py-4\">\n {t('integration_ksef_direct.received_documents.loading', 'Loading...')}\n </p>\n )}\n\n {doc && !loading && (\n <div className=\"flex flex-col gap-4 overflow-y-auto\">\n <dl className=\"grid grid-cols-2 gap-x-6 gap-y-2 text-sm\">\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.ksef_reference', 'KSeF Ref.')}</dt>\n <dd className=\"font-mono break-all\">{doc.ksefReferenceNumber}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.invoice_number', 'Invoice No.')}</dt>\n <dd>{doc.invoiceNumber ?? '\u2014'}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.seller_nip', 'Seller NIP')}</dt>\n <dd>{doc.sellerNip ?? '\u2014'}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.seller_name', 'Seller')}</dt>\n <dd>{doc.sellerName ?? '\u2014'}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.issue_date', 'Issue Date')}</dt>\n <dd>{doc.issueDate ?? '\u2014'}</dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.gross_amount', 'Gross Amount')}</dt>\n <dd>\n {doc.grossAmount != null\n ? `${parseFloat(doc.grossAmount).toLocaleString('pl-PL', { minimumFractionDigits: 2 })} ${doc.currency ?? 'PLN'}`\n : '\u2014'}\n </dd>\n </div>\n <div>\n <dt className=\"text-muted-foreground\">{t('integration_ksef_direct.received_documents.column.status', 'Status')}</dt>\n <dd>\n <StatusBadge variant={STATUS_VARIANT[doc.status] ?? 'warning'}>\n {t(`integration_ksef_direct.received_documents.status.${doc.status}`, doc.status)}\n </StatusBadge>\n </dd>\n </div>\n {doc.errorMessage && (\n <div className=\"col-span-2\">\n <dt className=\"text-muted-foreground\">Error</dt>\n <dd className=\"text-status-destructive-text\">{doc.errorMessage}</dd>\n </div>\n )}\n </dl>\n\n {doc.rawXml && (\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium\">XML</span>\n <Button size=\"sm\" variant=\"ghost\" onClick={handleCopy} aria-label=\"Copy XML\">\n <Copy className=\"size-4 mr-1\" />\n {copied\n ? t('integration_ksef_direct.received_documents.xml_copied', 'Copied')\n : t('integration_ksef_direct.received_documents.copy_xml', 'Copy XML')}\n </Button>\n </div>\n <pre className=\"text-xs font-mono bg-muted rounded p-3 overflow-auto max-h-64 whitespace-pre-wrap break-all\">\n {doc.rawXml}\n </pre>\n </div>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n )\n}\n\n// \u2500\u2500\u2500 Fetch Dialog \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction FetchDialog({ onClose, onSuccess }: { onClose: () => void; onSuccess: () => void }) {\n const t = useT()\n const [reference, setReference] = React.useState('')\n const [error, setError] = React.useState<string | null>(null)\n const [isSubmitting, setSubmitting] = React.useState(false)\n\n const { runMutation } = useGuardedMutation<{ entityType: string }>({\n contextId: 'integration_ksef_direct:fetch-received-document',\n })\n\n React.useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose()\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') void handleSubmit()\n }\n window.addEventListener('keydown', handler)\n return () => window.removeEventListener('keydown', handler)\n })\n\n async function handleSubmit() {\n setError(null)\n setSubmitting(true)\n try {\n await runMutation({\n operation: async () => {\n const result = await apiCall('/api/integration-ksef-direct/received-documents/fetch', {\n method: 'POST',\n body: JSON.stringify({ ksefReferenceNumber: reference }),\n })\n if (!result.ok) {\n const body = result.result as Record<string, unknown>\n throw new Error(typeof body?.error === 'string' ? body.error : 'Error')\n }\n return result.result\n },\n context: { entityType: 'integration_ksef_direct.received_document' },\n mutationPayload: { entityType: 'integration_ksef_direct.received_document' },\n })\n flash(t('integration_ksef_direct.received_documents.fetch_success', 'Document fetched successfully.'), 'success')\n onClose()\n onSuccess()\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Error')\n } finally {\n setSubmitting(false)\n }\n }\n\n return (\n <Dialog open onOpenChange={(open: boolean) => { if (!open) onClose() }}>\n <DialogContent className=\"max-w-md\">\n <DialogHeader>\n <DialogTitle>{t('integration_ksef_direct.received_documents.dialog_fetch.title', 'Fetch Document by KSeF Reference')}</DialogTitle>\n </DialogHeader>\n\n <div className=\"flex flex-col gap-4\">\n {error && (\n <Alert variant=\"destructive\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n )}\n <FormField label={t('integration_ksef_direct.received_documents.column.ksef_reference', 'KSeF Reference Number')} required>\n <Input\n value={reference}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setReference(e.target.value)}\n placeholder=\"e.g. 1234567890...\"\n className=\"font-mono\"\n />\n </FormField>\n </div>\n\n <DialogFooter>\n <Button variant=\"outline\" onClick={onClose} type=\"button\">\n {t('integration_ksef_direct.received_documents.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSubmit} disabled={isSubmitting || !reference.trim()} type=\"button\">\n {t('integration_ksef_direct.received_documents.dialog_fetch.submit', 'Fetch')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n\n// \u2500\u2500\u2500 Main Page \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport default function ReceivedDocumentsPage() {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const [rows, setRows] = React.useState<ReceivedDocumentRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [isLoading, setLoading] = React.useState(false)\n const [fetchDialogOpen, setFetchDialogOpen] = React.useState(false)\n const [detailId, setDetailId] = React.useState<string | null>(null)\n\n const fetchData = React.useCallback(async () => {\n setLoading(true)\n try {\n const result = await apiCall<ApiResponse>(\n `/api/integration-ksef-direct/received-documents?page=${page}&pageSize=${PAGE_SIZE}`,\n )\n if (result.ok && result.result) {\n setRows(result.result.items)\n setTotal(result.result.total)\n setTotalPages(Math.max(1, Math.ceil(result.result.total / PAGE_SIZE)))\n } else {\n setRows([])\n setTotal(0)\n setTotalPages(1)\n }\n } catch {\n setRows([])\n setTotal(0)\n setTotalPages(1)\n } finally {\n setLoading(false)\n }\n }, [page])\n\n React.useEffect(() => { void fetchData() }, [fetchData, scopeVersion])\n\n const columns = React.useMemo<ColumnDef<ReceivedDocumentRow, unknown>[]>(() => [\n {\n id: 'sellerNip',\n accessorKey: 'sellerNip',\n header: t('integration_ksef_direct.received_documents.column.seller_nip', 'Seller NIP'),\n cell: ({ row }) => row.original.sellerNip ?? '\u2014',\n },\n {\n id: 'sellerName',\n accessorKey: 'sellerName',\n header: t('integration_ksef_direct.received_documents.column.seller_name', 'Seller'),\n cell: ({ row }) => row.original.sellerName ?? '\u2014',\n },\n {\n id: 'invoiceNumber',\n accessorKey: 'invoiceNumber',\n header: t('integration_ksef_direct.received_documents.column.invoice_number', 'Invoice No.'),\n cell: ({ row }) => row.original.invoiceNumber ?? '\u2014',\n },\n {\n id: 'issueDate',\n accessorKey: 'issueDate',\n header: t('integration_ksef_direct.received_documents.column.issue_date', 'Issue Date'),\n cell: ({ row }) => row.original.issueDate ?? '\u2014',\n },\n {\n id: 'grossAmount',\n header: t('integration_ksef_direct.received_documents.column.gross_amount', 'Gross Amount'),\n cell: ({ row }) => row.original.grossAmount != null\n ? (\n <span className=\"tabular-nums\">\n {parseFloat(row.original.grossAmount).toLocaleString('pl-PL', { minimumFractionDigits: 2 })}{' '}\n {row.original.currency ?? 'PLN'}\n </span>\n )\n : '\u2014',\n },\n {\n id: 'status',\n accessorKey: 'status',\n header: t('integration_ksef_direct.received_documents.column.status', 'Status'),\n cell: ({ row }) => (\n <StatusBadge variant={STATUS_VARIANT[row.original.status] ?? 'warning'}>\n {t(`integration_ksef_direct.received_documents.status.${row.original.status}`, row.original.status)}\n </StatusBadge>\n ),\n },\n {\n id: 'ksefReferenceNumber',\n accessorKey: 'ksefReferenceNumber',\n header: t('integration_ksef_direct.received_documents.column.ksef_reference', 'KSeF Ref.'),\n cell: ({ row }) => (\n <span className=\"font-mono text-sm truncate max-w-48 block\" title={row.original.ksefReferenceNumber}>\n {row.original.ksefReferenceNumber}\n </span>\n ),\n },\n ], [t])\n\n const toolbar = (\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => setFetchDialogOpen(true)}\n >\n <Search className=\"size-4 mr-2\" />\n {t('integration_ksef_direct.received_documents.fetch_button', 'Fetch by reference')}\n </Button>\n )\n\n return (\n <Page>\n <PageBody>\n <DataTable<ReceivedDocumentRow>\n entityId=\"ksef_direct_received_document\"\n columns={columns}\n data={rows}\n isLoading={isLoading}\n actions={toolbar}\n emptyState={t('integration_ksef_direct.received_documents.empty', 'No received documents found.')}\n pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, onPageChange: setPage }}\n onRowClick={(row) => setDetailId(row.id)}\n />\n </PageBody>\n\n {fetchDialogOpen && (\n <FetchDialog\n onClose={() => setFetchDialogOpen(false)}\n onSuccess={() => void fetchData()}\n />\n )}\n\n {detailId && (\n <DetailModal\n documentId={detailId}\n onClose={() => setDetailId(null)}\n />\n )}\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA4GU,cAcI,YAdJ;AA1GV,YAAY,WAAW;AACvB,SAAS,MAAM,cAAc;AAC7B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAE1B,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,QAAQ,eAAe,cAAc,aAAa,oBAAoB;AAC/E,SAAS,iBAAiB;AAC1B,SAAS,OAAO,wBAAwB;AACxC,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,0BAA0B;AAEnC,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AAEd,MAAM,eAAe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AC;AAAA;AAAA,QACC,SAAS,MAAM,mBAAmB,KAAK;AAAA,QACvC,WAAW,MAAM,KAAK,UAAU;AAAA;AAAA,IAClC;AAAA,IAGD,YACC;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ,SAAS,MAAM,YAAY,IAAI;AAAA;AAAA,IACjC;AAAA,KAEJ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { FileText, Inbox } from "lucide-react";
|
|
6
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
7
|
+
import { SectionHeader } from "@open-mercato/ui/backend/SectionHeader";
|
|
8
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
9
|
+
import { StatusBadge } from "@open-mercato/ui/primitives/status-badge";
|
|
10
|
+
import { LoadingMessage, ErrorMessage } from "@open-mercato/ui/backend/detail";
|
|
11
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
12
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
13
|
+
import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
14
|
+
const pageMetadata = {
|
|
15
|
+
requireAuth: true,
|
|
16
|
+
requireFeatures: ["integration_ksef_direct.manage"]
|
|
17
|
+
};
|
|
18
|
+
function KsefDirectPage() {
|
|
19
|
+
const t = useT();
|
|
20
|
+
const scopeVersion = useOrganizationScopeVersion();
|
|
21
|
+
const [state, setState] = React.useState(null);
|
|
22
|
+
const [isLoading, setLoading] = React.useState(false);
|
|
23
|
+
const [isChecking, setChecking] = React.useState(false);
|
|
24
|
+
const [fetchError, setFetchError] = React.useState(null);
|
|
25
|
+
const fetchStatus = React.useCallback(async () => {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
setFetchError(null);
|
|
28
|
+
try {
|
|
29
|
+
const result = await apiCall("/api/integration-ksef-direct/health");
|
|
30
|
+
if (result.ok && result.result) {
|
|
31
|
+
setState(result.result);
|
|
32
|
+
} else {
|
|
33
|
+
setFetchError("Failed to load connection status");
|
|
34
|
+
}
|
|
35
|
+
} catch {
|
|
36
|
+
setFetchError("Failed to load connection status");
|
|
37
|
+
} finally {
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
fetchStatus();
|
|
43
|
+
}, [fetchStatus, scopeVersion]);
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
const handleKeyDown = (e) => {
|
|
46
|
+
if (e.key === "Escape") {
|
|
47
|
+
window.history.back();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
51
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
52
|
+
}, []);
|
|
53
|
+
async function handleCheckConnection() {
|
|
54
|
+
setChecking(true);
|
|
55
|
+
try {
|
|
56
|
+
const result = await apiCall("/api/integration-ksef-direct/health");
|
|
57
|
+
if (result.ok && result.result) {
|
|
58
|
+
setState(result.result);
|
|
59
|
+
}
|
|
60
|
+
} finally {
|
|
61
|
+
setChecking(false);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getStatusVariant(status) {
|
|
65
|
+
switch (status) {
|
|
66
|
+
case "connected":
|
|
67
|
+
return "success";
|
|
68
|
+
case "error":
|
|
69
|
+
return "error";
|
|
70
|
+
case "checking":
|
|
71
|
+
return "warning";
|
|
72
|
+
default:
|
|
73
|
+
return "neutral";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function getStatusLabel(status) {
|
|
77
|
+
switch (status) {
|
|
78
|
+
case "connected":
|
|
79
|
+
return t("integration_ksef_direct.health.connected", "Connected");
|
|
80
|
+
case "error":
|
|
81
|
+
return t("integration_ksef_direct.health.error", "Connection error");
|
|
82
|
+
case "checking":
|
|
83
|
+
return t("integration_ksef_direct.health.checking", "Checking...");
|
|
84
|
+
default:
|
|
85
|
+
return t("integration_ksef_direct.health.unconfigured", "Not configured");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsxs(PageBody, { children: [
|
|
89
|
+
/* @__PURE__ */ jsx(SectionHeader, { title: t("integration_ksef_direct.title", "KSeF Direct Integration") }),
|
|
90
|
+
isLoading && !state && /* @__PURE__ */ jsx(LoadingMessage, { label: t("integration_ksef_direct.health.loading", "Loading...") }),
|
|
91
|
+
fetchError && !isLoading && /* @__PURE__ */ jsx(ErrorMessage, { label: fetchError }),
|
|
92
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 mt-2 mb-6", children: [
|
|
93
|
+
/* @__PURE__ */ jsx(Link, { href: "/backend/integration-ksef-direct/documents", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-lg border border-border p-4 hover:bg-muted/50 transition-colors cursor-pointer", children: [
|
|
94
|
+
/* @__PURE__ */ jsx(FileText, { className: "h-5 w-5 text-muted-foreground shrink-0" }),
|
|
95
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
96
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: t("integration_ksef_direct.nav.documents", "Sent Documents") }),
|
|
97
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("integration_ksef_direct.nav.documents_desc", "Outgoing invoices sent to KSeF") })
|
|
98
|
+
] })
|
|
99
|
+
] }) }),
|
|
100
|
+
/* @__PURE__ */ jsx(Link, { href: "/backend/integration-ksef-direct/received-documents", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-lg border border-border p-4 hover:bg-muted/50 transition-colors cursor-pointer", children: [
|
|
101
|
+
/* @__PURE__ */ jsx(Inbox, { className: "h-5 w-5 text-muted-foreground shrink-0" }),
|
|
102
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
103
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: t("integration_ksef_direct.nav.received_documents", "Received Documents") }),
|
|
104
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("integration_ksef_direct.nav.received_documents_desc", "Invoices received from KSeF") })
|
|
105
|
+
] })
|
|
106
|
+
] }) })
|
|
107
|
+
] }),
|
|
108
|
+
state && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
110
|
+
/* @__PURE__ */ jsx(StatusBadge, { variant: getStatusVariant(state.status), children: getStatusLabel(state.status) }),
|
|
111
|
+
state.environment && /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
|
|
112
|
+
t("integration_ksef_direct.health.environment", "Environment:"),
|
|
113
|
+
" ",
|
|
114
|
+
/* @__PURE__ */ jsx("strong", { children: state.environment.toUpperCase() })
|
|
115
|
+
] })
|
|
116
|
+
] }),
|
|
117
|
+
state.lastCheckedAt && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
118
|
+
t("integration_ksef_direct.health.last_checked", "Last check:"),
|
|
119
|
+
" ",
|
|
120
|
+
new Date(state.lastCheckedAt).toLocaleString()
|
|
121
|
+
] }),
|
|
122
|
+
state.status === "connected" && state.rateLimits && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
123
|
+
t("integration_ksef_direct.health.rate_limits", "Rate limits:"),
|
|
124
|
+
" ",
|
|
125
|
+
[
|
|
126
|
+
state.rateLimits.otherPerSecond != null && `${state.rateLimits.otherPerSecond} req/s`,
|
|
127
|
+
state.rateLimits.otherPerMinute != null && `${state.rateLimits.otherPerMinute} req/min`
|
|
128
|
+
].filter(Boolean).join(" \xB7 ")
|
|
129
|
+
] }),
|
|
130
|
+
state.status === "error" && state.error && /* @__PURE__ */ jsx(
|
|
131
|
+
ErrorMessage,
|
|
132
|
+
{
|
|
133
|
+
label: state.error,
|
|
134
|
+
description: state.errorCode
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end pt-2", children: /* @__PURE__ */ jsx(
|
|
138
|
+
Button,
|
|
139
|
+
{
|
|
140
|
+
type: "button",
|
|
141
|
+
onClick: handleCheckConnection,
|
|
142
|
+
disabled: isChecking,
|
|
143
|
+
variant: "outline",
|
|
144
|
+
children: isChecking ? t("integration_ksef_direct.health.checking", "Checking...") : t("integration_ksef_direct.health.check_button", "Check connection")
|
|
145
|
+
}
|
|
146
|
+
) })
|
|
147
|
+
] })
|
|
148
|
+
] }) });
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
KsefDirectPage as default,
|
|
152
|
+
pageMetadata
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/integration_ksef_direct/backend/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { FileText, Inbox } from 'lucide-react'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { SectionHeader } from '@open-mercato/ui/backend/SectionHeader'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { StatusBadge } from '@open-mercato/ui/primitives/status-badge'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\n\nexport const pageMetadata = {\n requireAuth: true,\n requireFeatures: ['integration_ksef_direct.manage'],\n}\n\ntype HealthStatus = 'unconfigured' | 'checking' | 'connected' | 'error'\n\ntype ConnectionState = {\n status: HealthStatus\n lastCheckedAt: string | null\n environment?: 'test' | 'production'\n rateLimits?: { otherPerSecond?: number; otherPerMinute?: number }\n error?: string\n errorCode?: string\n}\n\nexport default function KsefDirectPage() {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const [state, setState] = React.useState<ConnectionState | null>(null)\n const [isLoading, setLoading] = React.useState(false)\n const [isChecking, setChecking] = React.useState(false)\n const [fetchError, setFetchError] = React.useState<string | null>(null)\n\n const fetchStatus = React.useCallback(async () => {\n setLoading(true)\n setFetchError(null)\n try {\n const result = await apiCall<ConnectionState>('/api/integration-ksef-direct/health')\n if (result.ok && result.result) {\n setState(result.result)\n } else {\n setFetchError('Failed to load connection status')\n }\n } catch {\n setFetchError('Failed to load connection status')\n } finally {\n setLoading(false)\n }\n }, [])\n\n React.useEffect(() => { fetchStatus() }, [fetchStatus, scopeVersion])\n\n React.useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n window.history.back()\n }\n }\n window.addEventListener('keydown', handleKeyDown)\n return () => window.removeEventListener('keydown', handleKeyDown)\n }, [])\n\n async function handleCheckConnection() {\n setChecking(true)\n try {\n const result = await apiCall<ConnectionState>('/api/integration-ksef-direct/health')\n if (result.ok && result.result) {\n setState(result.result)\n }\n } finally {\n setChecking(false)\n }\n }\n\n function getStatusVariant(status: HealthStatus): 'success' | 'error' | 'neutral' | 'warning' {\n switch (status) {\n case 'connected': return 'success'\n case 'error': return 'error'\n case 'checking': return 'warning'\n default: return 'neutral'\n }\n }\n\n function getStatusLabel(status: HealthStatus): string {\n switch (status) {\n case 'connected': return t('integration_ksef_direct.health.connected', 'Connected')\n case 'error': return t('integration_ksef_direct.health.error', 'Connection error')\n case 'checking': return t('integration_ksef_direct.health.checking', 'Checking...')\n default: return t('integration_ksef_direct.health.unconfigured', 'Not configured')\n }\n }\n\n return (\n <Page>\n <PageBody>\n <SectionHeader title={t('integration_ksef_direct.title', 'KSeF Direct Integration')} />\n\n {isLoading && !state && <LoadingMessage label={t('integration_ksef_direct.health.loading', 'Loading...')} />}\n {fetchError && !isLoading && <ErrorMessage label={fetchError} />}\n\n <div className=\"grid grid-cols-2 gap-3 mt-2 mb-6\">\n <Link href=\"/backend/integration-ksef-direct/documents\">\n <div className=\"flex items-center gap-3 rounded-lg border border-border p-4 hover:bg-muted/50 transition-colors cursor-pointer\">\n <FileText className=\"h-5 w-5 text-muted-foreground shrink-0\" />\n <div>\n <p className=\"text-sm font-medium\">{t('integration_ksef_direct.nav.documents', 'Sent Documents')}</p>\n <p className=\"text-xs text-muted-foreground\">{t('integration_ksef_direct.nav.documents_desc', 'Outgoing invoices sent to KSeF')}</p>\n </div>\n </div>\n </Link>\n <Link href=\"/backend/integration-ksef-direct/received-documents\">\n <div className=\"flex items-center gap-3 rounded-lg border border-border p-4 hover:bg-muted/50 transition-colors cursor-pointer\">\n <Inbox className=\"h-5 w-5 text-muted-foreground shrink-0\" />\n <div>\n <p className=\"text-sm font-medium\">{t('integration_ksef_direct.nav.received_documents', 'Received Documents')}</p>\n <p className=\"text-xs text-muted-foreground\">{t('integration_ksef_direct.nav.received_documents_desc', 'Invoices received from KSeF')}</p>\n </div>\n </div>\n </Link>\n </div>\n\n {state && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-3\">\n <StatusBadge variant={getStatusVariant(state.status)}>\n {getStatusLabel(state.status)}\n </StatusBadge>\n {state.environment && (\n <span className=\"text-sm text-muted-foreground\">\n {t('integration_ksef_direct.health.environment', 'Environment:')} <strong>{state.environment.toUpperCase()}</strong>\n </span>\n )}\n </div>\n\n {state.lastCheckedAt && (\n <p className=\"text-sm text-muted-foreground\">\n {t('integration_ksef_direct.health.last_checked', 'Last check:')}{' '}\n {new Date(state.lastCheckedAt).toLocaleString()}\n </p>\n )}\n\n {state.status === 'connected' && state.rateLimits && (\n <p className=\"text-sm text-muted-foreground\">\n {t('integration_ksef_direct.health.rate_limits', 'Rate limits:')}{' '}\n {[\n state.rateLimits.otherPerSecond != null && `${state.rateLimits.otherPerSecond} req/s`,\n state.rateLimits.otherPerMinute != null && `${state.rateLimits.otherPerMinute} req/min`,\n ]\n .filter(Boolean)\n .join(' \u00B7 ')}\n </p>\n )}\n\n {state.status === 'error' && state.error && (\n <ErrorMessage\n label={state.error}\n description={state.errorCode}\n />\n )}\n\n <div className=\"flex justify-end pt-2\">\n <Button\n type=\"button\"\n onClick={handleCheckConnection}\n disabled={isChecking}\n variant=\"outline\"\n >\n {isChecking\n ? t('integration_ksef_direct.health.checking', 'Checking...')\n : t('integration_ksef_direct.health.check_button', 'Check connection')}\n </Button>\n </div>\n </div>\n )}\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAoGQ,cASM,YATN;AAlGR,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,UAAU,aAAa;AAChC,SAAS,MAAM,gBAAgB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,mCAAmC;AAErC,MAAM,eAAe;AAAA,EAC1B,aAAa;AAAA,EACb,iBAAiB,CAAC,gCAAgC;AACpD;AAae,SAAR,iBAAkC;AACvC,QAAM,IAAI,KAAK;AACf,QAAM,eAAe,4BAA4B;AACjD,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAiC,IAAI;AACrE,QAAM,CAAC,WAAW,UAAU,IAAI,MAAM,SAAS,KAAK;AACpD,QAAM,CAAC,YAAY,WAAW,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAwB,IAAI;AAEtE,QAAM,cAAc,MAAM,YAAY,YAAY;AAChD,eAAW,IAAI;AACf,kBAAc,IAAI;AAClB,QAAI;AACF,YAAM,SAAS,MAAM,QAAyB,qCAAqC;AACnF,UAAI,OA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AI,KAAK,MAAM,aAAa,EAAE,eAAe;AAAA,SAChD;AAAA,MAGD,MAAM,WAAW,eAAe,MAAM,cACrC,qBAAC,OAAE,WAAU,iCACV;AAAA,UAAE,8CAA8C,cAAc;AAAA,QAAG;AAAA,QACjE;AAAA,UACC,MAAM,WAAW,kBAAkB,QAAQ,GAAG,MAAM,WAAW,cAAc;AAAA,UAC7E,MAAM,WAAW,kBAAkB,QAAQ,GAAG,MAAM,WAAW,cAAc;AAAA,QAC/E,EACG,OAAO,OAAO,EACd,KAAK,QAAK;AAAA,SACf;AAAA,MAGD,MAAM,WAAW,WAAW,MAAM,SACjC;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,MAAM;AAAA,UACb,aAAa,MAAM;AAAA;AAAA,MACrB;AAAA,MAGF,oBAAC,SAAI,WAAU,yBACb;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS;AAAA,UACT,UAAU;AAAA,UACV,SAAQ;AAAA,UAEP,uBACG,EAAE,2CAA2C,aAAa,IAC1D,EAAE,+CAA+C,kBAAkB;AAAA;AAAA,MACzE,GACF;AAAA,OACF;AAAA,KAEJ,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { KsefDirectDocument } from "../data/entities.js";
|
|
2
|
+
import { emitKsefDirectEvent } from "../events.js";
|
|
3
|
+
class KsefDirectNotConfiguredError extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("KSEF_DIRECT_NOT_CONFIGURED");
|
|
6
|
+
this.name = "KsefDirectNotConfiguredError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const VAT_RATE_MAP = { "0": 0, "5": 5, "8": 8, "23": 23, ZW: 0, NP: 0 };
|
|
10
|
+
function round2(value) {
|
|
11
|
+
return Math.round(value * 100) / 100;
|
|
12
|
+
}
|
|
13
|
+
function computeLineItem(item) {
|
|
14
|
+
const netAmount = round2(item.quantity * item.unitNetPrice);
|
|
15
|
+
const rate = VAT_RATE_MAP[item.vatRate] ?? 0;
|
|
16
|
+
const vatAmount = round2(netAmount * rate / 100);
|
|
17
|
+
return {
|
|
18
|
+
description: item.description,
|
|
19
|
+
quantity: item.quantity,
|
|
20
|
+
unit: item.unit,
|
|
21
|
+
unitNetPrice: item.unitNetPrice,
|
|
22
|
+
vatRate: item.vatRate,
|
|
23
|
+
netAmount,
|
|
24
|
+
vatAmount,
|
|
25
|
+
grossAmount: round2(netAmount + vatAmount)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function createKsefDirectDocument(em, tenantId, organizationId, input, credentialsService) {
|
|
29
|
+
const credentials = await credentialsService?.resolve("integration_ksef_direct", { tenantId, organizationId });
|
|
30
|
+
if (!credentials?.nip) {
|
|
31
|
+
throw new KsefDirectNotConfiguredError();
|
|
32
|
+
}
|
|
33
|
+
let sellerName = input.sellerName ?? null;
|
|
34
|
+
if (!sellerName) {
|
|
35
|
+
const { Organization } = await import("@open-mercato/core/modules/directory/data/entities");
|
|
36
|
+
const org = await em.findOne(Organization, { id: organizationId });
|
|
37
|
+
sellerName = org?.name ?? null;
|
|
38
|
+
}
|
|
39
|
+
const storedLineItems = input.lineItems.map(computeLineItem);
|
|
40
|
+
const netAmount = round2(storedLineItems.reduce((sum, l) => sum + l.netAmount, 0));
|
|
41
|
+
const vatAmount = round2(storedLineItems.reduce((sum, l) => sum + l.vatAmount, 0));
|
|
42
|
+
const grossAmount = round2(netAmount + vatAmount);
|
|
43
|
+
const now = /* @__PURE__ */ new Date();
|
|
44
|
+
const doc = em.create(KsefDirectDocument, {
|
|
45
|
+
organizationId,
|
|
46
|
+
tenantId,
|
|
47
|
+
source: "manual",
|
|
48
|
+
status: "draft",
|
|
49
|
+
sellerNip: credentials.nip,
|
|
50
|
+
sellerName,
|
|
51
|
+
sellerAddressL1: input.sellerAddressL1 ?? null,
|
|
52
|
+
sellerCity: input.sellerCity ?? null,
|
|
53
|
+
sellerCountry: input.sellerCountry ?? null,
|
|
54
|
+
buyerNip: input.buyerNip,
|
|
55
|
+
buyerName: input.buyerName ?? null,
|
|
56
|
+
invoiceNumber: input.invoiceNumber,
|
|
57
|
+
issueDate: new Date(input.issueDate),
|
|
58
|
+
saleDate: input.saleDate ? new Date(input.saleDate) : null,
|
|
59
|
+
netAmount: String(netAmount),
|
|
60
|
+
vatAmount: String(vatAmount),
|
|
61
|
+
grossAmount: String(grossAmount),
|
|
62
|
+
currency: input.currency ?? "PLN",
|
|
63
|
+
lineItems: storedLineItems,
|
|
64
|
+
notes: input.notes ?? null,
|
|
65
|
+
createdAt: now,
|
|
66
|
+
updatedAt: now
|
|
67
|
+
});
|
|
68
|
+
await em.persist(doc).flush();
|
|
69
|
+
await emitKsefDirectEvent("ksef_direct.document.created", {
|
|
70
|
+
documentId: doc.id,
|
|
71
|
+
organizationId,
|
|
72
|
+
tenantId
|
|
73
|
+
});
|
|
74
|
+
return { id: doc.id, status: doc.status, invoiceNumber: doc.invoiceNumber, sellerNip: doc.sellerNip };
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
KsefDirectNotConfiguredError,
|
|
78
|
+
createKsefDirectDocument
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=create-ksef-direct-document.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/integration_ksef_direct/commands/create-ksef-direct-document.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CreateKsefDirectDocumentInput, KsefDirectLineItemInput } from '../data/validators'\nimport { KsefDirectDocument, type KsefDirectStoredLineItem } from '../data/entities'\nimport { emitKsefDirectEvent } from '../events'\n\nexport class KsefDirectNotConfiguredError extends Error {\n constructor() {\n super('KSEF_DIRECT_NOT_CONFIGURED')\n this.name = 'KsefDirectNotConfiguredError'\n }\n}\n\nconst VAT_RATE_MAP: Record<string, number> = { '0': 0, '5': 5, '8': 8, '23': 23, ZW: 0, NP: 0 }\n\nfunction round2(value: number): number {\n return Math.round(value * 100) / 100\n}\n\nfunction computeLineItem(item: KsefDirectLineItemInput): KsefDirectStoredLineItem {\n const netAmount = round2(item.quantity * item.unitNetPrice)\n const rate = VAT_RATE_MAP[item.vatRate] ?? 0\n const vatAmount = round2(netAmount * rate / 100)\n return {\n description: item.description,\n quantity: item.quantity,\n unit: item.unit,\n unitNetPrice: item.unitNetPrice,\n vatRate: item.vatRate,\n netAmount,\n vatAmount,\n grossAmount: round2(netAmount + vatAmount),\n }\n}\n\nexport async function createKsefDirectDocument(\n em: any,\n tenantId: string,\n organizationId: string,\n input: CreateKsefDirectDocumentInput,\n credentialsService: any,\n): Promise<{ id: string; status: string; invoiceNumber: string; sellerNip: string }> {\n const credentials = await credentialsService?.resolve('integration_ksef_direct', { tenantId, organizationId })\n if (!credentials?.nip) {\n throw new KsefDirectNotConfiguredError()\n }\n\n let sellerName = input.sellerName ?? null\n if (!sellerName) {\n const { Organization } = await import('@open-mercato/core/modules/directory/data/entities')\n const org = await em.findOne(Organization, { id: organizationId })\n sellerName = org?.name ?? null\n }\n\n const storedLineItems = input.lineItems.map(computeLineItem)\n const netAmount = round2(storedLineItems.reduce((sum, l) => sum + l.netAmount, 0))\n const vatAmount = round2(storedLineItems.reduce((sum, l) => sum + l.vatAmount, 0))\n const grossAmount = round2(netAmount + vatAmount)\n const now = new Date()\n\n const doc = em.create(KsefDirectDocument, {\n organizationId,\n tenantId,\n source: 'manual' as const,\n status: 'draft' as const,\n sellerNip: credentials.nip,\n sellerName,\n sellerAddressL1: input.sellerAddressL1 ?? null,\n sellerCity: input.sellerCity ?? null,\n sellerCountry: input.sellerCountry ?? null,\n buyerNip: input.buyerNip,\n buyerName: input.buyerName ?? null,\n invoiceNumber: input.invoiceNumber,\n issueDate: new Date(input.issueDate),\n saleDate: input.saleDate ? new Date(input.saleDate) : null,\n netAmount: String(netAmount),\n vatAmount: String(vatAmount),\n grossAmount: String(grossAmount),\n currency: input.currency ?? 'PLN',\n lineItems: storedLineItems,\n notes: input.notes ?? null,\n createdAt: now,\n updatedAt: now,\n })\n\n await em.persist(doc).flush()\n\n await emitKsefDirectEvent('ksef_direct.document.created', {\n documentId: doc.id,\n organizationId,\n tenantId,\n })\n\n return { id: doc.id, status: doc.status, invoiceNumber: doc.invoiceNumber, sellerNip: doc.sellerNip }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAAyD;AAClE,SAAS,2BAA2B;AAE7B,MAAM,qCAAqC,MAAM;AAAA,EACtD,cAAc;AACZ,UAAM,4BAA4B;AAClC,SAAK,OAAO;AAAA,EACd;AACF;AAEA,MAAM,eAAuC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,IAAI,IAAI,GAAG,IAAI,EAAE;AAE9F,SAAS,OAAO,OAAuB;AACrC,SAAO,KAAK,MAAM,QAAQ,GAAG,IAAI;AACnC;AAEA,SAAS,gBAAgB,MAAyD;AAChF,QAAM,YAAY,OAAO,KAAK,WAAW,KAAK,YAAY;AAC1D,QAAM,OAAO,aAAa,KAAK,OAAO,KAAK;AAC3C,QAAM,YAAY,OAAO,YAAY,OAAO,GAAG;AAC/C,SAAO;AAAA,IACL,aAAa,KAAK;AAAA,IAClB,UAAU,KAAK;AAAA,IACf,MAAM,KAAK;AAAA,IACX,cAAc,KAAK;AAAA,IACnB,SAAS,KAAK;AAAA,IACd;AAAA,IACA;AAAA,IACA,aAAa,OAAO,YAAY,SAAS;AAAA,EAC3C;AACF;AAEA,eAAsB,yBACpB,IACA,UACA,gBACA,OACA,oBACmF;AACnF,QAAM,cAAc,MAAM,oBAAoB,QAAQ,2BAA2B,EAAE,UAAU,eAAe,CAAC;AAC7G,MAAI,CAAC,aAAa,KAAK;AACrB,UAAM,IAAI,6BAA6B;AAAA,EACzC;AAEA,MAAI,aAAa,MAAM,cAAc;AACrC,MAAI,CAAC,YAAY;AACf,UAAM,EAAE,aAAa,IAAI,MAAM,OAAO,oDAAoD;AAC1F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e,WAAW,IAAI,UAAU;AACtG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createModuleQueue } from "@open-mercato/queue";
|
|
2
|
+
import { KsefDirectDocument } from "../data/entities.js";
|
|
3
|
+
import { emitKsefDirectEvent } from "../events.js";
|
|
4
|
+
class KsefDocumentNotFoundError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Document not found");
|
|
7
|
+
this.status = 404;
|
|
8
|
+
this.name = "KsefDocumentNotFoundError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
class KsefDocumentNotQueueableError extends Error {
|
|
12
|
+
constructor(currentStatus) {
|
|
13
|
+
super(`Document cannot be queued: current status is '${currentStatus}'`);
|
|
14
|
+
this.status = 409;
|
|
15
|
+
this.name = "KsefDocumentNotQueueableError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function enqueueKsefDirectDocument(em, tenantId, organizationId, documentId) {
|
|
19
|
+
const doc = await em.findOne(KsefDirectDocument, { id: documentId, organizationId, tenantId });
|
|
20
|
+
if (!doc) {
|
|
21
|
+
throw new KsefDocumentNotFoundError();
|
|
22
|
+
}
|
|
23
|
+
if (!["draft", "failed"].includes(doc.status)) {
|
|
24
|
+
throw new KsefDocumentNotQueueableError(doc.status);
|
|
25
|
+
}
|
|
26
|
+
doc.status = "queued";
|
|
27
|
+
doc.updatedAt = /* @__PURE__ */ new Date();
|
|
28
|
+
await em.flush();
|
|
29
|
+
await emitKsefDirectEvent("ksef_direct.document.queued", {
|
|
30
|
+
documentId: doc.id,
|
|
31
|
+
organizationId,
|
|
32
|
+
tenantId
|
|
33
|
+
});
|
|
34
|
+
const queue = createModuleQueue("ksef_direct_send");
|
|
35
|
+
await queue.enqueue({ documentId: doc.id, organizationId, tenantId });
|
|
36
|
+
return { id: doc.id, status: doc.status, invoiceNumber: doc.invoiceNumber };
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
KsefDocumentNotFoundError,
|
|
40
|
+
KsefDocumentNotQueueableError,
|
|
41
|
+
enqueueKsefDirectDocument
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=enqueue-ksef-direct-document.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/integration_ksef_direct/commands/enqueue-ksef-direct-document.ts"],
|
|
4
|
+
"sourcesContent": ["import { createModuleQueue } from '@open-mercato/queue'\nimport { KsefDirectDocument } from '../data/entities'\nimport { emitKsefDirectEvent } from '../events'\n\nexport class KsefDocumentNotFoundError extends Error {\n readonly status = 404\n constructor() {\n super('Document not found')\n this.name = 'KsefDocumentNotFoundError'\n }\n}\n\nexport class KsefDocumentNotQueueableError extends Error {\n readonly status = 409\n constructor(currentStatus: string) {\n super(`Document cannot be queued: current status is '${currentStatus}'`)\n this.name = 'KsefDocumentNotQueueableError'\n }\n}\n\nexport type SendKsefDocumentJobPayload = {\n documentId: string\n organizationId: string\n tenantId: string\n}\n\nexport async function enqueueKsefDirectDocument(\n em: any,\n tenantId: string,\n organizationId: string,\n documentId: string,\n): Promise<{ id: string; status: string; invoiceNumber: string }> {\n const doc = await em.findOne(KsefDirectDocument, { id: documentId, organizationId, tenantId })\n\n if (!doc) {\n throw new KsefDocumentNotFoundError()\n }\n\n if (!['draft', 'failed'].includes(doc.status)) {\n throw new KsefDocumentNotQueueableError(doc.status)\n }\n\n doc.status = 'queued'\n doc.updatedAt = new Date()\n await em.flush()\n\n await emitKsefDirectEvent('ksef_direct.document.queued', {\n documentId: doc.id,\n organizationId,\n tenantId,\n })\n\n const queue = createModuleQueue<SendKsefDocumentJobPayload>('ksef_direct_send')\n await queue.enqueue({ documentId: doc.id, organizationId, tenantId })\n\n return { id: doc.id, status: doc.status, invoiceNumber: doc.invoiceNumber }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAE7B,MAAM,kCAAkC,MAAM;AAAA,EAEnD,cAAc;AACZ,UAAM,oBAAoB;AAF5B,SAAS,SAAS;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,sCAAsC,MAAM;AAAA,EAEvD,YAAY,eAAuB;AACjC,UAAM,iDAAiD,aAAa,GAAG;AAFzE,SAAS,SAAS;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;AAQA,eAAsB,0BACpB,IACA,UACA,gBACA,YACgE;AAChE,QAAM,MAAM,MAAM,GAAG,QAAQ,oBAAoB,EAAE,IAAI,YAAY,gBAAgB,SAAS,CAAC;AAE7F,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,0BAA0B;AAAA,EACtC;AAEA,MAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,SAAS,IAAI,MAAM,GAAG;AAC7C,UAAM,IAAI,8BAA8B,IAAI,MAAM;AAAA,EACpD;AAEA,MAAI,SAAS;AACb,MAAI,YAAY,oBAAI,KAAK;AACzB,QAAM,GAAG,MAAM;AAEf,QAAM,oBAAoB,+BAA+B;AAAA,IACvD,YAAY,IAAI;AAAA,IAChB;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,QAAQ,kBAA8C,kBAAkB;AAC9E,QAAM,MAAM,QAAQ,EAAE,YAAY,IAAI,IAAI,gBAAgB,SAAS,CAAC;AAEpE,SAAO,EAAE,IAAI,IAAI,IAAI,QAAQ,IAAI,QAAQ,eAAe,IAAI,cAAc;AAC5E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
import { Entity, PrimaryKey, Property, Index, Unique } from "@mikro-orm/decorators/legacy";
|
|
12
|
+
let KsefDirectDocument = class {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.source = "manual";
|
|
15
|
+
this.status = "draft";
|
|
16
|
+
this.currency = "PLN";
|
|
17
|
+
this.lineItems = [];
|
|
18
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
19
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
__decorateClass([
|
|
23
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
24
|
+
], KsefDirectDocument.prototype, "id", 2);
|
|
25
|
+
__decorateClass([
|
|
26
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
27
|
+
], KsefDirectDocument.prototype, "organizationId", 2);
|
|
28
|
+
__decorateClass([
|
|
29
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
30
|
+
], KsefDirectDocument.prototype, "tenantId", 2);
|
|
31
|
+
__decorateClass([
|
|
32
|
+
Property({ name: "source", type: "text", default: "manual" })
|
|
33
|
+
], KsefDirectDocument.prototype, "source", 2);
|
|
34
|
+
__decorateClass([
|
|
35
|
+
Property({ name: "status", type: "text", default: "draft" })
|
|
36
|
+
], KsefDirectDocument.prototype, "status", 2);
|
|
37
|
+
__decorateClass([
|
|
38
|
+
Property({ name: "ksef_reference_number", type: "text", nullable: true })
|
|
39
|
+
], KsefDirectDocument.prototype, "ksefReferenceNumber", 2);
|
|
40
|
+
__decorateClass([
|
|
41
|
+
Property({ name: "seller_nip", type: "text" })
|
|
42
|
+
], KsefDirectDocument.prototype, "sellerNip", 2);
|
|
43
|
+
__decorateClass([
|
|
44
|
+
Property({ name: "buyer_nip", type: "text" })
|
|
45
|
+
], KsefDirectDocument.prototype, "buyerNip", 2);
|
|
46
|
+
__decorateClass([
|
|
47
|
+
Property({ name: "buyer_name", type: "text", nullable: true })
|
|
48
|
+
], KsefDirectDocument.prototype, "buyerName", 2);
|
|
49
|
+
__decorateClass([
|
|
50
|
+
Property({ name: "invoice_number", type: "text" })
|
|
51
|
+
], KsefDirectDocument.prototype, "invoiceNumber", 2);
|
|
52
|
+
__decorateClass([
|
|
53
|
+
Property({ name: "issue_date", type: Date })
|
|
54
|
+
], KsefDirectDocument.prototype, "issueDate", 2);
|
|
55
|
+
__decorateClass([
|
|
56
|
+
Property({ name: "sale_date", type: Date, nullable: true })
|
|
57
|
+
], KsefDirectDocument.prototype, "saleDate", 2);
|
|
58
|
+
__decorateClass([
|
|
59
|
+
Property({ name: "net_amount", type: "string", columnType: "numeric(15,2)" })
|
|
60
|
+
], KsefDirectDocument.prototype, "netAmount", 2);
|
|
61
|
+
__decorateClass([
|
|
62
|
+
Property({ name: "vat_amount", type: "string", columnType: "numeric(15,2)" })
|
|
63
|
+
], KsefDirectDocument.prototype, "vatAmount", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
Property({ name: "gross_amount", type: "string", columnType: "numeric(15,2)" })
|
|
66
|
+
], KsefDirectDocument.prototype, "grossAmount", 2);
|
|
67
|
+
__decorateClass([
|
|
68
|
+
Property({ name: "currency", type: "text", default: "PLN" })
|
|
69
|
+
], KsefDirectDocument.prototype, "currency", 2);
|
|
70
|
+
__decorateClass([
|
|
71
|
+
Property({ name: "line_items", type: "json", columnType: "jsonb" })
|
|
72
|
+
], KsefDirectDocument.prototype, "lineItems", 2);
|
|
73
|
+
__decorateClass([
|
|
74
|
+
Property({ name: "notes", type: "text", nullable: true })
|
|
75
|
+
], KsefDirectDocument.prototype, "notes", 2);
|
|
76
|
+
__decorateClass([
|
|
77
|
+
Property({ name: "ksef_processing_reference_number", type: "text", nullable: true })
|
|
78
|
+
], KsefDirectDocument.prototype, "ksefProcessingReferenceNumber", 2);
|
|
79
|
+
__decorateClass([
|
|
80
|
+
Property({ name: "seller_name", type: "text", nullable: true })
|
|
81
|
+
], KsefDirectDocument.prototype, "sellerName", 2);
|
|
82
|
+
__decorateClass([
|
|
83
|
+
Property({ name: "seller_address_l1", type: "text", nullable: true })
|
|
84
|
+
], KsefDirectDocument.prototype, "sellerAddressL1", 2);
|
|
85
|
+
__decorateClass([
|
|
86
|
+
Property({ name: "seller_city", type: "text", nullable: true })
|
|
87
|
+
], KsefDirectDocument.prototype, "sellerCity", 2);
|
|
88
|
+
__decorateClass([
|
|
89
|
+
Property({ name: "seller_country", type: "text", nullable: true })
|
|
90
|
+
], KsefDirectDocument.prototype, "sellerCountry", 2);
|
|
91
|
+
__decorateClass([
|
|
92
|
+
Property({ name: "error_message", type: "text", nullable: true })
|
|
93
|
+
], KsefDirectDocument.prototype, "errorMessage", 2);
|
|
94
|
+
__decorateClass([
|
|
95
|
+
Property({ name: "created_at", type: Date })
|
|
96
|
+
], KsefDirectDocument.prototype, "createdAt", 2);
|
|
97
|
+
__decorateClass([
|
|
98
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
99
|
+
], KsefDirectDocument.prototype, "updatedAt", 2);
|
|
100
|
+
KsefDirectDocument = __decorateClass([
|
|
101
|
+
Entity({ tableName: "ksef_direct_documents" }),
|
|
102
|
+
Index({ properties: ["organizationId", "tenantId"] }),
|
|
103
|
+
Index({ properties: ["organizationId", "tenantId", "status"] }),
|
|
104
|
+
Index({ properties: ["organizationId", "tenantId", "source"] }),
|
|
105
|
+
Index({ properties: ["ksefReferenceNumber"] })
|
|
106
|
+
], KsefDirectDocument);
|
|
107
|
+
let KsefDirectReceivedDocument = class {
|
|
108
|
+
constructor() {
|
|
109
|
+
this.status = "pending_download";
|
|
110
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
111
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__decorateClass([
|
|
115
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
116
|
+
], KsefDirectReceivedDocument.prototype, "id", 2);
|
|
117
|
+
__decorateClass([
|
|
118
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
119
|
+
], KsefDirectReceivedDocument.prototype, "organizationId", 2);
|
|
120
|
+
__decorateClass([
|
|
121
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
122
|
+
], KsefDirectReceivedDocument.prototype, "tenantId", 2);
|
|
123
|
+
__decorateClass([
|
|
124
|
+
Property({ name: "ksef_reference_number", type: "text" })
|
|
125
|
+
], KsefDirectReceivedDocument.prototype, "ksefReferenceNumber", 2);
|
|
126
|
+
__decorateClass([
|
|
127
|
+
Property({ name: "raw_xml", type: "text", nullable: true })
|
|
128
|
+
], KsefDirectReceivedDocument.prototype, "rawXml", 2);
|
|
129
|
+
__decorateClass([
|
|
130
|
+
Property({ name: "invoice_number", type: "text", nullable: true })
|
|
131
|
+
], KsefDirectReceivedDocument.prototype, "invoiceNumber", 2);
|
|
132
|
+
__decorateClass([
|
|
133
|
+
Property({ name: "seller_nip", type: "text", nullable: true })
|
|
134
|
+
], KsefDirectReceivedDocument.prototype, "sellerNip", 2);
|
|
135
|
+
__decorateClass([
|
|
136
|
+
Property({ name: "seller_name", type: "text", nullable: true })
|
|
137
|
+
], KsefDirectReceivedDocument.prototype, "sellerName", 2);
|
|
138
|
+
__decorateClass([
|
|
139
|
+
Property({ name: "issue_date", type: "string", columnType: "date", nullable: true })
|
|
140
|
+
], KsefDirectReceivedDocument.prototype, "issueDate", 2);
|
|
141
|
+
__decorateClass([
|
|
142
|
+
Property({ name: "currency", type: "text", nullable: true })
|
|
143
|
+
], KsefDirectReceivedDocument.prototype, "currency", 2);
|
|
144
|
+
__decorateClass([
|
|
145
|
+
Property({ name: "net_amount", type: "string", columnType: "numeric(15,2)", nullable: true })
|
|
146
|
+
], KsefDirectReceivedDocument.prototype, "netAmount", 2);
|
|
147
|
+
__decorateClass([
|
|
148
|
+
Property({ name: "vat_amount", type: "string", columnType: "numeric(15,2)", nullable: true })
|
|
149
|
+
], KsefDirectReceivedDocument.prototype, "vatAmount", 2);
|
|
150
|
+
__decorateClass([
|
|
151
|
+
Property({ name: "gross_amount", type: "string", columnType: "numeric(15,2)", nullable: true })
|
|
152
|
+
], KsefDirectReceivedDocument.prototype, "grossAmount", 2);
|
|
153
|
+
__decorateClass([
|
|
154
|
+
Property({ name: "status", type: "text", default: "pending_download" })
|
|
155
|
+
], KsefDirectReceivedDocument.prototype, "status", 2);
|
|
156
|
+
__decorateClass([
|
|
157
|
+
Property({ name: "error_message", type: "text", nullable: true })
|
|
158
|
+
], KsefDirectReceivedDocument.prototype, "errorMessage", 2);
|
|
159
|
+
__decorateClass([
|
|
160
|
+
Property({ name: "upo_download_url", type: "text", nullable: true })
|
|
161
|
+
], KsefDirectReceivedDocument.prototype, "upoDownloadUrl", 2);
|
|
162
|
+
__decorateClass([
|
|
163
|
+
Property({ name: "invoice_download_url", type: "text", nullable: true })
|
|
164
|
+
], KsefDirectReceivedDocument.prototype, "invoiceDownloadUrl", 2);
|
|
165
|
+
__decorateClass([
|
|
166
|
+
Property({ name: "synced_at", type: Date, nullable: true })
|
|
167
|
+
], KsefDirectReceivedDocument.prototype, "syncedAt", 2);
|
|
168
|
+
__decorateClass([
|
|
169
|
+
Property({ name: "created_at", type: Date })
|
|
170
|
+
], KsefDirectReceivedDocument.prototype, "createdAt", 2);
|
|
171
|
+
__decorateClass([
|
|
172
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
173
|
+
], KsefDirectReceivedDocument.prototype, "updatedAt", 2);
|
|
174
|
+
KsefDirectReceivedDocument = __decorateClass([
|
|
175
|
+
Entity({ tableName: "ksef_direct_received_documents" }),
|
|
176
|
+
Index({ properties: ["organizationId", "tenantId"] }),
|
|
177
|
+
Index({ properties: ["organizationId", "tenantId", "status"] }),
|
|
178
|
+
Unique({ properties: ["organizationId", "ksefReferenceNumber"] })
|
|
179
|
+
], KsefDirectReceivedDocument);
|
|
180
|
+
let KsefDirectConnection = class {
|
|
181
|
+
constructor() {
|
|
182
|
+
this.status = "unconfigured";
|
|
183
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
184
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
__decorateClass([
|
|
188
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
189
|
+
], KsefDirectConnection.prototype, "id", 2);
|
|
190
|
+
__decorateClass([
|
|
191
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
192
|
+
], KsefDirectConnection.prototype, "organizationId", 2);
|
|
193
|
+
__decorateClass([
|
|
194
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
195
|
+
], KsefDirectConnection.prototype, "tenantId", 2);
|
|
196
|
+
__decorateClass([
|
|
197
|
+
Property({ name: "status", type: "text", default: "unconfigured" })
|
|
198
|
+
], KsefDirectConnection.prototype, "status", 2);
|
|
199
|
+
__decorateClass([
|
|
200
|
+
Property({ name: "last_checked_at", type: Date, nullable: true })
|
|
201
|
+
], KsefDirectConnection.prototype, "lastCheckedAt", 2);
|
|
202
|
+
__decorateClass([
|
|
203
|
+
Property({ name: "error_message", type: "text", nullable: true })
|
|
204
|
+
], KsefDirectConnection.prototype, "errorMessage", 2);
|
|
205
|
+
__decorateClass([
|
|
206
|
+
Property({ name: "error_code", type: "text", nullable: true })
|
|
207
|
+
], KsefDirectConnection.prototype, "errorCode", 2);
|
|
208
|
+
__decorateClass([
|
|
209
|
+
Property({ name: "created_at", type: Date })
|
|
210
|
+
], KsefDirectConnection.prototype, "createdAt", 2);
|
|
211
|
+
__decorateClass([
|
|
212
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
213
|
+
], KsefDirectConnection.prototype, "updatedAt", 2);
|
|
214
|
+
KsefDirectConnection = __decorateClass([
|
|
215
|
+
Entity({ tableName: "ksef_direct_connections" }),
|
|
216
|
+
Index({ properties: ["status", "updatedAt"] }),
|
|
217
|
+
Unique({ properties: ["organizationId", "tenantId"] })
|
|
218
|
+
], KsefDirectConnection);
|
|
219
|
+
export {
|
|
220
|
+
KsefDirectConnection,
|
|
221
|
+
KsefDirectDocument,
|
|
222
|
+
KsefDirectReceivedDocument
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=entities.js.map
|