@unimaze/billing 0.1.0 → 0.1.2-rc.10

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 (101) hide show
  1. package/README.md +11 -3
  2. package/lib/common/components/attachments/Attachment.d.ts +8 -2
  3. package/lib/common/components/attachments/Attachment.js +33 -8
  4. package/lib/common/components/attachments/index.d.ts +9 -2
  5. package/lib/common/components/attachments/index.js +15 -6
  6. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +6 -0
  7. package/lib/common/components/base-information/ReferenceIdentifiers.js +40 -0
  8. package/lib/common/components/base-information/index.d.ts +6 -3
  9. package/lib/common/components/base-information/index.js +100 -81
  10. package/lib/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  11. package/lib/common/components/billing-lines/BillingCalculations.js +61 -0
  12. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  13. package/lib/common/components/billing-lines/BillingTaxSummary.js +51 -0
  14. package/lib/common/components/billing-lines/billingLIneFormData.d.ts +7 -0
  15. package/lib/common/components/billing-lines/billingLIneFormData.js +63 -0
  16. package/lib/common/components/billing-lines/index.d.ts +10 -24
  17. package/lib/common/components/billing-lines/index.js +117 -39
  18. package/lib/common/components/customer/hardCoddedCustomer.d.ts +7 -0
  19. package/lib/common/components/{issuer/index.js → customer/hardCoddedCustomer.js} +5 -8
  20. package/lib/common/components/customer/index.d.ts +6 -0
  21. package/lib/common/components/customer/index.js +93 -0
  22. package/lib/common/components/delivery-location/index.d.ts +5 -2
  23. package/lib/common/components/delivery-location/index.js +43 -11
  24. package/lib/common/components/editable-cell/index.d.ts +1 -1
  25. package/lib/common/components/editable-cell/index.js +77 -11
  26. package/lib/common/components/editable-row/index.d.ts +5 -5
  27. package/lib/common/components/editable-row/index.js +8 -6
  28. package/lib/common/components/form-item/index.d.ts +21 -0
  29. package/lib/common/components/form-item/index.js +27 -0
  30. package/lib/common/components/index.d.ts +10 -5
  31. package/lib/common/components/index.js +20 -8
  32. package/lib/common/components/locale-intl/index.d.ts +10 -0
  33. package/lib/common/components/locale-intl/index.js +45 -0
  34. package/lib/common/components/payment-method/index.d.ts +6 -3
  35. package/lib/common/components/payment-method/index.js +67 -27
  36. package/lib/common/components/supplier/index.d.ts +6 -0
  37. package/lib/common/components/supplier/index.js +93 -0
  38. package/lib/common/consts/validationRules.d.ts +2 -3
  39. package/lib/common/consts/validationRules.js +1 -8
  40. package/lib/common/enums/index.d.ts +1 -1
  41. package/lib/common/enums/index.js +2 -4
  42. package/lib/common/types/BillingLineMetadataOverride.d.ts +2 -1
  43. package/lib/common/types/ReceiverRequirements.d.ts +81 -0
  44. package/lib/common/types/ReceiverRequirements.js +379 -0
  45. package/lib/create-credit-note/index.d.ts +2 -3
  46. package/lib/create-credit-note/index.js +17 -28
  47. package/lib/create-invoice/index.d.ts +1 -2
  48. package/lib/create-invoice/index.js +79 -21
  49. package/lib/example/src/index.d.ts +1 -1
  50. package/lib/index.d.ts +2 -3
  51. package/lib/index.js +8 -5
  52. package/lib/src/common/components/attachments/Attachment.d.ts +21 -0
  53. package/lib/src/common/components/attachments/index.d.ts +10 -0
  54. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +6 -0
  55. package/lib/src/common/components/base-information/index.d.ts +12 -0
  56. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  57. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  58. package/lib/src/common/components/billing-lines/billingLIneFormData.d.ts +7 -0
  59. package/lib/src/common/components/billing-lines/index.d.ts +13 -0
  60. package/lib/src/common/components/component-container/Content.d.ts +7 -0
  61. package/lib/src/common/components/component-container/Header.d.ts +9 -0
  62. package/lib/src/common/components/component-container/index.d.ts +10 -0
  63. package/lib/src/common/components/customer/index.d.ts +6 -0
  64. package/lib/src/common/components/delivery-location/index.d.ts +6 -0
  65. package/lib/src/common/components/editable-cell/index.d.ts +11 -0
  66. package/lib/src/common/components/editable-row/index.d.ts +6 -0
  67. package/lib/src/common/components/form-item/index.d.ts +21 -0
  68. package/lib/src/common/components/index.d.ts +10 -0
  69. package/lib/src/common/components/locale-intl/index.d.ts +10 -0
  70. package/lib/src/common/components/payment-method/index.d.ts +6 -0
  71. package/lib/src/common/components/supplier/index.d.ts +6 -0
  72. package/lib/src/common/consts/validationRules.d.ts +6 -0
  73. package/lib/src/common/types/ReceiverRequirements.d.ts +81 -0
  74. package/lib/src/create-invoice/index.d.ts +14 -0
  75. package/lib/src/translations/locales.d.ts +74 -0
  76. package/lib/src/utils/ApiUtility.d.ts +21 -0
  77. package/lib/src/utils/BillingLineUtility.d.ts +8 -0
  78. package/lib/src/utils/ConversionUtility.d.ts +5 -0
  79. package/lib/src/utils/RequirementsUtility.d.ts +5 -0
  80. package/lib/src/utils/billingLineFormData.d.ts +7 -0
  81. package/lib/src/utils/index.d.ts +2 -0
  82. package/lib/style/index.css +0 -1222
  83. package/lib/translations/locales/is.json +70 -0
  84. package/lib/translations/locales.d.ts +74 -0
  85. package/lib/translations/locales.js +10 -0
  86. package/lib/utils/ApiUtility.d.ts +21 -0
  87. package/lib/utils/ApiUtility.js +59 -0
  88. package/lib/utils/BillingLineUtility.d.ts +8 -0
  89. package/lib/utils/BillingLineUtility.js +66 -0
  90. package/lib/utils/ConversionUtility.d.ts +5 -0
  91. package/lib/utils/ConversionUtility.js +146 -0
  92. package/lib/utils/RequirementsUtility.d.ts +5 -0
  93. package/lib/utils/RequirementsUtility.js +23 -0
  94. package/lib/utils/billingLineFormData.d.ts +7 -0
  95. package/lib/utils/billingLineFormData.js +63 -0
  96. package/lib/utils/index.d.ts +2 -5
  97. package/lib/utils/index.js +5 -162
  98. package/package.json +22 -7
  99. package/lib/common/components/issuer/index.d.ts +0 -7
  100. package/lib/common/components/payer/index.d.ts +0 -3
  101. package/lib/common/components/payer/index.js +0 -50
@@ -0,0 +1,70 @@
1
+ {
2
+ "attachment_labels_Reference": "Tilvísun",
3
+ "attachment_labels_Reference_requiredMessage": "Vinsamlega sláið inn tilvísun",
4
+ "attachment_labels_Description": "Lýsing",
5
+ "attachment_labels_Description_requiredMessage": "Vinsamlega sláið inn lýsingu",
6
+ "attachment_labels_File": "Skrá",
7
+ "attachment_title": "Viðhengi",
8
+ "baseInformation_title": "Grunnupplýsingar",
9
+ "baseInformation_invoiceNo": "Reikningsnr.",
10
+ "baseInformation_issueDate": "Útgáfudags.",
11
+ "baseInformation_dueDate": "Gjalddagi",
12
+ "baseInformation_orderReference_documentNo": "Pöntunarnr.",
13
+ "baseInformation_notes": "Athugasemdir",
14
+ "baseInformation_currencyCode": "Gjaldmiðill",
15
+ "billingCalculations_labels_TaxAmountWithoutVat": "Samtals án VSK",
16
+ "billingCalculations_labels_TotalVatAmount": "Samtals VSK upphæð",
17
+ "billingCalculations_labels_TotalAmountWithVat": "Samtals með VSK",
18
+ "billingTaxSummary_taxOverview": "Skattsyfirlit",
19
+ "billingTaxSummary_taxableAmount": "Skattskyld upphæð",
20
+ "billingTaxSummary_taxAmount": "Skattur",
21
+ "billingLines_title": "Reikningslínur",
22
+ "billingLines_itemNo": "Vörunr.",
23
+ "billingLines_name": "Nafn",
24
+ "billingLines_quantity": "Fjöldi",
25
+ "billingLines_unitOfMeasure": "Mælieining",
26
+ "billingLines_unitPriceAmount": "Verð pr. einingu",
27
+ "billingLines_taxCategoryType": "Skattflokkur",
28
+ "billingLines_taxCategoryPercentage": "Skattprósenta",
29
+ "billingLines_discount": "Afsláttur",
30
+ "billingLines_lineAmount": "Upphæð",
31
+ "billingLines_taxAmount": "Upphæð með skatti",
32
+ "billingLines_button_addRow": "Bæta við röð",
33
+ "deliveryLocation_title": "Afhendingarstaður",
34
+ "deliveryLocation_partyName": "Nafn aðila",
35
+ "deliveryLocation_streetNameAndNumber": "Heimilisfang",
36
+ "deliveryLocation_postalZone": "Póstnúmer",
37
+ "deliveryLocation_city": "Bær/Borg",
38
+ "deliveryLocation_countryCode": "Landsnúmer",
39
+ "formItem_required_errorMessage": "Það þarf að fylla út í þennan reit",
40
+ "paymentMethod_labels_domesticTransfer_bankNo": "Bankanúmer",
41
+ "paymentMethod_labels_domesticTransfer_typeNo": "Týpunúmer",
42
+ "paymentMethod_labels_domesticTransfer_accountNo": "Reikningsnúmer",
43
+ "paymentMethod_labels_domesticTransfer_paymentReference": "Greiðslutilvísun",
44
+ "paymentMethod_labels_icelandicClaim_bankNo": "Bankanúmer",
45
+ "paymentMethod_labels_icelandicClaim_claimNo": "Kröfunúmer",
46
+ "paymentMethod_labels_methods_undefined": "Óskilgreint",
47
+ "paymentMethod_labels_methods_mutuallyAgreed": "Skv. samkomulagi",
48
+ "paymentMethod_labels_methods_domesticTransfer": "Millifærsla innanlands",
49
+ "paymentMethod_labels_methods_domesticClaim": "Krafa",
50
+ "supplier_title": "Birgi",
51
+ "supplier_name": "Nafn birgja",
52
+ "supplier_identifier": "Kenni",
53
+ "supplier_vatNumber": "VSK nr.",
54
+ "supplier_address_streetNameAndNumber": "Heimilisfang",
55
+ "supplier_address_zip_postalCode": "Póstnúmer",
56
+ "supplier_address_city": "Borg",
57
+ "supplier_address_countryCode": "Landsnúmer",
58
+ "supplier_contact_email": "Netfang",
59
+ "supplier_contact_name": "Nafn tengiliðs",
60
+ "supplier_notValidEmail": "Þetta er ekki gilt netfang",
61
+ "customer_title": "Viðskiptavinur",
62
+ "customer_name": "Nafn viðskiptavinar",
63
+ "customer_identifier": "Kennitala",
64
+ "customer_address_streetNameAndNumber": "Heimilisfang",
65
+ "customer_address_zip_postalCode": "Póstnúmer",
66
+ "customer_address_city": "Borg",
67
+ "customer_address_countryCode": "Landsnúmer",
68
+ "customer_contact_email": "Netfang",
69
+ "customer_contact_name": "Nafn tengiliðs"
70
+ }
@@ -0,0 +1,74 @@
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
+ "baseInformation_title": string;
11
+ "baseInformation_invoiceNo": string;
12
+ "baseInformation_issueDate": string;
13
+ "baseInformation_dueDate": string;
14
+ "baseInformation_orderReference_documentNo": string;
15
+ "baseInformation_notes": string;
16
+ "baseInformation_currencyCode": string;
17
+ "billingCalculations_labels_TaxAmountWithoutVat": string;
18
+ "billingCalculations_labels_TotalVatAmount": string;
19
+ "billingCalculations_labels_TotalAmountWithVat": string;
20
+ "billingTaxSummary_taxOverview": string;
21
+ "billingTaxSummary_taxableAmount": string;
22
+ "billingTaxSummary_taxAmount": string;
23
+ "billingLines_title": string;
24
+ "billingLines_itemNo": string;
25
+ "billingLines_name": string;
26
+ "billingLines_quantity": string;
27
+ "billingLines_unitOfMeasure": string;
28
+ "billingLines_unitPriceAmount": string;
29
+ "billingLines_taxCategoryType": string;
30
+ "billingLines_taxCategoryPercentage": string;
31
+ "billingLines_discount": string;
32
+ "billingLines_lineAmount": string;
33
+ "billingLines_taxAmount": string;
34
+ "billingLines_button_addRow": string;
35
+ "deliveryLocation_title": string;
36
+ "deliveryLocation_partyName": string;
37
+ "deliveryLocation_streetNameAndNumber": string;
38
+ "deliveryLocation_postalZone": string;
39
+ "deliveryLocation_city": string;
40
+ "deliveryLocation_countryCode": string;
41
+ "formItem_required_errorMessage": string;
42
+ "paymentMethod_labels_domesticTransfer_bankNo": string;
43
+ "paymentMethod_labels_domesticTransfer_typeNo": string;
44
+ "paymentMethod_labels_domesticTransfer_accountNo": string;
45
+ "paymentMethod_labels_domesticTransfer_paymentReference": string;
46
+ "paymentMethod_labels_icelandicClaim_bankNo": string;
47
+ "paymentMethod_labels_icelandicClaim_claimNo": string;
48
+ "paymentMethod_labels_methods_undefined": string;
49
+ "paymentMethod_labels_methods_mutuallyAgreed": string;
50
+ "paymentMethod_labels_methods_domesticTransfer": string;
51
+ "paymentMethod_labels_methods_domesticClaim": string;
52
+ "supplier_title": string;
53
+ "supplier_name": string;
54
+ "supplier_identifier": string;
55
+ "supplier_vatNumber": string;
56
+ "supplier_address_streetNameAndNumber": string;
57
+ "supplier_address_zip_postalCode": string;
58
+ "supplier_address_city": string;
59
+ "supplier_address_countryCode": string;
60
+ "supplier_contact_email": string;
61
+ "supplier_contact_name": string;
62
+ "supplier_notValidEmail": string;
63
+ "customer_title": string;
64
+ "customer_name": string;
65
+ "customer_identifier": string;
66
+ "customer_address_streetNameAndNumber": string;
67
+ "customer_address_zip_postalCode": string;
68
+ "customer_address_city": string;
69
+ "customer_address_countryCode": string;
70
+ "customer_contact_email": string;
71
+ "customer_contact_name": string;
72
+ };
73
+ };
74
+ export default _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var is_json_1 = __importDefault(require("./locales/is.json"));
7
+ // English is the default message in each of our source files, so no need for a separate en.json file
8
+ var en = {};
9
+ // If we add more than just spanish, just import the files and export it below: export default { en, es, de }
10
+ exports.default = { en: en, is: is_json_1.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,59 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var api_clients_1 = require("@unimaze/api-clients");
18
+ var mapi_1 = require("@unimaze/api-clients/lib/mapi");
19
+ var axios_1 = __importDefault(require("axios"));
20
+ var initialiseTransactionApi = function (mapiBaseUrl) {
21
+ var apiConfig = {
22
+ basePath: mapiBaseUrl,
23
+ };
24
+ var initiatedConfig = new mapi_1.Configuration(apiConfig);
25
+ return new api_clients_1.mapi.TransactionApi(initiatedConfig);
26
+ };
27
+ var initialiseMessageApi = function (mapiBaseUrl) {
28
+ var apiConfig = {
29
+ basePath: mapiBaseUrl,
30
+ };
31
+ var initiatedConfig = new mapi_1.Configuration(apiConfig);
32
+ return new api_clients_1.mapi.MessageApi(initiatedConfig);
33
+ };
34
+ var submitDocument = function (data, attachDocument, mapiBaseUrl, apiKey) {
35
+ var messageApi = initialiseMessageApi(mapiBaseUrl);
36
+ var messageId = attachDocument.messageId, name = attachDocument.name, contentType = attachDocument.contentType, more = attachDocument.more;
37
+ return messageApi.addDocuments(messageId, name, contentType, more, undefined, undefined, undefined, createOptionsData(data, apiKey));
38
+ };
39
+ exports.submitDocument = submitDocument;
40
+ var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, apiKey, callName, language) {
41
+ var transactionApi = initialiseTransactionApi(mapiBaseUrl);
42
+ var messageId = createSubmitInvoice.messageId, more = createSubmitInvoice.more, conversationIdentifier = createSubmitInvoice.conversationIdentifier, processingMode = createSubmitInvoice.processingMode, services = createSubmitInvoice.services, invoiceMetadataInput = createSubmitInvoice.invoiceMetadataInput;
43
+ return transactionApi.createSubmitInvoice(messageId, more, conversationIdentifier, processingMode, services, invoiceMetadataInput, createOptions(apiKey, callName, language));
44
+ };
45
+ exports.submitInvoice = submitInvoice;
46
+ var createOptions = function (apiKey, callName, language) {
47
+ return __assign({ headers: __assign({ "Accept-Language": language ? language : "en" }, (apiKey && { Authorization: "Bearer " + window.btoa(apiKey) })) }, (callName && { cancelToken: getCancelToken(callName) }));
48
+ };
49
+ var createOptionsData = function (data, apiKey, callName, language) {
50
+ return __assign({ headers: __assign({ "Accept-Language": language ? language : "en" }, (apiKey && { Authorization: "Bearer " + window.btoa(apiKey) }), { 'Content-Type': 'application/octet-stream' }) }, (callName && { cancelToken: getCancelToken(callName) }), { data: data });
51
+ };
52
+ var getCancelToken = function (callName) {
53
+ var cancelTokenSource = window[callName];
54
+ if (cancelTokenSource) {
55
+ cancelTokenSource.cancel("only one call allowed. Canceling previous call");
56
+ }
57
+ window[callName] = axios_1.default.CancelToken.source();
58
+ return window[callName].token;
59
+ };
@@ -0,0 +1,8 @@
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
+ export declare const billingLinesFieldsMetadata: (formInstance: FormInstance) => BillingLineMetadata[];
5
+ export declare const calculateTaxableAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null) => number;
6
+ export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
7
+ export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum) => number;
8
+ export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum) => string;
@@ -0,0 +1,66 @@
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 api_1 = require("@unimaze/api-clients/lib/mapi/api");
15
+ exports.billingLinesFieldsMetadata = function (formInstance) {
16
+ var billingLinesMetadata = formInstance.getFieldValue("billingLinesMetadata");
17
+ return billingLinesMetadata.map(function (billingLine) {
18
+ var taxableAmount = exports.calculateTaxableAmount(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
19
+ var taxPercentage = exports.calculateTaxPercentage(billingLine.taxCategoryType);
20
+ var taxAmount = exports.calculateTaxAmount(taxableAmount, taxPercentage);
21
+ var mappedBillingLine = __assign({}, billingLine, { taxableAmount: taxableAmount,
22
+ taxAmount: taxAmount,
23
+ taxPercentage: taxPercentage });
24
+ if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
25
+ delete mappedBillingLine.discountValue;
26
+ }
27
+ return mappedBillingLine;
28
+ });
29
+ };
30
+ exports.calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount) {
31
+ if (!quantity || !unitPriceAmount) {
32
+ return 0;
33
+ }
34
+ if (discountValue) {
35
+ if (discountValue.endsWith("%")) {
36
+ // (quantity * unitPriceAmount) * ((100 - discountValue) / 100)
37
+ return ((quantity * unitPriceAmount) * ((100 - parseFloat(discountValue)) / 100));
38
+ }
39
+ else {
40
+ // (quantity * unitPriceAmount) - discountValue
41
+ return ((quantity * unitPriceAmount) - parseFloat(discountValue));
42
+ }
43
+ }
44
+ else {
45
+ return (quantity * unitPriceAmount);
46
+ }
47
+ };
48
+ exports.calculateTaxAmount = function (taxableAmount, taxPercentage) {
49
+ // taxableAmount * (taxPercentage / 100)
50
+ return (taxableAmount * (taxPercentage / 100));
51
+ };
52
+ exports.calculateTaxPercentage = function (taxCategoryType) {
53
+ // inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
54
+ switch (taxCategoryType) {
55
+ case api_1.TaxCategoryTypeEnum.StandardRated:
56
+ return 24;
57
+ case api_1.TaxCategoryTypeEnum.ReducedRated:
58
+ return 11;
59
+ case api_1.TaxCategoryTypeEnum.ZeroRated:
60
+ case api_1.TaxCategoryTypeEnum.Exempt:
61
+ return 0;
62
+ }
63
+ };
64
+ exports.generateTaxCategoryLabel = function (taxCategoryType) {
65
+ return exports.calculateTaxPercentage(taxCategoryType) + "% (" + taxCategoryType + ")";
66
+ };
@@ -0,0 +1,5 @@
1
+ import { BillingLineMetadata, InvoiceMetadataInput } from "@unimaze/api-clients/lib/mapi";
2
+ import { Store } from "antd/es/form/interface";
3
+ import { ProfileOutput } from "@unimaze/api-clients/lib/wapi2";
4
+ declare const convertToInvoiceMetadataInput: (formValues: Store, billingLines: BillingLineMetadata[], customer?: ProfileOutput | undefined) => InvoiceMetadataInput;
5
+ export { /*convertToCreditNoteMetadataInput,*/ convertToInvoiceMetadataInput };
@@ -0,0 +1,146 @@
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 removeEmpty = function (obj) {
15
+ return Object.keys(obj)
16
+ .filter(function (k) { return obj[k] != null; }) // Remove undef. and null.
17
+ .reduce(function (newObj, k) {
18
+ var _a, _b;
19
+ return typeof obj[k] === "object"
20
+ ? __assign({}, newObj, (_a = {}, _a[k] = removeEmpty(obj[k]), _a)) : __assign({}, newObj, (_b = {}, _b[k] = obj[k], _b));
21
+ }, // Copy value.
22
+ {});
23
+ };
24
+ var convertDates = function (date) {
25
+ return date ? date.utc().toDate() : undefined;
26
+ };
27
+ var isEmpty = function (map) {
28
+ for (var key in map) {
29
+ if (map.hasOwnProperty(key)) {
30
+ return false;
31
+ }
32
+ }
33
+ return true;
34
+ };
35
+ var getIdentifierWithPrefix = function (identifier) {
36
+ if (!identifier.startsWith("0196:")) {
37
+ return "0196:" + identifier;
38
+ }
39
+ else {
40
+ return identifier;
41
+ }
42
+ };
43
+ var convertToInvoiceMetadataInput = function (formValues, billingLines, customer) {
44
+ var issueDate = convertDates(formValues.invoice.issueDate);
45
+ var dueDate = convertDates(formValues.invoice.dueDate);
46
+ // tslint:disable-next-line:no-console
47
+ console.log(issueDate);
48
+ var cleanedFormValues = removeEmpty(formValues);
49
+ var invoice = cleanedFormValues.invoice;
50
+ // fix delivery
51
+ var delivery = invoice.delivery;
52
+ if (delivery) {
53
+ if (isEmpty(delivery.address)) {
54
+ delete delivery.address;
55
+ }
56
+ }
57
+ var resp = {
58
+ messageHandling: {
59
+ receiverIdentifier: customer.participantLegalIsoIdentifier,
60
+ fallbackEmailAddress: customer.email,
61
+ fallbackContactName: customer.name,
62
+ },
63
+ invoice: {
64
+ customer: {
65
+ identifier: getIdentifierWithPrefix(invoice.customer.identifier),
66
+ address: {
67
+ streetNameAndNumber: invoice.customer.address.streetNameAndNumber,
68
+ postalZone: invoice.customer.address.postalZone,
69
+ city: invoice.customer.address.city,
70
+ countryCode: invoice.customer.address.countryCode // customer.country!,
71
+ // countrySubEntity: "",
72
+ // addressLine2: "",
73
+ // addressLine3: ""
74
+ },
75
+ name: invoice.customer.name,
76
+ contact: {
77
+ electronicMail: invoice.customer.contact.electronicMail,
78
+ telephone: invoice.customer.contact.telephone,
79
+ }
80
+ },
81
+ supplier: {
82
+ identifier: getIdentifierWithPrefix(invoice.supplier.identifier),
83
+ address: {
84
+ streetNameAndNumber: invoice.supplier.address.streetNameAndNumber,
85
+ postalZone: invoice.supplier.address.postalZone,
86
+ city: invoice.supplier.address.city,
87
+ countryCode: invoice.supplier.address.countryCode,
88
+ },
89
+ vatNumber: invoice.supplier.vatNumber,
90
+ name: invoice.supplier.name,
91
+ contact: {
92
+ electronicMail: invoice.supplier.contact.electronicMail,
93
+ name: invoice.supplier.contact.name,
94
+ },
95
+ },
96
+ delivery: delivery,
97
+ // delivery: {
98
+ // actualDeliveryDate: null,
99
+ // address: {
100
+ // streetNameAndNumber: invoice.delivery!.address!.streetNameAndNumber,
101
+ // postalZone: invoice.delivery!.address!.postalZone,
102
+ // city: invoice.delivery!.address!.city,
103
+ // countryCode: invoice.delivery!.address!.countryCode,
104
+ // // countrySubEntity: "",
105
+ // // addressLine2: "",
106
+ // // addressLine3: ""
107
+ // },
108
+ // locationIdentifier: invoice.delivery!.locationIdentifier,
109
+ // partyName: ""
110
+ // // partyName and actualDeliveryData are missing from the form
111
+ // // Description is missing from convertToInvoiceMetadataInput but present in the form
112
+ // },
113
+ invoiceNo: invoice.invoiceNo,
114
+ issueDate: issueDate,
115
+ dueDate: dueDate,
116
+ notes: invoice.notes,
117
+ currencyCode: invoice.currencyCode,
118
+ paymentTerms: {
119
+ note: ""
120
+ },
121
+ // Payment terms doesnt exist in form
122
+ invoiceLines: billingLines,
123
+ // invoiceLines: [{
124
+ // quantity: 1,
125
+ // unitPriceAmount: 123,
126
+ // taxCategoryType: TaxCategoryTypeEnum.Exempt,
127
+ // itemNo: "asd",
128
+ // name: "asdasd",
129
+ // unitOfMeasure: {
130
+ // code: "asd"
131
+ // },
132
+ // taxableAmount: 123,
133
+ // taxAmount: 0,
134
+ // taxPercentage: 0
135
+ // }],
136
+ payableAmount: 0,
137
+ orderReference: {
138
+ documentNo: invoice.orderReference.documentNo,
139
+ },
140
+ }
141
+ };
142
+ // tslint:disable-next-line:no-console
143
+ console.log(resp);
144
+ return resp;
145
+ };
146
+ exports.convertToInvoiceMetadataInput = convertToInvoiceMetadataInput;
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReceiverRequirements = function (recRequirements, key) {
4
+ return recRequirements[key];
5
+ };
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;
14
+ };
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
+ }
21
+ }
22
+ return defaultLabel;
23
+ };
@@ -0,0 +1,7 @@
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
+ export declare const billingLinesFieldsMetadata: (formInstance: FormInstance) => BillingLineMetadata[];
5
+ export declare const calculateTaxableAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null) => number;
6
+ export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
7
+ export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum) => number;
@@ -0,0 +1,63 @@
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 api_1 = require("@unimaze/api-clients/lib/mapi/api");
15
+ exports.billingLinesFieldsMetadata = function (formInstance) {
16
+ var billingLinesMetadata = formInstance.getFieldValue("billingLinesMetadata");
17
+ return billingLinesMetadata.map(function (billingLine) {
18
+ var taxableAmount = exports.calculateTaxableAmount(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
19
+ var taxPercentage = exports.calculateTaxPercentage(billingLine.taxCategoryType);
20
+ var taxAmount = exports.calculateTaxAmount(taxableAmount, taxPercentage);
21
+ var mappedBillingLine = __assign({}, billingLine, { taxableAmount: taxableAmount,
22
+ taxAmount: taxAmount,
23
+ taxPercentage: taxPercentage });
24
+ if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
25
+ delete mappedBillingLine.discountValue;
26
+ }
27
+ return mappedBillingLine;
28
+ });
29
+ };
30
+ exports.calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount) {
31
+ if (!quantity || !unitPriceAmount) {
32
+ return 0;
33
+ }
34
+ if (discountValue) {
35
+ if (discountValue.endsWith("%")) {
36
+ // (quantity * unitPriceAmount) * ((100 - discountValue) / 100)
37
+ return ((quantity * unitPriceAmount) * ((100 - parseFloat(discountValue)) / 100));
38
+ }
39
+ else {
40
+ // (quantity * unitPriceAmount) - discountValue
41
+ return ((quantity * unitPriceAmount) - parseFloat(discountValue));
42
+ }
43
+ }
44
+ else {
45
+ return (quantity * unitPriceAmount);
46
+ }
47
+ };
48
+ exports.calculateTaxAmount = function (taxableAmount, taxPercentage) {
49
+ // taxableAmount * (taxPercentage / 100)
50
+ return (taxableAmount * (taxPercentage / 100));
51
+ };
52
+ exports.calculateTaxPercentage = function (taxCategoryType) {
53
+ // inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
54
+ switch (taxCategoryType) {
55
+ case api_1.TaxCategoryTypeEnum.StandardRated:
56
+ return 24;
57
+ case api_1.TaxCategoryTypeEnum.ReducedRated:
58
+ return 11;
59
+ case api_1.TaxCategoryTypeEnum.ZeroRated:
60
+ case api_1.TaxCategoryTypeEnum.Exempt:
61
+ return 0;
62
+ }
63
+ };
@@ -1,5 +1,2 @@
1
- import { InvoiceMetadataInput, CreditNoteMetadataInput } from "@unimaze/api-clients/lib/mapi";
2
- export declare class Utility {
3
- static convertToInvoiceMetadataInput: (formValues: any) => InvoiceMetadataInput;
4
- static convertToCreditNoteMetadataInput: (formValues: any) => CreditNoteMetadataInput;
5
- }
1
+ export { convertToInvoiceMetadataInput } from "./ConversionUtility";
2
+ export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument } from "./ApiUtility";