@unimaze/billing 0.5.0-sjova.0 → 0.6.0-rc.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.
Files changed (71) hide show
  1. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +8 -2
  2. package/lib/common/components/base-information/ReferenceIdentifiers.js +100 -25
  3. package/lib/common/components/base-information/index.d.ts +5 -1
  4. package/lib/common/components/base-information/index.js +28 -71
  5. package/lib/common/components/billing-lines/NewBillingLines.d.ts +3 -1
  6. package/lib/common/components/billing-lines/NewBillingLines.js +8 -8
  7. package/lib/common/components/customer/index.d.ts +3 -1
  8. package/lib/common/components/customer/index.js +1 -1
  9. package/lib/common/components/delivery-location/index.d.ts +6 -2
  10. package/lib/common/components/delivery-location/index.js +5 -24
  11. package/lib/common/components/form-item/index.d.ts +4 -2
  12. package/lib/common/components/form-item/index.js +3 -4
  13. package/lib/common/components/payment-method/index.d.ts +3 -1
  14. package/lib/common/components/payment-method/index.js +60 -24
  15. package/lib/common/components/supplier/index.d.ts +3 -1
  16. package/lib/common/components/supplier/index.js +9 -45
  17. package/lib/common/types/AppConfiguration.d.ts +11 -1
  18. package/lib/common/types/CommonProps.d.ts +3 -0
  19. package/lib/common/types/NewReceiverRequirements.d.ts +25 -0
  20. package/lib/common/types/NewReceiverRequirements.js +2 -0
  21. package/lib/common/types/ReceiverRequirements.d.ts +0 -1
  22. package/lib/common/types/ReceiverRequirements.js +318 -310
  23. package/lib/create-credit-note/index.d.ts +4 -3
  24. package/lib/create-credit-note/index.js +1 -1
  25. package/lib/create-invoice/IntlLoader.js +1 -1
  26. package/lib/create-invoice/index.d.ts +1 -1
  27. package/lib/create-invoice/index.js +28 -8
  28. package/lib/example/src/index.d.ts +1 -0
  29. package/lib/src/common/components/attachments/Attachment.d.ts +18 -0
  30. package/lib/src/common/components/attachments/index.d.ts +6 -0
  31. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +18 -0
  32. package/lib/src/common/components/base-information/index.d.ts +13 -0
  33. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  34. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  35. package/lib/src/common/components/billing-lines/index.d.ts +28 -0
  36. package/lib/src/common/components/component-container/Content.d.ts +7 -0
  37. package/lib/src/common/components/component-container/Header.d.ts +9 -0
  38. package/lib/src/common/components/component-container/index.d.ts +11 -0
  39. package/lib/src/common/components/customer/index.d.ts +18 -0
  40. package/lib/src/common/components/delivery-location/index.d.ts +10 -0
  41. package/lib/src/common/components/editable-cell/index.d.ts +15 -0
  42. package/lib/src/common/components/editable-row/index.d.ts +5 -0
  43. package/lib/src/common/components/form-item/index.d.ts +28 -0
  44. package/lib/src/common/components/index.d.ts +10 -0
  45. package/lib/src/common/components/payment-method/index.d.ts +11 -0
  46. package/lib/src/common/components/payment-method/paymentMethodForConversion.d.ts +9 -0
  47. package/lib/src/common/components/supplier/index.d.ts +12 -0
  48. package/lib/src/common/consts/formLayout.d.ts +74 -0
  49. package/lib/src/common/consts/validationRules.d.ts +6 -0
  50. package/lib/src/common/types/ReceiverRequirements.d.ts +80 -0
  51. package/lib/src/create-invoice/IntlLoader.d.ts +14 -0
  52. package/lib/src/create-invoice/index.d.ts +11 -0
  53. package/lib/src/translations/locales.d.ts +142 -0
  54. package/lib/src/utils/ApiUtility.d.ts +21 -0
  55. package/lib/src/utils/BillingLineUtility.d.ts +10 -0
  56. package/lib/src/utils/ConversionUtility.d.ts +8 -0
  57. package/lib/src/utils/IntlUtility.d.ts +4 -0
  58. package/lib/src/utils/RequirementsUtility.d.ts +6 -0
  59. package/lib/src/utils/index.d.ts +2 -0
  60. package/lib/translations/locales/is.json +3 -3
  61. package/lib/translations/locales.d.ts +3 -3
  62. package/lib/utils/BillingLineUtility.d.ts +1 -1
  63. package/lib/utils/ReferenceIdentifierUtility.d.ts +6 -0
  64. package/lib/utils/ReferenceIdentifierUtility.js +24 -0
  65. package/lib/utils/RequirementsUtility.d.ts +5 -4
  66. package/lib/utils/RequirementsUtility.js +42 -17
  67. package/package.json +2 -2
  68. package/lib/utils/FileUploadUtility.d.ts +0 -7
  69. package/lib/utils/FileUploadUtility.js +0 -26
  70. package/lib/utils/FormatingUtility.d.ts +0 -2
  71. package/lib/utils/FormatingUtility.js +0 -6
@@ -0,0 +1,142 @@
1
+ declare const _default: {
2
+ en: {};
3
+ is: {
4
+ "attachment_labels_Reference": string;
5
+ "attachment_labels_Reference_requiredMessage": string;
6
+ "attachment_labels_Description": string;
7
+ "attachment_labels_Description_requiredMessage": string;
8
+ "attachment_labels_File": string;
9
+ "attachment_title": string;
10
+ "attachment_tooltip_title": string;
11
+ "baseInformation_title": string;
12
+ "baseInformation_invoiceNo": string;
13
+ "baseInformation_issueDate": string;
14
+ "baseInformation_issueDate_title": string;
15
+ "baseInformation_dueDate": string;
16
+ "baseInformation_dueDate_title": string;
17
+ "baseInformation_orderReference_documentNo": string;
18
+ "baseInformation_orderReference_documentNo_title": string;
19
+ "baseInformation_notes": string;
20
+ "baseInformation_currencyCode": string;
21
+ "billingCalculations_labels_TaxAmountWithoutVat": string;
22
+ "billingCalculations_labels_TotalVatAmount": string;
23
+ "billingCalculations_labels_TotalAmountWithVat": string;
24
+ "billingCalculations_labels_RoundingAmount": string;
25
+ "billingCalculations_labels_AmountPayable": string;
26
+ "billingTaxSummary_taxOverview": string;
27
+ "billingTaxSummary_taxableAmount": string;
28
+ "billingTaxSummary_taxAmount": string;
29
+ "billingTaxSummary_taxCategoryType_labels_StandardRated": string;
30
+ "billingTaxSummary_taxCategoryType_labels_ReducedRated": string;
31
+ "billingTaxSummary_taxCategoryType_labels_ZeroRated": string;
32
+ "billingTaxSummary_taxCategoryType_labels_Exempt": string;
33
+ "billingLines_title": string;
34
+ "billingLines_tooltip_title": string;
35
+ "billingLines_itemNo": string;
36
+ "billingLines_name": string;
37
+ "billingLines_quantity": string;
38
+ "billingLines_unitOfMeasure": string;
39
+ "billingLines_unitPriceAmount": string;
40
+ "billingLines_taxCategoryType": string;
41
+ "billingLines_taxCategoryType_title": string;
42
+ "billingLines_taxCategoryPercentage": string;
43
+ "billingLines_discount": string;
44
+ "billingLines_lineAmount": string;
45
+ "billingLines_taxAmount": string;
46
+ "billingLines_button_addRow": string;
47
+ "billingLines_placeholders_itemNo": string;
48
+ "billingLines_placeholders_newItem": string;
49
+ "deliveryLocation_title": string;
50
+ "deliveryLocation_partyName": string;
51
+ "deliveryLocation_streetNameAndNumber": string;
52
+ "deliveryLocation_postalZone": string;
53
+ "deliveryLocation_city": string;
54
+ "deliveryLocation_countryCode": string;
55
+ "formItem_required_errorMessage": string;
56
+ "paymentMethod_title": string;
57
+ "paymentMethod_labels_domesticTransfer_bankNo": string;
58
+ "paymentMethod_labels_domesticTransfer_typeNo": string;
59
+ "paymentMethod_labels_domesticTransfer_accountType": string;
60
+ "paymentMethod_labels_domesticTransfer_accountNo": string;
61
+ "paymentMethod_labels_domesticTransfer_paymentReference": string;
62
+ "paymentMethod_labels_icelandicClaim_bankNo": string;
63
+ "paymentMethod_labels_icelandicClaim_claimNo": string;
64
+ "paymentMethod_labels_methods_undefined": string;
65
+ "paymentMethod_labels_methods_mutuallyAgreed": string;
66
+ "paymentMethod_labels_methods_domesticTransfer": string;
67
+ "paymentMethod_labels_methods_domesticClaim": string;
68
+ "paymentMethod_rules_number": string;
69
+ "paymentMethod_rules_Length": string;
70
+ "supplier_title": string;
71
+ "supplier_name": string;
72
+ "supplier_identifier": string;
73
+ "supplier_vatNumber": string;
74
+ "supplier_address_streetNameAndNumber": string;
75
+ "supplier_address_zip_postalCode": string;
76
+ "supplier_address_city": string;
77
+ "supplier_address_countryCode": string;
78
+ "supplier_contact_email": string;
79
+ "supplier_contact_email_title": string;
80
+ "supplier_contact_name": string;
81
+ "supplier_notValidEmail": string;
82
+ "customer_title": string;
83
+ "customer_selectTheCustomer": string;
84
+ "customer_name": string;
85
+ "customer_identifier": string;
86
+ "customer_address_streetNameAndNumber": string;
87
+ "customer_address_zip_postalCode": string;
88
+ "customer_address_city": string;
89
+ "customer_address_countryCode": string;
90
+ "customer_contact_email": string;
91
+ "customer_contact_name": string;
92
+ "referenceIdentifiers_labels_addButton": string;
93
+ "referenceIdentifiers_labels_referenceIdentifier": string;
94
+ "referenceIdentifiers_labels_referenceIdentifier_title": string;
95
+ "attachment_labels_uploadFileMsg": string;
96
+ "attachment_labels_descriptionErrorMsg": string;
97
+ "baseInformation_currency_ISK": string;
98
+ "baseInformation_currency_DKK": string;
99
+ "baseInformation_currency_NOK": string;
100
+ "baseInformation_currency_SEK": string;
101
+ "baseInformation_currency_EUR": string;
102
+ "baseInformation_currency_USD": string;
103
+ "baseInformation_currency_GBP": string;
104
+ "baseInformation_dueDateErrorMsg": string;
105
+ "taxCategoryType_labels_StandardRated": string;
106
+ "taxCategoryType_labels_ReducedRated": string;
107
+ "taxCategoryType_labels_ZeroRated": string;
108
+ "taxCategoryType_labels_Exempt": string;
109
+ "unitOfMeasure_labels_Piece": string;
110
+ "unitOfMeasure_labels_Kilogram": string;
111
+ "unitOfMeasure_labels_Month": string;
112
+ "unitOfMeasure_labels_Package": string;
113
+ "unitOfMeasure_labels_Year": string;
114
+ "unitOfMeasure_labels_Day": string;
115
+ "unitOfMeasure_labels_Hour": string;
116
+ "unitOfMeasure_labels_Kilometre": string;
117
+ "unitOfMeasure_labels_Metre": string;
118
+ "unitOfMeasure_labels_Litre": string;
119
+ "unitOfMeasure_labels_SquareMetre": string;
120
+ "unitOfMeasure_labels_CubicMetre": string;
121
+ "unitOfMeasure_labels_Tonne": string;
122
+ "unitOfMeasure_labels_KiloWattHour": string;
123
+ "unitOfMeasure_labels_One": string;
124
+ "createInvoice_addDocumentLineMsg": string;
125
+ "createInvoice_selectCustomerMsg": string;
126
+ "createInvoice_successfullySubmittedInvoiceMsg": string;
127
+ "createInvoice_successfullyUploadedAttachmentMsg": string;
128
+ "createInvoice_ErrorUploadedAttachmentMsg": string;
129
+ "createInvoice_Submit": string;
130
+ "billingLines_labels_addButton": string;
131
+ "rulesMessages_name_required": string;
132
+ "rulesMessages_unitOfMeasure_required": string;
133
+ "rulesMessages_unitPriceAmount_required": string;
134
+ "rulesMessages_unitPriceAmount_type": string;
135
+ "rulesMessages_taxCategoryType_required": string;
136
+ "rulesMessages_discountValue_pattern": string;
137
+ "referenceIdentifiers_labels_carNumber": string;
138
+ "referenceIdentifiers_labels_identifier": string;
139
+ "referenceIdentifiers_labels_propertyNumber": string;
140
+ };
141
+ };
142
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { mapi } from "@unimaze/api-clients";
2
+ import { InvoiceMetadataInput, TransactionProcessingMode } from "@unimaze/api-clients/lib/mapi/api";
3
+ import { AxiosPromise } from "axios";
4
+ import { LanguageProp } from "../common/types/CommonProps";
5
+ interface CreateSubmitInvoice {
6
+ messageId: string;
7
+ more: boolean;
8
+ conversationIdentifier?: string;
9
+ processingMode?: TransactionProcessingMode;
10
+ services?: string[];
11
+ invoiceMetadataInput?: InvoiceMetadataInput;
12
+ }
13
+ interface AttachDocument {
14
+ messageId: string;
15
+ name: string;
16
+ contentType: string;
17
+ more: boolean;
18
+ }
19
+ declare const submitDocument: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey?: string | undefined) => AxiosPromise<mapi.MessageOutput>;
20
+ declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, apiKey?: string | undefined, callName?: string | undefined, language?: LanguageProp) => AxiosPromise<mapi.MessageOutput>;
21
+ export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument };
@@ -0,0 +1,10 @@
1
+ import { BillingLineMetadata } from '@unimaze/api-clients/lib/mapi';
2
+ import { FormInstance } from "antd/es/form";
3
+ import { TaxCategoryTypeEnum } from "@unimaze/api-clients/lib/mapi/api";
4
+ import React from "react";
5
+ export declare const billingLinesFieldsMetadata: (formInstance: FormInstance) => BillingLineMetadata[];
6
+ export declare const calculateTaxableAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null) => number;
7
+ export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
8
+ export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum) => number;
9
+ export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum, taxCategoryTypeTranslated: string) => string;
10
+ export declare const getCorrectInputNode: (dataIdx: "unitOfMeasure" | "taxCategoryType" | "itemNo" | "name" | "description" | "quantity" | "unitPriceAmount" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "notes" | "accountingCost" | "billingPeriod" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "referenceIdentifiers" | "orderLineReference" | "key") => React.ReactChild;
@@ -0,0 +1,8 @@
1
+ import { BillingLineMetadata, InvoiceMetadataInput, PartyMetadata } from "@unimaze/api-clients/lib/mapi";
2
+ import { Store } from "antd/es/form/interface";
3
+ import { ProfileOutput } from "@unimaze/api-clients/lib/wapi2";
4
+ import { PaymentMeansMetadata } from "@unimaze/api-clients/lib/mapi/api";
5
+ declare const convertToInvoiceMetadataInput: (formValues: Store, billingLines: BillingLineMetadata[], paymentMethod: PaymentMeansMetadata, chosenCustomer: PartyMetadata) => InvoiceMetadataInput;
6
+ declare const profileOutputToPartyMetadata: (profileOutput: ProfileOutput) => PartyMetadata;
7
+ declare const convertToReadableKennitala: (isoIdentifier: string) => string;
8
+ export { convertToInvoiceMetadataInput, profileOutputToPartyMetadata, convertToReadableKennitala };
@@ -0,0 +1,4 @@
1
+ import { FormattedNumber, InjectedIntl } from "react-intl";
2
+ declare const icelandicNumberLocaleWorkaroundChrome: (value: number, intl: InjectedIntl, options?: FormattedNumber.PropsBase | undefined) => string;
3
+ declare const returnDecimalSeparatorForLocale: (locale: string | null) => string | undefined;
4
+ export { icelandicNumberLocaleWorkaroundChrome, returnDecimalSeparatorForLocale };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { AvailableFields } from "../common/types/ReceiverRequirements";
3
+ import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
4
+ export declare const getFieldRequirements: (receiverRequirements: NewReceiverRequirements, key: AvailableFields) => FieldDefinition | undefined;
5
+ export declare const getFieldLabelOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabel: React.ReactNode) => React.ReactNode;
6
+ export declare const getFieldIsRequired: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean) => boolean;
@@ -0,0 +1,2 @@
1
+ export { convertToInvoiceMetadataInput } from "./ConversionUtility";
2
+ export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument } from "./ApiUtility";
@@ -132,7 +132,7 @@
132
132
  "rulesMessages_unitPriceAmount_type": "Einingaverð þarf að vera tala",
133
133
  "rulesMessages_taxCategoryType_required": "Vinsamlega veljið skattflokk",
134
134
  "rulesMessages_discountValue_pattern": "Vinsamlega notið einungis tölustafi og prósentumerki í lokin",
135
- "referenceIdentifiers_labels_carNumber": "Bílnúmer",
136
- "referenceIdentifiers_labels_identifier": "Kennitala",
137
- "referenceIdentifiers_labels_propertyNumber": "Fasteignanúmer"
135
+ "referenceIdentifiers_labels_AKY": "Bílnúmer",
136
+ "referenceIdentifiers_labels_ARR": "Kennitala",
137
+ "referenceIdentifiers_labels_LOC": "Fasteignanúmer"
138
138
  }
@@ -134,9 +134,9 @@ declare const _default: {
134
134
  "rulesMessages_unitPriceAmount_type": string;
135
135
  "rulesMessages_taxCategoryType_required": string;
136
136
  "rulesMessages_discountValue_pattern": string;
137
- "referenceIdentifiers_labels_carNumber": string;
138
- "referenceIdentifiers_labels_identifier": string;
139
- "referenceIdentifiers_labels_propertyNumber": string;
137
+ "referenceIdentifiers_labels_AKY": string;
138
+ "referenceIdentifiers_labels_ARR": string;
139
+ "referenceIdentifiers_labels_LOC": string;
140
140
  };
141
141
  };
142
142
  export default _default;
@@ -7,4 +7,4 @@ export declare const calculateTaxableAmount: (discountValue: string | null | und
7
7
  export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
8
8
  export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum) => number;
9
9
  export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum, taxCategoryTypeTranslated: string) => string;
10
- export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "notes" | "referenceIdentifiers" | "accountingCost" | "billingPeriod" | "unitOfMeasure" | "taxCategoryType" | "itemNo" | "quantity" | "unitPriceAmount" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "orderLineReference") => React.ReactChild;
10
+ export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "referenceIdentifiers" | "notes" | "accountingCost" | "billingPeriod" | "unitOfMeasure" | "taxCategoryType" | "itemNo" | "quantity" | "unitPriceAmount" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "orderLineReference") => React.ReactChild;
@@ -0,0 +1,6 @@
1
+ import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
2
+ export interface FieldDefinitionWithOriginalKey extends FieldDefinition {
3
+ originalKey: string;
4
+ }
5
+ declare const getReferenceIdentifierOptions: (receiverRequirement: NewReceiverRequirements) => FieldDefinitionWithOriginalKey[];
6
+ export { getReferenceIdentifierOptions };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ var getReferenceIdentifierFieldDefinitions = function (receiverRequirement) {
15
+ return receiverRequirement.fieldDefinitions.filter(function (fieldRequirement) { return fieldRequirement.key.startsWith("referenceIdentifier"); });
16
+ };
17
+ var getReferenceIdentifierOptions = function (receiverRequirement) {
18
+ var referenceIdentifierFieldDefinitions = getReferenceIdentifierFieldDefinitions(receiverRequirement);
19
+ return referenceIdentifierFieldDefinitions.map(function (fieldDefinition) {
20
+ var delimiterIndex = fieldDefinition.key.indexOf(".");
21
+ return __assign({}, fieldDefinition, { key: fieldDefinition.key.substring(delimiterIndex + 1), originalKey: fieldDefinition.key });
22
+ });
23
+ };
24
+ exports.getReferenceIdentifierOptions = getReferenceIdentifierOptions;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { AvailableFields, FieldRequirement, ReceiverRequirements } from "../common/types/ReceiverRequirements";
3
- export declare const getReceiverRequirements: (recRequirements: ReceiverRequirements, key: AvailableFields) => FieldRequirement;
4
- export declare const getReceiverRequirementsIsRequired: (recRequirements: ReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean) => boolean;
5
- export declare const getReceiverRequirementsLabelWithDefault: (recRequirements: ReceiverRequirements, key: AvailableFields, defaultLabel: React.ReactNode) => React.ReactNode;
2
+ import { AvailableFields } from "../common/types/ReceiverRequirements";
3
+ import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
4
+ export declare const getFieldRequirements: (receiverRequirements: NewReceiverRequirements, key: AvailableFields) => FieldDefinition | undefined;
5
+ export declare const getFieldLabelOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabel: React.ReactNode) => React.ReactNode;
6
+ export declare const getFieldIsRequired: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean) => boolean;
@@ -1,23 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getReceiverRequirements = function (recRequirements, key) {
4
- return recRequirements[key];
3
+ // export const getReceiverRequirements = (recRequirements: ReceiverRequirements, key: AvailableFields): FieldRequirement => {
4
+ // return recRequirements[key]!;
5
+ // };
6
+ //
7
+ // export const getReceiverRequirementsIsRequired = (recRequirements: ReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean): boolean => {
8
+ // if (recRequirements.hasOwnProperty(key)) {
9
+ // const recRequirement = recRequirements[key];
10
+ // if (recRequirement) {
11
+ // return recRequirement.isRequired
12
+ // }
13
+ // }
14
+ // return defaultIsRequired;
15
+ // };
16
+ //
17
+ // export const getReceiverRequirementsLabelWithDefault = (recRequirements: ReceiverRequirements, key: AvailableFields, defaultLabel: React.ReactNode): React.ReactNode => {
18
+ // if (recRequirements.hasOwnProperty(key)) {
19
+ // const recRequirement = recRequirements[key];
20
+ // if (recRequirement && recRequirement.label) {
21
+ // return recRequirement.label
22
+ // }
23
+ // }
24
+ // return defaultLabel;
25
+ // };
26
+ exports.getFieldRequirements = function (receiverRequirements, key) {
27
+ return receiverRequirements.fieldDefinitions.find(function (field) { return field.key === key; });
5
28
  };
6
- exports.getReceiverRequirementsIsRequired = function (recRequirements, key, defaultIsRequired) {
7
- if (recRequirements.hasOwnProperty(key)) {
8
- var recRequirement = recRequirements[key];
9
- if (recRequirement) {
10
- return recRequirement.isRequired;
11
- }
12
- }
13
- return defaultIsRequired;
29
+ exports.getFieldLabelOverride = function (receiverRequirements, key, defaultLabel) {
30
+ var fieldRequirement = exports.getFieldRequirements(receiverRequirements, key);
31
+ return fieldRequirement && fieldRequirement.properties.hasOwnProperty("label") ? fieldRequirement.properties.label : defaultLabel;
32
+ };
33
+ exports.getFieldIsRequired = function (receiverRequirements, key, defaultIsRequired) {
34
+ var fieldRequirement = exports.getFieldRequirements(receiverRequirements, key);
35
+ var fieldCardinality = fieldRequirement && fieldRequirement.properties.hasOwnProperty("cardinality") && fieldRequirement.properties.cardinality;
36
+ return fieldCardinality ? cardinalityToRequired(fieldCardinality) : defaultIsRequired;
14
37
  };
15
- exports.getReceiverRequirementsLabelWithDefault = function (recRequirements, key, defaultLabel) {
16
- if (recRequirements.hasOwnProperty(key)) {
17
- var recRequirement = recRequirements[key];
18
- if (recRequirement && recRequirement.label) {
19
- return recRequirement.label;
20
- }
38
+ var cardinalityToRequired = function (cardinality) {
39
+ switch (cardinality) {
40
+ case "0..0":
41
+ case "0..1":
42
+ return false;
43
+ case "1..1":
44
+ return true;
45
+ default:
46
+ throw new Error("Cardinality \"" + cardinality + "\" is not supported");
21
47
  }
22
- return defaultLabel;
23
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.5.0-sjova.0",
3
+ "version": "0.6.0-rc.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "dependencies": {
11
11
  "@ant-design/compatible": "latest",
12
- "@unimaze/api-clients": "1.2.0",
12
+ "@unimaze/api-clients": "2.0.1",
13
13
  "react-hot-loader": "^4.12.20",
14
14
  "react-intl": "2.9.0",
15
15
  "uuid": "latest"
@@ -1,7 +0,0 @@
1
- import { UploadFile } from "antd/es/upload/interface";
2
- declare const reportIfFileIsValid: (file: UploadFile<any>, errorMessages: {
3
- uploadFailed: string;
4
- uploadErrorWrongType: string;
5
- uploadErrorToLarge: string;
6
- }) => boolean;
7
- export { reportIfFileIsValid };
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var antd_1 = require("antd");
4
- var reportIfFileIsValid = function (file, errorMessages) {
5
- var isFileCorrectType = (file.type === "application/pdf"
6
- || file.type === "image/jpeg"
7
- || file.type === "image/png"
8
- || file.type === "image/gif"
9
- || file.type === "image/tiff"
10
- || file.type === "text/plain");
11
- var isFileCorrectSize = (file.size <= 1024000);
12
- if (!isFileCorrectType) {
13
- antd_1.notification.error({
14
- message: errorMessages.uploadFailed,
15
- description: errorMessages.uploadErrorWrongType
16
- });
17
- }
18
- if (!isFileCorrectSize) {
19
- antd_1.notification.error({
20
- message: errorMessages.uploadFailed,
21
- description: errorMessages.uploadErrorToLarge
22
- });
23
- }
24
- return isFileCorrectType && isFileCorrectSize;
25
- };
26
- exports.reportIfFileIsValid = reportIfFileIsValid;
@@ -1,2 +0,0 @@
1
- declare const formatCurrency: (value: number | null, currency: string, intl: any) => string;
2
- export { formatCurrency };
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var formatCurrency = function (value, currency, intl) {
4
- return intl.formatNumber(value ? value : 0, { style: "currency", currency: currency });
5
- };
6
- exports.formatCurrency = formatCurrency;