@unimaze/billing 0.1.2-rc.8 → 0.2.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 (85) hide show
  1. package/lib/common/components/attachments/Attachment.d.ts +7 -3
  2. package/lib/common/components/attachments/Attachment.js +69 -15
  3. package/lib/common/components/attachments/index.d.ts +5 -2
  4. package/lib/common/components/attachments/index.js +18 -5
  5. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +17 -0
  6. package/lib/common/components/base-information/ReferenceIdentifiers.js +54 -0
  7. package/lib/common/components/base-information/index.d.ts +6 -3
  8. package/lib/common/components/base-information/index.js +131 -80
  9. package/lib/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  10. package/lib/common/components/billing-lines/BillingCalculations.js +63 -0
  11. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  12. package/lib/common/components/billing-lines/BillingTaxSummary.js +53 -0
  13. package/lib/common/components/billing-lines/NewBillingLines.d.ts +10 -0
  14. package/lib/common/components/billing-lines/NewBillingLines.js +77 -0
  15. package/lib/common/components/billing-lines/index.d.ts +7 -15
  16. package/lib/common/components/billing-lines/index.js +173 -62
  17. package/lib/{src/common/components/issuer/index.d.ts → common/components/customer/hardCoddedCustomer.d.ts} +2 -2
  18. package/lib/common/components/{issuer/index.js → customer/hardCoddedCustomer.js} +5 -8
  19. package/lib/common/components/customer/index.d.ts +5 -6
  20. package/lib/common/components/customer/index.js +101 -12
  21. package/lib/common/components/delivery-location/index.d.ts +5 -2
  22. package/lib/common/components/delivery-location/index.js +65 -10
  23. package/lib/common/components/editable-cell/index.js +7 -9
  24. package/lib/common/components/form-item/index.d.ts +23 -0
  25. package/lib/common/components/form-item/index.js +44 -0
  26. package/lib/common/components/locale-intl/index.d.ts +10 -0
  27. package/lib/common/components/locale-intl/index.js +45 -0
  28. package/lib/common/components/payment-method/index.d.ts +6 -3
  29. package/lib/common/components/payment-method/index.js +107 -15
  30. package/lib/common/components/payment-method/paymentMethodForConversion.d.ts +9 -0
  31. package/lib/common/components/payment-method/paymentMethodForConversion.js +44 -0
  32. package/lib/common/components/supplier/index.d.ts +5 -2
  33. package/lib/common/components/supplier/index.js +108 -28
  34. package/lib/common/consts/formLayout.d.ts +44 -0
  35. package/lib/common/consts/formLayout.js +35 -0
  36. package/lib/common/consts/validationRules.js +0 -7
  37. package/lib/common/types/ReceiverRequirements.d.ts +71 -72
  38. package/lib/common/types/ReceiverRequirements.js +64 -81
  39. package/lib/create-credit-note/index.js +2 -4
  40. package/lib/create-invoice/index.js +131 -26
  41. package/lib/src/common/components/attachments/Attachment.d.ts +7 -3
  42. package/lib/src/common/components/attachments/index.d.ts +5 -2
  43. package/lib/src/common/components/base-information/ReferenceIdentifiers.d.ts +17 -0
  44. package/lib/src/common/components/base-information/index.d.ts +6 -3
  45. package/lib/src/common/components/billing-lines/BillingCalculations.d.ts +11 -0
  46. package/lib/src/common/components/billing-lines/BillingTaxSummary.d.ts +10 -0
  47. package/lib/src/common/components/billing-lines/NewBillingLines.d.ts +10 -0
  48. package/lib/src/common/components/billing-lines/index.d.ts +7 -15
  49. package/lib/src/common/components/customer/index.d.ts +5 -6
  50. package/lib/src/common/components/delivery-location/index.d.ts +5 -2
  51. package/lib/src/common/components/form-item/index.d.ts +23 -0
  52. package/lib/src/common/components/locale-intl/index.d.ts +10 -0
  53. package/lib/src/common/components/payment-method/index.d.ts +6 -3
  54. package/lib/src/common/components/payment-method/paymentMethodForConversion.d.ts +9 -0
  55. package/lib/src/common/components/supplier/index.d.ts +5 -2
  56. package/lib/src/common/consts/formLayout.d.ts +44 -0
  57. package/lib/src/common/types/ReceiverRequirements.d.ts +71 -72
  58. package/lib/src/translations/locales.d.ts +75 -0
  59. package/lib/src/utils/ApiUtility.d.ts +8 -1
  60. package/lib/src/utils/BillingLineUtility.d.ts +10 -0
  61. package/lib/src/utils/ConversionUtility.d.ts +4 -3
  62. package/lib/src/utils/RequirementsUtility.d.ts +3 -1
  63. package/lib/src/utils/index.d.ts +1 -1
  64. package/lib/translations/locales/is.json +71 -0
  65. package/lib/translations/locales.d.ts +75 -0
  66. package/lib/translations/locales.js +10 -0
  67. package/lib/utils/ApiUtility.d.ts +8 -1
  68. package/lib/utils/ApiUtility.js +17 -1
  69. package/lib/utils/BillingLineUtility.d.ts +10 -0
  70. package/lib/utils/BillingLineUtility.js +90 -0
  71. package/lib/utils/ConversionUtility.d.ts +4 -3
  72. package/lib/utils/ConversionUtility.js +98 -66
  73. package/lib/utils/RequirementsUtility.d.ts +3 -1
  74. package/lib/utils/RequirementsUtility.js +15 -5
  75. package/lib/utils/index.d.ts +1 -1
  76. package/lib/utils/index.js +1 -0
  77. package/package.json +8 -5
  78. package/lib/common/components/component-container/style/index.d.ts +0 -1
  79. package/lib/common/components/component-container/style/index.js +0 -3
  80. package/lib/common/components/issuer/index.d.ts +0 -7
  81. package/lib/common/components/payer/index.d.ts +0 -3
  82. package/lib/common/components/payer/index.js +0 -51
  83. package/lib/src/common/components/payer/index.d.ts +0 -3
  84. package/lib/style/index.d.ts +0 -1
  85. package/lib/style/index.js +0 -3
@@ -0,0 +1,75 @@
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
+ };
74
+ };
75
+ 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 };
@@ -10,5 +10,12 @@ interface CreateSubmitInvoice {
10
10
  services?: string[];
11
11
  invoiceMetadataInput?: InvoiceMetadataInput;
12
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>;
13
20
  declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, apiKey?: string | undefined, callName?: string | undefined, language?: LanguageProp) => AxiosPromise<mapi.MessageOutput>;
14
- export { submitInvoice, CreateSubmitInvoice };
21
+ export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument };
@@ -24,6 +24,19 @@ var initialiseTransactionApi = function (mapiBaseUrl) {
24
24
  var initiatedConfig = new mapi_1.Configuration(apiConfig);
25
25
  return new api_clients_1.mapi.TransactionApi(initiatedConfig);
26
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;
27
40
  var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, apiKey, callName, language) {
28
41
  var transactionApi = initialiseTransactionApi(mapiBaseUrl);
29
42
  var messageId = createSubmitInvoice.messageId, more = createSubmitInvoice.more, conversationIdentifier = createSubmitInvoice.conversationIdentifier, processingMode = createSubmitInvoice.processingMode, services = createSubmitInvoice.services, invoiceMetadataInput = createSubmitInvoice.invoiceMetadataInput;
@@ -31,7 +44,10 @@ var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, apiKey, callName
31
44
  };
32
45
  exports.submitInvoice = submitInvoice;
33
46
  var createOptions = function (apiKey, callName, language) {
34
- return __assign({ headers: __assign({ "Accept-Language": language ? language : "en" }, (apiKey && { Authorization: "Bearer apikey-" + window.btoa(apiKey) })) }, (callName && { cancelToken: getCancelToken(callName) }));
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 });
35
51
  };
36
52
  var getCancelToken = function (callName) {
37
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,5 +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
- declare const convertToInvoiceMetadataInput: (formValues: Store, customer: ProfileOutput) => InvoiceMetadataInput;
5
- export { /*convertToCreditNoteMetadataInput,*/ convertToInvoiceMetadataInput };
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 };
@@ -1,90 +1,122 @@
1
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
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var convertToInvoiceMetadataInput = function (formValues, customer) {
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, paymentMethod, customer) {
44
+ var issueDate = convertDates(formValues.invoice.issueDate);
45
+ var dueDate = convertDates(formValues.invoice.dueDate);
46
+ var referenceIdentifiersArray = formValues.invoice.referenceIdentifiers;
47
+ var cleanedFormValues = removeEmpty(formValues);
48
+ var invoice = cleanedFormValues.invoice;
49
+ // fix delivery
50
+ var delivery = invoice.delivery;
51
+ if (delivery) {
52
+ if (isEmpty(delivery.address)) {
53
+ delete delivery.address;
54
+ }
55
+ if (Object.keys(delivery).length === 0 && delivery.constructor === Object) {
56
+ delivery = undefined;
57
+ }
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;
4
67
  var resp = {
5
68
  messageHandling: {
6
- receiverIdentifier: formValues.invoice.supplier.identifier,
7
- fallbackEmailAddress: formValues.invoice.supplier.contact.email,
8
- fallbackContactName: formValues.invoice.supplier.contact.name,
69
+ receiverIdentifier: customer.participantLegalIsoIdentifier,
70
+ fallbackEmailAddress: customer.email,
71
+ fallbackContactName: customer.name,
9
72
  },
10
73
  invoice: {
11
74
  customer: {
12
75
  identifier: customer.participantLegalIsoIdentifier,
13
76
  address: {
14
- streetNameAndNumber: customer.participantLegalAddressStreet,
15
- postalZone: customer.participantLegalAddressPostalCode,
16
- city: customer.participantLegalAddressCity,
17
- countryCode: customer.country,
18
- countrySubEntity: "",
19
- addressLine2: "",
20
- addressLine3: ""
77
+ streetNameAndNumber: invoice.customer.address.streetNameAndNumber,
78
+ postalZone: invoice.customer.address.postalZone,
79
+ city: invoice.customer.address.city,
80
+ countryCode: invoice.customer.address.countryCode
21
81
  },
22
- name: customer.name,
82
+ name: invoice.customer.name,
23
83
  contact: {
24
- electronicMail: customer.email,
25
- fax: "",
26
- name: "",
27
- telephone: customer.phoneNumber
84
+ electronicMail: invoice.customer.contact.electronicMail,
85
+ telephone: invoice.customer.contact.telephone,
28
86
  }
29
87
  },
30
- // Supplier is pre filled, doesnt exist in the form || will be passed to already filled up form
31
88
  supplier: {
32
- identifier: formValues.invoice.supplier.identifier,
89
+ identifier: getIdentifierWithPrefix(invoice.supplier.identifier),
33
90
  address: {
34
- streetNameAndNumber: formValues.invoice.supplier.address.address,
35
- postalZone: formValues.invoice.supplier.address.zip,
36
- city: formValues.invoice.supplier.address.city,
37
- countryCode: formValues.invoice.supplier.address.country,
38
- countrySubEntity: "",
39
- addressLine2: "",
40
- addressLine3: ""
41
- // last 3 fileds in address are missing in form
91
+ streetNameAndNumber: invoice.supplier.address.streetNameAndNumber,
92
+ postalZone: invoice.supplier.address.postalZone,
93
+ city: invoice.supplier.address.city,
94
+ countryCode: invoice.supplier.address.countryCode,
42
95
  },
43
- vatNumber: "",
44
- name: formValues.invoice.supplier.name,
96
+ vatNumber: invoice.supplier.vatNumber,
97
+ name: invoice.supplier.name,
45
98
  contact: {
46
- electronicMail: formValues.invoice.supplier.contact.email,
47
- fax: "",
48
- name: formValues.invoice.supplier.contact.name,
49
- telephone: ""
50
- // fax, telephone do not exist in form
99
+ electronicMail: invoice.supplier.contact.electronicMail,
100
+ name: invoice.supplier.contact.name,
51
101
  },
52
102
  },
53
- delivery: {
54
- actualDeliveryDate: null,
55
- address: {
56
- streetNameAndNumber: formValues.invoice.delivery.address.address,
57
- postalZone: "",
58
- city: formValues.invoice.delivery.address.city,
59
- countryCode: "",
60
- countrySubEntity: "",
61
- addressLine2: "",
62
- addressLine3: ""
63
- // Country code, postalZone, country sub entry, address2 and 3 missing from the form
64
- },
65
- locationIdentifier: formValues.invoice.delivery.locationIdentifier,
66
- partyName: ""
67
- // partyName and actualDeliveryData are missing from the form
68
- // Description is missing from convertToInvoiceMetadataInput but present in the form
69
- },
70
- issueDate: formValues.invoice.issueDate,
71
- dueDate: null,
72
- invoiceNo: formValues.invoice.invoiceNo,
73
- paymentTerms: {
74
- note: ""
75
- },
76
- // Payment terms doesnt exist in form
77
- currencyCode: formValues.invoice.currency,
78
- invoiceLines: [],
79
- notes: formValues.invoice.notes,
80
- payableAmount: 0,
81
- orderReference: {
82
- documentNo: "",
83
- },
103
+ delivery: delivery,
104
+ invoiceNo: invoice.invoiceNo,
105
+ issueDate: issueDate,
106
+ dueDate: dueDate,
107
+ notes: invoice.notes,
108
+ currencyCode: invoice.currencyCode,
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,
84
115
  }
85
116
  };
86
- // tslint:disable-next-line:no-console
87
- console.log(resp);
117
+ if (resp.invoice && resp.invoice.delivery && resp.invoice.delivery === {}) {
118
+ delete resp.invoice.delivery;
119
+ }
88
120
  return resp;
89
121
  };
90
122
  exports.convertToInvoiceMetadataInput = convertToInvoiceMetadataInput;
@@ -1,3 +1,5 @@
1
+ import React from 'react';
1
2
  import { AvailableFields, FieldRequirement, ReceiverRequirements } from "../common/types/ReceiverRequirements";
2
3
  export declare const getReceiverRequirements: (recRequirements: ReceiverRequirements, key: AvailableFields) => FieldRequirement;
3
- export declare const getReceiverRequirementsLabelWithDefault: (recRequirements: ReceiverRequirements, key: AvailableFields, defaultLabel: string) => string;
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;
@@ -3,11 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getReceiverRequirements = function (recRequirements, key) {
4
4
  return recRequirements[key];
5
5
  };
6
- exports.getReceiverRequirementsLabelWithDefault = function (recRequirements, key, defaultLabel) {
7
- if (recRequirements[key].label) {
8
- return recRequirements[key].label;
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
+ }
9
12
  }
10
- else {
11
- return defaultLabel;
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
+ }
12
21
  }
22
+ return defaultLabel;
13
23
  };
@@ -1,2 +1,2 @@
1
1
  export { convertToInvoiceMetadataInput } from "./ConversionUtility";
2
- export { submitInvoice, CreateSubmitInvoice } from "./ApiUtility";
2
+ export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument } from "./ApiUtility";
@@ -4,3 +4,4 @@ var ConversionUtility_1 = require("./ConversionUtility");
4
4
  exports.convertToInvoiceMetadataInput = ConversionUtility_1.convertToInvoiceMetadataInput; /*, convertToCreditNoteMetadataInput*/
5
5
  var ApiUtility_1 = require("./ApiUtility");
6
6
  exports.submitInvoice = ApiUtility_1.submitInvoice;
7
+ exports.submitDocument = ApiUtility_1.submitDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.1.2-rc.8",
3
+ "version": "0.2.0-rc.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -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": "^3.0.0",
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 +0,0 @@
1
- import "./index.css";
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./index.css");
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import { wapi2 } from "@unimaze/api-clients";
3
- interface Props {
4
- issuer: wapi2.ProfileOutput;
5
- }
6
- declare const Issuer: React.FC<Props>;
7
- export default Issuer;
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const Payer: React.FC;
3
- export default Payer;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __importStar = (this && this.__importStar) || function (mod) {
3
- if (mod && mod.__esModule) return mod;
4
- var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
7
- return result;
8
- };
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- var React = __importStar(require("react"));
14
- var component_container_1 = __importDefault(require("../component-container"));
15
- var antd_1 = require("antd");
16
- var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
17
- var Payer = function () {
18
- return (React.createElement(component_container_1.default, { title: "Invoice issuer" },
19
- React.createElement(antd_1.Form.Item, { label: ReceiverRequirements_1.getReceiverRequirementsLabelWithDefault(ReceiverRequirements_1.receiverRequirementsObject, ReceiverRequirements_1.AvailableFields["payer.name"], "Name/identifier"), style: { marginBottom: 0 } },
20
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "50%" }, name: ["invoice", "customer", "name"], rules: [
21
- {
22
- required: ReceiverRequirements_1.getReceiverRequirements(ReceiverRequirements_1.receiverRequirementsObject, ReceiverRequirements_1.AvailableFields["payer.name"]).isRequired,
23
- message: 'Please input payer name',
24
- },
25
- ] },
26
- React.createElement(antd_1.Input, null)),
27
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "50%", paddingLeft: "3px" }, name: ["invoice", "customer", "isoIdentifier"], rules: [
28
- {
29
- required: true,
30
- message: 'Please input payer identifier',
31
- },
32
- ] },
33
- React.createElement(antd_1.Input, null))),
34
- React.createElement(antd_1.Form.Item, { label: "Address", name: ["invoice", "customer", "address", "address"] },
35
- React.createElement(antd_1.Input, null)),
36
- React.createElement(antd_1.Form.Item, { label: "Zip/City" },
37
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, name: ["invoice", "customer", "address", "zip"] },
38
- React.createElement(antd_1.Input, null)),
39
- React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: ["invoice", "customer", "address", "city"] },
40
- React.createElement(antd_1.Input, null))),
41
- React.createElement(antd_1.Form.Item, { label: "Country", name: ["invoice", "customer", "address", "country"] },
42
- React.createElement(antd_1.Input, null)),
43
- React.createElement(antd_1.Form.Item, { label: "E-mail", name: ["invoice", "customer", "contact", "email"], rules: [
44
- {
45
- type: 'email',
46
- message: 'The input is not valid E-mail!',
47
- }
48
- ] },
49
- React.createElement(antd_1.Input, null))));
50
- };
51
- exports.default = Payer;
@@ -1,3 +0,0 @@
1
- import * as React from 'react';
2
- declare const Payer: React.FC;
3
- export default Payer;
@@ -1 +0,0 @@
1
- import "./index.css";
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./index.css");