@micromerce/formbuilder-react 1.0.1017 → 1.0.1019
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/formbuilder.js +2 -2
- package/dist/formbuilder.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/utils/payment/index.d.ts +16 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { queryControl } from "./components/QueryControl/data/defaultControls";
|
|
|
18
18
|
import { FormBuilderConfig } from "./types";
|
|
19
19
|
import { compactVatId, vatIdProblem } from "./components/controls/SubtypeInput/vatId";
|
|
20
20
|
import type { VatIdProblem } from "./components/controls/SubtypeInput/vatId";
|
|
21
|
-
import { DUE_SOON_DAYS, PAYMENT_PILLS, PAYMENT_TONES, formatAmount, formatPaymentDate, parseAmount, paymentFieldsOf, paymentLines, paymentState, paymentTotal, transactionRefsOf } from "./utils/payment";
|
|
21
|
+
import { DUE_SOON_DAYS, PAYMENT_PILLS, PAYMENT_TONES, formatAmount, formatPaymentDate, parseAmount, paymentFieldsOf, paymentLines, paymentState, paymentTotal, comparesWithAccount, DEFAULT_ACCOUNT_CURRENCY, transactionRefsOf } from "./utils/payment";
|
|
22
22
|
import type { IPaymentValues, PaymentRole, PaymentState, PaymentTone } from "./utils/payment";
|
|
23
23
|
import { getCountries, parsePhoneNumber } from "react-phone-number-input/max";
|
|
24
24
|
import PHONE_FLAGS from "react-phone-number-input/flags";
|
|
@@ -26,5 +26,5 @@ import { SOCIAL_NETWORKS, handleOf, isValidSocialLink, networkOf } from "./utils
|
|
|
26
26
|
import { FormBuilderThemeProvider, FORM_BUILDER_TOKENS, LEGACY_CSS_VARS, toCssVars } from "./theme";
|
|
27
27
|
import type { FormBuilderTheme, FormBuilderThemeKey, FormBuilderThemePreset } from "./theme";
|
|
28
28
|
export type { FormBuilderTheme, FormBuilderThemeKey, FormBuilderThemePreset, VatIdProblem, IPaymentValues, PaymentRole, PaymentState, PaymentTone, };
|
|
29
|
-
export { FormBuilderThemeProvider, FORM_BUILDER_TOKENS, LEGACY_CSS_VARS, toCssVars, FormBuilder, FormBuilderConfig, queryControl, Select, MultiSelect, Checkbox, ControlWrapper, FormFooter, Input, InputFreeSolo, FormList, FormGroup, MrnInput, PasswordInput, Textarea, TrafficLightCardSelect, useValueGenerator, compactVatId, vatIdProblem, SOCIAL_NETWORKS, isValidSocialLink, networkOf, handleOf, parsePhoneNumber, getCountries, PHONE_FLAGS, DUE_SOON_DAYS, PAYMENT_PILLS, PAYMENT_TONES, formatAmount, formatPaymentDate, parseAmount, paymentFieldsOf, paymentLines, paymentState, paymentTotal, transactionRefsOf, };
|
|
29
|
+
export { FormBuilderThemeProvider, FORM_BUILDER_TOKENS, LEGACY_CSS_VARS, toCssVars, FormBuilder, FormBuilderConfig, queryControl, Select, MultiSelect, Checkbox, ControlWrapper, FormFooter, Input, InputFreeSolo, FormList, FormGroup, MrnInput, PasswordInput, Textarea, TrafficLightCardSelect, useValueGenerator, compactVatId, vatIdProblem, SOCIAL_NETWORKS, isValidSocialLink, networkOf, handleOf, parsePhoneNumber, getCountries, PHONE_FLAGS, DUE_SOON_DAYS, PAYMENT_PILLS, PAYMENT_TONES, formatAmount, formatPaymentDate, parseAmount, paymentFieldsOf, paymentLines, paymentState, paymentTotal, comparesWithAccount, DEFAULT_ACCOUNT_CURRENCY, transactionRefsOf, };
|
|
30
30
|
export default FormBuilder;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* live pill and hint) and service-entity's detail view (exported from the package), so the two never
|
|
4
4
|
* judge a payment differently. Nothing here writes a value; it only reads what the invoice holds.
|
|
5
5
|
*/
|
|
6
|
-
export declare const PAYMENT_ROLES: readonly ["due", "paidOn", "method", "transactions", "amount"];
|
|
6
|
+
export declare const PAYMENT_ROLES: readonly ["due", "paidOn", "method", "transactions", "amount", "currency"];
|
|
7
7
|
export type PaymentRole = (typeof PAYMENT_ROLES)[number];
|
|
8
8
|
/** The field of each role: `custom-attributes.fields`, else the defaults of the form (anchor or group). */
|
|
9
9
|
export declare const paymentFieldsOf: (customAttributes: unknown, isGroup?: boolean) => Partial<Record<PaymentRole, string>>;
|
|
@@ -20,6 +20,8 @@ export interface IPaymentValues {
|
|
|
20
20
|
* transactions, or `custom-attributes.unlinkedPayment` is "ignore". Then a payment date alone means paid.
|
|
21
21
|
*/
|
|
22
22
|
linksTransactions?: boolean;
|
|
23
|
+
/** The invoice's currency (role "currency", an ISO code); another than the account's skips the total check. */
|
|
24
|
+
currency?: string;
|
|
23
25
|
}
|
|
24
26
|
export type PaymentState = {
|
|
25
27
|
kind: "paid";
|
|
@@ -78,12 +80,23 @@ export declare const transactionRefsOf: (value: unknown, refField?: string) => s
|
|
|
78
80
|
export declare const parseAmount: (value: unknown) => number | undefined;
|
|
79
81
|
/** "1.380,50" — two decimals, German grouping, no currency (the invoice's currency is not known here). */
|
|
80
82
|
export declare const formatAmount: (value: number) => string;
|
|
83
|
+
/** The account currency a payment is compared in when `accountCurrency` is not set. */
|
|
84
|
+
export declare const DEFAULT_ACCOUNT_CURRENCY = "EUR";
|
|
85
|
+
/**
|
|
86
|
+
* Whether an invoice in this currency can be compared with the bank account's transactions: yes without an
|
|
87
|
+
* invoice currency (as before the currency role existed) and when both are the same ISO code, ignoring case.
|
|
88
|
+
* A USD invoice paid from a EUR account books a different amount (271,10 USD as -248,02 EUR) and is no mismatch.
|
|
89
|
+
*/
|
|
90
|
+
export declare const comparesWithAccount: (invoiceCurrency?: string, accountCurrency?: string) => boolean;
|
|
81
91
|
/**
|
|
82
92
|
* The linked transactions against the invoice: their total (by magnitude — an outgoing payment is negative
|
|
83
93
|
* on the bank side) and whether it matches the invoice amount to the cent. `matches` is undefined without
|
|
84
|
-
* an invoice amount.
|
|
94
|
+
* an invoice amount, and when the invoice is in another currency than the account (`currency`).
|
|
85
95
|
*/
|
|
86
|
-
export declare const paymentTotal: (transactionAmounts: number[], invoiceAmount?: number
|
|
96
|
+
export declare const paymentTotal: (transactionAmounts: number[], invoiceAmount?: number, currency?: {
|
|
97
|
+
invoice?: string;
|
|
98
|
+
account?: string;
|
|
99
|
+
}) => {
|
|
87
100
|
total: number;
|
|
88
101
|
matches?: boolean;
|
|
89
102
|
};
|