@unimaze/billing 0.1.2-rc.7 → 0.1.2-rc.9

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 (44) hide show
  1. package/lib/common/components/attachments/Attachment.d.ts +4 -1
  2. package/lib/common/components/attachments/Attachment.js +5 -2
  3. package/lib/common/components/attachments/index.d.ts +5 -1
  4. package/lib/common/components/attachments/index.js +4 -3
  5. package/lib/common/components/base-information/index.js +68 -78
  6. package/lib/common/components/billing-lines/BillingLIneFormData.d.ts +6 -0
  7. package/lib/common/components/billing-lines/BillingLIneFormData.js +6 -0
  8. package/lib/common/components/delivery-location/index.js +13 -7
  9. package/lib/common/components/form-item/index.d.ts +18 -0
  10. package/lib/common/components/form-item/index.js +20 -0
  11. package/lib/common/components/supplier/index.js +31 -25
  12. package/lib/common/types/ReceiverRequirements.d.ts +71 -15
  13. package/lib/common/types/ReceiverRequirements.js +410 -8
  14. package/lib/create-credit-note/index.js +1 -2
  15. package/lib/create-invoice/index.js +47 -6
  16. package/lib/src/common/components/attachments/Attachment.d.ts +4 -1
  17. package/lib/src/common/components/attachments/index.d.ts +5 -1
  18. package/lib/src/common/components/billing-lines/BillingLIneFormData.d.ts +6 -0
  19. package/lib/src/common/components/form-item/index.d.ts +18 -0
  20. package/lib/src/common/types/ReceiverRequirements.d.ts +71 -15
  21. package/lib/src/utils/ApiUtility.d.ts +8 -1
  22. package/lib/src/utils/ConversionUtility.d.ts +2 -1
  23. package/lib/src/utils/RequirementsUtility.d.ts +3 -1
  24. package/lib/src/utils/index.d.ts +1 -1
  25. package/lib/style/index.css +0 -1222
  26. package/lib/utils/ApiUtility.d.ts +8 -1
  27. package/lib/utils/ApiUtility.js +17 -1
  28. package/lib/utils/ConversionUtility.d.ts +2 -1
  29. package/lib/utils/ConversionUtility.js +98 -50
  30. package/lib/utils/RequirementsUtility.d.ts +3 -1
  31. package/lib/utils/RequirementsUtility.js +15 -5
  32. package/lib/utils/index.d.ts +1 -1
  33. package/lib/utils/index.js +1 -0
  34. package/package.json +1 -1
  35. package/lib/common/components/component-container/style/index.d.ts +0 -1
  36. package/lib/common/components/component-container/style/index.js +0 -3
  37. package/lib/common/components/issuer/index.d.ts +0 -7
  38. package/lib/common/components/issuer/index.js +0 -28
  39. package/lib/common/components/payer/index.d.ts +0 -3
  40. package/lib/common/components/payer/index.js +0 -51
  41. package/lib/src/common/components/issuer/index.d.ts +0 -7
  42. package/lib/src/common/components/payer/index.d.ts +0 -3
  43. package/lib/style/index.d.ts +0 -1
  44. package/lib/style/index.js +0 -3
@@ -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 apikey-" + 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];
@@ -1,5 +1,6 @@
1
1
  import { 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;
4
+ import { IBillingLinesMetadata } from "../common/components/billing-lines/BillingLIneFormData";
5
+ declare const convertToInvoiceMetadataInput: (formValues: Store, billingLines: IBillingLinesMetadata, customer: ProfileOutput) => InvoiceMetadataInput;
5
6
  export { /*convertToCreditNoteMetadataInput,*/ convertToInvoiceMetadataInput };
@@ -1,11 +1,57 @@
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 mapi_1 = require("@unimaze/api-clients/lib/mapi");
15
+ var removeEmpty = function (obj) {
16
+ return Object.keys(obj)
17
+ .filter(function (k) { return obj[k] != null; }) // Remove undef. and null.
18
+ .reduce(function (newObj, k) {
19
+ var _a, _b;
20
+ return typeof obj[k] === "object"
21
+ ? __assign({}, newObj, (_a = {}, _a[k] = removeEmpty(obj[k]), _a)) : __assign({}, newObj, (_b = {}, _b[k] = obj[k], _b));
22
+ }, // Copy value.
23
+ {});
24
+ };
25
+ var convertDates = function (date) {
26
+ return date ? date.utc().toDate() : undefined;
27
+ };
28
+ var isEmpty = function (map) {
29
+ for (var key in map) {
30
+ if (map.hasOwnProperty(key)) {
31
+ return false;
32
+ }
33
+ }
34
+ return true;
35
+ };
36
+ var convertToInvoiceMetadataInput = function (formValues, billingLines, customer) {
37
+ var issueDate = convertDates(formValues.invoice.issueDate);
38
+ var dueDate = convertDates(formValues.invoice.dueDate);
39
+ // tslint:disable-next-line:no-console
40
+ console.log(issueDate);
41
+ var cleanedFormValues = removeEmpty(formValues);
42
+ var invoice = cleanedFormValues.invoice;
43
+ // fix delivery
44
+ var delivery = invoice.delivery;
45
+ if (delivery) {
46
+ if (isEmpty(delivery.address)) {
47
+ delete delivery.address;
48
+ }
49
+ }
4
50
  var resp = {
5
51
  messageHandling: {
6
- receiverIdentifier: formValues.invoice.supplier.identifier,
7
- fallbackEmailAddress: formValues.invoice.supplier.contact.email,
8
- fallbackContactName: formValues.invoice.supplier.contact.name,
52
+ receiverIdentifier: customer.participantLegalIsoIdentifier,
53
+ fallbackEmailAddress: customer.email,
54
+ fallbackContactName: customer.name,
9
55
  },
10
56
  invoice: {
11
57
  customer: {
@@ -15,71 +61,73 @@ var convertToInvoiceMetadataInput = function (formValues, customer) {
15
61
  postalZone: customer.participantLegalAddressPostalCode,
16
62
  city: customer.participantLegalAddressCity,
17
63
  countryCode: customer.country,
18
- countrySubEntity: "",
19
- addressLine2: "",
20
- addressLine3: ""
21
64
  },
22
65
  name: customer.name,
23
66
  contact: {
24
67
  electronicMail: customer.email,
25
- fax: "",
26
- name: "",
27
68
  telephone: customer.phoneNumber
69
+ // fax: "",
70
+ // name: "",
28
71
  }
29
72
  },
30
- // Supplier is pre filled, doesnt exist in the form || will be passed to already filled up form
31
73
  supplier: {
32
- identifier: formValues.invoice.supplier.identifier,
74
+ identifier: invoice.supplier.identifier,
33
75
  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
76
+ streetNameAndNumber: invoice.supplier.address.streetNameAndNumber,
77
+ postalZone: invoice.supplier.address.postalZone,
78
+ city: invoice.supplier.address.city,
79
+ countryCode: invoice.supplier.address.countryCode,
42
80
  },
43
- vatNumber: "",
44
- name: formValues.invoice.supplier.name,
81
+ vatNumber: invoice.supplier.vatNumber,
82
+ name: invoice.supplier.name,
45
83
  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
51
- },
52
- },
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
84
+ electronicMail: invoice.supplier.contact.electronicMail,
85
+ name: invoice.supplier.contact.name,
64
86
  },
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
87
  },
70
- issueDate: formValues.invoice.issueDate,
71
- dueDate: null,
72
- invoiceNo: formValues.invoice.invoiceNo,
88
+ 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
+ invoiceNo: invoice.invoiceNo,
106
+ issueDate: issueDate,
107
+ dueDate: dueDate,
108
+ notes: invoice.notes,
109
+ currencyCode: invoice.currencyCode,
73
110
  paymentTerms: {
74
111
  note: ""
75
112
  },
76
113
  // Payment terms doesnt exist in form
77
- currencyCode: formValues.invoice.currency,
78
- invoiceLines: [],
79
- notes: formValues.invoice.notes,
114
+ // invoiceLines: billingLines.billingLineMetadata,
115
+ invoiceLines: [{
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
+ }],
80
128
  payableAmount: 0,
81
129
  orderReference: {
82
- documentNo: "",
130
+ documentNo: invoice.orderReference.documentNo,
83
131
  },
84
132
  }
85
133
  };
@@ -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) {
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.7",
3
+ "version": "0.1.2-rc.9",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -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,28 +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 Issuer = function (props) {
16
- var _a = props.issuer, participantLegalIsoIdentifier = _a.participantLegalIsoIdentifier, participantLegalAddressPostalCode = _a.participantLegalAddressPostalCode, participantLegalAddressCity = _a.participantLegalAddressCity, participantLegalAddressStreet = _a.participantLegalAddressStreet, email = _a.email, name = _a.name, country = _a.country;
17
- return (React.createElement(component_container_1.default, { title: "Issuer" },
18
- React.createElement("div", null,
19
- React.createElement("strong", null, name),
20
- " (",
21
- participantLegalIsoIdentifier,
22
- ")"),
23
- React.createElement("div", null, participantLegalAddressPostalCode + " " + participantLegalAddressCity),
24
- React.createElement("div", null, participantLegalAddressStreet),
25
- React.createElement("div", null, country),
26
- React.createElement("div", null, email)));
27
- };
28
- exports.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,7 +0,0 @@
1
- import * as React from 'react';
2
- import { wapi2 } from "@unimaze/api-clients";
3
- interface Props {
4
- customer: 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 +0,0 @@
1
- import "./index.css";
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./index.css");