@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/src/target.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { addMoney, type MoneyTotals } from './money.ts';
|
|
2
|
+
import { paymentsReceived } from './invoices.ts';
|
|
3
|
+
import { leadOutcome } from './leads.ts';
|
|
4
|
+
import { dealOutcome } from './pipeline.ts';
|
|
5
|
+
import type { Deal, Lead, Remittance } from './types.ts';
|
|
6
|
+
|
|
7
|
+
export interface SalesTarget {
|
|
8
|
+
/** The target per currency: leads' target values, each qualified lead's replaced by its deal's. */
|
|
9
|
+
target: MoneyTotals;
|
|
10
|
+
/** Won deals' target values per currency. */
|
|
11
|
+
won: MoneyTotals;
|
|
12
|
+
/** Payments received less refunds on the deals' invoices, per currency. */
|
|
13
|
+
received: MoneyTotals;
|
|
14
|
+
/** Received against target per currency, 0 to 1 (more than 1 past the target). */
|
|
15
|
+
progress: Readonly<Record<string, number>>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The sales target and progress towards it. The target is the sum of the leads' target values, using the deal's target
|
|
20
|
+
* value instead once a lead is qualified into a deal. Deals created without a lead count too, as they're qualified
|
|
21
|
+
* already; unqualified leads don't, and neither do lost deals or the leads they came from (decided 27 Oct 2026, in
|
|
22
|
+
* place of keeping lost deals in): the target is what's still open or won.
|
|
23
|
+
* Progress is the payments received against the target (decided 24 Oct 2026): money in on the invoices raised for the
|
|
24
|
+
* deals (`Deal.invoices`), refunds taken off. Payments on invoices without a deal, such as repeat orders, don't count.
|
|
25
|
+
*/
|
|
26
|
+
export function salesTarget(
|
|
27
|
+
leads: readonly Lead[],
|
|
28
|
+
deals: readonly Deal[],
|
|
29
|
+
remittances: readonly Remittance[],
|
|
30
|
+
): SalesTarget {
|
|
31
|
+
const fromLeads = new Set(deals.flatMap((deal) => (deal.leadSource ? [deal.leadSource.urn] : [])));
|
|
32
|
+
let target: MoneyTotals = {};
|
|
33
|
+
let won: MoneyTotals = {};
|
|
34
|
+
for (const deal of deals) {
|
|
35
|
+
const outcome = dealOutcome(deal);
|
|
36
|
+
if (outcome === 'LOST') continue;
|
|
37
|
+
target = addMoney(target, deal.targetValue);
|
|
38
|
+
if (outcome === 'WON') won = addMoney(won, deal.targetValue);
|
|
39
|
+
}
|
|
40
|
+
for (const lead of leads) {
|
|
41
|
+
if (leadOutcome(lead) === 'CLOSED') continue;
|
|
42
|
+
// A lead that became one of these deals (its leadSource) is counted by its deal's value above.
|
|
43
|
+
if (fromLeads.has(lead.urn)) continue;
|
|
44
|
+
target = addMoney(target, lead.targetValue);
|
|
45
|
+
}
|
|
46
|
+
const invoiced = new Set(deals.flatMap((deal) => deal.invoices.map((invoice) => invoice.urn)));
|
|
47
|
+
const received = paymentsReceived(remittances.filter((remittance) => invoiced.has(remittance.paymentInvoice.urn)));
|
|
48
|
+
const progress = Object.fromEntries(
|
|
49
|
+
Object.entries(target)
|
|
50
|
+
.filter(([, minor]) => minor > 0)
|
|
51
|
+
.map(([currency, minor]) => [currency, (received[currency] ?? 0) / minor]),
|
|
52
|
+
);
|
|
53
|
+
return { target, won, received, progress };
|
|
54
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import type { Workflow, WorkflowStage } from '@baack-software/baack-ts-client';
|
|
2
|
+
import type { Ref } from '@baack-software/baack-ts-tasks';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* CRM concepts, named as the Baack API names them (leads, deals and payment invoices are in the API from 26 Oct 2026;
|
|
6
|
+
* remittances are still a proposal, see docs/PLAN.md). Links are refs (`{ urn }`), as the API's shallow links are.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An amount of money in whole minor units (pence, cents), as content money items write it: `unitValue: 125000` with
|
|
11
|
+
* `currencyCode: "GBP"` is 1,250.00 GBP. `formattedValue` is the server's text for it, when it sends one. Decided
|
|
12
|
+
* 24 Oct 2026; invoices move to the same format.
|
|
13
|
+
*/
|
|
14
|
+
export interface Money {
|
|
15
|
+
unitValue: number;
|
|
16
|
+
/** An ISO 4217 code such as `GBP`. */
|
|
17
|
+
currencyCode: string;
|
|
18
|
+
formattedValue?: string | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Where a lead came from. */
|
|
22
|
+
export type LeadSource = 'WEBSITE' | 'REFERRAL' | 'SOCIAL' | 'EMAIL' | 'CALL' | 'ADS' | 'EVENT' | 'UNKNOWN';
|
|
23
|
+
|
|
24
|
+
/** How far a lead has got: only progress. How it ended is its `outcome`. */
|
|
25
|
+
export type LeadStatus = 'NEW' | 'CONTACTED' | 'QUALIFIED';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* How a lead ended, as a deal's outcome does: still being worked, converted into a deal (a lead's won), or closed as
|
|
29
|
+
* unqualified (a lead's lost).
|
|
30
|
+
*/
|
|
31
|
+
export type LeadOutcome = 'IN_PROGRESS' | 'CONVERTED' | 'CLOSED';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A prospect who hasn't been qualified yet. People are always identities, so their names are held securely as person
|
|
35
|
+
* names: a lead links a contact identity rather than holding a name, and a business by its contact company, whose name
|
|
36
|
+
* is the company's. A lead converted into a deal is the deal's `leadSource`.
|
|
37
|
+
*/
|
|
38
|
+
export interface Lead {
|
|
39
|
+
urn: string;
|
|
40
|
+
url?: string | null;
|
|
41
|
+
/** The company whose lead this is. */
|
|
42
|
+
owner: Ref;
|
|
43
|
+
/** What the lead is about, for example "Club robes for the spring season". */
|
|
44
|
+
title: string;
|
|
45
|
+
/** The person, as an identity. */
|
|
46
|
+
contactIdentity?: Ref | null;
|
|
47
|
+
/** The prospect's company, which holds its name. A consumer's lead has none. */
|
|
48
|
+
contactCompany?: Ref | null;
|
|
49
|
+
source: LeadSource;
|
|
50
|
+
status: LeadStatus;
|
|
51
|
+
/** In progress, converted or closed. In progress when absent. */
|
|
52
|
+
outcome?: LeadOutcome | null;
|
|
53
|
+
/** What the lead could be worth. Counts towards the sales target until the lead is converted into a deal. */
|
|
54
|
+
targetValue?: Money | null;
|
|
55
|
+
/** Who's working the lead. */
|
|
56
|
+
assignee?: Ref | null;
|
|
57
|
+
/** Why the lead was closed as unqualified. */
|
|
58
|
+
closedReason?: string | null;
|
|
59
|
+
/** A content entity for the business's own fields about the lead, as companies have. */
|
|
60
|
+
entity?: Ref | null;
|
|
61
|
+
createdTimestamp: string;
|
|
62
|
+
updatedTimestamp?: string | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** How a deal stands: still open, won or lost. */
|
|
66
|
+
export type DealOutcome = 'OPEN' | 'WON' | 'LOST';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A deal pipeline: any workflow. Workflows are dynamic and not about deals, so a deal carries its own outcome and
|
|
70
|
+
* probability; its stage is only where it is in the workflow.
|
|
71
|
+
*/
|
|
72
|
+
export type Pipeline = Workflow;
|
|
73
|
+
|
|
74
|
+
/** A pipeline's stage: a workflow stage. */
|
|
75
|
+
export type PipelineStage = WorkflowStage;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A qualified opportunity, moving through a pipeline (a workflow) stage by stage until it's won or lost.
|
|
79
|
+
*/
|
|
80
|
+
export interface Deal {
|
|
81
|
+
urn: string;
|
|
82
|
+
url?: string | null;
|
|
83
|
+
owner: Ref;
|
|
84
|
+
title: string;
|
|
85
|
+
/** The customer's companies: usually one. */
|
|
86
|
+
contactCompanies: Ref[];
|
|
87
|
+
/** The people involved, as identities. */
|
|
88
|
+
contactIdentities: Ref[];
|
|
89
|
+
/** The deal's stage, in its pipeline (any workflow): named as a task's stage is. */
|
|
90
|
+
workflowStage?: Ref | null;
|
|
91
|
+
/** Open, won or lost, on the deal itself rather than its stage. Open when absent. */
|
|
92
|
+
outcome?: DealOutcome | null;
|
|
93
|
+
/** The chance it's won, 0 to 100, for weighted pipeline value. */
|
|
94
|
+
probability?: number | null;
|
|
95
|
+
/** What the deal is worth. Replaces its lead's target value in the sales target. */
|
|
96
|
+
targetValue?: Money | null;
|
|
97
|
+
/** When it's expected to close. */
|
|
98
|
+
targetCloseTimestamp?: string | null;
|
|
99
|
+
/** When it was won or lost, cleared when it reopens. */
|
|
100
|
+
closeTimestamp?: string | null;
|
|
101
|
+
/** Why it was lost, as leads have `closedReason`. */
|
|
102
|
+
lostReason?: string | null;
|
|
103
|
+
assignee?: Ref | null;
|
|
104
|
+
/** The lead it was converted from. */
|
|
105
|
+
leadSource?: Ref | null;
|
|
106
|
+
/** Invoices raised for it; there may be several. The link lives here, not on the invoice. */
|
|
107
|
+
invoices: Ref[];
|
|
108
|
+
/** A content entity for the business's own fields about the deal, as companies have. */
|
|
109
|
+
entity?: Ref | null;
|
|
110
|
+
createdTimestamp: string;
|
|
111
|
+
updatedTimestamp?: string | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The payment invoice statuses the API has. */
|
|
115
|
+
export type InvoiceStatus = 'DRAFT' | 'IN_REVIEW' | 'AUTHORISED' | 'PENDING' | 'VOIDED' | 'PAID' | 'REFUNDED';
|
|
116
|
+
|
|
117
|
+
/** Whether an invoice's line prices include tax. */
|
|
118
|
+
export type LineItemTax = 'EXCLUSIVE' | 'INCLUSIVE' | 'NO_TAX';
|
|
119
|
+
|
|
120
|
+
/** How an invoice line is taxed. */
|
|
121
|
+
export type Taxability = 'TAXABLE' | 'NON_TAXABLE' | 'TAX_EXEMPT' | 'PARTIALLY_TAXABLE' | 'NOT_APPLICABLE';
|
|
122
|
+
|
|
123
|
+
/** Who pays or receives an invoice: a company, an identity, or both (a person at a company). */
|
|
124
|
+
export interface InvoiceParty {
|
|
125
|
+
company?: Ref | null;
|
|
126
|
+
identity?: Ref | null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** An invoice line, as the API has it (`/n/v1/invoiceline/`). */
|
|
130
|
+
export interface InvoiceLine {
|
|
131
|
+
urn: string;
|
|
132
|
+
lineNumber?: number | null;
|
|
133
|
+
description?: string | null;
|
|
134
|
+
itemCode?: string | null;
|
|
135
|
+
quantity?: number | null;
|
|
136
|
+
/** In major units (pounds), unlike the line's money amounts. */
|
|
137
|
+
unitPrice?: number | null;
|
|
138
|
+
price?: Money | null;
|
|
139
|
+
tax?: Money | null;
|
|
140
|
+
discountPrice?: Money | null;
|
|
141
|
+
discountRate?: number | null;
|
|
142
|
+
taxability?: Taxability | null;
|
|
143
|
+
taxName?: string | null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A payment invoice (`/n/v1/paymentinvoice/`): its amounts as money in `currencyCode`, its lines, and the payments and
|
|
148
|
+
* refunds against it (`remittances`). Deals link to their invoices (`Deal.invoices`).
|
|
149
|
+
*/
|
|
150
|
+
export interface Invoice {
|
|
151
|
+
urn: string;
|
|
152
|
+
url?: string | null;
|
|
153
|
+
owner: Ref;
|
|
154
|
+
/** Who pays. */
|
|
155
|
+
remitter?: InvoiceParty | null;
|
|
156
|
+
/** Who the invoice is addressed to. */
|
|
157
|
+
recipient?: InvoiceParty | null;
|
|
158
|
+
status: InvoiceStatus;
|
|
159
|
+
currencyCode: string;
|
|
160
|
+
lineItemTax?: LineItemTax | null;
|
|
161
|
+
subTotal?: Money | null;
|
|
162
|
+
discount?: Money | null;
|
|
163
|
+
tax?: Money | null;
|
|
164
|
+
/** Required on create. */
|
|
165
|
+
total: Money;
|
|
166
|
+
paid?: Money | null;
|
|
167
|
+
refunded?: Money | null;
|
|
168
|
+
issuedTimestamp?: string | null;
|
|
169
|
+
dueTimestamp?: string | null;
|
|
170
|
+
fullyPaidTimestamp?: string | null;
|
|
171
|
+
lines?: InvoiceLine[];
|
|
172
|
+
/** Payments and refunds against it, as the API lists them on the invoice. */
|
|
173
|
+
remittances?: Remittance[];
|
|
174
|
+
updatedTimestamp?: string | null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Whether a remittance is money received for an invoice or a refund paid back. */
|
|
178
|
+
export type RemittanceDirection = 'PAYMENT' | 'REFUND';
|
|
179
|
+
export type RemittanceStatus = 'RECEIVED' | 'FAILED' | 'REVERSED';
|
|
180
|
+
export type RemittanceMethod = 'BANK_TRANSFER' | 'CARD_PAYMENT' | 'DIRECT_DEBIT' | 'CASH' | 'E_WALLET' | 'OTHER';
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* One payment received against an invoice, or a refund paid back (`/n/v1/invoiceremittance/`). It has no owner of its
|
|
184
|
+
* own: a company's remittances are its invoices'. An invoice's `paid`, `refunded`, `status` and `fullyPaidTimestamp`
|
|
185
|
+
* follow from them (see `invoiceFromRemittances`).
|
|
186
|
+
*/
|
|
187
|
+
export interface Remittance {
|
|
188
|
+
urn: string;
|
|
189
|
+
url?: string | null;
|
|
190
|
+
paymentInvoice: Ref;
|
|
191
|
+
remittanceDirection: RemittanceDirection;
|
|
192
|
+
remittanceStatus: RemittanceStatus;
|
|
193
|
+
remittanceMethod: RemittanceMethod;
|
|
194
|
+
value: Money;
|
|
195
|
+
/** The bank or card reference. */
|
|
196
|
+
reference?: string | null;
|
|
197
|
+
/** Who paid: a company, an identity, or both. */
|
|
198
|
+
remittingCompany?: Ref | null;
|
|
199
|
+
remittingIdentity?: Ref | null;
|
|
200
|
+
receivedTimestamp: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The CRM concepts, each served by the API or by sample data (see CrmClient). */
|
|
204
|
+
export type CrmConcept = 'leads' | 'deals' | 'pipelines' | 'invoices' | 'remittances';
|
|
205
|
+
|
|
206
|
+
export const CRM_CONCEPTS: readonly CrmConcept[] = ['leads', 'deals', 'pipelines', 'invoices', 'remittances'];
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* A new person, as the lead and customer forms make them: an identity with a person, the person's name (held
|
|
210
|
+
* securely, as person names are) and an email address.
|
|
211
|
+
*/
|
|
212
|
+
export interface NewContact {
|
|
213
|
+
givenName: string;
|
|
214
|
+
familyName?: string | undefined;
|
|
215
|
+
email?: string | undefined;
|
|
216
|
+
telephone?: string | undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** How to reach a person: their email address and telephone number, each empty when they have none. */
|
|
220
|
+
export interface ContactDetails {
|
|
221
|
+
email: string;
|
|
222
|
+
telephone: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** A person made through the CRM, named for showing: the identity, and the company it was made for, if any. */
|
|
226
|
+
export interface CrmPerson {
|
|
227
|
+
urn: string;
|
|
228
|
+
name: string;
|
|
229
|
+
company?: Ref | null;
|
|
230
|
+
}
|