@unimaze/billing 0.1.2-rc.9 → 0.2.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.
- package/lib/common/components/attachments/Attachment.d.ts +6 -5
- package/lib/common/components/attachments/Attachment.js +75 -18
- package/lib/common/components/attachments/index.d.ts +5 -6
- package/lib/common/components/attachments/index.js +20 -6
- package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +17 -0
- package/lib/common/components/base-information/ReferenceIdentifiers.js +58 -0
- package/lib/common/components/base-information/index.d.ts +6 -3
- package/lib/common/components/base-information/index.js +86 -10
- package/lib/common/components/billing-lines/BillingCalculations.d.ts +11 -0
- package/lib/common/components/billing-lines/BillingCalculations.js +63 -0
- package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
- package/lib/common/components/billing-lines/BillingTaxSummary.js +53 -0
- package/lib/common/components/billing-lines/NewBillingLines.d.ts +10 -0
- package/lib/common/components/billing-lines/NewBillingLines.js +77 -0
- package/lib/common/components/billing-lines/index.d.ts +7 -15
- package/lib/common/components/billing-lines/index.js +177 -62
- package/lib/common/components/customer/hardCoddedCustomer.d.ts +7 -0
- package/lib/common/components/customer/hardCoddedCustomer.js +25 -0
- package/lib/common/components/customer/index.d.ts +5 -6
- package/lib/common/components/customer/index.js +125 -12
- package/lib/common/components/delivery-location/index.d.ts +5 -2
- package/lib/common/components/delivery-location/index.js +69 -8
- package/lib/common/components/editable-cell/index.js +7 -9
- package/lib/common/components/form-item/index.d.ts +12 -7
- package/lib/common/components/form-item/index.js +31 -7
- package/lib/common/components/locale-intl/index.d.ts +10 -0
- package/lib/common/components/locale-intl/index.js +45 -0
- package/lib/common/components/payment-method/index.d.ts +6 -3
- package/lib/common/components/payment-method/index.js +136 -16
- package/lib/common/components/payment-method/paymentMethodForConversion.d.ts +9 -0
- package/lib/common/components/payment-method/paymentMethodForConversion.js +44 -0
- package/lib/common/components/supplier/index.d.ts +9 -2
- package/lib/common/components/supplier/index.js +125 -24
- package/lib/common/consts/formLayout.d.ts +44 -0
- package/lib/common/consts/formLayout.js +35 -0
- package/lib/common/consts/validationRules.js +0 -7
- package/lib/common/types/ReceiverRequirements.d.ts +1 -1
- package/lib/common/types/ReceiverRequirements.js +8 -69
- package/lib/create-credit-note/index.js +3 -5
- package/lib/create-invoice/index.js +107 -43
- package/lib/src/common/components/attachments/Attachment.d.ts +6 -5
- package/lib/src/common/components/attachments/index.d.ts +5 -6
- package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +17 -0
- package/lib/src/common/components/base-information/index.d.ts +6 -3
- package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +11 -0
- package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
- package/lib/src/common/components/billing-lines/NewBillingLines.d.ts +10 -0
- package/lib/src/common/components/billing-lines/index.d.ts +7 -15
- package/lib/src/common/components/customer/index.d.ts +5 -6
- package/lib/src/common/components/delivery-location/index.d.ts +5 -2
- package/lib/src/common/components/form-item/index.d.ts +12 -7
- package/lib/src/common/components/locale-intl/index.d.ts +10 -0
- package/lib/src/common/components/payment-method/index.d.ts +6 -3
- package/lib/src/common/components/payment-method/paymentMethodForConversion.d.ts +9 -0
- package/lib/src/common/components/supplier/index.d.ts +9 -2
- package/lib/src/common/consts/formLayout.d.ts +44 -0
- package/lib/src/common/types/ReceiverRequirements.d.ts +1 -1
- package/lib/src/translations/locales.d.ts +77 -0
- package/lib/src/utils/BillingLineUtility.d.ts +10 -0
- package/lib/src/utils/ConversionUtility.d.ts +4 -4
- package/lib/translations/locales/is.json +73 -0
- package/lib/translations/locales.d.ts +77 -0
- package/lib/translations/locales.js +10 -0
- package/lib/utils/ApiUtility.js +1 -1
- package/lib/utils/BillingLineUtility.d.ts +10 -0
- package/lib/utils/BillingLineUtility.js +90 -0
- package/lib/utils/ConversionUtility.d.ts +4 -4
- package/lib/utils/ConversionUtility.js +39 -55
- package/lib/utils/RequirementsUtility.js +1 -1
- package/package.json +9 -6
- package/lib/common/components/billing-lines/BillingLIneFormData.d.ts +0 -6
- package/lib/common/components/billing-lines/BillingLIneFormData.js +0 -6
- package/lib/src/common/components/billing-lines/BillingLIneFormData.d.ts +0 -6
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
"paymentMethod_rulles_number": "Notið aðeins tölustafi",
|
|
51
|
+
"supplier_title": "Birgi",
|
|
52
|
+
"supplier_name": "Nafn birgja",
|
|
53
|
+
"supplier_identifier": "Kenni",
|
|
54
|
+
"supplier_vatNumber": "VSK nr.",
|
|
55
|
+
"supplier_address_streetNameAndNumber": "Heimilisfang",
|
|
56
|
+
"supplier_address_zip_postalCode": "Póstnúmer",
|
|
57
|
+
"supplier_address_city": "Borg",
|
|
58
|
+
"supplier_address_countryCode": "Landsnúmer",
|
|
59
|
+
"supplier_contact_email": "Netfang",
|
|
60
|
+
"supplier_contact_name": "Nafn tengiliðs",
|
|
61
|
+
"supplier_notValidEmail": "Þetta er ekki gilt netfang",
|
|
62
|
+
"customer_title": "Viðskiptavinur",
|
|
63
|
+
"customer_name": "Nafn viðskiptavinar",
|
|
64
|
+
"customer_identifier": "Kennitala",
|
|
65
|
+
"customer_address_streetNameAndNumber": "Heimilisfang",
|
|
66
|
+
"customer_address_zip_postalCode": "Póstnúmer",
|
|
67
|
+
"customer_address_city": "Borg",
|
|
68
|
+
"customer_address_countryCode": "Landsnúmer",
|
|
69
|
+
"customer_contact_email": "Netfang",
|
|
70
|
+
"customer_contact_name": "Nafn tengiliðs",
|
|
71
|
+
"referenceIdentifiers_labels_addButton": "Bætið við tilvísunarnúmeri",
|
|
72
|
+
"referenceIdentifiers_labels_referenceIdentifier": "Tilvísunarnúmer"
|
|
73
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
"paymentMethod_rulles_number": string;
|
|
53
|
+
"supplier_title": string;
|
|
54
|
+
"supplier_name": string;
|
|
55
|
+
"supplier_identifier": string;
|
|
56
|
+
"supplier_vatNumber": string;
|
|
57
|
+
"supplier_address_streetNameAndNumber": string;
|
|
58
|
+
"supplier_address_zip_postalCode": string;
|
|
59
|
+
"supplier_address_city": string;
|
|
60
|
+
"supplier_address_countryCode": string;
|
|
61
|
+
"supplier_contact_email": string;
|
|
62
|
+
"supplier_contact_name": string;
|
|
63
|
+
"supplier_notValidEmail": string;
|
|
64
|
+
"customer_title": string;
|
|
65
|
+
"customer_name": string;
|
|
66
|
+
"customer_identifier": string;
|
|
67
|
+
"customer_address_streetNameAndNumber": string;
|
|
68
|
+
"customer_address_zip_postalCode": string;
|
|
69
|
+
"customer_address_city": string;
|
|
70
|
+
"customer_address_countryCode": string;
|
|
71
|
+
"customer_contact_email": string;
|
|
72
|
+
"customer_contact_name": string;
|
|
73
|
+
"referenceIdentifiers_labels_addButton": string;
|
|
74
|
+
"referenceIdentifiers_labels_referenceIdentifier": string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
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 };
|
package/lib/utils/ApiUtility.js
CHANGED
|
@@ -47,7 +47,7 @@ var createOptions = function (apiKey, callName, language) {
|
|
|
47
47
|
return __assign({ headers: __assign({ "Accept-Language": language ? language : "en" }, (apiKey && { Authorization: "Bearer " + window.btoa(apiKey) })) }, (callName && { cancelToken: getCancelToken(callName) }));
|
|
48
48
|
};
|
|
49
49
|
var createOptionsData = function (data, apiKey, callName, language) {
|
|
50
|
-
return __assign({ headers: __assign({ "Accept-Language": language ? language : "en" }, (apiKey && { Authorization: "Bearer
|
|
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
51
|
};
|
|
52
52
|
var getCancelToken = function (callName) {
|
|
53
53
|
var cancelTokenSource = window[callName];
|
|
@@ -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) => string;
|
|
10
|
+
export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "notes" | "referenceIdentifiers" | "unitOfMeasure" | "itemNo" | "quantity" | "unitPriceAmount" | "taxCategoryType" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "accountingCost" | "billingPeriod" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "orderLineReference") => React.ReactChild;
|
|
@@ -0,0 +1,90 @@
|
|
|
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_1 = require("@unimaze/api-clients/lib/mapi/api");
|
|
18
|
+
var react_1 = __importDefault(require("react"));
|
|
19
|
+
var antd_1 = require("antd");
|
|
20
|
+
var models_1 = require("@unimaze/api-clients/lib/mapi/models");
|
|
21
|
+
exports.billingLinesFieldsMetadata = function (formInstance) {
|
|
22
|
+
var billingLinesMetadata = formInstance.getFieldValue("billingLinesMetadata");
|
|
23
|
+
return billingLinesMetadata.map(function (billingLine) {
|
|
24
|
+
var taxableAmount = exports.calculateTaxableAmount(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
|
|
25
|
+
var taxPercentage = exports.calculateTaxPercentage(billingLine.taxCategoryType);
|
|
26
|
+
var taxAmount = exports.calculateTaxAmount(taxableAmount, taxPercentage);
|
|
27
|
+
var mappedBillingLine = __assign({}, billingLine, { taxableAmount: taxableAmount,
|
|
28
|
+
taxAmount: taxAmount,
|
|
29
|
+
taxPercentage: taxPercentage });
|
|
30
|
+
if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
|
|
31
|
+
delete mappedBillingLine.discountValue;
|
|
32
|
+
}
|
|
33
|
+
return mappedBillingLine;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount) {
|
|
37
|
+
if (!quantity || !unitPriceAmount) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
if (discountValue) {
|
|
41
|
+
if (discountValue.endsWith("%")) {
|
|
42
|
+
// (quantity * unitPriceAmount) * ((100 - discountValue) / 100)
|
|
43
|
+
return ((quantity * unitPriceAmount) * ((100 - parseFloat(discountValue)) / 100));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// (quantity * unitPriceAmount) - discountValue
|
|
47
|
+
return ((quantity * unitPriceAmount) - parseFloat(discountValue));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return (quantity * unitPriceAmount);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.calculateTaxAmount = function (taxableAmount, taxPercentage) {
|
|
55
|
+
// taxableAmount * (taxPercentage / 100)
|
|
56
|
+
return (taxableAmount * (taxPercentage / 100));
|
|
57
|
+
};
|
|
58
|
+
exports.calculateTaxPercentage = function (taxCategoryType) {
|
|
59
|
+
// inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
|
|
60
|
+
switch (taxCategoryType) {
|
|
61
|
+
case api_1.TaxCategoryTypeEnum.StandardRated:
|
|
62
|
+
return 24;
|
|
63
|
+
case api_1.TaxCategoryTypeEnum.ReducedRated:
|
|
64
|
+
return 11;
|
|
65
|
+
case api_1.TaxCategoryTypeEnum.ZeroRated:
|
|
66
|
+
case api_1.TaxCategoryTypeEnum.Exempt:
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.generateTaxCategoryLabel = function (taxCategoryType) {
|
|
71
|
+
return exports.calculateTaxPercentage(taxCategoryType) + "% (" + taxCategoryType + ")";
|
|
72
|
+
};
|
|
73
|
+
exports.getCorrectInputNode = function (dataIdx) {
|
|
74
|
+
switch (dataIdx) {
|
|
75
|
+
case "quantity":
|
|
76
|
+
case "unitPriceAmount":
|
|
77
|
+
return react_1.default.createElement(antd_1.InputNumber, { step: 1 });
|
|
78
|
+
case "unitOfMeasure":
|
|
79
|
+
return (react_1.default.createElement(antd_1.Select, null, Object.keys(models_1.UnitOfMeasureMetadataUnitEnum).map(function (unitOfMeasure) {
|
|
80
|
+
if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
|
|
81
|
+
return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, unitOfMeasure));
|
|
82
|
+
})));
|
|
83
|
+
case "taxCategoryType":
|
|
84
|
+
return (react_1.default.createElement(antd_1.Select, null, Object.keys(models_1.BillingLineMetadataTaxCategoryTypeEnum).map(function (taxCategoryType) {
|
|
85
|
+
return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
|
|
86
|
+
})));
|
|
87
|
+
default:
|
|
88
|
+
return react_1.default.createElement(antd_1.Input, null);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { InvoiceMetadataInput } from "@unimaze/api-clients/lib/mapi";
|
|
1
|
+
import { BillingLineMetadata, InvoiceMetadataInput } from "@unimaze/api-clients/lib/mapi";
|
|
2
2
|
import { Store } from "antd/es/form/interface";
|
|
3
3
|
import { ProfileOutput } from "@unimaze/api-clients/lib/wapi2";
|
|
4
|
-
import {
|
|
5
|
-
declare const convertToInvoiceMetadataInput: (formValues: Store, billingLines:
|
|
6
|
-
export {
|
|
4
|
+
import { PaymentMeansMetadata } from "@unimaze/api-clients/lib/mapi/api";
|
|
5
|
+
declare const convertToInvoiceMetadataInput: (formValues: Store, billingLines: BillingLineMetadata[], paymentMethod: PaymentMeansMetadata, customer?: ProfileOutput | undefined) => InvoiceMetadataInput;
|
|
6
|
+
export { convertToInvoiceMetadataInput };
|
|
@@ -11,7 +11,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var mapi_1 = require("@unimaze/api-clients/lib/mapi");
|
|
15
14
|
var removeEmpty = function (obj) {
|
|
16
15
|
return Object.keys(obj)
|
|
17
16
|
.filter(function (k) { return obj[k] != null; }) // Remove undef. and null.
|
|
@@ -33,11 +32,18 @@ var isEmpty = function (map) {
|
|
|
33
32
|
}
|
|
34
33
|
return true;
|
|
35
34
|
};
|
|
36
|
-
var
|
|
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, paymentMethod, customer) {
|
|
37
44
|
var issueDate = convertDates(formValues.invoice.issueDate);
|
|
38
45
|
var dueDate = convertDates(formValues.invoice.dueDate);
|
|
39
|
-
|
|
40
|
-
console.log(issueDate);
|
|
46
|
+
var referenceIdentifiersArray = formValues.invoice.referenceIdentifiers;
|
|
41
47
|
var cleanedFormValues = removeEmpty(formValues);
|
|
42
48
|
var invoice = cleanedFormValues.invoice;
|
|
43
49
|
// fix delivery
|
|
@@ -46,7 +52,18 @@ var convertToInvoiceMetadataInput = function (formValues, billingLines, customer
|
|
|
46
52
|
if (isEmpty(delivery.address)) {
|
|
47
53
|
delete delivery.address;
|
|
48
54
|
}
|
|
55
|
+
if (Object.keys(delivery).length === 0 && delivery.constructor === Object) {
|
|
56
|
+
delivery = undefined;
|
|
57
|
+
}
|
|
49
58
|
}
|
|
59
|
+
var referenceIdentifiers = referenceIdentifiersArray
|
|
60
|
+
? referenceIdentifiersArray.length === 0
|
|
61
|
+
? null
|
|
62
|
+
: referenceIdentifiersArray.map(function (referenceId) { return ({
|
|
63
|
+
code: referenceId.code.value,
|
|
64
|
+
value: referenceId.value
|
|
65
|
+
}); })
|
|
66
|
+
: null;
|
|
50
67
|
var resp = {
|
|
51
68
|
messageHandling: {
|
|
52
69
|
receiverIdentifier: customer.participantLegalIsoIdentifier,
|
|
@@ -55,23 +72,21 @@ var convertToInvoiceMetadataInput = function (formValues, billingLines, customer
|
|
|
55
72
|
},
|
|
56
73
|
invoice: {
|
|
57
74
|
customer: {
|
|
58
|
-
identifier: customer.
|
|
75
|
+
identifier: getIdentifierWithPrefix(invoice.customer.identifier),
|
|
59
76
|
address: {
|
|
60
|
-
streetNameAndNumber: customer.
|
|
61
|
-
postalZone: customer.
|
|
62
|
-
city: customer.
|
|
63
|
-
countryCode: customer.
|
|
77
|
+
streetNameAndNumber: invoice.customer.address.streetNameAndNumber,
|
|
78
|
+
postalZone: invoice.customer.address.postalZone,
|
|
79
|
+
city: invoice.customer.address.city,
|
|
80
|
+
countryCode: invoice.customer.address.countryCode
|
|
64
81
|
},
|
|
65
|
-
name: customer.name,
|
|
82
|
+
name: invoice.customer.name,
|
|
66
83
|
contact: {
|
|
67
|
-
electronicMail: customer.
|
|
68
|
-
telephone: customer.
|
|
69
|
-
// fax: "",
|
|
70
|
-
// name: "",
|
|
84
|
+
electronicMail: invoice.customer.contact.electronicMail,
|
|
85
|
+
telephone: invoice.customer.contact.telephone,
|
|
71
86
|
}
|
|
72
87
|
},
|
|
73
88
|
supplier: {
|
|
74
|
-
identifier: invoice.supplier.identifier,
|
|
89
|
+
identifier: getIdentifierWithPrefix(invoice.supplier.identifier),
|
|
75
90
|
address: {
|
|
76
91
|
streetNameAndNumber: invoice.supplier.address.streetNameAndNumber,
|
|
77
92
|
postalZone: invoice.supplier.address.postalZone,
|
|
@@ -86,53 +101,22 @@ var convertToInvoiceMetadataInput = function (formValues, billingLines, customer
|
|
|
86
101
|
},
|
|
87
102
|
},
|
|
88
103
|
delivery: delivery,
|
|
89
|
-
// delivery: {
|
|
90
|
-
// actualDeliveryDate: null,
|
|
91
|
-
// address: {
|
|
92
|
-
// streetNameAndNumber: invoice.delivery!.address!.streetNameAndNumber,
|
|
93
|
-
// postalZone: invoice.delivery!.address!.postalZone,
|
|
94
|
-
// city: invoice.delivery!.address!.city,
|
|
95
|
-
// countryCode: invoice.delivery!.address!.countryCode,
|
|
96
|
-
// // countrySubEntity: "",
|
|
97
|
-
// // addressLine2: "",
|
|
98
|
-
// // addressLine3: ""
|
|
99
|
-
// },
|
|
100
|
-
// locationIdentifier: invoice.delivery!.locationIdentifier,
|
|
101
|
-
// partyName: ""
|
|
102
|
-
// // partyName and actualDeliveryData are missing from the form
|
|
103
|
-
// // Description is missing from convertToInvoiceMetadataInput but present in the form
|
|
104
|
-
// },
|
|
105
104
|
invoiceNo: invoice.invoiceNo,
|
|
106
105
|
issueDate: issueDate,
|
|
107
106
|
dueDate: dueDate,
|
|
108
107
|
notes: invoice.notes,
|
|
109
108
|
currencyCode: invoice.currencyCode,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
quantity: 1,
|
|
117
|
-
unitPriceAmount: 123,
|
|
118
|
-
taxCategoryType: mapi_1.TaxCategoryTypeEnum.Exempt,
|
|
119
|
-
itemNo: "asd",
|
|
120
|
-
name: "asdasd",
|
|
121
|
-
unitOfMeasure: {
|
|
122
|
-
code: "asd"
|
|
123
|
-
},
|
|
124
|
-
taxableAmount: 123,
|
|
125
|
-
taxAmount: 0,
|
|
126
|
-
taxPercentage: 0
|
|
127
|
-
}],
|
|
128
|
-
payableAmount: 0,
|
|
129
|
-
orderReference: {
|
|
130
|
-
documentNo: invoice.orderReference.documentNo,
|
|
131
|
-
},
|
|
109
|
+
invoiceLines: billingLines,
|
|
110
|
+
// invoiceLines: invoice.invoiceLines, // FOR NEW BILLING LINES
|
|
111
|
+
// payableAmount: 0, // Calculated? either doesnt exist or part of the Billing/Invoice Lines
|
|
112
|
+
buyerReference: invoice.buyerReference,
|
|
113
|
+
paymentMeans: paymentMethod,
|
|
114
|
+
referenceIdentifiers: referenceIdentifiers,
|
|
132
115
|
}
|
|
133
116
|
};
|
|
134
|
-
|
|
135
|
-
|
|
117
|
+
if (resp.invoice && resp.invoice.delivery && resp.invoice.delivery === {}) {
|
|
118
|
+
delete resp.invoice.delivery;
|
|
119
|
+
}
|
|
136
120
|
return resp;
|
|
137
121
|
};
|
|
138
122
|
exports.convertToInvoiceMetadataInput = convertToInvoiceMetadataInput;
|
|
@@ -15,7 +15,7 @@ exports.getReceiverRequirementsIsRequired = function (recRequirements, key, defa
|
|
|
15
15
|
exports.getReceiverRequirementsLabelWithDefault = function (recRequirements, key, defaultLabel) {
|
|
16
16
|
if (recRequirements.hasOwnProperty(key)) {
|
|
17
17
|
var recRequirement = recRequirements[key];
|
|
18
|
-
if (recRequirement) {
|
|
18
|
+
if (recRequirement && recRequirement.label) {
|
|
19
19
|
return recRequirement.label;
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unimaze/billing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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": "
|
|
12
|
+
"@unimaze/api-clients": "1.2.0",
|
|
13
13
|
"react-hot-loader": "^4.12.20",
|
|
14
14
|
"uuid": "latest"
|
|
15
15
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/lodash": "^4.14.149",
|
|
19
19
|
"@types/react": "16.9.34",
|
|
20
20
|
"@types/react-dom": "16.9.7",
|
|
21
|
-
"@types/react-intl": "
|
|
21
|
+
"@types/react-intl": "2.3.18",
|
|
22
22
|
"@types/uuid": "latest",
|
|
23
23
|
"antd": "4.3.3",
|
|
24
24
|
"awesome-typescript-loader": "^5.2.1",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"react": "16.13.1",
|
|
38
38
|
"react-dom": "16.13.1",
|
|
39
39
|
"react-intl": "^2.9.0",
|
|
40
|
-
"react-intl.macro": "^0.3.7",
|
|
41
40
|
"rimraf": "^3.0.2",
|
|
42
41
|
"style-loader": "^1.1.3",
|
|
43
42
|
"tslint": "^6.1.1",
|
|
@@ -53,8 +52,7 @@
|
|
|
53
52
|
"axios": "^0.19.2",
|
|
54
53
|
"react": "16.13.1",
|
|
55
54
|
"react-dom": "16.13.1",
|
|
56
|
-
"react-intl": "^2.9.0"
|
|
57
|
-
"react-intl.macro": "^0.3.7"
|
|
55
|
+
"react-intl": "^2.9.0"
|
|
58
56
|
},
|
|
59
57
|
"resolutions": {
|
|
60
58
|
"@types/react": "16.9.34",
|
|
@@ -85,6 +83,11 @@
|
|
|
85
83
|
"examples:build": "webpack -d --mode development --config example/webpack.config.js",
|
|
86
84
|
"start": "yarn run examples"
|
|
87
85
|
},
|
|
86
|
+
"babelMacros": {
|
|
87
|
+
"react-intl": {
|
|
88
|
+
"pure": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
88
91
|
"author": "",
|
|
89
92
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
90
93
|
"repository": {
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { BillingLineMetadata } from '@unimaze/api-clients/lib/mapi';
|
|
2
|
-
import { FormInstance } from "antd/es/form";
|
|
3
|
-
export interface IBillingLinesMetadata {
|
|
4
|
-
billingLineMetadata: BillingLineMetadata[];
|
|
5
|
-
}
|
|
6
|
-
export declare const BillingLinesFieldsMetadata: (formInstance: FormInstance) => IBillingLinesMetadata;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { BillingLineMetadata } from '@unimaze/api-clients/lib/mapi';
|
|
2
|
-
import { FormInstance } from "antd/es/form";
|
|
3
|
-
export interface IBillingLinesMetadata {
|
|
4
|
-
billingLineMetadata: Array<BillingLineMetadata>;
|
|
5
|
-
}
|
|
6
|
-
export declare const BillingLinesFieldsMetadata: (formInstance: FormInstance) => IBillingLinesMetadata;
|