@unimaze/billing 0.1.2-rc.10 → 0.1.2-rc.2

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 +3 -11
  2. package/lib/common/components/attachments/Attachment.d.ts +2 -8
  3. package/lib/common/components/attachments/Attachment.js +8 -33
  4. package/lib/common/components/attachments/index.d.ts +2 -9
  5. package/lib/common/components/attachments/index.js +6 -15
  6. package/lib/common/components/base-information/index.d.ts +3 -6
  7. package/lib/common/components/base-information/index.js +81 -100
  8. package/lib/common/components/billing-lines/index.d.ts +23 -9
  9. package/lib/common/components/billing-lines/index.js +38 -116
  10. package/lib/common/components/delivery-location/index.d.ts +2 -5
  11. package/lib/common/components/delivery-location/index.js +11 -43
  12. package/lib/common/components/editable-cell/index.d.ts +1 -1
  13. package/lib/common/components/editable-cell/index.js +10 -76
  14. package/lib/common/components/editable-row/index.d.ts +5 -5
  15. package/lib/common/components/editable-row/index.js +6 -8
  16. package/lib/common/components/index.d.ts +5 -10
  17. package/lib/common/components/index.js +8 -20
  18. package/lib/common/components/issuer/index.d.ts +7 -0
  19. package/lib/common/components/{customer/hardCoddedCustomer.js → issuer/index.js} +8 -5
  20. package/lib/common/components/payer/index.d.ts +3 -0
  21. package/lib/common/components/payer/index.js +50 -0
  22. package/lib/common/components/payment-method/index.d.ts +3 -6
  23. package/lib/common/components/payment-method/index.js +17 -57
  24. package/lib/common/consts/validationRules.d.ts +3 -2
  25. package/lib/common/consts/validationRules.js +7 -0
  26. package/lib/common/enums/index.d.ts +1 -1
  27. package/lib/common/enums/index.js +4 -2
  28. package/lib/common/types/BillingLineMetadataOverride.d.ts +0 -1
  29. package/lib/create-credit-note/index.d.ts +2 -1
  30. package/lib/create-credit-note/index.js +14 -6
  31. package/lib/create-invoice/index.d.ts +2 -1
  32. package/lib/create-invoice/index.js +21 -79
  33. package/lib/example/src/index.d.ts +1 -1
  34. package/lib/index.js +0 -5
  35. package/lib/src/common/components/attachments/Attachment.d.ts +2 -8
  36. package/lib/src/common/components/attachments/index.d.ts +2 -9
  37. package/lib/src/common/components/base-information/index.d.ts +3 -6
  38. package/lib/src/common/components/billing-lines/index.d.ts +23 -9
  39. package/lib/src/common/components/delivery-location/index.d.ts +2 -5
  40. package/lib/src/common/components/editable-cell/index.d.ts +1 -1
  41. package/lib/src/common/components/editable-row/index.d.ts +5 -5
  42. package/lib/src/common/components/issuer/index.d.ts +7 -0
  43. package/lib/src/common/components/payer/index.d.ts +3 -0
  44. package/lib/src/common/components/payment-method/index.d.ts +3 -6
  45. package/lib/src/common/consts/validationRules.d.ts +3 -2
  46. package/lib/src/create-credit-note/index.d.ts +9 -0
  47. package/lib/src/create-invoice/index.d.ts +2 -1
  48. package/lib/src/index.d.ts +4 -0
  49. package/lib/style/index.css +1222 -0
  50. package/lib/utils/ApiUtility.d.ts +1 -8
  51. package/lib/utils/ApiUtility.js +1 -17
  52. package/lib/utils/ConversionUtility.d.ts +4 -5
  53. package/lib/utils/ConversionUtility.js +133 -121
  54. package/lib/utils/index.d.ts +2 -2
  55. package/lib/utils/index.js +2 -2
  56. package/package.json +7 -12
  57. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +0 -6
  58. package/lib/common/components/base-information/ReferenceIdentifiers.js +0 -40
  59. package/lib/common/components/billing-lines/BillingCalculations.d.ts +0 -11
  60. package/lib/common/components/billing-lines/BillingCalculations.js +0 -61
  61. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +0 -10
  62. package/lib/common/components/billing-lines/BillingTaxSummary.js +0 -51
  63. package/lib/common/components/billing-lines/billingLIneFormData.d.ts +0 -7
  64. package/lib/common/components/billing-lines/billingLIneFormData.js +0 -63
  65. package/lib/common/components/customer/hardCoddedCustomer.d.ts +0 -7
  66. package/lib/common/components/customer/index.d.ts +0 -6
  67. package/lib/common/components/customer/index.js +0 -93
  68. package/lib/common/components/form-item/index.d.ts +0 -21
  69. package/lib/common/components/form-item/index.js +0 -27
  70. package/lib/common/components/locale-intl/index.d.ts +0 -10
  71. package/lib/common/components/locale-intl/index.js +0 -45
  72. package/lib/common/components/supplier/index.d.ts +0 -6
  73. package/lib/common/components/supplier/index.js +0 -93
  74. package/lib/common/types/ReceiverRequirements.d.ts +0 -81
  75. package/lib/common/types/ReceiverRequirements.js +0 -379
  76. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +0 -6
  77. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +0 -11
  78. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +0 -10
  79. package/lib/src/common/components/billing-lines/billingLIneFormData.d.ts +0 -7
  80. package/lib/src/common/components/customer/index.d.ts +0 -6
  81. package/lib/src/common/components/form-item/index.d.ts +0 -21
  82. package/lib/src/common/components/index.d.ts +0 -10
  83. package/lib/src/common/components/locale-intl/index.d.ts +0 -10
  84. package/lib/src/common/components/supplier/index.d.ts +0 -6
  85. package/lib/src/common/types/ReceiverRequirements.d.ts +0 -81
  86. package/lib/src/translations/locales.d.ts +0 -74
  87. package/lib/src/utils/ApiUtility.d.ts +0 -21
  88. package/lib/src/utils/BillingLineUtility.d.ts +0 -8
  89. package/lib/src/utils/ConversionUtility.d.ts +0 -5
  90. package/lib/src/utils/RequirementsUtility.d.ts +0 -5
  91. package/lib/src/utils/billingLineFormData.d.ts +0 -7
  92. package/lib/src/utils/index.d.ts +0 -2
  93. package/lib/translations/locales/is.json +0 -70
  94. package/lib/translations/locales.d.ts +0 -74
  95. package/lib/translations/locales.js +0 -10
  96. package/lib/utils/BillingLineUtility.d.ts +0 -8
  97. package/lib/utils/BillingLineUtility.js +0 -66
  98. package/lib/utils/RequirementsUtility.d.ts +0 -5
  99. package/lib/utils/RequirementsUtility.js +0 -23
  100. package/lib/utils/billingLineFormData.d.ts +0 -7
  101. package/lib/utils/billingLineFormData.js +0 -63
@@ -1,5 +0,0 @@
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 };
@@ -1,5 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- export { convertToInvoiceMetadataInput } from "./ConversionUtility";
2
- export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument } from "./ApiUtility";
@@ -1,70 +0,0 @@
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
- }
@@ -1,74 +0,0 @@
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;
@@ -1,10 +0,0 @@
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 };
@@ -1,8 +0,0 @@
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;
@@ -1,66 +0,0 @@
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
- };
@@ -1,5 +0,0 @@
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;
@@ -1,23 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
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;
@@ -1,63 +0,0 @@
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
- };