@fayz-ai/plugin-fiscal-br 0.15.13 → 0.16.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/dist/InvoiceNotesButton-4L7SLYMA.js +6 -0
- package/dist/{InvoiceNotesButton-SC3G7FUR.js.map → InvoiceNotesButton-4L7SLYMA.js.map} +1 -1
- package/dist/NotasFiscaisView-LU4A65J7.js +6 -0
- package/dist/NotasFiscaisView-LU4A65J7.js.map +1 -0
- package/dist/OrderNoteCard-NZOVNTR3.js +5 -0
- package/dist/{OrderNoteCard-PDSK2AS3.js.map → OrderNoteCard-NZOVNTR3.js.map} +1 -1
- package/dist/UnitFiscalWidgets-XSED3WPQ.js +564 -0
- package/dist/UnitFiscalWidgets-XSED3WPQ.js.map +1 -0
- package/dist/{chunk-ODMEESFD.js → chunk-CWYTWKXW.js} +23 -3
- package/dist/chunk-CWYTWKXW.js.map +1 -0
- package/dist/chunk-E5TUJOGT.js +644 -0
- package/dist/chunk-E5TUJOGT.js.map +1 -0
- package/dist/{chunk-SSPDH22E.js → chunk-ITWWGLEV.js} +3 -3
- package/dist/{chunk-SSPDH22E.js.map → chunk-ITWWGLEV.js.map} +1 -1
- package/dist/chunk-U4TQSVWI.js +269 -0
- package/dist/chunk-U4TQSVWI.js.map +1 -0
- package/dist/chunk-YSRG5JQI.js +205 -0
- package/dist/chunk-YSRG5JQI.js.map +1 -0
- package/dist/data/issued.d.ts +97 -0
- package/dist/data/issued.d.ts.map +1 -1
- package/dist/data/registries.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/notes.d.ts +35 -1
- package/dist/lib/notes.d.ts.map +1 -1
- package/dist/migrations/index.d.ts +4 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +5 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +400 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/views/InvoiceNotesButton.d.ts.map +1 -1
- package/dist/views/NotasFiscaisView.d.ts +4 -0
- package/dist/views/NotasFiscaisView.d.ts.map +1 -0
- package/dist/views/UnitFiscalWidgets.d.ts +6 -4
- package/dist/views/UnitFiscalWidgets.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/InvoiceNotesButton-SC3G7FUR.js +0 -5
- package/dist/OrderNoteCard-PDSK2AS3.js +0 -5
- package/dist/UnitFiscalWidgets-K4PX3HWG.js +0 -503
- package/dist/UnitFiscalWidgets-K4PX3HWG.js.map +0 -1
- package/dist/chunk-F325US5P.js +0 -387
- package/dist/chunk-F325US5P.js.map +0 -1
- package/dist/chunk-ODMEESFD.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/data/issued.ts"],"names":["error"],"mappings":";;;AAKA,SAAS,EAAA,GAAK;AACZ,EAAA,MAAM,WAAW,yBAAA,EAA0B;AAC3C,EAAA,IAAI,CAAC,QAAA,EAAU,MAAM,IAAI,MAAM,0BAA0B,CAAA;AACzD,EAAA,OAAO,QAAA;AACT;AAEA,IAAM,YAAA,GAAe,CAAA;AAAA;AAAA,wDAAA,CAAA;AAIrB,SAAS,OAAO,CAAA,EAAoB;AAClC,EAAA,OAAO;AAAA,IACL,YAAY,CAAA,CAAE,WAAA;AAAA,IACd,OAAO,CAAA,CAAE,KAAA;AAAA,IACT,QAAQ,CAAA,CAAE,MAAA;AAAA,IACV,WAAA,EAAa,EAAE,WAAA,IAAe,IAAA;AAAA,IAC9B,MAAA,EAAQ,EAAE,MAAA,IAAU,IAAA;AAAA,IACpB,MAAA,EAAQ,EAAE,MAAA,IAAU,IAAA;AAAA,IACpB,SAAA,EAAW,EAAE,UAAA,IAAc,IAAA;AAAA,IAC3B,gBAAA,EAAkB,EAAE,iBAAA,IAAqB,IAAA;AAAA,IACzC,aAAA,EAAe,EAAE,uBAAA,IAA2B,IAA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I,KAAA,CAAM,iBAAA,CAAkB,KAAK,CAAC,CAAA;AAAA,EAC1C;AACF;AAEA,eAAsB,aAAa,UAAA,EAAmC;AACpE,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,UAAA,CAAW,GAAA,CAAI,UAAU,CAAA;AAAA,EACxC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,iBAAA,CAAkB,KAAK,CAAC,CAAA;AAAA,EAC1C;AACF","file":"chunk-U4TQSVWI.js","sourcesContent":["import { getSupabaseClientOptional } from '@fayz-ai/core'\nimport { getActiveTenantId } from '@fayz-ai/admin'\nimport type { IssuedNote, IssuedNoteEvent } from '../lib/issued-note'\nimport { invoiceNotes, noteErrorSentence, orderNotes, type BatchResult, type OrderNote, type PendingInvoice } from '../lib/notes'\n\nfunction sb() {\n const supabase = getSupabaseClientOptional() as any\n if (!supabase) throw new Error('Supabase not initialized')\n return supabase\n}\n\nconst NOTE_COLUMNS = `document_id, model, status, environment, number, series, access_key,\n verification_code, provider_integration_id, total_value, recipient_snapshot, rejection_payload,\n created_at, authorized_at, cancelled_at, cancel_reason`\n\nfunction toNote(r: any): IssuedNote {\n return {\n documentId: r.document_id,\n model: r.model,\n status: r.status,\n environment: r.environment ?? null,\n number: r.number ?? null,\n series: r.series ?? null,\n accessKey: r.access_key ?? null,\n verificationCode: r.verification_code ?? null,\n integrationId: r.provider_integration_id ?? null,\n totalValue: r.total_value == null ? null : Number(r.total_value),\n recipient: r.recipient_snapshot ?? null,\n rejection: r.rejection_payload ?? null,\n createdAt: r.created_at,\n authorizedAt: r.authorized_at ?? null,\n cancelledAt: r.cancelled_at ?? null,\n cancelReason: r.cancel_reason ?? null,\n }\n}\n\n/**\n * The notes of a financial invoice, reached through its order: a note covers\n * orders (N:N `plg_fiscalbr_document_orders`) or was issued straight from one\n * (`plg_fiscalbr_documents.order_id`, the restaurant tab).\n */\nexport async function listInvoiceNotes(invoiceId: string): Promise<IssuedNote[]> {\n const db = sb()\n const byId = new Map<string, IssuedNote>()\n\n // NFS-e is issued straight from the receivable: the document carries invoice_id.\n const own = await db.from('plg_fiscalbr_documents').select(NOTE_COLUMNS).eq('invoice_id', invoiceId)\n if (own.error) throw own.error\n for (const r of own.data ?? []) byId.set(r.document_id, toNote(r))\n\n // NFC-e/NF-e reach the receivable through its order (N:N or the tab's order_id).\n const { data: inv, error: invError } = await db.from('plg_financial_invoices')\n .select('order_id').eq('id', invoiceId).maybeSingle()\n if (invError) throw invError\n const orderId: string | null = inv?.order_id ?? null\n if (orderId) {\n const [linked, direct] = await Promise.all([\n db.from('plg_fiscalbr_document_orders').select('document_id').eq('order_id', orderId),\n db.from('plg_fiscalbr_documents').select(NOTE_COLUMNS).eq('order_id', orderId),\n ])\n if (linked.error) throw linked.error\n if (direct.error) throw direct.error\n for (const r of direct.data ?? []) byId.set(r.document_id, toNote(r))\n const missing = (linked.data ?? []).map((r: any) => r.document_id as string).filter((id: string) => !byId.has(id))\n if (missing.length) {\n const { data, error } = await db.from('plg_fiscalbr_documents').select(NOTE_COLUMNS).in('document_id', missing)\n if (error) throw error\n for (const r of data ?? []) byId.set(r.document_id, toNote(r))\n }\n }\n return [...byId.values()].sort((a, b) => b.createdAt.localeCompare(a.createdAt))\n}\n\n/** The taker's address as the NFS-e needs it; `id` is null when the person has none yet. */\nexport interface TomadorAddress {\n id: string | null\n postalCode: string | null\n street: string | null\n number: string | null\n district: string | null\n city: string | null\n state: string | null\n}\n\n/** One service line as it will read on the note. */\nexport interface NfsePreviewItem {\n name: string | null\n description: string | null\n quantity: number | null\n unitPrice: number | null\n total: number | null\n}\n\n/** The tax setup the emitter will apply, read from the unit's fiscal config. */\nexport interface NfsePreviewFiscal {\n issRate: number | null\n serviceCodeNational: string | null\n serviceCodeMunicipal: string | null\n}\n\n/** Who issues the note and whether its digital certificate is in place. */\nexport interface NfsePreviewEmitter {\n unitId: string | null\n company: string | null\n cnpj: string | null\n certificate: { configured: boolean; holder: string | null; expiresAt: string | null }\n}\n\n/** What the NFS-e will carry for a receivable, so the operator sees it — and fixes the taker — before issuing. */\nexport interface NfsePreview {\n invoice: { id: string; number: string | null; total: number | null; discount: number | null }\n personId: string | null\n tomador: {\n name: string | null\n /** Raw `document_number` (CPF or CNPJ); null when the record has none. */\n document: string | null\n email: string | null\n address: TomadorAddress | null\n }\n /** The service lines; the note's discriminação is built from these. */\n items: NfsePreviewItem[]\n /** The text that will describe the service on the note (the invoice summary, or the lines joined). */\n serviceDescription: string | null\n /** Null when the unit's fiscal config could not be read. */\n fiscal: NfsePreviewFiscal | null\n /** Who issues the note (company, CNPJ, certificate); null when unreadable. */\n emitter: NfsePreviewEmitter | null\n}\n\n/**\n * Reads the receivable and its taker so the modal can preview the note and let\n * the operator complete a missing CPF/CNPJ or address BEFORE issuing — the two\n * things the backend's `tomadorOf` refuses the note for.\n */\nexport async function previewInvoiceNfse(invoiceId: string): Promise<NfsePreview> {\n const db = sb()\n const { data: inv, error } = await db.from('plg_financial_invoices')\n .select('id, number, total, description, unit_id, counterparty_person_id').eq('id', invoiceId).maybeSingle()\n if (error) throw error\n const pid: string | null = inv?.counterparty_person_id ?? null\n\n // Taker, service lines and the unit's tax config, in parallel — each one\n // degrades on its own so a missing piece never blanks the whole preview.\n const [person, addrs, items, unitCtx] = await Promise.all([\n pid ? db.from('people').select('name, document_number, email').eq('id', pid).maybeSingle() : Promise.resolve({ data: null }),\n pid ? db.from('addresses').select('id, postal_code, street, number, district, city, state')\n .eq('owner_type', 'person').eq('owner_id', pid).order('is_default', { ascending: false }).limit(1) : Promise.resolve({ data: [] }),\n // The lines read through the bridge view (the items table does not carry\n // invoice_id); a service line's product can sit in item_metadata.referenceId.\n db.from('v_financial_invoice_lines').select('product_id, name, description, quantity, unit_price, total, item_metadata')\n .eq('invoice_id', invoiceId),\n unitContextForPreview(db, inv?.unit_id ?? null),\n ])\n\n const a = ((addrs as any).data ?? [])[0]\n const tomador: NfsePreview['tomador'] = {\n name: (person as any).data?.name ?? null,\n document: (person as any).data?.document_number ?? null,\n email: (person as any).data?.email ?? null,\n address: a ? { id: a.id, postalCode: a.postal_code, street: a.street, number: a.number, district: a.district, city: a.city, state: a.state } : null,\n }\n\n const lines: NfsePreviewItem[] = ((items as any).data ?? []).map((r: any) => ({\n name: r.name ?? null, description: r.description ?? null,\n quantity: r.quantity == null ? null : Number(r.quantity),\n unitPrice: r.unit_price == null ? null : Number(r.unit_price),\n total: r.total == null ? null : Number(r.total),\n }))\n // A fiscal group can name its services on the note (nfse_description): resolve\n // it from each line's product → tax group. Best-effort — degrades to the\n // invoice summary / line names if the config is absent.\n const productIds = ((items as any).data ?? [])\n .map((r: any) => r.product_id || r.item_metadata?.referenceId)\n .filter(Boolean)\n const groupDescription = await groupDescriptionForItems(db, productIds)\n\n // The note's discriminação: the group's custom text, else the invoice summary, else the lines.\n const serviceDescription = groupDescription\n || (inv?.description && String(inv.description).trim())\n || lines.map((l) => l.name || l.description).filter(Boolean).join(', ')\n || null\n\n return {\n invoice: {\n id: invoiceId, number: inv?.number ?? null,\n total: inv?.total == null ? null : Number(inv.total),\n discount: inv?.discount == null ? null : Number(inv.discount),\n },\n personId: pid,\n tomador,\n items: lines,\n serviceDescription,\n fiscal: unitCtx.fiscal,\n emitter: unitCtx.emitter,\n }\n}\n\n/** The fiscal group's custom NFS-e description for a set of products, joined when several; null when none set. */\nasync function groupDescriptionForItems(db: any, productIds: string[]): Promise<string | null> {\n const ids = [...new Set(productIds)]\n if (!ids.length) return null\n try {\n const { data: taxInfo } = await db.from('plg_fiscalbr_product_tax_info').select('tax_group_id').in('product_id', ids)\n const groupIds = [...new Set((taxInfo ?? []).map((t: any) => t.tax_group_id).filter(Boolean))]\n if (!groupIds.length) return null\n const { data: groups } = await db.from('plg_fiscalbr_tax_groups').select('nfse_description').in('id', groupIds)\n const descs = [...new Set((groups ?? []).map((g: any) => g.nfse_description).filter((d: any) => d && String(d).trim()))]\n return descs.length ? descs.join(' | ') : null\n } catch { return null }\n}\n\n/** The unit's fiscal config (ISS rate, codes) AND its emitter (company, CNPJ, certificate), via its legal entity. */\nasync function unitContextForPreview(db: any, unitId: string | null): Promise<{ fiscal: NfsePreviewFiscal | null; emitter: NfsePreviewEmitter | null }> {\n if (!unitId) return { fiscal: null, emitter: null }\n try {\n const { data: unit } = await db.from('v_units').select('legal_entity_id').eq('id', unitId).maybeSingle()\n const legalEntityId = unit?.legal_entity_id\n if (!legalEntityId) return { fiscal: null, emitter: null }\n const [settings, company] = await Promise.all([\n db.from('plg_fiscalbr_emitter_settings')\n .select('nfse_iss_rate, nfse_service_code_national, nfse_service_code_municipal, certificate_provider_id, certificate_cn, certificate_expires_at')\n .eq('legal_entity_id', legalEntityId).maybeSingle(),\n db.from('company_legal_entities').select('legal_name, trade_name, document_number').eq('id', legalEntityId).maybeSingle(),\n ])\n const s = settings.data\n const c = company.data\n const fiscal: NfsePreviewFiscal | null = s ? {\n issRate: s.nfse_iss_rate == null ? null : Number(s.nfse_iss_rate),\n serviceCodeNational: s.nfse_service_code_national ?? null,\n serviceCodeMunicipal: s.nfse_service_code_municipal ?? null,\n } : null\n const emitter: NfsePreviewEmitter = {\n unitId,\n company: (c?.trade_name || c?.legal_name) ?? null,\n cnpj: c?.document_number ?? null,\n certificate: {\n configured: !!(s?.certificate_provider_id),\n holder: s?.certificate_cn ?? null,\n expiresAt: s?.certificate_expires_at ?? null,\n },\n }\n return { fiscal, emitter }\n } catch { return { fiscal: null, emitter: null } }\n}\n\n/** Writes the taker's CPF/CNPJ onto the person record (digits only). */\nexport async function saveTomadorDocument(personId: string, documentDigits: string): Promise<void> {\n const { error } = await sb().from('people').update({ document_number: documentDigits }).eq('id', personId)\n if (error) throw error\n}\n\n/** Creates or updates the taker's address; returns the row id so the panel keeps editing it. */\nexport async function saveTomadorAddress(personId: string, address: TomadorAddress): Promise<string> {\n const db = sb()\n const row = {\n owner_type: 'person', owner_id: personId,\n postal_code: address.postalCode, street: address.street, number: address.number,\n district: address.district, city: address.city, state: address.state,\n }\n if (address.id) {\n const { error } = await db.from('addresses').update(row).eq('id', address.id)\n if (error) throw error\n return address.id\n }\n const { data, error } = await db.from('addresses').insert(row).select('id').single()\n if (error) throw error\n return data.id as string\n}\n\n/** Issues the receivable's NFS-e through the integration service; returns the note as it stands (usually processing). */\nexport async function issueInvoiceNfse(invoiceId: string, observacoes?: string): Promise<OrderNote> {\n try {\n return await invoiceNotes.issue(invoiceId, observacoes)\n } catch (error) {\n throw new Error(noteErrorSentence(error))\n }\n}\n\n/** The receivables of the period with no live NFS-e yet (the \"Sem nota\" list). */\nexport async function listPendingNfse(params: { from?: string; to?: string; limit?: number } = {}): Promise<PendingInvoice[]> {\n try {\n return await invoiceNotes.pending(params)\n } catch (error) {\n throw new Error(noteErrorSentence(error))\n }\n}\n\n/**\n * The period's receivables with no live NFS-e, read straight from the ledger so\n * the «Notas Fiscais» screen lists them even before the integration service is\n * reachable. `issuable` is optimistic here (the service makes the final call on\n * emit); the batch reports back what it could not issue and why.\n */\nexport async function listPendingNfseLocal(params: { from?: string; limit?: number } = {}): Promise<PendingInvoice[]> {\n const db = sb()\n let q = db.from('plg_financial_invoices')\n .select('id, number, total, counterparty_person_id, issue_date, competence_date')\n .eq('direction', 'receivable')\n .order('issue_date', { ascending: false })\n .limit(params.limit ?? 300)\n if (params.from) q = q.gte('issue_date', params.from)\n const { data: invs, error } = await q\n if (error) throw error\n const rows = invs ?? []\n const ids = rows.map((i: any) => i.id)\n if (!ids.length) return []\n // A receivable is «sem nota» while it has no processing/authorized document.\n // Best-effort: on a cluster where the NFS-e-from-receivable schema is not yet\n // applied (`invoice_id` absent), nothing can be linked, so all are sem nota.\n const withNote = new Set<string>()\n const { data: docs } = await db.from('plg_fiscalbr_documents')\n .select('invoice_id, status').in('invoice_id', ids).in('status', ['processing', 'authorized'])\n for (const d of docs ?? []) withNote.add((d as any).invoice_id)\n const pending = rows.filter((i: any) => i.counterparty_person_id && !withNote.has(i.id))\n // Names in one go, so the list reads «Maria…», not a person id.\n const personIds = [...new Set(pending.map((i: any) => i.counterparty_person_id))]\n const names = new Map<string, string>()\n if (personIds.length) {\n const { data: people } = await db.from('people').select('id, name').in('id', personIds)\n for (const p of people ?? []) names.set(p.id, p.name)\n }\n return pending.map((i: any) => ({\n invoiceId: i.id,\n number: i.number ?? null,\n customerName: names.get(i.counterparty_person_id) ?? null,\n date: i.issue_date ?? i.competence_date ?? null,\n total: i.total == null ? 0 : Number(i.total),\n paid: 0,\n issuable: true,\n reason: null,\n }))\n}\n\n/** Issues NFS-e for several receivables at once; one failing does not stop the rest. */\nexport async function issueNfseBatch(invoiceIds: string[]): Promise<BatchResult[]> {\n try {\n return await invoiceNotes.batch(invoiceIds)\n } catch (error) {\n throw new Error(noteErrorSentence(error))\n }\n}\n\n/** The tenant's issued NFS-e, newest first, optionally by status and period (RLS scopes the tenant). */\nexport async function listIssuedNfse(params: { status?: IssuedNote['status']; from?: string; limit?: number } = {}): Promise<IssuedNote[]> {\n const db = sb()\n let q = db.from('plg_fiscalbr_documents').select(NOTE_COLUMNS).eq('model', 'nfse')\n .order('created_at', { ascending: false }).limit(params.limit ?? 200)\n if (params.status) q = q.eq('status', params.status)\n if (params.from) q = q.gte('created_at', params.from)\n const { data, error } = await q\n if (error) throw error\n return (data ?? []).map(toNote)\n}\n\nexport async function listNoteEvents(documentId: string): Promise<IssuedNoteEvent[]> {\n const { data, error } = await sb().from('plg_fiscalbr_document_events')\n .select('id, event_type, status, justification, created_at')\n .eq('document_id', documentId)\n .order('created_at', { ascending: false })\n .limit(30)\n if (error) throw error\n return (data ?? []).map((e: any) => ({\n id: e.id, eventType: e.event_type, status: e.status ?? null,\n justification: e.justification ?? null, createdAt: e.created_at,\n }))\n}\n\n/** Asks PlugNotas for the note's current state, through the integration service; returns the stored status. */\nexport async function refreshNote(documentId: string): Promise<string> {\n try {\n return (await orderNotes.read(documentId)).status\n } catch (error) {\n throw new Error(noteErrorSentence(error))\n }\n}\n\nexport async function cancelNote(documentId: string, justification: string): Promise<string> {\n try {\n return (await orderNotes.cancel(documentId, justification)).status\n } catch (error) {\n throw new Error(noteErrorSentence(error))\n }\n}\n\nexport async function fetchNotePdf(documentId: string): Promise<Blob> {\n try {\n return await orderNotes.pdf(documentId)\n } catch (error) {\n throw new Error(noteErrorSentence(error))\n }\n}\n"]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { listIssuedNfse, listPendingNfseLocal, issueNfseBatch } from './chunk-U4TQSVWI.js';
|
|
2
|
+
import { MODEL_LABEL, STATUS_META, statusLabel, recipientLabel } from './chunk-CWYTWKXW.js';
|
|
3
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
4
|
+
import { RefreshCw, Loader2, FileCheck2 } from 'lucide-react';
|
|
5
|
+
import { Badge, SubpageHeader, Button, ListFilterBar, DataTable, toast } from '@fayz-ai/ui';
|
|
6
|
+
import { describeError, formatCurrency } from '@fayz-ai/core';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var TONE_VARIANT = {
|
|
10
|
+
success: "success",
|
|
11
|
+
warning: "warning",
|
|
12
|
+
danger: "destructive",
|
|
13
|
+
muted: "default"
|
|
14
|
+
};
|
|
15
|
+
var money = (v) => v == null ? "\u2014" : formatCurrency(v);
|
|
16
|
+
var day = (v) => v ? new Date(v).toLocaleDateString("pt-BR") : "\u2014";
|
|
17
|
+
var STATUS_OPTIONS = [
|
|
18
|
+
{ value: "sem_nota", label: "Sem nota", dot: "hsl(var(--warning))" },
|
|
19
|
+
{ value: "authorized", label: "Autorizadas", dot: "hsl(var(--success))" },
|
|
20
|
+
{ value: "processing", label: "Processando", dot: "hsl(var(--warning))" },
|
|
21
|
+
{ value: "rejected", label: "Rejeitadas", dot: "hsl(var(--destructive))" },
|
|
22
|
+
{ value: "cancelled", label: "Canceladas", dot: "hsl(var(--muted-foreground))" }
|
|
23
|
+
];
|
|
24
|
+
var PERIOD_OPTIONS = [
|
|
25
|
+
{ value: "7", label: "\xDAltimos 7 dias" },
|
|
26
|
+
{ value: "30", label: "\xDAltimos 30 dias" },
|
|
27
|
+
{ value: "90", label: "\xDAltimos 90 dias" }
|
|
28
|
+
];
|
|
29
|
+
var sinceDays = (days) => days ? new Date(Date.now() - Number(days) * 864e5).toISOString() : void 0;
|
|
30
|
+
var issuedRow = (n) => {
|
|
31
|
+
const meta = STATUS_META[n.status] ?? STATUS_META.error;
|
|
32
|
+
return {
|
|
33
|
+
key: n.documentId,
|
|
34
|
+
kind: "issued",
|
|
35
|
+
issuable: false,
|
|
36
|
+
model: n.model,
|
|
37
|
+
number: n.number,
|
|
38
|
+
tomador: recipientLabel(n.recipient),
|
|
39
|
+
date: n.createdAt,
|
|
40
|
+
total: n.totalValue,
|
|
41
|
+
statusKey: n.status ?? "error",
|
|
42
|
+
statusText: statusLabel(n),
|
|
43
|
+
tone: meta.tone,
|
|
44
|
+
test: n.environment === "homologacao",
|
|
45
|
+
reason: null
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
var pendingRow = (r) => ({
|
|
49
|
+
key: `pending:${r.invoiceId}`,
|
|
50
|
+
kind: "pending",
|
|
51
|
+
invoiceId: r.invoiceId,
|
|
52
|
+
issuable: r.issuable,
|
|
53
|
+
model: null,
|
|
54
|
+
number: r.number,
|
|
55
|
+
tomador: r.customerName ?? "Sem cliente",
|
|
56
|
+
date: r.date,
|
|
57
|
+
total: r.total,
|
|
58
|
+
statusKey: "sem_nota",
|
|
59
|
+
statusText: "Sem nota",
|
|
60
|
+
tone: "warning",
|
|
61
|
+
test: false,
|
|
62
|
+
reason: r.issuable ? null : r.reason
|
|
63
|
+
});
|
|
64
|
+
function NotasFiscaisView() {
|
|
65
|
+
const [issued, setIssued] = useState(null);
|
|
66
|
+
const [pending, setPending] = useState([]);
|
|
67
|
+
const [error, setError] = useState(null);
|
|
68
|
+
const [status, setStatus] = useState(void 0);
|
|
69
|
+
const [period, setPeriod] = useState("30");
|
|
70
|
+
const [selected, setSelected] = useState([]);
|
|
71
|
+
const [issuing, setIssuing] = useState(false);
|
|
72
|
+
const load = useCallback(async () => {
|
|
73
|
+
setIssued(null);
|
|
74
|
+
setError(null);
|
|
75
|
+
const [iss, pend] = await Promise.allSettled([
|
|
76
|
+
listIssuedNfse({ from: sinceDays(period), limit: 300 }),
|
|
77
|
+
listPendingNfseLocal({ from: sinceDays(period), limit: 300 })
|
|
78
|
+
]);
|
|
79
|
+
if (iss.status === "fulfilled") setIssued(iss.value);
|
|
80
|
+
else {
|
|
81
|
+
setIssued([]);
|
|
82
|
+
setError(describeError(iss.reason));
|
|
83
|
+
}
|
|
84
|
+
setPending(pend.status === "fulfilled" ? pend.value : []);
|
|
85
|
+
setSelected([]);
|
|
86
|
+
}, [period]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
void load();
|
|
89
|
+
}, [load]);
|
|
90
|
+
const rows = useMemo(() => {
|
|
91
|
+
const all = [...pending.map(pendingRow), ...(issued ?? []).map(issuedRow)];
|
|
92
|
+
const filtered = status ? all.filter((r) => r.statusKey === status) : all;
|
|
93
|
+
return filtered.sort((a, b) => (b.date ?? "").localeCompare(a.date ?? ""));
|
|
94
|
+
}, [issued, pending, status]);
|
|
95
|
+
const issuableIds = useMemo(() => new Set(pending.filter((p) => p.issuable).map((p) => p.invoiceId)), [pending]);
|
|
96
|
+
const picked = selected.filter((id) => issuableIds.has(id));
|
|
97
|
+
const emit = async () => {
|
|
98
|
+
if (!picked.length) return;
|
|
99
|
+
setIssuing(true);
|
|
100
|
+
try {
|
|
101
|
+
const results = await issueNfseBatch(picked);
|
|
102
|
+
const ok = results.filter((r) => r.note && r.error === null).length;
|
|
103
|
+
const fail = results.length - ok;
|
|
104
|
+
if (ok) toast.success(`${ok} NFS-e enviada(s)`, fail ? { description: `${fail} n\xE3o sa\xEDram \u2014 veja os motivos na lista.` } : void 0);
|
|
105
|
+
if (fail && !ok) toast.error(`${fail} venda(s) sem NFS-e`, { description: results.find((r) => r.message)?.message ?? void 0 });
|
|
106
|
+
await load();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
toast.error("N\xE3o foi poss\xEDvel emitir em lote", { description: describeError(e) });
|
|
109
|
+
} finally {
|
|
110
|
+
setIssuing(false);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const columns = useMemo(() => [
|
|
114
|
+
{
|
|
115
|
+
id: "model",
|
|
116
|
+
header: "Modelo",
|
|
117
|
+
meta: { mobile: "badge" },
|
|
118
|
+
cell: ({ row: { original: r } }) => r.model ? /* @__PURE__ */ jsx(Badge, { variant: "outline", children: MODEL_LABEL[r.model] ?? r.model }) : /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" })
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "number",
|
|
122
|
+
header: "N\xFAmero",
|
|
123
|
+
meta: { mobile: "hidden" },
|
|
124
|
+
cell: ({ row: { original: r } }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-sm text-muted-foreground", children: r.number ?? "\u2014" })
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: "tomador",
|
|
128
|
+
header: "Tomador",
|
|
129
|
+
meta: { mobile: "title", truncate: true },
|
|
130
|
+
cell: ({ row: { original: r } }) => /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
|
|
131
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm", children: r.tomador }),
|
|
132
|
+
r.reason && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-muted-foreground", children: r.reason })
|
|
133
|
+
] })
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "status",
|
|
137
|
+
header: "Situa\xE7\xE3o",
|
|
138
|
+
meta: { mobile: "badge" },
|
|
139
|
+
cell: ({ row: { original: r } }) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
140
|
+
/* @__PURE__ */ jsx(Badge, { variant: TONE_VARIANT[r.tone], children: r.statusText }),
|
|
141
|
+
r.test && /* @__PURE__ */ jsx("span", { className: "rounded border border-destructive px-1 text-[10px] font-semibold text-destructive", children: "TESTE" })
|
|
142
|
+
] })
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "date",
|
|
146
|
+
header: "Data",
|
|
147
|
+
cell: ({ row: { original: r } }) => /* @__PURE__ */ jsx("span", { className: "text-xs tabular-nums text-muted-foreground", children: day(r.date) })
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "total",
|
|
151
|
+
header: "Valor",
|
|
152
|
+
meta: { className: "text-right" },
|
|
153
|
+
cell: ({ row: { original: r } }) => /* @__PURE__ */ jsx("span", { className: "text-sm tabular-nums font-medium", children: money(r.total) })
|
|
154
|
+
}
|
|
155
|
+
], []);
|
|
156
|
+
const filters = [
|
|
157
|
+
{ id: "status", label: "Situa\xE7\xE3o", allLabel: "Todas", options: STATUS_OPTIONS, value: status, onChange: setStatus },
|
|
158
|
+
{ id: "period", label: "Per\xEDodo", allLabel: "Qualquer per\xEDodo", options: PERIOD_OPTIONS, value: period, onChange: setPeriod }
|
|
159
|
+
];
|
|
160
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
161
|
+
/* @__PURE__ */ jsx(SubpageHeader, { title: "Notas Fiscais" }),
|
|
162
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
|
|
163
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
164
|
+
/* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: load, disabled: issued === null, children: [
|
|
165
|
+
/* @__PURE__ */ jsx(RefreshCw, { className: "h-3.5 w-3.5", "aria-hidden": true }),
|
|
166
|
+
" Atualizar"
|
|
167
|
+
] }),
|
|
168
|
+
picked.length > 0 && /* @__PURE__ */ jsxs(Button, { size: "sm", onClick: emit, disabled: issuing, children: [
|
|
169
|
+
issuing ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin", "aria-hidden": true }) : /* @__PURE__ */ jsx(FileCheck2, { className: "h-3.5 w-3.5", "aria-hidden": true }),
|
|
170
|
+
issuing ? "Emitindo\u2026" : `Emitir ${picked.length}`
|
|
171
|
+
] })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ jsx(ListFilterBar, { filters, onClear: () => {
|
|
174
|
+
setStatus(void 0);
|
|
175
|
+
setPeriod(void 0);
|
|
176
|
+
} })
|
|
177
|
+
] }),
|
|
178
|
+
error && /* @__PURE__ */ jsxs("p", { className: "rounded-card border border-dashed p-3 text-center text-xs text-muted-foreground", children: [
|
|
179
|
+
"As notas emitidas est\xE3o listadas. As contas \xABsem nota\xBB n\xE3o puderam ser lidas agora: ",
|
|
180
|
+
error
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ jsx(
|
|
183
|
+
DataTable,
|
|
184
|
+
{
|
|
185
|
+
columns,
|
|
186
|
+
data: rows,
|
|
187
|
+
loading: issued === null,
|
|
188
|
+
selectable: true,
|
|
189
|
+
selectedIds: selected,
|
|
190
|
+
onSelectedIdsChange: setSelected,
|
|
191
|
+
getRowId: (r) => r.invoiceId ?? r.key,
|
|
192
|
+
rowClassName: (r) => r.kind === "pending" && !r.issuable ? "opacity-60" : void 0,
|
|
193
|
+
mobileLayout: "cards",
|
|
194
|
+
emptyMessage: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
195
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: "Nenhuma nota neste recorte" }),
|
|
196
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Ajuste a situa\xE7\xE3o ou o per\xEDodo, ou emita a partir de uma conta a receber." })
|
|
197
|
+
] })
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export { NotasFiscaisView };
|
|
204
|
+
//# sourceMappingURL=chunk-YSRG5JQI.js.map
|
|
205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A;AAAA;AAEJ,GAAA,EACF,CAAA;AAEJ","file":"chunk-YSRG5JQI.js","sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { FileCheck2, Loader2, RefreshCw } from 'lucide-react'\nimport {\n Badge, Button, DataTable, ListFilterBar, SubpageHeader, toast,\n type FilterChipOption, type ListFilterDef,\n} from '@fayz-ai/ui'\nimport { describeError, formatCurrency } from '@fayz-ai/core'\nimport { issueNfseBatch, listIssuedNfse, listPendingNfseLocal } from '../data/issued'\nimport type { PendingInvoice } from '../lib/notes'\nimport { MODEL_LABEL, recipientLabel, STATUS_META, statusLabel, type IssuedNote, type StatusTone } from '../lib/issued-note'\n\nconst TONE_VARIANT: Record<StatusTone, 'success' | 'warning' | 'destructive' | 'default'> = {\n success: 'success', warning: 'warning', danger: 'destructive', muted: 'default',\n}\nconst money = (v: number | null) => (v == null ? '—' : formatCurrency(v))\nconst day = (v: string | null) => (v ? new Date(v).toLocaleDateString('pt-BR') : '—')\n\n// One row for both worlds: a note that was issued, and a receivable that has none\n// yet («Sem nota»). The screen lists them together — see all by default — and the\n// «Sem nota» rows are the ones that can be picked for a batch.\ninterface NoteRow {\n key: string\n kind: 'issued' | 'pending'\n invoiceId?: string\n issuable: boolean\n model: IssuedNote['model'] | null\n number: string | null\n tomador: string\n date: string | null\n total: number | null\n statusKey: 'authorized' | 'processing' | 'rejected' | 'cancelled' | 'error' | 'sem_nota'\n statusText: string\n tone: StatusTone\n test: boolean\n reason: string | null\n}\n\nconst STATUS_OPTIONS: FilterChipOption[] = [\n { value: 'sem_nota', label: 'Sem nota', dot: 'hsl(var(--warning))' },\n { value: 'authorized', label: 'Autorizadas', dot: 'hsl(var(--success))' },\n { value: 'processing', label: 'Processando', dot: 'hsl(var(--warning))' },\n { value: 'rejected', label: 'Rejeitadas', dot: 'hsl(var(--destructive))' },\n { value: 'cancelled', label: 'Canceladas', dot: 'hsl(var(--muted-foreground))' },\n]\nconst PERIOD_OPTIONS: FilterChipOption[] = [\n { value: '7', label: 'Últimos 7 dias' },\n { value: '30', label: 'Últimos 30 dias' },\n { value: '90', label: 'Últimos 90 dias' },\n]\nconst sinceDays = (days: string | undefined) =>\n days ? new Date(Date.now() - Number(days) * 86400_000).toISOString() : undefined\n\nconst issuedRow = (n: IssuedNote): NoteRow => {\n const meta = STATUS_META[n.status] ?? STATUS_META.error\n return {\n key: n.documentId, kind: 'issued', issuable: false,\n model: n.model, number: n.number, tomador: recipientLabel(n.recipient),\n date: n.createdAt, total: n.totalValue,\n statusKey: (n.status as NoteRow['statusKey']) ?? 'error', statusText: statusLabel(n), tone: meta.tone,\n test: n.environment === 'homologacao', reason: null,\n }\n}\nconst pendingRow = (r: PendingInvoice): NoteRow => ({\n key: `pending:${r.invoiceId}`, kind: 'pending', invoiceId: r.invoiceId, issuable: r.issuable,\n model: null, number: r.number, tomador: r.customerName ?? 'Sem cliente',\n date: r.date, total: r.total,\n statusKey: 'sem_nota', statusText: 'Sem nota', tone: 'warning', test: false,\n reason: r.issuable ? null : r.reason,\n})\n\n/** «Fiscal → Notas emitidas»: every NFS-e and every note-less receivable in one list, issued in a batch from here. */\nexport function NotasFiscaisView() {\n const [issued, setIssued] = useState<IssuedNote[] | null>(null)\n const [pending, setPending] = useState<PendingInvoice[]>([])\n const [error, setError] = useState<string | null>(null)\n const [status, setStatus] = useState<string | undefined>(undefined)\n const [period, setPeriod] = useState<string | undefined>('30')\n const [selected, setSelected] = useState<string[]>([])\n const [issuing, setIssuing] = useState(false)\n\n const load = useCallback(async () => {\n setIssued(null)\n setError(null)\n // Issued notes read from the ledger (works offline of the service); the\n // «Sem nota» list needs the integration service, so a failure there must\n // not blank the whole screen — the issued notes still show.\n const [iss, pend] = await Promise.allSettled([\n listIssuedNfse({ from: sinceDays(period), limit: 300 }),\n listPendingNfseLocal({ from: sinceDays(period), limit: 300 }),\n ])\n if (iss.status === 'fulfilled') setIssued(iss.value)\n else { setIssued([]); setError(describeError(iss.reason)) }\n setPending(pend.status === 'fulfilled' ? pend.value : [])\n setSelected([])\n }, [period])\n useEffect(() => { void load() }, [load])\n\n const rows = useMemo<NoteRow[]>(() => {\n const all = [...pending.map(pendingRow), ...(issued ?? []).map(issuedRow)]\n const filtered = status ? all.filter((r) => r.statusKey === status) : all\n return filtered.sort((a, b) => (b.date ?? '').localeCompare(a.date ?? ''))\n }, [issued, pending, status])\n\n const issuableIds = useMemo(() => new Set(pending.filter((p) => p.issuable).map((p) => p.invoiceId)), [pending])\n const picked = selected.filter((id) => issuableIds.has(id))\n\n const emit = async () => {\n if (!picked.length) return\n setIssuing(true)\n try {\n const results = await issueNfseBatch(picked)\n const ok = results.filter((r) => r.note && r.error === null).length\n const fail = results.length - ok\n if (ok) toast.success(`${ok} NFS-e enviada(s)`, fail ? { description: `${fail} não saíram — veja os motivos na lista.` } : undefined)\n if (fail && !ok) toast.error(`${fail} venda(s) sem NFS-e`, { description: results.find((r) => r.message)?.message ?? undefined })\n await load()\n } catch (e) {\n toast.error('Não foi possível emitir em lote', { description: describeError(e) })\n } finally {\n setIssuing(false)\n }\n }\n\n const columns = useMemo<ColumnDef<NoteRow>[]>(() => [\n {\n id: 'model', header: 'Modelo', meta: { mobile: 'badge' },\n cell: ({ row: { original: r } }) => (\n r.model ? <Badge variant=\"outline\">{MODEL_LABEL[r.model] ?? r.model}</Badge> : <span className=\"text-xs text-muted-foreground\">—</span>\n ),\n },\n {\n id: 'number', header: 'Número', meta: { mobile: 'hidden' },\n cell: ({ row: { original: r } }) => <span className=\"font-mono text-sm text-muted-foreground\">{r.number ?? '—'}</span>,\n },\n {\n id: 'tomador', header: 'Tomador', meta: { mobile: 'title', truncate: true },\n cell: ({ row: { original: r } }) => (\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"truncate text-sm\">{r.tomador}</span>\n {r.reason && <span className=\"truncate text-[11px] text-muted-foreground\">{r.reason}</span>}\n </span>\n ),\n },\n {\n id: 'status', header: 'Situação', meta: { mobile: 'badge' },\n cell: ({ row: { original: r } }) => (\n <span className=\"inline-flex items-center gap-1.5\">\n <Badge variant={TONE_VARIANT[r.tone]}>{r.statusText}</Badge>\n {r.test && <span className=\"rounded border border-destructive px-1 text-[10px] font-semibold text-destructive\">TESTE</span>}\n </span>\n ),\n },\n {\n id: 'date', header: 'Data',\n cell: ({ row: { original: r } }) => <span className=\"text-xs tabular-nums text-muted-foreground\">{day(r.date)}</span>,\n },\n {\n id: 'total', header: 'Valor', meta: { className: 'text-right' },\n cell: ({ row: { original: r } }) => <span className=\"text-sm tabular-nums font-medium\">{money(r.total)}</span>,\n },\n ], [])\n\n const filters: ListFilterDef[] = [\n { id: 'status', label: 'Situação', allLabel: 'Todas', options: STATUS_OPTIONS, value: status, onChange: setStatus },\n { id: 'period', label: 'Período', allLabel: 'Qualquer período', options: PERIOD_OPTIONS, value: period, onChange: setPeriod },\n ]\n\n return (\n <div className=\"space-y-4\">\n <SubpageHeader title=\"Notas Fiscais\" />\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <div className=\"flex items-center gap-2\">\n <Button variant=\"outline\" size=\"sm\" onClick={load} disabled={issued === null}>\n <RefreshCw className=\"h-3.5 w-3.5\" aria-hidden /> Atualizar\n </Button>\n {picked.length > 0 && (\n <Button size=\"sm\" onClick={emit} disabled={issuing}>\n {issuing ? <Loader2 className=\"h-3.5 w-3.5 animate-spin\" aria-hidden /> : <FileCheck2 className=\"h-3.5 w-3.5\" aria-hidden />}\n {issuing ? 'Emitindo…' : `Emitir ${picked.length}`}\n </Button>\n )}\n </div>\n <ListFilterBar filters={filters} onClear={() => { setStatus(undefined); setPeriod(undefined) }} />\n </div>\n {error && (\n <p className=\"rounded-card border border-dashed p-3 text-center text-xs text-muted-foreground\">\n As notas emitidas estão listadas. As contas «sem nota» não puderam ser lidas agora: {error}\n </p>\n )}\n <DataTable\n columns={columns}\n data={rows}\n loading={issued === null}\n selectable\n selectedIds={selected}\n onSelectedIdsChange={setSelected}\n getRowId={(r) => r.invoiceId ?? r.key}\n rowClassName={(r) => (r.kind === 'pending' && !r.issuable ? 'opacity-60' : undefined)}\n mobileLayout=\"cards\"\n emptyMessage={\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium text-foreground\">Nenhuma nota neste recorte</p>\n <p className=\"text-xs text-muted-foreground\">Ajuste a situação ou o período, ou emita a partir de uma conta a receber.</p>\n </div>\n }\n />\n </div>\n )\n}\n"]}
|
package/dist/data/issued.d.ts
CHANGED
|
@@ -1,10 +1,107 @@
|
|
|
1
1
|
import type { IssuedNote, IssuedNoteEvent } from '../lib/issued-note';
|
|
2
|
+
import { type BatchResult, type OrderNote, type PendingInvoice } from '../lib/notes';
|
|
2
3
|
/**
|
|
3
4
|
* The notes of a financial invoice, reached through its order: a note covers
|
|
4
5
|
* orders (N:N `plg_fiscalbr_document_orders`) or was issued straight from one
|
|
5
6
|
* (`plg_fiscalbr_documents.order_id`, the restaurant tab).
|
|
6
7
|
*/
|
|
7
8
|
export declare function listInvoiceNotes(invoiceId: string): Promise<IssuedNote[]>;
|
|
9
|
+
/** The taker's address as the NFS-e needs it; `id` is null when the person has none yet. */
|
|
10
|
+
export interface TomadorAddress {
|
|
11
|
+
id: string | null;
|
|
12
|
+
postalCode: string | null;
|
|
13
|
+
street: string | null;
|
|
14
|
+
number: string | null;
|
|
15
|
+
district: string | null;
|
|
16
|
+
city: string | null;
|
|
17
|
+
state: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** One service line as it will read on the note. */
|
|
20
|
+
export interface NfsePreviewItem {
|
|
21
|
+
name: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
quantity: number | null;
|
|
24
|
+
unitPrice: number | null;
|
|
25
|
+
total: number | null;
|
|
26
|
+
}
|
|
27
|
+
/** The tax setup the emitter will apply, read from the unit's fiscal config. */
|
|
28
|
+
export interface NfsePreviewFiscal {
|
|
29
|
+
issRate: number | null;
|
|
30
|
+
serviceCodeNational: string | null;
|
|
31
|
+
serviceCodeMunicipal: string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Who issues the note and whether its digital certificate is in place. */
|
|
34
|
+
export interface NfsePreviewEmitter {
|
|
35
|
+
unitId: string | null;
|
|
36
|
+
company: string | null;
|
|
37
|
+
cnpj: string | null;
|
|
38
|
+
certificate: {
|
|
39
|
+
configured: boolean;
|
|
40
|
+
holder: string | null;
|
|
41
|
+
expiresAt: string | null;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** What the NFS-e will carry for a receivable, so the operator sees it — and fixes the taker — before issuing. */
|
|
45
|
+
export interface NfsePreview {
|
|
46
|
+
invoice: {
|
|
47
|
+
id: string;
|
|
48
|
+
number: string | null;
|
|
49
|
+
total: number | null;
|
|
50
|
+
discount: number | null;
|
|
51
|
+
};
|
|
52
|
+
personId: string | null;
|
|
53
|
+
tomador: {
|
|
54
|
+
name: string | null;
|
|
55
|
+
/** Raw `document_number` (CPF or CNPJ); null when the record has none. */
|
|
56
|
+
document: string | null;
|
|
57
|
+
email: string | null;
|
|
58
|
+
address: TomadorAddress | null;
|
|
59
|
+
};
|
|
60
|
+
/** The service lines; the note's discriminação is built from these. */
|
|
61
|
+
items: NfsePreviewItem[];
|
|
62
|
+
/** The text that will describe the service on the note (the invoice summary, or the lines joined). */
|
|
63
|
+
serviceDescription: string | null;
|
|
64
|
+
/** Null when the unit's fiscal config could not be read. */
|
|
65
|
+
fiscal: NfsePreviewFiscal | null;
|
|
66
|
+
/** Who issues the note (company, CNPJ, certificate); null when unreadable. */
|
|
67
|
+
emitter: NfsePreviewEmitter | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Reads the receivable and its taker so the modal can preview the note and let
|
|
71
|
+
* the operator complete a missing CPF/CNPJ or address BEFORE issuing — the two
|
|
72
|
+
* things the backend's `tomadorOf` refuses the note for.
|
|
73
|
+
*/
|
|
74
|
+
export declare function previewInvoiceNfse(invoiceId: string): Promise<NfsePreview>;
|
|
75
|
+
/** Writes the taker's CPF/CNPJ onto the person record (digits only). */
|
|
76
|
+
export declare function saveTomadorDocument(personId: string, documentDigits: string): Promise<void>;
|
|
77
|
+
/** Creates or updates the taker's address; returns the row id so the panel keeps editing it. */
|
|
78
|
+
export declare function saveTomadorAddress(personId: string, address: TomadorAddress): Promise<string>;
|
|
79
|
+
/** Issues the receivable's NFS-e through the integration service; returns the note as it stands (usually processing). */
|
|
80
|
+
export declare function issueInvoiceNfse(invoiceId: string, observacoes?: string): Promise<OrderNote>;
|
|
81
|
+
/** The receivables of the period with no live NFS-e yet (the "Sem nota" list). */
|
|
82
|
+
export declare function listPendingNfse(params?: {
|
|
83
|
+
from?: string;
|
|
84
|
+
to?: string;
|
|
85
|
+
limit?: number;
|
|
86
|
+
}): Promise<PendingInvoice[]>;
|
|
87
|
+
/**
|
|
88
|
+
* The period's receivables with no live NFS-e, read straight from the ledger so
|
|
89
|
+
* the «Notas Fiscais» screen lists them even before the integration service is
|
|
90
|
+
* reachable. `issuable` is optimistic here (the service makes the final call on
|
|
91
|
+
* emit); the batch reports back what it could not issue and why.
|
|
92
|
+
*/
|
|
93
|
+
export declare function listPendingNfseLocal(params?: {
|
|
94
|
+
from?: string;
|
|
95
|
+
limit?: number;
|
|
96
|
+
}): Promise<PendingInvoice[]>;
|
|
97
|
+
/** Issues NFS-e for several receivables at once; one failing does not stop the rest. */
|
|
98
|
+
export declare function issueNfseBatch(invoiceIds: string[]): Promise<BatchResult[]>;
|
|
99
|
+
/** The tenant's issued NFS-e, newest first, optionally by status and period (RLS scopes the tenant). */
|
|
100
|
+
export declare function listIssuedNfse(params?: {
|
|
101
|
+
status?: IssuedNote['status'];
|
|
102
|
+
from?: string;
|
|
103
|
+
limit?: number;
|
|
104
|
+
}): Promise<IssuedNote[]>;
|
|
8
105
|
export declare function listNoteEvents(documentId: string): Promise<IssuedNoteEvent[]>;
|
|
9
106
|
/** Asks PlugNotas for the note's current state, through the integration service; returns the stored status. */
|
|
10
107
|
export declare function refreshNote(documentId: string): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issued.d.ts","sourceRoot":"","sources":["../../src/data/issued.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"issued.d.ts","sourceRoot":"","sources":["../../src/data/issued.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAA+C,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAiCjI;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA8B/E;AAED,4FAA4F;AAC5F,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;I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;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3F;AAED,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../src/data/registries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../../src/data/registries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAwGjE,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,EAQ/C,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './data/receipt';
|
|
|
13
13
|
export * from './lib/receipt';
|
|
14
14
|
export * from './lib/issued-note';
|
|
15
15
|
export { InvoiceNotesButton } from './views/InvoiceNotesButton';
|
|
16
|
+
export { NotasFiscaisView } from './views/NotasFiscaisView';
|
|
16
17
|
export { NoteReceiptCard } from './views/NoteReceiptCard';
|
|
17
18
|
export { InboundNotesPage } from './views/InboundNotesPage';
|
|
18
19
|
export { InboundNotesView } from './views/InboundNotesView';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAqD,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAuBtG,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC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View } from './chunk-VMZN3UYW.js';
|
|
2
|
+
import { findInboxNoteByOperation, findInboxNoteByNumber } from './chunk-GXI2FGDQ.js';
|
|
3
|
+
export { NfeParseError, NoteReconcileView, PullByKeyError, STOCK_BEARING_ENTRY_TYPES, acceptNote, addNoteAttachment, extractPaymentCode, fillInboxLines, findInboxNoteByNumber, findInboxNoteByOperation, getInboxIntakeHealth, getInboxNote, getInboxNotePdf, getInboxNoteXml, getNotePayable, healInboxNote, isStockBearing, linkInboxSupplier, listChartAccountNodes, listChartAccounts, listInboxNotes, listMeasurementUnits, listNoteAttachments, listProductStockUnits, listProductsByIds, listStockLocations, listSupplierMap, moveNoteAttachmentsToInvoice, onlyDigits, parseNfeXml, paymentLabel, paymentTypeFromCode, pullNoteByKey, rejectNote, removeNoteAttachment, saveNoteDecision, searchProducts, stageNoteFromXml, suggestNoteItems, syncNewNotes, toStagePayload } from './chunk-GXI2FGDQ.js';
|
|
2
4
|
export { IssuedNotesView, ReturnedNotesView, TaxGroupsView } from './chunk-JRP5AZFJ.js';
|
|
3
5
|
import { emitters, emitterErrorSentence, TAX_REGIMES, SPECIAL_TAX_REGIMES, GATE_LABELS } from './chunk-ZJGXUJKM.js';
|
|
4
6
|
export { GATE_LABELS, SPECIAL_TAX_REGIMES, TAX_REGIMES, emitterErrorSentence, emitters } from './chunk-ZJGXUJKM.js';
|
|
5
|
-
export { OrderNoteCard } from './chunk-SSPDH22E.js';
|
|
6
|
-
export { InvoiceNotesButton, cancelNote, fetchNotePdf, listInvoiceNotes, listNoteEvents, refreshNote } from './chunk-F325US5P.js';
|
|
7
|
-
export { CANCEL_MIN_JUSTIFICATION, EVENT_LABEL, MODEL_LABEL, NOTE_STATUS_LABEL, STATUS_META, eventStatusLabel, explainRejection, isWithoutEffect, noteErrorSentence, notesButtonState, optionSentence, orderNotes, recipientLabel, refusalSentence, statusLabel, summarizeNotes } from './chunk-ODMEESFD.js';
|
|
8
|
-
export { ABATE_REFUSALS, NoteReceiptCard, abateInvoiceItem, abateRefusalOf, getReceiptOccurrence } from './chunk-3BDFMEYY.js';
|
|
9
|
-
import { findInboxNoteByOperation, findInboxNoteByNumber } from './chunk-GXI2FGDQ.js';
|
|
10
|
-
export { NfeParseError, NoteReconcileView, PullByKeyError, STOCK_BEARING_ENTRY_TYPES, acceptNote, addNoteAttachment, extractPaymentCode, fillInboxLines, findInboxNoteByNumber, findInboxNoteByOperation, getInboxIntakeHealth, getInboxNote, getInboxNotePdf, getInboxNoteXml, getNotePayable, healInboxNote, isStockBearing, linkInboxSupplier, listChartAccountNodes, listChartAccounts, listInboxNotes, listMeasurementUnits, listNoteAttachments, listProductStockUnits, listProductsByIds, listStockLocations, listSupplierMap, moveNoteAttachmentsToInvoice, onlyDigits, parseNfeXml, paymentLabel, paymentTypeFromCode, pullNoteByKey, rejectNote, removeNoteAttachment, saveNoteDecision, searchProducts, stageNoteFromXml, suggestNoteItems, syncNewNotes, toStagePayload } from './chunk-GXI2FGDQ.js';
|
|
11
7
|
import './chunk-5LI2FDOM.js';
|
|
8
|
+
export { OrderNoteCard } from './chunk-ITWWGLEV.js';
|
|
9
|
+
export { InvoiceNotesButton } from './chunk-E5TUJOGT.js';
|
|
10
|
+
export { NotasFiscaisView } from './chunk-YSRG5JQI.js';
|
|
11
|
+
export { cancelNote, fetchNotePdf, issueInvoiceNfse, issueNfseBatch, listInvoiceNotes, listIssuedNfse, listNoteEvents, listPendingNfse, listPendingNfseLocal, previewInvoiceNfse, refreshNote, saveTomadorAddress, saveTomadorDocument } from './chunk-U4TQSVWI.js';
|
|
12
|
+
export { CANCEL_MIN_JUSTIFICATION, EVENT_LABEL, MODEL_LABEL, NOTE_STATUS_LABEL, STATUS_META, eventStatusLabel, explainRejection, invoiceNotes, isWithoutEffect, noteErrorSentence, notesButtonState, optionSentence, orderNotes, recipientLabel, refusalSentence, statusLabel, summarizeNotes } from './chunk-CWYTWKXW.js';
|
|
12
13
|
import { EmitterError } from './chunk-2GHTB3Z2.js';
|
|
13
14
|
export { EmitterError } from './chunk-2GHTB3Z2.js';
|
|
15
|
+
export { ABATE_REFUSALS, NoteReceiptCard, abateInvoiceItem, abateRefusalOf, getReceiptOccurrence } from './chunk-3BDFMEYY.js';
|
|
14
16
|
export { SHORTAGE_REASONS, hasShortage, isShortageReason, parseQty, pendingAbatement, receivedFraction, receivedQty, receivedStockQty, receivedValue, shortageQty, shortageReasonKey, shortageValue, summarizeOccurrence } from './chunk-DHCCZXUM.js';
|
|
15
17
|
import React from 'react';
|
|
16
18
|
import { createConnectionStore, recordRailFields, RECORD_GROUP, activeFacet, lazyComponent, registerTranslations, describeError, navigateApp, maskCpfCnpj, tl, connectionStatus, definePlugin } from '@fayz-ai/core';
|
|
@@ -20,7 +22,7 @@ import { Eye, Check, X, ShieldCheck } from 'lucide-react';
|
|
|
20
22
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
23
|
import { MIGRATIONS } from '#migrations/main';
|
|
22
24
|
import { registerDocumentOpener, UNIT_DETAIL_ZONES, ORDER_DETAIL_ZONES } from '@fayz-ai/admin';
|
|
23
|
-
import { FINANCIAL_INVOICE_ZONES } from '@fayz-ai/financial/views/zones';
|
|
25
|
+
import { FINANCIAL_FISCAL_ZONES, FINANCIAL_INVOICE_ZONES } from '@fayz-ai/financial/views/zones';
|
|
24
26
|
|
|
25
27
|
function EmittersPanel() {
|
|
26
28
|
const [list, setList] = React.useState(null);
|
|
@@ -451,6 +453,12 @@ var taxGroupEntity = {
|
|
|
451
453
|
columns: 2,
|
|
452
454
|
description: "A reforma tribut\xE1ria. Em branco enquanto n\xE3o for exigido da sua opera\xE7\xE3o."
|
|
453
455
|
},
|
|
456
|
+
{
|
|
457
|
+
id: "nfse",
|
|
458
|
+
label: "NFS-e (servi\xE7o)",
|
|
459
|
+
columns: 1,
|
|
460
|
+
description: "Como os servi\xE7os deste grupo aparecem na nota de servi\xE7o."
|
|
461
|
+
},
|
|
454
462
|
{ ...RECORD_GROUP }
|
|
455
463
|
],
|
|
456
464
|
fields: [
|
|
@@ -495,6 +503,18 @@ var taxGroupEntity = {
|
|
|
495
503
|
{ key: "cofinsRate", label: "Al\xEDquota COFINS (%)", type: "number", min: 0, max: 100, showInTable: false, group: "pis_cofins" },
|
|
496
504
|
{ key: "ibsCbsSituation", label: "Situa\xE7\xE3o IBS/CBS", type: "text", showInTable: false, group: "ibs_cbs" },
|
|
497
505
|
{ key: "ibsCbsClassification", label: "Classifica\xE7\xE3o IBS/CBS", type: "text", showInTable: false, group: "ibs_cbs" },
|
|
506
|
+
// The discriminação the city hall note carries for this group's services,
|
|
507
|
+
// when the service's own name is not what should be printed («Sessão de
|
|
508
|
+
// terapia capilar» → «PRESTAÇÃO DE SERVIÇOS DE ESTÉTICA»). Empty = the name.
|
|
509
|
+
{
|
|
510
|
+
key: "nfseDescription",
|
|
511
|
+
label: "Descri\xE7\xE3o na nota",
|
|
512
|
+
type: "textarea",
|
|
513
|
+
showInTable: false,
|
|
514
|
+
group: "nfse",
|
|
515
|
+
span: 2,
|
|
516
|
+
hint: "Texto que descreve o servi\xE7o na NFS-e. Em branco, a nota usa o nome do pr\xF3prio servi\xE7o."
|
|
517
|
+
},
|
|
498
518
|
...recordRailFields({ tagsTable: "plg_fiscalbr_tax_groups", activeLabel: "Ativo" })
|
|
499
519
|
],
|
|
500
520
|
data: {
|
|
@@ -832,10 +852,10 @@ registerDocumentOpener(NFE_OPENER);
|
|
|
832
852
|
// src/index.ts
|
|
833
853
|
registerTranslations(fiscalBrLocales);
|
|
834
854
|
var InboundNotesPage3 = React.lazy(() => import('./InboundNotesPage-IEPEEOY2.js').then((m) => ({ default: m.InboundNotesPage })));
|
|
835
|
-
var
|
|
836
|
-
var
|
|
837
|
-
var
|
|
838
|
-
var OrderNoteCard2 = lazyComponent(() => import('./OrderNoteCard-
|
|
855
|
+
var UnitFiscalCard = lazyComponent(() => import('./UnitFiscalWidgets-XSED3WPQ.js').then((m) => m.UnitFiscalCard));
|
|
856
|
+
var InvoiceNotesButton2 = lazyComponent(() => import('./InvoiceNotesButton-4L7SLYMA.js').then((m) => m.InvoiceNotesButton));
|
|
857
|
+
var NotasFiscaisView2 = React.lazy(() => import('./NotasFiscaisView-LU4A65J7.js').then((m) => ({ default: m.NotasFiscaisView })));
|
|
858
|
+
var OrderNoteCard2 = lazyComponent(() => import('./OrderNoteCard-NZOVNTR3.js').then((m) => m.OrderNoteCard));
|
|
839
859
|
var NoteReceiptCard2 = lazyComponent(() => import('./NoteReceiptCard-H5BMFPU7.js').then((m) => m.NoteReceiptCard));
|
|
840
860
|
function createPlugNotasPlugin(options = {}) {
|
|
841
861
|
return definePlugin({
|
|
@@ -858,8 +878,18 @@ function createPlugNotasPlugin(options = {}) {
|
|
|
858
878
|
//
|
|
859
879
|
// A rota própria FICA: ela é o deep link (`#/inbound-notes`), e é por onde o
|
|
860
880
|
// agente e um link de e-mail chegam sem passar pela faixa de abas.
|
|
881
|
+
// «Notas Fiscais» NÃO tem linha no rail: ela já vive dentro do Financeiro
|
|
882
|
+
// (grupo «Fiscal» → Notas emitidas), ao lado de Contas a Receber, de onde a
|
|
883
|
+
// nota sai. Uma segunda entrada no menu principal era repetição. A rota
|
|
884
|
+
// própria FICA como deep link (`#/fiscal/notas-fiscais`). Entrada de Notas
|
|
885
|
+
// segue SEM linha — assunto de Estoque, montada por extraViews do inventário.
|
|
861
886
|
navigation: [],
|
|
862
887
|
routes: [
|
|
888
|
+
{
|
|
889
|
+
path: "/fiscal/notas-fiscais",
|
|
890
|
+
component: NotasFiscaisView2,
|
|
891
|
+
permission: { feature: "financial", action: "read" }
|
|
892
|
+
},
|
|
863
893
|
{
|
|
864
894
|
path: "/inbound-notes",
|
|
865
895
|
// O registro de rotas monta componentes sem prop. A opção do host entra
|
|
@@ -874,9 +904,18 @@ function createPlugNotasPlugin(options = {}) {
|
|
|
874
904
|
registries: fiscalRegistries,
|
|
875
905
|
widgets: [
|
|
876
906
|
{
|
|
877
|
-
|
|
907
|
+
// One card for the whole fiscal setup: certificate + emission config.
|
|
908
|
+
id: "fiscal-br-unit-fiscal",
|
|
878
909
|
zone: UNIT_DETAIL_ZONES.certificate,
|
|
879
|
-
component:
|
|
910
|
+
component: UnitFiscalCard,
|
|
911
|
+
order: 0,
|
|
912
|
+
permission: { feature: "financial", action: "read" }
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
// The whole «Fiscal → Notas emitidas» screen: issued list + «Sem nota»/batch.
|
|
916
|
+
id: "fiscal-br-notas-fiscais",
|
|
917
|
+
zone: FINANCIAL_FISCAL_ZONES.documents,
|
|
918
|
+
component: NotasFiscaisView2,
|
|
880
919
|
order: 0,
|
|
881
920
|
permission: { feature: "financial", action: "read" }
|
|
882
921
|
},
|
|
@@ -902,13 +941,6 @@ function createPlugNotasPlugin(options = {}) {
|
|
|
902
941
|
component: OrderNoteCard2,
|
|
903
942
|
order: 0,
|
|
904
943
|
permission: { feature: "financial", action: "read" }
|
|
905
|
-
},
|
|
906
|
-
{
|
|
907
|
-
id: "fiscal-br-unit-fiscal",
|
|
908
|
-
zone: UNIT_DETAIL_ZONES.fiscal,
|
|
909
|
-
component: UnitFiscalWidget,
|
|
910
|
-
order: 0,
|
|
911
|
-
permission: { feature: "financial", action: "read" }
|
|
912
944
|
}
|
|
913
945
|
],
|
|
914
946
|
// PlugNotas is reached by the integration service (control-sdk-backend
|