@baack-software/baack-ts-crm 0.0.0-stage → 0.0.3
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/LICENSE +201 -0
- package/README.md +74 -2
- package/dist/account.d.ts +36 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/account.js +48 -0
- package/dist/account.js.map +1 -0
- package/dist/backend.d.ts +104 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +328 -0
- package/dist/backend.js.map +1 -0
- package/dist/crm-client.d.ts +164 -0
- package/dist/crm-client.d.ts.map +1 -0
- package/dist/crm-client.js +252 -0
- package/dist/crm-client.js.map +1 -0
- package/dist/deal-order.d.ts +42 -0
- package/dist/deal-order.d.ts.map +1 -0
- package/dist/deal-order.js +80 -0
- package/dist/deal-order.js.map +1 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +33 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.d.ts +53 -0
- package/dist/invoices.d.ts.map +1 -0
- package/dist/invoices.js +155 -0
- package/dist/invoices.js.map +1 -0
- package/dist/leads.d.ts +29 -0
- package/dist/leads.d.ts.map +1 -0
- package/dist/leads.js +56 -0
- package/dist/leads.js.map +1 -0
- package/dist/mock/index.d.ts +43 -0
- package/dist/mock/index.d.ts.map +1 -0
- package/dist/mock/index.js +303 -0
- package/dist/mock/index.js.map +1 -0
- package/dist/money.d.ts +29 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/money.js +82 -0
- package/dist/money.js.map +1 -0
- package/dist/period.d.ts +30 -0
- package/dist/period.d.ts.map +1 -0
- package/dist/period.js +49 -0
- package/dist/period.js.map +1 -0
- package/dist/pipeline.d.ts +36 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +58 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/react/Charts.d.ts +19 -0
- package/dist/react/Charts.d.ts.map +1 -0
- package/dist/react/Charts.js +38 -0
- package/dist/react/Charts.js.map +1 -0
- package/dist/react/ChoiceCombobox.d.ts +36 -0
- package/dist/react/ChoiceCombobox.d.ts.map +1 -0
- package/dist/react/ChoiceCombobox.js +105 -0
- package/dist/react/ChoiceCombobox.js.map +1 -0
- package/dist/react/CompanyAccountView.d.ts +21 -0
- package/dist/react/CompanyAccountView.d.ts.map +1 -0
- package/dist/react/CompanyAccountView.js +27 -0
- package/dist/react/CompanyAccountView.js.map +1 -0
- package/dist/react/DashboardCards.d.ts +32 -0
- package/dist/react/DashboardCards.d.ts.map +1 -0
- package/dist/react/DashboardCards.js +38 -0
- package/dist/react/DashboardCards.js.map +1 -0
- package/dist/react/DealsBoard.d.ts +49 -0
- package/dist/react/DealsBoard.d.ts.map +1 -0
- package/dist/react/DealsBoard.js +82 -0
- package/dist/react/DealsBoard.js.map +1 -0
- package/dist/react/Details.d.ts +85 -0
- package/dist/react/Details.d.ts.map +1 -0
- package/dist/react/Details.js +268 -0
- package/dist/react/Details.js.map +1 -0
- package/dist/react/Forms.d.ts +190 -0
- package/dist/react/Forms.d.ts.map +1 -0
- package/dist/react/Forms.js +494 -0
- package/dist/react/Forms.js.map +1 -0
- package/dist/react/LeadsTable.d.ts +22 -0
- package/dist/react/LeadsTable.d.ts.map +1 -0
- package/dist/react/LeadsTable.js +79 -0
- package/dist/react/LeadsTable.js.map +1 -0
- package/dist/react/Sales.d.ts +68 -0
- package/dist/react/Sales.d.ts.map +1 -0
- package/dist/react/Sales.js +270 -0
- package/dist/react/Sales.js.map +1 -0
- package/dist/react/SidePanel.d.ts +31 -0
- package/dist/react/SidePanel.d.ts.map +1 -0
- package/dist/react/SidePanel.js +49 -0
- package/dist/react/SidePanel.js.map +1 -0
- package/dist/react/format.d.ts +28 -0
- package/dist/react/format.d.ts.map +1 -0
- package/dist/react/format.js +30 -0
- package/dist/react/format.js.map +1 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +15 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/parts.d.ts +55 -0
- package/dist/react/parts.d.ts.map +1 -0
- package/dist/react/parts.js +82 -0
- package/dist/react/parts.js.map +1 -0
- package/dist/react/pipeline-choice.d.ts +19 -0
- package/dist/react/pipeline-choice.d.ts.map +1 -0
- package/dist/react/pipeline-choice.js +39 -0
- package/dist/react/pipeline-choice.js.map +1 -0
- package/dist/react/text.d.ts +232 -0
- package/dist/react/text.d.ts.map +1 -0
- package/dist/react/text.js +229 -0
- package/dist/react/text.js.map +1 -0
- package/dist/react/ui/alert.d.ts +11 -0
- package/dist/react/ui/alert.d.ts.map +1 -0
- package/dist/react/ui/alert.js +29 -0
- package/dist/react/ui/alert.js.map +1 -0
- package/dist/react/ui/badge.d.ts +10 -0
- package/dist/react/ui/badge.d.ts.map +1 -0
- package/dist/react/ui/badge.js +26 -0
- package/dist/react/ui/badge.js.map +1 -0
- package/dist/react/ui/button.d.ts +11 -0
- package/dist/react/ui/button.d.ts.map +1 -0
- package/dist/react/ui/button.js +37 -0
- package/dist/react/ui/button.js.map +1 -0
- package/dist/react/ui/card.d.ts +12 -0
- package/dist/react/ui/card.d.ts.map +1 -0
- package/dist/react/ui/card.js +26 -0
- package/dist/react/ui/card.js.map +1 -0
- package/dist/react/ui/chart.d.ts +45 -0
- package/dist/react/ui/chart.d.ts.map +1 -0
- package/dist/react/ui/chart.js +116 -0
- package/dist/react/ui/chart.js.map +1 -0
- package/dist/react/ui/input.d.ts +4 -0
- package/dist/react/ui/input.d.ts.map +1 -0
- package/dist/react/ui/input.js +8 -0
- package/dist/react/ui/input.js.map +1 -0
- package/dist/react/ui/label.d.ts +5 -0
- package/dist/react/ui/label.d.ts.map +1 -0
- package/dist/react/ui/label.js +10 -0
- package/dist/react/ui/label.js.map +1 -0
- package/dist/react/ui/progress.d.ts +5 -0
- package/dist/react/ui/progress.d.ts.map +1 -0
- package/dist/react/ui/progress.js +10 -0
- package/dist/react/ui/progress.js.map +1 -0
- package/dist/react/ui/select.d.ts +16 -0
- package/dist/react/ui/select.d.ts.map +1 -0
- package/dist/react/ui/select.js +37 -0
- package/dist/react/ui/select.js.map +1 -0
- package/dist/react/ui/separator.d.ts +5 -0
- package/dist/react/ui/separator.d.ts.map +1 -0
- package/dist/react/ui/separator.js +10 -0
- package/dist/react/ui/separator.js.map +1 -0
- package/dist/react/ui/sheet.d.ts +15 -0
- package/dist/react/ui/sheet.d.ts.map +1 -0
- package/dist/react/ui/sheet.js +38 -0
- package/dist/react/ui/sheet.js.map +1 -0
- package/dist/react/ui/skeleton.d.ts +3 -0
- package/dist/react/ui/skeleton.d.ts.map +1 -0
- package/dist/react/ui/skeleton.js +7 -0
- package/dist/react/ui/skeleton.js.map +1 -0
- package/dist/react/ui/table.d.ts +11 -0
- package/dist/react/ui/table.d.ts.map +1 -0
- package/dist/react/ui/table.js +29 -0
- package/dist/react/ui/table.js.map +1 -0
- package/dist/react/ui/tabs.d.ts +12 -0
- package/dist/react/ui/tabs.d.ts.map +1 -0
- package/dist/react/ui/tabs.js +31 -0
- package/dist/react/ui/tabs.js.map +1 -0
- package/dist/react/views.d.ts +82 -0
- package/dist/react/views.d.ts.map +1 -0
- package/dist/react/views.js +241 -0
- package/dist/react/views.js.map +1 -0
- package/dist/sales.d.ts +82 -0
- package/dist/sales.d.ts.map +1 -0
- package/dist/sales.js +87 -0
- package/dist/sales.js.map +1 -0
- package/dist/store.d.ts +159 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +305 -0
- package/dist/store.js.map +1 -0
- package/dist/target.d.ts +22 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +40 -0
- package/dist/target.js.map +1 -0
- package/dist/types.d.ts +204 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +100 -4
- package/src/account.ts +79 -0
- package/src/backend.ts +501 -0
- package/src/crm-client.ts +393 -0
- package/src/deal-order.ts +116 -0
- package/src/errors.ts +34 -0
- package/src/index.ts +13 -0
- package/src/invoices.ts +177 -0
- package/src/leads.ts +78 -0
- package/src/mock/index.ts +398 -0
- package/src/money.ts +104 -0
- package/src/period.ts +71 -0
- package/src/pipeline.ts +82 -0
- package/src/react/Charts.tsx +143 -0
- package/src/react/ChoiceCombobox.tsx +227 -0
- package/src/react/CompanyAccountView.tsx +198 -0
- package/src/react/DashboardCards.tsx +171 -0
- package/src/react/DealsBoard.tsx +344 -0
- package/src/react/Details.tsx +870 -0
- package/src/react/Forms.tsx +1486 -0
- package/src/react/LeadsTable.tsx +234 -0
- package/src/react/Sales.tsx +827 -0
- package/src/react/SidePanel.tsx +104 -0
- package/src/react/format.ts +53 -0
- package/src/react/index.ts +14 -0
- package/src/react/parts.tsx +183 -0
- package/src/react/pipeline-choice.ts +54 -0
- package/src/react/text.ts +232 -0
- package/src/react/ui/README.md +6 -0
- package/src/react/ui/alert.tsx +75 -0
- package/src/react/ui/badge.tsx +48 -0
- package/src/react/ui/button.tsx +66 -0
- package/src/react/ui/card.tsx +102 -0
- package/src/react/ui/chart.tsx +304 -0
- package/src/react/ui/input.tsx +18 -0
- package/src/react/ui/label.tsx +23 -0
- package/src/react/ui/progress.tsx +30 -0
- package/src/react/ui/select.tsx +189 -0
- package/src/react/ui/separator.tsx +27 -0
- package/src/react/ui/sheet.tsx +145 -0
- package/src/react/ui/skeleton.tsx +13 -0
- package/src/react/ui/table.tsx +113 -0
- package/src/react/ui/tabs.tsx +89 -0
- package/src/react/views.tsx +633 -0
- package/src/sales.ts +167 -0
- package/src/store.ts +528 -0
- package/src/target.ts +54 -0
- package/src/types.ts +230 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { Workflow, WorkflowStage } from '@baack-software/baack-ts-client';
|
|
2
|
+
import type { Ref } from '@baack-software/baack-ts-tasks';
|
|
3
|
+
/**
|
|
4
|
+
* An amount of money in whole minor units (pence, cents), as content money items write it: `unitValue: 125000` with
|
|
5
|
+
* `currencyCode: "GBP"` is 1,250.00 GBP. `formattedValue` is the server's text for it, when it sends one. Decided
|
|
6
|
+
* 24 Oct 2026; invoices move to the same format.
|
|
7
|
+
*/
|
|
8
|
+
export interface Money {
|
|
9
|
+
unitValue: number;
|
|
10
|
+
/** An ISO 4217 code such as `GBP`. */
|
|
11
|
+
currencyCode: string;
|
|
12
|
+
formattedValue?: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** Where a lead came from. */
|
|
15
|
+
export type LeadSource = 'WEBSITE' | 'REFERRAL' | 'SOCIAL' | 'EMAIL' | 'CALL' | 'ADS' | 'EVENT' | 'UNKNOWN';
|
|
16
|
+
/** How far a lead has got: only progress. How it ended is its `outcome`. */
|
|
17
|
+
export type LeadStatus = 'NEW' | 'CONTACTED' | 'QUALIFIED';
|
|
18
|
+
/**
|
|
19
|
+
* How a lead ended, as a deal's outcome does: still being worked, converted into a deal (a lead's won), or closed as
|
|
20
|
+
* unqualified (a lead's lost).
|
|
21
|
+
*/
|
|
22
|
+
export type LeadOutcome = 'IN_PROGRESS' | 'CONVERTED' | 'CLOSED';
|
|
23
|
+
/**
|
|
24
|
+
* A prospect who hasn't been qualified yet. People are always identities, so their names are held securely as person
|
|
25
|
+
* names: a lead links a contact identity rather than holding a name, and a business by its contact company, whose name
|
|
26
|
+
* is the company's. A lead converted into a deal is the deal's `leadSource`.
|
|
27
|
+
*/
|
|
28
|
+
export interface Lead {
|
|
29
|
+
urn: string;
|
|
30
|
+
url?: string | null;
|
|
31
|
+
/** The company whose lead this is. */
|
|
32
|
+
owner: Ref;
|
|
33
|
+
/** What the lead is about, for example "Club robes for the spring season". */
|
|
34
|
+
title: string;
|
|
35
|
+
/** The person, as an identity. */
|
|
36
|
+
contactIdentity?: Ref | null;
|
|
37
|
+
/** The prospect's company, which holds its name. A consumer's lead has none. */
|
|
38
|
+
contactCompany?: Ref | null;
|
|
39
|
+
source: LeadSource;
|
|
40
|
+
status: LeadStatus;
|
|
41
|
+
/** In progress, converted or closed. In progress when absent. */
|
|
42
|
+
outcome?: LeadOutcome | null;
|
|
43
|
+
/** What the lead could be worth. Counts towards the sales target until the lead is converted into a deal. */
|
|
44
|
+
targetValue?: Money | null;
|
|
45
|
+
/** Who's working the lead. */
|
|
46
|
+
assignee?: Ref | null;
|
|
47
|
+
/** Why the lead was closed as unqualified. */
|
|
48
|
+
closedReason?: string | null;
|
|
49
|
+
/** A content entity for the business's own fields about the lead, as companies have. */
|
|
50
|
+
entity?: Ref | null;
|
|
51
|
+
createdTimestamp: string;
|
|
52
|
+
updatedTimestamp?: string | null;
|
|
53
|
+
}
|
|
54
|
+
/** How a deal stands: still open, won or lost. */
|
|
55
|
+
export type DealOutcome = 'OPEN' | 'WON' | 'LOST';
|
|
56
|
+
/**
|
|
57
|
+
* A deal pipeline: any workflow. Workflows are dynamic and not about deals, so a deal carries its own outcome and
|
|
58
|
+
* probability; its stage is only where it is in the workflow.
|
|
59
|
+
*/
|
|
60
|
+
export type Pipeline = Workflow;
|
|
61
|
+
/** A pipeline's stage: a workflow stage. */
|
|
62
|
+
export type PipelineStage = WorkflowStage;
|
|
63
|
+
/**
|
|
64
|
+
* A qualified opportunity, moving through a pipeline (a workflow) stage by stage until it's won or lost.
|
|
65
|
+
*/
|
|
66
|
+
export interface Deal {
|
|
67
|
+
urn: string;
|
|
68
|
+
url?: string | null;
|
|
69
|
+
owner: Ref;
|
|
70
|
+
title: string;
|
|
71
|
+
/** The customer's companies: usually one. */
|
|
72
|
+
contactCompanies: Ref[];
|
|
73
|
+
/** The people involved, as identities. */
|
|
74
|
+
contactIdentities: Ref[];
|
|
75
|
+
/** The deal's stage, in its pipeline (any workflow): named as a task's stage is. */
|
|
76
|
+
workflowStage?: Ref | null;
|
|
77
|
+
/** Open, won or lost, on the deal itself rather than its stage. Open when absent. */
|
|
78
|
+
outcome?: DealOutcome | null;
|
|
79
|
+
/** The chance it's won, 0 to 100, for weighted pipeline value. */
|
|
80
|
+
probability?: number | null;
|
|
81
|
+
/** What the deal is worth. Replaces its lead's target value in the sales target. */
|
|
82
|
+
targetValue?: Money | null;
|
|
83
|
+
/** When it's expected to close. */
|
|
84
|
+
targetCloseTimestamp?: string | null;
|
|
85
|
+
/** When it was won or lost, cleared when it reopens. */
|
|
86
|
+
closeTimestamp?: string | null;
|
|
87
|
+
/** Why it was lost, as leads have `closedReason`. */
|
|
88
|
+
lostReason?: string | null;
|
|
89
|
+
assignee?: Ref | null;
|
|
90
|
+
/** The lead it was converted from. */
|
|
91
|
+
leadSource?: Ref | null;
|
|
92
|
+
/** Invoices raised for it; there may be several. The link lives here, not on the invoice. */
|
|
93
|
+
invoices: Ref[];
|
|
94
|
+
/** A content entity for the business's own fields about the deal, as companies have. */
|
|
95
|
+
entity?: Ref | null;
|
|
96
|
+
createdTimestamp: string;
|
|
97
|
+
updatedTimestamp?: string | null;
|
|
98
|
+
}
|
|
99
|
+
/** The payment invoice statuses the API has. */
|
|
100
|
+
export type InvoiceStatus = 'DRAFT' | 'IN_REVIEW' | 'AUTHORISED' | 'PENDING' | 'VOIDED' | 'PAID' | 'REFUNDED';
|
|
101
|
+
/** Whether an invoice's line prices include tax. */
|
|
102
|
+
export type LineItemTax = 'EXCLUSIVE' | 'INCLUSIVE' | 'NO_TAX';
|
|
103
|
+
/** How an invoice line is taxed. */
|
|
104
|
+
export type Taxability = 'TAXABLE' | 'NON_TAXABLE' | 'TAX_EXEMPT' | 'PARTIALLY_TAXABLE' | 'NOT_APPLICABLE';
|
|
105
|
+
/** Who pays or receives an invoice: a company, an identity, or both (a person at a company). */
|
|
106
|
+
export interface InvoiceParty {
|
|
107
|
+
company?: Ref | null;
|
|
108
|
+
identity?: Ref | null;
|
|
109
|
+
}
|
|
110
|
+
/** An invoice line, as the API has it (`/n/v1/invoiceline/`). */
|
|
111
|
+
export interface InvoiceLine {
|
|
112
|
+
urn: string;
|
|
113
|
+
lineNumber?: number | null;
|
|
114
|
+
description?: string | null;
|
|
115
|
+
itemCode?: string | null;
|
|
116
|
+
quantity?: number | null;
|
|
117
|
+
/** In major units (pounds), unlike the line's money amounts. */
|
|
118
|
+
unitPrice?: number | null;
|
|
119
|
+
price?: Money | null;
|
|
120
|
+
tax?: Money | null;
|
|
121
|
+
discountPrice?: Money | null;
|
|
122
|
+
discountRate?: number | null;
|
|
123
|
+
taxability?: Taxability | null;
|
|
124
|
+
taxName?: string | null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A payment invoice (`/n/v1/paymentinvoice/`): its amounts as money in `currencyCode`, its lines, and the payments and
|
|
128
|
+
* refunds against it (`remittances`). Deals link to their invoices (`Deal.invoices`).
|
|
129
|
+
*/
|
|
130
|
+
export interface Invoice {
|
|
131
|
+
urn: string;
|
|
132
|
+
url?: string | null;
|
|
133
|
+
owner: Ref;
|
|
134
|
+
/** Who pays. */
|
|
135
|
+
remitter?: InvoiceParty | null;
|
|
136
|
+
/** Who the invoice is addressed to. */
|
|
137
|
+
recipient?: InvoiceParty | null;
|
|
138
|
+
status: InvoiceStatus;
|
|
139
|
+
currencyCode: string;
|
|
140
|
+
lineItemTax?: LineItemTax | null;
|
|
141
|
+
subTotal?: Money | null;
|
|
142
|
+
discount?: Money | null;
|
|
143
|
+
tax?: Money | null;
|
|
144
|
+
/** Required on create. */
|
|
145
|
+
total: Money;
|
|
146
|
+
paid?: Money | null;
|
|
147
|
+
refunded?: Money | null;
|
|
148
|
+
issuedTimestamp?: string | null;
|
|
149
|
+
dueTimestamp?: string | null;
|
|
150
|
+
fullyPaidTimestamp?: string | null;
|
|
151
|
+
lines?: InvoiceLine[];
|
|
152
|
+
/** Payments and refunds against it, as the API lists them on the invoice. */
|
|
153
|
+
remittances?: Remittance[];
|
|
154
|
+
updatedTimestamp?: string | null;
|
|
155
|
+
}
|
|
156
|
+
/** Whether a remittance is money received for an invoice or a refund paid back. */
|
|
157
|
+
export type RemittanceDirection = 'PAYMENT' | 'REFUND';
|
|
158
|
+
export type RemittanceStatus = 'RECEIVED' | 'FAILED' | 'REVERSED';
|
|
159
|
+
export type RemittanceMethod = 'BANK_TRANSFER' | 'CARD_PAYMENT' | 'DIRECT_DEBIT' | 'CASH' | 'E_WALLET' | 'OTHER';
|
|
160
|
+
/**
|
|
161
|
+
* One payment received against an invoice, or a refund paid back (`/n/v1/invoiceremittance/`). It has no owner of its
|
|
162
|
+
* own: a company's remittances are its invoices'. An invoice's `paid`, `refunded`, `status` and `fullyPaidTimestamp`
|
|
163
|
+
* follow from them (see `invoiceFromRemittances`).
|
|
164
|
+
*/
|
|
165
|
+
export interface Remittance {
|
|
166
|
+
urn: string;
|
|
167
|
+
url?: string | null;
|
|
168
|
+
paymentInvoice: Ref;
|
|
169
|
+
remittanceDirection: RemittanceDirection;
|
|
170
|
+
remittanceStatus: RemittanceStatus;
|
|
171
|
+
remittanceMethod: RemittanceMethod;
|
|
172
|
+
value: Money;
|
|
173
|
+
/** The bank or card reference. */
|
|
174
|
+
reference?: string | null;
|
|
175
|
+
/** Who paid: a company, an identity, or both. */
|
|
176
|
+
remittingCompany?: Ref | null;
|
|
177
|
+
remittingIdentity?: Ref | null;
|
|
178
|
+
receivedTimestamp: string;
|
|
179
|
+
}
|
|
180
|
+
/** The CRM concepts, each served by the API or by sample data (see CrmClient). */
|
|
181
|
+
export type CrmConcept = 'leads' | 'deals' | 'pipelines' | 'invoices' | 'remittances';
|
|
182
|
+
export declare const CRM_CONCEPTS: readonly CrmConcept[];
|
|
183
|
+
/**
|
|
184
|
+
* A new person, as the lead and customer forms make them: an identity with a person, the person's name (held
|
|
185
|
+
* securely, as person names are) and an email address.
|
|
186
|
+
*/
|
|
187
|
+
export interface NewContact {
|
|
188
|
+
givenName: string;
|
|
189
|
+
familyName?: string | undefined;
|
|
190
|
+
email?: string | undefined;
|
|
191
|
+
telephone?: string | undefined;
|
|
192
|
+
}
|
|
193
|
+
/** How to reach a person: their email address and telephone number, each empty when they have none. */
|
|
194
|
+
export interface ContactDetails {
|
|
195
|
+
email: string;
|
|
196
|
+
telephone: string;
|
|
197
|
+
}
|
|
198
|
+
/** A person made through the CRM, named for showing: the identity, and the company it was made for, if any. */
|
|
199
|
+
export interface CrmPerson {
|
|
200
|
+
urn: string;
|
|
201
|
+
name: string;
|
|
202
|
+
company?: Ref | null;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAO1D;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5G,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,WAAW,GAAG,WAAW,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,sCAAsC;IACtC,KAAK,EAAE,GAAG,CAAC;IACX,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,eAAe,CAAC,EAAE,GAAG,GAAG,IAAI,C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B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,uGAAuG;AACvG,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+GAA+G;AAC/G,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CACtB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6MA,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,102 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@baack-software/baack-ts-crm",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "TypeScript tools for a Baack CRM: leads, deals, pipelines, invoices and payments, with helpers, sample data and (later) shadcn/ui components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Baack",
|
|
7
|
+
"CRM",
|
|
8
|
+
"leads",
|
|
9
|
+
"deals",
|
|
10
|
+
"sales"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/Baack-Software/baack-ts-crm#readme",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/Baack-Software/baack-ts-crm.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"author": "baack-dakkad",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"module": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./mock": {
|
|
29
|
+
"types": "./dist/mock/index.d.ts",
|
|
30
|
+
"import": "./dist/mock/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./store": {
|
|
33
|
+
"types": "./dist/store.d.ts",
|
|
34
|
+
"import": "./dist/store.js"
|
|
35
|
+
},
|
|
36
|
+
"./react": {
|
|
37
|
+
"types": "./dist/react/index.d.ts",
|
|
38
|
+
"import": "./dist/react/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"src"
|
|
44
|
+
],
|
|
45
|
+
"sideEffects": false,
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.build.json",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"prepublishOnly": "npm run typecheck && npm test && npm run build",
|
|
54
|
+
"demo": "vite --config demo/vite.config.ts",
|
|
55
|
+
"demo:build": "vite build --config demo/vite.config.ts --outDir ../demo-dist --emptyOutDir"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@baack-software/baack-ts-client": ">=0.0.7",
|
|
59
|
+
"@baack-software/baack-ts-tasks": ">=0.0.1",
|
|
60
|
+
"react": ">=19",
|
|
61
|
+
"react-dom": ">=19",
|
|
62
|
+
"recharts": ">=3.8"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@baack-software/baack-ts-client": "file:../baack-ts-client",
|
|
66
|
+
"@baack-software/baack-ts-tasks": "file:../baack-ts-tasks",
|
|
67
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
68
|
+
"@testing-library/react": "^16.3.3",
|
|
69
|
+
"@testing-library/user-event": "^14.6.8",
|
|
70
|
+
"@types/node": "^24.0.0",
|
|
71
|
+
"@types/react": "^19.3.0",
|
|
72
|
+
"@types/react-dom": "^19.3.0",
|
|
73
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
74
|
+
"jsdom": "^30.1.2",
|
|
75
|
+
"react": "^19.3.0",
|
|
76
|
+
"react-dom": "^19.3.0",
|
|
77
|
+
"recharts": "^3.8.0",
|
|
78
|
+
"shadcn": "^4.21.0",
|
|
79
|
+
"tailwindcss": "^4.3.3",
|
|
80
|
+
"tw-animate-css": "^1.4.0",
|
|
81
|
+
"typescript": "^5.0.0",
|
|
82
|
+
"vite": "^8.3.4",
|
|
83
|
+
"vitest": "^5.0.2"
|
|
84
|
+
},
|
|
85
|
+
"publishConfig": {
|
|
86
|
+
"access": "public"
|
|
87
|
+
},
|
|
88
|
+
"dependencies": {
|
|
89
|
+
"class-variance-authority": "^0.7.1",
|
|
90
|
+
"cn": "^0.5.0",
|
|
91
|
+
"lucide-react": "^1.56.0",
|
|
92
|
+
"radix-ui": "^1.8.1"
|
|
93
|
+
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
95
|
+
"react": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"react-dom": {
|
|
99
|
+
"optional": true
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
package/src/account.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isOpenLead } from './leads.ts';
|
|
2
|
+
import { addMoney, type MoneyTotals } from './money.ts';
|
|
3
|
+
import { dealOutcome, isDealWith } from './pipeline.ts';
|
|
4
|
+
import { outstandingTotals, overdueTotals, paymentsReceived } from './invoices.ts';
|
|
5
|
+
import { withPayments } from './sales.ts';
|
|
6
|
+
import type { Deal, Invoice, InvoiceParty, Lead, Pipeline, Remittance } from './types.ts';
|
|
7
|
+
|
|
8
|
+
/** Everything a CRM knows about one customer company, for its account page. */
|
|
9
|
+
export interface CompanyAccount {
|
|
10
|
+
company: string;
|
|
11
|
+
leads: Lead[];
|
|
12
|
+
openLeads: Lead[];
|
|
13
|
+
deals: Deal[];
|
|
14
|
+
openDeals: Deal[];
|
|
15
|
+
/** Open deals' target values. */
|
|
16
|
+
openValue: MoneyTotals;
|
|
17
|
+
/** Won deals' target values. */
|
|
18
|
+
wonValue: MoneyTotals;
|
|
19
|
+
/** Invoices to or paid by the company. */
|
|
20
|
+
invoices: Invoice[];
|
|
21
|
+
outstanding: MoneyTotals;
|
|
22
|
+
overdue: MoneyTotals;
|
|
23
|
+
/** Payments against the company's invoices, newest first. */
|
|
24
|
+
payments: Remittance[];
|
|
25
|
+
/** Received less refunded. */
|
|
26
|
+
received: MoneyTotals;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AccountData {
|
|
30
|
+
leads: readonly Lead[];
|
|
31
|
+
deals: readonly Deal[];
|
|
32
|
+
pipelines: readonly Pipeline[];
|
|
33
|
+
invoices: readonly Invoice[];
|
|
34
|
+
remittances: readonly Remittance[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isParty = (party: InvoiceParty | null | undefined, company: string) => party?.company?.urn === company;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* One company's account, from a CRM owner's records: the company's leads and deals, the invoices it was sent or pays,
|
|
41
|
+
* and the payments against them. People and tasks about the company come from the identity search and
|
|
42
|
+
* baack-ts-tasks, which the host already has.
|
|
43
|
+
*/
|
|
44
|
+
export function companyAccount(company: string, data: AccountData, now = new Date()): CompanyAccount {
|
|
45
|
+
const leads = data.leads.filter((lead) => lead.contactCompany?.urn === company);
|
|
46
|
+
const deals = data.deals.filter((deal) => isDealWith(deal, company));
|
|
47
|
+
let openValue: MoneyTotals = {};
|
|
48
|
+
let wonValue: MoneyTotals = {};
|
|
49
|
+
const openDeals: Deal[] = [];
|
|
50
|
+
for (const deal of deals) {
|
|
51
|
+
const outcome = dealOutcome(deal);
|
|
52
|
+
if (outcome === 'OPEN') {
|
|
53
|
+
openDeals.push(deal);
|
|
54
|
+
openValue = addMoney(openValue, deal.targetValue);
|
|
55
|
+
} else if (outcome === 'WON') wonValue = addMoney(wonValue, deal.targetValue);
|
|
56
|
+
}
|
|
57
|
+
// Paid amounts follow the payments, so one just recorded shows on its invoice.
|
|
58
|
+
const invoices = withPayments(data.invoices, data.remittances).filter(
|
|
59
|
+
(invoice) => isParty(invoice.recipient, company) || isParty(invoice.remitter, company),
|
|
60
|
+
);
|
|
61
|
+
const invoiceUrns = new Set(invoices.map((invoice) => invoice.urn));
|
|
62
|
+
const payments = data.remittances
|
|
63
|
+
.filter((remittance) => invoiceUrns.has(remittance.paymentInvoice.urn))
|
|
64
|
+
.toSorted((a, b) => b.receivedTimestamp.localeCompare(a.receivedTimestamp));
|
|
65
|
+
return {
|
|
66
|
+
company,
|
|
67
|
+
leads,
|
|
68
|
+
openLeads: leads.filter(isOpenLead),
|
|
69
|
+
deals,
|
|
70
|
+
openDeals,
|
|
71
|
+
openValue,
|
|
72
|
+
wonValue,
|
|
73
|
+
invoices,
|
|
74
|
+
outstanding: outstandingTotals(invoices),
|
|
75
|
+
overdue: overdueTotals(invoices, now),
|
|
76
|
+
payments,
|
|
77
|
+
received: paymentsReceived(payments),
|
|
78
|
+
};
|
|
79
|
+
}
|