@bisondesk/core-sdk 1.0.677 → 1.0.678

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.
Files changed (144) hide show
  1. package/lib/apis/exchange-rates.d.ts +0 -3
  2. package/lib/apis/exchange-rates.d.ts.map +1 -1
  3. package/lib/apis/exchange-rates.js +0 -29
  4. package/lib/apis/exchange-rates.js.map +1 -1
  5. package/lib/apis/organization-bank-accounts.d.ts +11 -0
  6. package/lib/apis/organization-bank-accounts.d.ts.map +1 -0
  7. package/lib/apis/organization-bank-accounts.js +47 -0
  8. package/lib/apis/organization-bank-accounts.js.map +1 -0
  9. package/lib/types/intercompany-payments.d.ts.map +1 -1
  10. package/lib/types/intercompany-payments.js.map +1 -1
  11. package/lib/types/offers.d.ts +1 -2
  12. package/lib/types/offers.d.ts.map +1 -1
  13. package/lib/types/offers.js.map +1 -1
  14. package/lib/types/opportunities.d.ts +0 -8
  15. package/lib/types/opportunities.d.ts.map +1 -1
  16. package/lib/types/opportunities.js.map +1 -1
  17. package/lib/types/opportunity-payments.d.ts +0 -9
  18. package/lib/types/opportunity-payments.d.ts.map +1 -1
  19. package/lib/types/opportunity-payments.js.map +1 -1
  20. package/lib/types/organization-bank-accounts.d.ts +35 -0
  21. package/lib/types/organization-bank-accounts.d.ts.map +1 -0
  22. package/lib/types/organization-bank-accounts.js +9 -0
  23. package/lib/types/organization-bank-accounts.js.map +1 -0
  24. package/lib/types/payment-exports.d.ts +23 -0
  25. package/lib/types/payment-exports.d.ts.map +1 -0
  26. package/lib/types/payment-exports.js +2 -0
  27. package/lib/types/payment-exports.js.map +1 -0
  28. package/lib/types/tenants.d.ts +1 -1
  29. package/lib/types/tenants.d.ts.map +1 -1
  30. package/lib/types/tenants.js +1 -0
  31. package/lib/types/tenants.js.map +1 -1
  32. package/lib/types/vehicle-purchase-payments.d.ts +52 -8
  33. package/lib/types/vehicle-purchase-payments.d.ts.map +1 -1
  34. package/lib/types/vehicle-purchase-payments.js +6 -0
  35. package/lib/types/vehicle-purchase-payments.js.map +1 -1
  36. package/lib/types/vehicles.d.ts +1 -7
  37. package/lib/types/vehicles.d.ts.map +1 -1
  38. package/lib/types/vehicles.js.map +1 -1
  39. package/lib/utils/organization-bank-accounts.d.ts +3 -0
  40. package/lib/utils/organization-bank-accounts.d.ts.map +1 -0
  41. package/lib/utils/organization-bank-accounts.js +9 -0
  42. package/lib/utils/organization-bank-accounts.js.map +1 -0
  43. package/lib/utils/tenants.d.ts +0 -3
  44. package/lib/utils/tenants.d.ts.map +1 -1
  45. package/lib/utils/tenants.js +0 -3
  46. package/lib/utils/tenants.js.map +1 -1
  47. package/lib/utils/tenants.test.js +1 -27
  48. package/lib/utils/tenants.test.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/apis/exchange-rates.ts +0 -49
  51. package/src/apis/organization-bank-accounts.ts +123 -0
  52. package/src/types/intercompany-payments.ts +3 -4
  53. package/src/types/offers.ts +0 -2
  54. package/src/types/opportunities.ts +0 -15
  55. package/src/types/opportunity-payments.ts +0 -23
  56. package/src/types/organization-bank-accounts.ts +56 -0
  57. package/src/types/payment-exports.ts +40 -0
  58. package/src/types/tenants.ts +7 -6
  59. package/src/types/vehicle-purchase-payments.ts +114 -13
  60. package/src/types/vehicles.ts +4 -15
  61. package/src/utils/organization-bank-accounts.ts +19 -0
  62. package/src/utils/tenants.test.ts +1 -39
  63. package/src/utils/tenants.ts +0 -17
  64. package/tsconfig.tsbuildinfo +1 -1
  65. package/lib/utils/opportunity-payments.d.ts +0 -3
  66. package/lib/utils/opportunity-payments.d.ts.map +0 -1
  67. package/lib/utils/opportunity-payments.js +0 -5
  68. package/lib/utils/opportunity-payments.js.map +0 -1
  69. package/lib/utils/opportunity-payments.test.d.ts +0 -2
  70. package/lib/utils/opportunity-payments.test.d.ts.map +0 -1
  71. package/lib/utils/opportunity-payments.test.js +0 -23
  72. package/lib/utils/opportunity-payments.test.js.map +0 -1
  73. package/src/types/activities.js +0 -13
  74. package/src/types/activities.js.map +0 -1
  75. package/src/types/comparables.js +0 -2
  76. package/src/types/comparables.js.map +0 -1
  77. package/src/types/crm.js +0 -58
  78. package/src/types/crm.js.map +0 -1
  79. package/src/types/dashboard.js +0 -2
  80. package/src/types/dashboard.js.map +0 -1
  81. package/src/types/definitions.js +0 -2
  82. package/src/types/definitions.js.map +0 -1
  83. package/src/types/fields.js +0 -2
  84. package/src/types/fields.js.map +0 -1
  85. package/src/types/insights.js +0 -2
  86. package/src/types/insights.js.map +0 -1
  87. package/src/types/interests.js +0 -6
  88. package/src/types/interests.js.map +0 -1
  89. package/src/types/internal-events.js +0 -18
  90. package/src/types/internal-events.js.map +0 -1
  91. package/src/types/internet-opportunities.js +0 -2
  92. package/src/types/internet-opportunities.js.map +0 -1
  93. package/src/types/internet-vehicles.js +0 -2
  94. package/src/types/internet-vehicles.js.map +0 -1
  95. package/src/types/leasing-administration.js +0 -2
  96. package/src/types/leasing-administration.js.map +0 -1
  97. package/src/types/leasing-debtors.js +0 -2
  98. package/src/types/leasing-debtors.js.map +0 -1
  99. package/src/types/leasing-search.js +0 -2
  100. package/src/types/leasing-search.js.map +0 -1
  101. package/src/types/leasing-settings.js +0 -7
  102. package/src/types/leasing-settings.js.map +0 -1
  103. package/src/types/leasing.js +0 -38
  104. package/src/types/leasing.js.map +0 -1
  105. package/src/types/marketing.js +0 -35
  106. package/src/types/marketing.js.map +0 -1
  107. package/src/types/offers.js +0 -56
  108. package/src/types/opportunities.js +0 -107
  109. package/src/types/opportunities.js.map +0 -1
  110. package/src/types/payments.js +0 -7
  111. package/src/types/picklists.js +0 -2
  112. package/src/types/picklists.js.map +0 -1
  113. package/src/types/quotes.js +0 -42
  114. package/src/types/recently-viewed.js +0 -2
  115. package/src/types/recently-viewed.js.map +0 -1
  116. package/src/types/reservations.js +0 -5
  117. package/src/types/reservations.js.map +0 -1
  118. package/src/types/roi-ratings.js +0 -5
  119. package/src/types/roi-ratings.js.map +0 -1
  120. package/src/types/saved-filters.js +0 -9
  121. package/src/types/saved-filters.js.map +0 -1
  122. package/src/types/search.js +0 -2
  123. package/src/types/search.js.map +0 -1
  124. package/src/types/settings.js +0 -2
  125. package/src/types/settings.js.map +0 -1
  126. package/src/types/templates.js +0 -2
  127. package/src/types/templates.js.map +0 -1
  128. package/src/types/tenants.js +0 -21
  129. package/src/types/tenants.js.map +0 -1
  130. package/src/types/user-performance.js +0 -7
  131. package/src/types/user-performance.js.map +0 -1
  132. package/src/types/utils.js +0 -2
  133. package/src/types/validation.js +0 -2
  134. package/src/types/validation.js.map +0 -1
  135. package/src/types/vehicle-sales.js +0 -6
  136. package/src/types/vehicle-sales.js.map +0 -1
  137. package/src/types/vehicles.js +0 -98
  138. package/src/types/vehicles.js.map +0 -1
  139. package/src/utils/leasing.js +0 -6
  140. package/src/utils/leasing.js.map +0 -1
  141. package/src/utils/opportunities.js +0 -48
  142. package/src/utils/opportunities.js.map +0 -1
  143. package/src/utils/opportunity-payments.test.ts +0 -31
  144. package/src/utils/opportunity-payments.ts +0 -15
@@ -0,0 +1,56 @@
1
+ import { BankAccountDetails } from '@bisondesk/commons-sdk/bank-accounts';
2
+
3
+ /**
4
+ * An accountant's confirmation of one account number. It only counts while the account still
5
+ * holds that number, so trust never carries over to a new number however the account was edited.
6
+ */
7
+ export type OrganizationBankAccountVerification = {
8
+ accountNumber: string;
9
+ verifiedBy: string;
10
+ verifiedAt: string;
11
+ };
12
+
13
+ export enum OrganizationBankAccountActions {
14
+ VERIFY = 'verify',
15
+ }
16
+
17
+ export enum OrganizationBankAccountActionBlockerCode {
18
+ CHANGED_NEEDS_VERIFICATION = 'changed_needs_verification',
19
+ }
20
+
21
+ export type OrganizationBankAccountActionBlocker = {
22
+ code: OrganizationBankAccountActionBlockerCode;
23
+ };
24
+
25
+ /**
26
+ * Why an action the user would otherwise see is refused right now. A missing permission hides the
27
+ * action instead.
28
+ */
29
+ export type OrganizationBankAccountBlockedAction = {
30
+ action: OrganizationBankAccountActions;
31
+ reasons: OrganizationBankAccountActionBlocker[];
32
+ };
33
+
34
+ export type OrganizationBankAccountMeta = {
35
+ blockedActions: OrganizationBankAccountBlockedAction[];
36
+ };
37
+
38
+ export type NewOrganizationBankAccount = BankAccountDetails & {
39
+ organizationId: string;
40
+ };
41
+
42
+ /**
43
+ * An organisation's bank account for outgoing SEPA transfers, never shared across companies. An
44
+ * organisation can hold several; at most one is its `default`, the one payment exports pay to.
45
+ * Editing the account number or holder name clears the manual verification, so a valid checksum is
46
+ * never mistaken for a confirmed account holder.
47
+ */
48
+ export type OrganizationBankAccount = NewOrganizationBankAccount & {
49
+ id: string;
50
+ default?: boolean;
51
+ createdAt: string;
52
+ createdBy: string;
53
+ modifiedAt: string;
54
+ modifiedBy: string;
55
+ verification?: OrganizationBankAccountVerification;
56
+ };
@@ -0,0 +1,40 @@
1
+ import { BankAccountDetails } from '@bisondesk/commons-sdk/bank-accounts';
2
+ import { AttachmentValue } from '@bisondesk/commons-sdk/types';
3
+
4
+ /**
5
+ * The transfer details of one payment, frozen at export time. A later edit to the payment or the
6
+ * supplier bank account must not rewrite what the sent file said, so the export keeps its own copy
7
+ * of every value that went into the XML. It also records the payment batch the payment was sent to
8
+ * processing in, so the export is a self-contained audit record even though one file can span
9
+ * several batches.
10
+ */
11
+ export type PaymentExportLine = {
12
+ paymentId: string;
13
+ vehicleId: string;
14
+ amount: string;
15
+ creditor: BankAccountDetails;
16
+ paymentBatchId: string;
17
+ transferReference?: string;
18
+ };
19
+
20
+ export type NewPaymentExport = {
21
+ /** Single execution date (`yyyy-MM-dd`) written to the file's `ReqdExctnDt`. */
22
+ executionDate: string;
23
+ /** Σ of the exported line amounts (string; computed with decimal arithmetic). */
24
+ totalAmount: string;
25
+ paymentIds: string[];
26
+ lines: PaymentExportLine[];
27
+ /** The generated SEPA file, stored in S3 and re-downloadable from Processing. */
28
+ xmlFile: AttachmentValue;
29
+ };
30
+
31
+ /**
32
+ * A generated SEPA file for a selection of Processing payments, plus the frozen record of exactly what
33
+ * was sent. Re-downloading serves the same file and never re-exports; a payment cancelled out of the
34
+ * file returns to Allowed and leaves this record intact.
35
+ */
36
+ export type PaymentExport = NewPaymentExport & {
37
+ id: string;
38
+ exportedAt: string;
39
+ exportedBy: string;
40
+ };
@@ -55,6 +55,13 @@ export enum TenantModule {
55
55
  Intercompany = 'intercompany',
56
56
  Opportunities = 'opportunities',
57
57
  Offers = 'offers',
58
+ /**
59
+ * The tenant pays suppliers through Isabel file exports (SEPA transfer files). It grants the
60
+ * export itself and the verification of the supplier bank accounts it pays to, and requires those
61
+ * account numbers to be valid IBANs. Without it, Processing payments are simply marked paid, and
62
+ * a bank account can hold any account number.
63
+ */
64
+ PaymentExports = 'payment_exports',
58
65
  Vehicles = 'vehicles',
59
66
  Tasks = 'tasks',
60
67
  TrackAndTrace = 'track_and_trace',
@@ -148,12 +155,6 @@ export type Branch = {
148
155
  exactAccounting?: boolean;
149
156
  accounting?: AccountingProvider;
150
157
  currency: string;
151
- /**
152
- * The currencies money moves in at this branch, its own `currency` included. Customer payments,
153
- * purchase prices, supplier invoice drafts and Exact bookings are supported in these currencies
154
- * only. Absent = the branch's own `currency` only. Set by script.
155
- */
156
- paymentCurrencies?: [string, ...string[]];
157
158
  adminNumberPrefix: string;
158
159
  stockNumberPrefix: string;
159
160
  vatNumber: string;
@@ -1,41 +1,142 @@
1
1
  import { BaseEvent } from './internal-events.js';
2
+ import { OrganizationBankAccountActions } from './organization-bank-accounts.js';
2
3
  import { SearchVehicle } from './vehicles.js';
3
4
 
4
5
  export const VEHICLE_PURCHASE_PAYMENT_ALLOWED_NOTIFICATION_ORIGIN =
5
6
  'vehicle-purchase-payment-allowed-notification';
6
7
 
7
8
  /**
8
- * A payment on a purchase priced in another currency is authorized and paid in that currency.
9
- * `amount` then holds its value in branch currency: `foreign.amount × foreign.exchangeRate`.
9
+ * The stage a supplier payment sits at, driving the Unpaid/Allowed/Processing/Executed tabs.
10
+ * A payment only ever moves forward: an authorised payment is `allowed`; sending it to processing
11
+ * groups it into a payment batch and hands it to accounting (`processing`), which exports it
12
+ * to the Isabel bank file; marking it paid moves it to `executed`.
13
+ * (`unpaid` is not a stage — it is an agreed purchase with an amount still to authorise.)
10
14
  */
11
- export type VehiclePurchasePaymentForeign = {
12
- amount: string;
13
- currencyCode: string;
14
- /** Branch currency units per 1 unit of `currencyCode`, the purchase's rate. */
15
- exchangeRate: string;
16
- };
15
+ export enum PaymentStage {
16
+ Allowed = 'allowed',
17
+ Processing = 'processing',
18
+ Executed = 'executed',
19
+ }
17
20
 
18
21
  export type NewVehiclePurchasePayment = {
19
22
  vehicleId: string;
20
- /** Branch currency. Derived from `foreign` when the purchase is priced in another currency. */
21
23
  amount: string;
22
- /** The backend takes the rate from the purchase. */
23
- foreign?: Pick<VehiclePurchasePaymentForeign, 'amount' | 'currencyCode'>;
24
24
  description?: string;
25
25
  paidAt?: string;
26
26
  paidBy?: string;
27
27
  };
28
28
 
29
- export type VehiclePurchasePayment = Omit<NewVehiclePurchasePayment, 'foreign'> & {
29
+ export type VehiclePurchasePayment = NewVehiclePurchasePayment & {
30
30
  id: string;
31
31
  createdBy: string;
32
32
  createdAt: string;
33
- foreign?: VehiclePurchasePaymentForeign;
33
+ stage: PaymentStage;
34
+ /** Manual settlement priority within the Allowed tab; lower is paid first. */
35
+ priority: number;
36
+ /** Set once the payment has been exported; links it to its payment export. */
37
+ exportId?: string;
38
+ /** The payment batch this payment was sent to processing in; unset while Allowed, and on payments
39
+ * marked paid straight from Allowed. */
40
+ paymentBatchId?: string;
41
+ /**
42
+ * Supplier-facing communication that becomes the SEPA transfer's remittance information (`RmtInf`),
43
+ * so the supplier can reconcile the payment to an invoice. Editable while Processing and not yet
44
+ * exported; prefilled from the latest purchase invoice. This is not the file's per-line
45
+ * `EndToEndId`.
46
+ */
47
+ transferReference?: string;
48
+ /** Who sent the payment to processing, and when — set at the Allowed → Processing step. */
49
+ sentToProcessingBy?: string;
50
+ sentToProcessingAt?: string;
51
+ };
52
+
53
+ /**
54
+ * One send to processing: the Allowed payments an accountant moved to Processing together, and who
55
+ * sent them. The Processing tab groups its rows by batch. A batch holds no amount of its own; its
56
+ * total is the sum of the payments still in it.
57
+ */
58
+ export type PaymentBatch = {
59
+ id: string;
60
+ createdAt: string;
61
+ createdBy: string;
62
+ };
63
+
64
+ /**
65
+ * Whether a payment's supplier can be paid in an export. Mirrors the export gate: a transfer needs a
66
+ * supplier bank account that carries an IBAN and holder name and has been verified. Shown as an
67
+ * export-blocked marker on the Processing rows, where the accountant clears it before exporting.
68
+ * (The invoice / pro-forma document half of the gate is not reflected here — its source is a Q3
69
+ * residual the backend export gate also defers.)
70
+ *
71
+ * The bank account is the supplier's default one, `bankAccountId`, which is the account an export
72
+ * pays. `bankAccountActions` lists what the current user may do on it, so a row can point out the
73
+ * accounts they can verify themselves. Once the account number or holder name changed, verify is
74
+ * left out for accountants, and for whichever Senior Accountant made the change (four-eyes).
75
+ */
76
+ export type PaymentExportChecks = {
77
+ bankAccountId?: string;
78
+ hasBankAccount: boolean;
79
+ bankAccountVerified: boolean;
80
+ bankAccountActions: OrganizationBankAccountActions[];
34
81
  };
35
82
 
36
83
  export type VehiclePurchasePaymentBff = {
37
84
  payment: VehiclePurchasePayment;
38
85
  vehicle: SearchVehicle;
86
+ /** Name of the supplier organisation (`vehicle.purchase.organizationId`), resolved for display. */
87
+ supplierName?: string;
88
+ /** Export checks on the supplier bank account; filled for the Processing list only. */
89
+ exportChecks?: PaymentExportChecks;
90
+ };
91
+
92
+ /**
93
+ * A row on the Unpaid tab: an agreed purchase that still has an amount to authorise for payment.
94
+ * Derived from the purchase deal and the payments already authorised, not a payment record.
95
+ */
96
+ export type UnpaidPurchase = {
97
+ vehicle: SearchVehicle;
98
+ /** The agreed purchase price including VAT (`deal.purchase` grossed up by `deal.purchaseVatRate`),
99
+ * so it matches the VAT-inclusive cost the vehicle purchase tab authorises against. */
100
+ purchaseAmount: string;
101
+ /** Sum of amounts already authorised (payments in any stage) for this vehicle. */
102
+ allowedAmount: string;
103
+ /** Sum of the authorised amounts already settled (payments in Executed) for this vehicle. */
104
+ paidAmount: string;
105
+ /** `purchaseAmount − allowedAmount`; always greater than zero for rows shown here. */
106
+ remainingAmount: string;
107
+ /** Due date of the purchase invoice. */
108
+ invoiceDueDate?: string;
109
+ /** Name of the supplier organisation (`vehicle.purchase.organizationId`), resolved for display. */
110
+ supplierName?: string;
111
+ };
112
+
113
+ /** Body of the export request: the Processing payments to put in one file, the paying account, and the execution date. */
114
+ export type ExportPaymentsRequest = {
115
+ paymentIds: string[];
116
+ /** The bank account (from documents settings) to pay the file from — the file's debtor. */
117
+ debtorBankAccountId: string;
118
+ /** Single execution date (`yyyy-MM-dd`) written to `ReqdExctnDt`; defaults to today. */
119
+ executionDate?: string;
120
+ };
121
+
122
+ /** Body of the mark-paid request: the payments (Allowed or Processing) to settle in one call. */
123
+ export type MarkPaymentsPaidRequest = {
124
+ paymentIds: string[];
125
+ };
126
+
127
+ /** Body of the send-to-processing request: the Allowed payments to send together as one batch. */
128
+ export type SendPaymentsToProcessingRequest = {
129
+ paymentIds: string[];
130
+ };
131
+
132
+ /**
133
+ * How many rows sit behind each payment tab, for the tab counters. Executed is unbounded and has no
134
+ * counter, so it is left out.
135
+ */
136
+ export type PurchasePaymentCounts = {
137
+ unpaid: number;
138
+ allowed: number;
139
+ processing: number;
39
140
  };
40
141
 
41
142
  export type VehiclePurchasePaymentCreateEvent = {
@@ -170,7 +170,6 @@ export type NewVehicleRequest = {
170
170
  dealStatus: VehiclePurchaseDealStatus;
171
171
  costs: {
172
172
  purchase: string;
173
- foreign?: VehiclePurchaseDealForeign;
174
173
  purchaseVatPercentage: string;
175
174
  commission?: string;
176
175
  externalTransport?: string;
@@ -812,18 +811,6 @@ export type VehiclePriceUpdateResponse =
812
811
  errors: VehiclePriceUpdateError[];
813
812
  };
814
813
 
815
- /**
816
- * The price the supplier asked, in the supplier's currency: one of the payment currencies of the
817
- * vehicle's branch. The purchase's `deal.purchase` is then `purchase × exchangeRate`, and payments
818
- * are authorized in `currencyCode`.
819
- */
820
- export type VehiclePurchaseDealForeign = {
821
- purchase: string; // exclusive VAT
822
- currencyCode: string;
823
- /** Branch currency units per 1 unit of `currencyCode`. */
824
- exchangeRate: string;
825
- };
826
-
827
814
  export type VehiclePurchase = {
828
815
  organizationId: string;
829
816
  contactId: string;
@@ -859,13 +846,15 @@ export type VehiclePurchase = {
859
846
  checkedInBy?: string;
860
847
  };
861
848
 
849
+ /** Due date of the supplier purchase invoice; editable from the payments page. */
850
+ invoiceDueDate?: string;
851
+
862
852
  deal: {
863
853
  status: VehiclePurchaseDealStatus; // partially set by the user, if there are payments then it is set automatically by the backend
864
854
  readyToDeliver?: boolean;
865
855
 
866
856
  purchaseVatRate?: string;
867
- purchase?: string; // exclusive VAT; derived from `foreign` when present
868
- foreign?: VehiclePurchaseDealForeign;
857
+ purchase?: string; // exclusive VAT
869
858
 
870
859
  bonus?: string; // sometimes manufacturers pay us a bonus when we reach a target
871
860
 
@@ -0,0 +1,19 @@
1
+ import { normalizeIban } from '@bisondesk/commons-sdk/iban';
2
+ import { OrganizationBankAccount } from '../types/organization-bank-accounts.js';
3
+
4
+ /**
5
+ * Whether an organisation's bank account can be paid: it carries a verification, and that
6
+ * verification was given for the account number the account holds now. A verification recorded
7
+ * without an account number, or for a different one, does not count.
8
+ *
9
+ * Shared so the export gate and the Processing rows read one rule.
10
+ */
11
+ export const isOrganizationBankAccountVerified = (
12
+ account: OrganizationBankAccount | undefined,
13
+ ): boolean => {
14
+ const verifiedAccountNumber = account?.verification?.accountNumber;
15
+ if (account == null || verifiedAccountNumber == null) {
16
+ return false;
17
+ }
18
+ return normalizeIban(verifiedAccountNumber) === normalizeIban(account.accountNumber);
19
+ };
@@ -1,11 +1,5 @@
1
1
  import { Branch, Tenant } from '../types/tenants.js';
2
- import {
3
- areBranchesQuoteCompatible,
4
- getBranchAskingVies,
5
- getBranchPaymentCurrencies,
6
- hasForeignPaymentCurrency,
7
- isForeignPaymentCurrency,
8
- } from './tenants.js';
2
+ import { areBranchesQuoteCompatible, getBranchAskingVies } from './tenants.js';
9
3
 
10
4
  const createBranch = (override?: Partial<Branch>): Branch => ({
11
5
  id: 'TTC',
@@ -71,35 +65,3 @@ describe('getBranchAskingVies', () => {
71
65
  expect(getBranchAskingVies(tenantOf([bolivia]), 'BO')).toBeUndefined();
72
66
  });
73
67
  });
74
-
75
- describe('payment currencies of a branch', () => {
76
- const southAmerica = createBranch({
77
- id: 'HPA South America',
78
- paymentCurrencies: ['EUR', 'USD'],
79
- });
80
-
81
- test('a branch without a list is paid in its own currency only', () => {
82
- expect(getBranchPaymentCurrencies(createBranch())).toEqual(['EUR']);
83
- });
84
-
85
- test('a branch with a list is paid in the currencies it lists', () => {
86
- expect(getBranchPaymentCurrencies(southAmerica)).toEqual(['EUR', 'USD']);
87
- });
88
-
89
- test.each([
90
- ['a listed currency other than its own', 'USD', true],
91
- ['its own currency', 'EUR', false],
92
- ['a currency it does not list', 'BOB', false],
93
- ])('%s is a foreign payment currency: %s', (_label, currencyCode, expected) => {
94
- expect(isForeignPaymentCurrency(southAmerica, currencyCode)).toBe(expected);
95
- });
96
-
97
- test('a branch without a list has no foreign payment currency', () => {
98
- expect(isForeignPaymentCurrency(createBranch(), 'USD')).toBe(false);
99
- expect(hasForeignPaymentCurrency(createBranch())).toBe(false);
100
- });
101
-
102
- test('a branch listing another currency has a foreign payment currency', () => {
103
- expect(hasForeignPaymentCurrency(southAmerica)).toBe(true);
104
- });
105
- });
@@ -24,23 +24,6 @@ export const getBranchAskingVies = (tenant: Tenant, branchId?: string): Branch |
24
24
  return europeanBranches.find((branch) => branch.id === branchId) ?? europeanBranches.at(0);
25
25
  };
26
26
 
27
- /** The currencies money moves in at the branch, its own currency included. */
28
- export const getBranchPaymentCurrencies = (branch: Branch): string[] =>
29
- branch.paymentCurrencies ?? [branch.currency];
30
-
31
- /**
32
- * Whether the branch can be paid, price a purchase or receive a supplier invoice in a currency
33
- * other than its own. Its own currency is never a foreign one.
34
- */
35
- export const isForeignPaymentCurrency = (branch: Branch, currencyCode: string): boolean =>
36
- currencyCode !== branch.currency && getBranchPaymentCurrencies(branch).includes(currencyCode);
37
-
38
- /** Whether the branch lists any payment currency other than its own. */
39
- export const hasForeignPaymentCurrency = (branch: Branch): boolean =>
40
- getBranchPaymentCurrencies(branch).some((currencyCode) =>
41
- isForeignPaymentCurrency(branch, currencyCode),
42
- );
43
-
44
27
  /** The source invoices the end customer directly; this branch collects payment and earns
45
28
  * commission (see {@link Branch.dropshipping}). */
46
29
  export const isDropshippingBranch = (branch: Branch): boolean => branch.dropshipping === true;