@unimaze/billing 0.11.4 → 0.12.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 (27) hide show
  1. package/lib/common/components/base-information/OrderReference.d.ts +12 -0
  2. package/lib/common/components/base-information/OrderReference.js +41 -0
  3. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +1 -10
  4. package/lib/common/components/base-information/ReferenceIdentifiers.js +78 -16
  5. package/lib/common/components/base-information/index.js +26 -36
  6. package/lib/common/components/billing-lines/BillingCalculations.js +11 -9
  7. package/lib/common/components/billing-lines/BillingTaxSummary.js +5 -4
  8. package/lib/common/components/billing-lines/NewBillingLines.js +91 -16
  9. package/lib/common/components/billing-lines/index.d.ts +6 -10
  10. package/lib/common/components/billing-lines/index.js +188 -195
  11. package/lib/common/components/form-item/index.d.ts +1 -1
  12. package/lib/common/components/form-item/index.js +1 -1
  13. package/lib/common/components/supplier/index.d.ts +1 -3
  14. package/lib/common/components/supplier/index.js +16 -5
  15. package/lib/common/types/BillingLineMetadataOverride.d.ts +3 -2
  16. package/lib/create-invoice/index.js +122 -69
  17. package/lib/style/index.css +4 -0
  18. package/lib/translations/locales/is.json +3 -1
  19. package/lib/translations/locales.d.ts +2 -0
  20. package/lib/utils/BillingLineUtility.d.ts +2 -2
  21. package/lib/utils/BillingLineUtility.js +5 -3
  22. package/lib/utils/ConversionUtility.d.ts +1 -1
  23. package/lib/utils/ConversionUtility.js +3 -2
  24. package/lib/utils/ReferenceIdentifierUtility.d.ts +2 -1
  25. package/lib/utils/ReferenceIdentifierUtility.js +1 -0
  26. package/lib/utils/RequirementsUtility.js +1 -1
  27. package/package.json +1 -1
@@ -31,10 +31,9 @@ var utils_1 = require("../utils");
31
31
  var BillingLineUtility_1 = require("../utils/BillingLineUtility");
32
32
  var paymentMethodForConversion_1 = require("../common/components/payment-method/paymentMethodForConversion");
33
33
  var uuid_1 = require("uuid");
34
- var editable_cell_1 = require("../common/components/editable-cell");
35
- var billing_lines_1 = require("../common/components/billing-lines");
36
34
  var react_google_recaptcha_1 = __importDefault(require("react-google-recaptcha"));
37
35
  var ApiUtility_1 = require("../utils/ApiUtility");
36
+ var ConversionUtility_1 = require("../utils/ConversionUtility");
38
37
  var translationMessages = react_intl_1.defineMessages({
39
38
  createInvoice_addDocumentLineMsg: {
40
39
  id: "createInvoice_addDocumentLineMsg",
@@ -71,61 +70,78 @@ var CreateInvoiceConstructor = function (props) {
71
70
  var form = antd_1.Form.useForm()[0];
72
71
  var _a = react_1.useState(false), submitting = _a[0], setSubmitting = _a[1];
73
72
  var _b = react_1.useState(true), isSubmitDisabled = _b[0], setIsSubmitDisabled = _b[1];
74
- var _c = react_1.useState(/*profileOutputToPartyMetadata(customers[0])*/ undefined), chosenCustomer = _c[0], setChosenCustomer = _c[1];
73
+ var _c = react_1.useState(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0])), chosenCustomer = _c[0], setChosenCustomer = _c[1];
75
74
  var _d = react_1.useState(), chosenCustomerApiKey = _d[0], setChosenCustomerApiKey = _d[1];
76
- var _e = react_1.useState(1), billingLinesEditableIndex = _e[0], setBillingLinesEditableIndex = _e[1];
77
- var initialBillingLineData = {
78
- key: billingLinesEditableIndex,
79
- itemNo: props.intl.formatMessage(billing_lines_1.translationMessages.billingLines_placeholders_itemNo),
80
- quantity: 0,
81
- taxAmount: 0,
82
- name: props.intl.formatMessage(billing_lines_1.translationMessages.billingLines_placeholders_newItem),
83
- unitOfMeasure: {
84
- value: mapi_1.Units.Piece,
85
- label: props.intl.formatMessage(editable_cell_1.commonTranslationMessages.unitOfMeasure_labels_Piece)
86
- },
87
- unitPriceAmount: 0,
88
- taxCategoryType: {
89
- value: mapi_1.TaxCategoryTypeEnum.OutsideTaxScope,
90
- label: props.intl.formatMessage(editable_cell_1.commonTranslationMessages.taxCategoryType_labels_OutsideTaxScope) + " (0%)"
91
- },
92
- discountValue: "0",
93
- taxableAmount: 0,
94
- taxPercentage: 0
95
- };
96
- var _f = react_1.useState([__assign({}, initialBillingLineData, { key: 0 })]), billingLinesDataSource = _f[0], setBillingLinesDataSource = _f[1];
75
+ // const [billingLinesEditableIndex, setBillingLinesEditableIndex] = useState<number>(1)
76
+ // const initialBillingLineData: BillingLineMetadataOverride = {
77
+ // key: billingLinesEditableIndex,
78
+ // itemNo: props.intl.formatMessage(billingLineTranslationMessages.billingLines_placeholders_itemNo), // "Item No.",// (dataSource.length > 0 ? Number(dataSource[dataSource.length-1].itemNo) + 1 : 1).toString(),
79
+ // quantity: 0,
80
+ // taxAmount: 0,
81
+ // name: props.intl.formatMessage(billingLineTranslationMessages.billingLines_placeholders_newItem), // `New Item`,
82
+ // unitOfMeasure: {
83
+ // value: Units.Piece,
84
+ // label: props.intl.formatMessage(commonTranslationMessages.unitOfMeasure_labels_Piece)
85
+ // },
86
+ // unitPriceAmount: 0,
87
+ // taxCategoryType: {
88
+ // value: TaxCategoryTypeEnum.OutsideTaxScope,
89
+ // label: `${props.intl.formatMessage(commonTranslationMessages.taxCategoryType_labels_OutsideTaxScope)} (0%)`
90
+ // },
91
+ // discountValue: "0",
92
+ // taxableAmount: 0,
93
+ // taxPercentage: 0
94
+ // };
95
+ // const [billingLinesDataSource, setBillingLinesDataSource] = useState<BillingLineMetadataOverride[]>([{
96
+ // ...initialBillingLineData,
97
+ // key: 0,
98
+ // }])
97
99
  // BILLING LINES
98
- var handleBillingLinesDelete = function (index) {
99
- var newDataSource = billingLinesDataSource.slice();
100
- var indexToDelete = newDataSource.findIndex(function (billingLine) { return billingLine.key === index; });
101
- newDataSource.splice(indexToDelete, 1);
102
- setBillingLinesDataSource(newDataSource);
103
- };
104
- var handleBillingLinesAdd = function (billingLineToAdd) {
105
- setBillingLinesDataSource(billingLinesDataSource.concat([billingLineToAdd]));
106
- setBillingLinesEditableIndex(billingLinesEditableIndex + 1);
107
- };
108
- var handleBillingLinesSave = function (row, formInstance) {
109
- var newData = billingLinesDataSource.slice();
110
- var index = newData.findIndex(function (i) {
111
- return row.key === i.key;
112
- });
113
- var item = newData[index];
114
- newData.splice(index, 1, __assign({}, item, row));
115
- var billingLineMetadata = newData.map(function (current) {
116
- return __assign({}, current, { unitOfMeasure: {
117
- unit: mapi_1.Units[current.unitOfMeasure.value],
118
- }, taxCategoryType: mapi_1.TaxCategoryTypeEnum[current.taxCategoryType.value] });
119
- });
120
- setBillingLinesDataSource(newData);
121
- handleSetBillingLineMetadata(formInstance, billingLineMetadata);
122
- };
100
+ // const handleBillingLinesDelete = (index: number) => {
101
+ // const newDataSource = [...billingLinesDataSource];
102
+ // const indexToDelete = newDataSource.findIndex(billingLine => billingLine.key === index)
103
+ // newDataSource.splice(indexToDelete, 1);
104
+ // setBillingLinesDataSource(newDataSource);
105
+ // };
106
+ //
107
+ // const handleBillingLinesAdd = (billingLineToAdd: BillingLineMetadataOverride) => {
108
+ // setBillingLinesDataSource([...billingLinesDataSource, billingLineToAdd])
109
+ // setBillingLinesEditableIndex(billingLinesEditableIndex + 1)
110
+ // };
111
+ //
112
+ //
113
+ // const handleBillingLinesSave = (row: BillingLineMetadataOverride, formInstance: FormInstance) => {
114
+ // const newData = [...billingLinesDataSource];
115
+ // const index = newData.findIndex((i) => {
116
+ // return row.key === i.key;
117
+ // });
118
+ //
119
+ // const item = newData[index];
120
+ // newData.splice(index, 1, {
121
+ // ...item,
122
+ // ...row,
123
+ // });
124
+ //
125
+ // const billingLineMetadata = newData.map<BillingLineMetadata>(current => {
126
+ // return {
127
+ // ...current,
128
+ // unitOfMeasure: {
129
+ // unit: Units[current.unitOfMeasure.value],
130
+ // },
131
+ // taxCategoryType: TaxCategoryTypeEnum[current.taxCategoryType.value]
132
+ // }
133
+ // });
134
+ //
135
+ // setBillingLinesDataSource(newData)
136
+ //
137
+ // handleSetBillingLineMetadata(formInstance, billingLineMetadata);
138
+ // };
123
139
  // END BILLING LINES
124
- var handleSetBillingLineMetadata = function (formInstance, billingLineMetadata) {
125
- formInstance.setFieldsValue({
126
- "billingLinesMetadata": billingLineMetadata
127
- });
128
- };
140
+ // const handleSetBillingLineMetadata = (formInstance: FormInstance, billingLineMetadata: BillingLineMetadata[]) => {
141
+ // formInstance.setFieldsValue({
142
+ // "billingLinesMetadata": billingLineMetadata
143
+ // })
144
+ // };
129
145
  var handleSubmit = function (values) {
130
146
  setSubmitting(true);
131
147
  var attachments = [
@@ -147,13 +163,13 @@ var CreateInvoiceConstructor = function (props) {
147
163
  // }
148
164
  //
149
165
  // })
150
- var billingLinesArray = form.getFieldValue("billingLinesMetadata");
151
- if (!billingLinesArray || billingLinesArray.length <= 0) {
152
- antd_1.message.error(intl.formatMessage(translationMessages.createInvoice_addDocumentLineMsg));
153
- // TODO: handle this better?
154
- setSubmitting(false);
155
- return;
156
- }
166
+ // const billingLinesArray: BillingLineMetadata[] = form.getFieldValue("billingLinesMetadata");
167
+ // if (!billingLinesArray || billingLinesArray.length <= 0) {
168
+ // message.error(intl.formatMessage(translationMessages.createInvoice_addDocumentLineMsg))
169
+ // // TODO: handle this better?
170
+ // setSubmitting(false);
171
+ // return;
172
+ // }
157
173
  if (!chosenCustomer) {
158
174
  antd_1.message.error(intl.formatMessage(translationMessages.createInvoice_selectCustomerMsg));
159
175
  // TODO: handle this better?
@@ -203,8 +219,8 @@ var CreateInvoiceConstructor = function (props) {
203
219
  // Clear the billing line dataSource
204
220
  setChosenCustomer(undefined);
205
221
  setChosenCustomerApiKey(undefined);
206
- setBillingLinesDataSource([__assign({}, initialBillingLineData, { key: 0 })]);
207
- setBillingLinesEditableIndex(0);
222
+ // setBillingLinesDataSource([{...initialBillingLineData, key: 0}])
223
+ // setBillingLinesEditableIndex(0);
208
224
  // TODO: remove this as soon as possible
209
225
  // location.reload();
210
226
  })
@@ -267,10 +283,34 @@ var CreateInvoiceConstructor = function (props) {
267
283
  });
268
284
  setChosenCustomerApiKey(props.customers[0].apiKey);
269
285
  }
286
+ var _e = react_1.useState(undefined), billingLinesMetadata = _e[0], setBillingLinesMetadata = _e[1];
287
+ var getBillingLines = function (changedValues, allValues) {
288
+ var invoiceLines = allValues.invoice.invoiceLines;
289
+ if (invoiceLines) {
290
+ var mappedBillingLines = invoiceLines.map(function (invoiceLine) {
291
+ if (invoiceLine) {
292
+ return ({
293
+ itemNo: invoiceLine.itemNo ? invoiceLine.itemNo : undefined,
294
+ name: invoiceLine.name ? invoiceLine.name : undefined,
295
+ quantity: invoiceLine.quantity ? invoiceLine.quantity : undefined,
296
+ unitPriceAmount: invoiceLine.unitPriceAmount ? invoiceLine.unitPriceAmount : undefined,
297
+ unitOfMeasure: {
298
+ unit: invoiceLine.unitOfMeasure && invoiceLine.unitOfMeasure.unit ? mapi_1.Units[invoiceLine.unitOfMeasure.unit] : undefined,
299
+ },
300
+ taxCategoryType: invoiceLine.taxCategoryType ? mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType] : undefined,
301
+ discountValue: invoiceLine.discountValue ? invoiceLine.discountValue : undefined,
302
+ });
303
+ }
304
+ else {
305
+ return {};
306
+ }
307
+ });
308
+ setBillingLinesMetadata(mappedBillingLines);
309
+ }
310
+ };
270
311
  return (react_1.default.createElement(antd_1.Spin, { spinning: submitting },
271
- react_1.default.createElement(antd_1.Form, __assign({}, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, initialValues: {
312
+ react_1.default.createElement(antd_1.Form, __assign({ onValuesChange: function (changedValues, allValues) { return getBillingLines(changedValues, allValues); } }, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, initialValues: {
272
313
  invoice: {
273
- currencyCode: "ISK",
274
314
  supplier: {
275
315
  address: {
276
316
  countryCode: "IS"
@@ -285,17 +325,30 @@ var CreateInvoiceConstructor = function (props) {
285
325
  referenceIdentifiers: [
286
326
  {}
287
327
  ],
328
+ invoiceLines: [{}]
288
329
  },
289
330
  } }),
290
331
  react_1.default.createElement(antd_1.Row, { gutter: [16, 16] },
291
332
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
292
- react_1.default.createElement(components_1.BaseInformation, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: props.legalIdentifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText })),
293
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
294
- react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements, billingLinesDataSource: billingLinesDataSource, rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form })),
333
+ react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements,
334
+ // billingLinesDataSource={billingLinesDataSource}
335
+ rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form })),
295
336
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
296
337
  react_1.default.createElement(components_1.Customer, { receiverRequirements: props.receiverRequirements, formInstance: form, customers: props.customers, chosenCustomer: chosenCustomer, setChosenCustomer: setChosenCustomer, setChosenCustomerApiKey: setChosenCustomerApiKey, rapiBaseUrl: props.rapiBaseUrl, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp })),
338
+ react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
339
+ react_1.default.createElement(components_1.BaseInformation, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: props.legalIdentifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText })),
297
340
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 24 } },
298
- react_1.default.createElement(components_1.BillingLines, { setBillingLineMetadata: handleSetBillingLineMetadata, formInstance: form, dataSource: billingLinesDataSource, editableIndex: billingLinesEditableIndex, handleAdd: handleBillingLinesAdd, initialBillingLineData: initialBillingLineData, handleDelete: handleBillingLinesDelete, handleSave: handleBillingLinesSave })),
341
+ react_1.default.createElement(components_1.BillingLines
342
+ // setBillingLineMetadata={handleSetBillingLineMetadata}
343
+ , {
344
+ // setBillingLineMetadata={handleSetBillingLineMetadata}
345
+ formInstance: form, billingLinesMetadata: billingLinesMetadata,
346
+ // editableIndex={billingLinesEditableIndex}
347
+ // handleAdd={handleBillingLinesAdd}
348
+ // initialBillingLineData={initialBillingLineData}
349
+ // handleDelete={handleBillingLinesDelete}
350
+ // handleSave={handleBillingLinesSave}
351
+ receiverRequirements: props.receiverRequirements })),
299
352
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
300
353
  react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form })),
301
354
  react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 16 } },
@@ -44,4 +44,8 @@
44
44
  .component_wrapper_padding {
45
45
  padding: 1em;
46
46
  }
47
+ .umz_noValidationMessage .ant-form-item-explain {
48
+ height: 20px !important;
49
+ visibility: hidden !important;
50
+ }
47
51
  /*# sourceMappingURL=index.css.map */
@@ -16,7 +16,9 @@
16
16
  "baseInformation_dueDate": "Gjalddagi",
17
17
  "baseInformation_dueDate_title": "Eindagi skal vera sá sami og gjalddagi",
18
18
  "baseInformation_buyerReferenceLabel": "Tilvísun kaupanda",
19
- "baseInformation_buyerReferenceLabel_helpText": "Tilvísun sem kaupandi hefur óskað sé sett á reikning, oft kallað \"þín tilvísun\" (your ref.), Notað í innri flokkun/samþykkt hjá kaupanda. Ef kaupandi hefur ekki tilgreint þetta sérstaklega, þá má setja hér inn nafn þess aðila sem pantaði (umbeðið).",
19
+ "baseInformation_buyerReferenceLabel_helpText": "Tilvísun sem kaupandi hefur óskað sé sett á reikning, oft kallað \"þín tilvísun\" (your ref.), Notað í innri flokkun/samþykkt hjá kaupanda. Ef kaupandi hefur ekki tilgreint þetta sérstaklega, þá má setja hér inn nafn þess aðila sem pantaði (umbeðið). Verður að tilgreina þegar ekkert pantananúmer á við.",
20
+ "baseInformation_orderReferenceLabel": "Pöntun nr.",
21
+ "baseInformation_orderReferenceLabel_helpText": "Aðeins má nota númer raunverulegrar pöntunar. Ef engin pöntun er til, verður að nota tilvísun kaupanda.",
20
22
  "baseInformation_notes": "Athugasemdir",
21
23
  "baseInformation_currencyCode": "Gjaldmiðill",
22
24
  "baseInformation_costCenter": "Kostnaðarstöð",
@@ -19,6 +19,8 @@ declare const _default: {
19
19
  "baseInformation_dueDate_title": string;
20
20
  "baseInformation_buyerReferenceLabel": string;
21
21
  "baseInformation_buyerReferenceLabel_helpText": string;
22
+ "baseInformation_orderReferenceLabel": string;
23
+ "baseInformation_orderReferenceLabel_helpText": string;
22
24
  "baseInformation_notes": string;
23
25
  "baseInformation_currencyCode": string;
24
26
  "baseInformation_costCenter": string;
@@ -5,6 +5,6 @@ import React from "react";
5
5
  export declare const billingLinesFieldsMetadata: (formInstance: FormInstance) => BillingLineMetadata[];
6
6
  export declare const calculateTaxableAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null) => number;
7
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, taxCategoryTypeTranslated: string) => string;
8
+ export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum | undefined) => number;
9
+ export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum | undefined, taxCategoryTypeTranslated: string) => string;
10
10
  export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "referenceIdentifiers" | "notes" | "accountingCost" | "billingPeriod" | "unitOfMeasure" | "taxCategoryType" | "itemNo" | "quantity" | "unitPriceAmount" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "orderLineReference") => React.ReactChild;
@@ -18,7 +18,7 @@ var api_1 = require("@unimaze/api-clients/lib/mapi/api");
18
18
  var react_1 = __importDefault(require("react"));
19
19
  var antd_1 = require("antd");
20
20
  exports.billingLinesFieldsMetadata = function (formInstance) {
21
- var billingLinesMetadata = formInstance.getFieldValue("billingLinesMetadata");
21
+ var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
22
22
  return billingLinesMetadata.map(function (billingLine) {
23
23
  var taxableAmount = exports.calculateTaxableAmount(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
24
24
  var taxPercentage = exports.calculateTaxPercentage(billingLine.taxCategoryType);
@@ -65,16 +65,18 @@ exports.calculateTaxPercentage = function (taxCategoryType) {
65
65
  case api_1.TaxCategoryTypeEnum.Exempt:
66
66
  case api_1.TaxCategoryTypeEnum.OutsideTaxScope:
67
67
  return 0;
68
+ default:
69
+ return 0;
68
70
  }
69
71
  };
70
72
  exports.generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTranslated) {
71
- return taxCategoryTypeTranslated + " (" + exports.calculateTaxPercentage(taxCategoryType) + "%)";
73
+ return taxCategoryType ? taxCategoryTypeTranslated + " (" + exports.calculateTaxPercentage(taxCategoryType) + "%)" : "";
72
74
  };
73
75
  exports.getCorrectInputNode = function (dataIdx) {
74
76
  switch (dataIdx) {
75
77
  case "quantity":
76
78
  case "unitPriceAmount":
77
- return react_1.default.createElement(antd_1.InputNumber, { step: 1 });
79
+ return react_1.default.createElement(antd_1.InputNumber, { step: 1, style: { width: "100%" } });
78
80
  case "unitOfMeasure":
79
81
  return (react_1.default.createElement(antd_1.Select, { dropdownMatchSelectWidth: false }, Object.keys(api_1.Units).map(function (unitOfMeasure) {
80
82
  if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
@@ -2,7 +2,7 @@ import { BillingLineMetadata, InvoiceMetadataInput, PartyMetadata } from "@unima
2
2
  import { Store } from "antd/es/form/interface";
3
3
  import { ProfileOutput } from "@unimaze/api-clients/lib/wapi2";
4
4
  import { PaymentMeansMetadata } from "@unimaze/api-clients/lib/mapi/api";
5
- declare const convertToInvoiceMetadataInput: (formValues: Store, billingLines: BillingLineMetadata[], paymentMethod: PaymentMeansMetadata, chosenCustomer: PartyMetadata) => InvoiceMetadataInput;
5
+ declare const convertToInvoiceMetadataInput: (formValues: Store, invoiceLinesWithCalculations: BillingLineMetadata[], paymentMethod: PaymentMeansMetadata, chosenCustomer: PartyMetadata) => InvoiceMetadataInput;
6
6
  declare const profileOutputToPartyMetadata: (profileOutput: ProfileOutput) => PartyMetadata;
7
7
  declare const convertToReadableKennitala: (isoIdentifier: string) => string;
8
8
  export { convertToInvoiceMetadataInput, profileOutputToPartyMetadata, convertToReadableKennitala };
@@ -45,7 +45,7 @@ var cleanIdentifier = function (identifier) {
45
45
  // return identifier.replace(/[^0-9]/g, "") // replace anything that isn't a numeric character
46
46
  return identifier.replace("-", ""); // remove the '-'
47
47
  };
48
- var convertToInvoiceMetadataInput = function (formValues, billingLines, paymentMethod, chosenCustomer) {
48
+ var convertToInvoiceMetadataInput = function (formValues, invoiceLinesWithCalculations, paymentMethod, chosenCustomer) {
49
49
  var issueDate = convertDates(formValues.invoice.issueDate);
50
50
  var dueDate = convertDates(formValues.invoice.dueDate);
51
51
  var referenceIdentifiersArray = formValues.invoice.referenceIdentifiers;
@@ -135,12 +135,13 @@ var convertToInvoiceMetadataInput = function (formValues, billingLines, paymentM
135
135
  dueDate: dueDate,
136
136
  notes: invoice.notes,
137
137
  currencyCode: invoice.currencyCode,
138
- invoiceLines: billingLines,
138
+ invoiceLines: invoiceLinesWithCalculations,
139
139
  // invoiceLines: invoice.invoiceLines, // FOR NEW BILLING LINES
140
140
  // payableAmount: 0, // Calculated? either doesnt exist or part of the Billing/Invoice Lines
141
141
  buyerReference: invoice.buyerReference,
142
142
  paymentMeans: paymentMethod,
143
143
  referenceIdentifiers: referenceIdentifiers,
144
+ orderReference: invoice.orderReference,
144
145
  }
145
146
  };
146
147
  if (resp.invoice && resp.invoice.delivery && resp.invoice.delivery === {}) {
@@ -2,5 +2,6 @@ import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewRec
2
2
  export interface FieldDefinitionWithOriginalKey extends FieldDefinition {
3
3
  originalKey: string;
4
4
  }
5
+ declare const getReferenceIdentifierFieldDefinitions: (receiverRequirements: NewReceiverRequirements) => FieldDefinition[];
5
6
  declare const getReferenceIdentifierOptions: (receiverRequirements: NewReceiverRequirements) => FieldDefinitionWithOriginalKey[];
6
- export { getReferenceIdentifierOptions };
7
+ export { getReferenceIdentifierOptions, getReferenceIdentifierFieldDefinitions };
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  var getReferenceIdentifierFieldDefinitions = function (receiverRequirements) {
15
15
  return receiverRequirements ? receiverRequirements.fieldDefinitions.filter(function (fieldRequirement) { return fieldRequirement.key.startsWith("referenceIdentifier"); }) : [];
16
16
  };
17
+ exports.getReferenceIdentifierFieldDefinitions = getReferenceIdentifierFieldDefinitions;
17
18
  var getReferenceIdentifierOptions = function (receiverRequirements) {
18
19
  var referenceIdentifierFieldDefinitions = getReferenceIdentifierFieldDefinitions(receiverRequirements);
19
20
  return referenceIdentifierFieldDefinitions.map(function (fieldDefinition) {
@@ -47,7 +47,7 @@ exports.getFieldLabelTooltipOverride = function (receiverRequirements, key, defa
47
47
  exports.getFieldIsRequired = function (receiverRequirements, key, defaultIsRequired) {
48
48
  var fieldRequirement = exports.getFieldRequirements(receiverRequirements, key);
49
49
  var fieldCardinality = fieldRequirement && fieldRequirement.properties.hasOwnProperty("cardinality") && fieldRequirement.properties.cardinality;
50
- return fieldCardinality ? cardinalityToRequired(fieldCardinality) : defaultIsRequired;
50
+ return fieldCardinality ? cardinalityToRequired(fieldCardinality) || defaultIsRequired : defaultIsRequired;
51
51
  };
52
52
  var cardinalityToRequired = function (cardinality) {
53
53
  switch (cardinality) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.11.4",
3
+ "version": "0.12.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",