@unimaze/billing 0.12.13 → 0.12.14
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/base-information/AccountingCost.d.ts +15 -0
- package/lib/common/components/base-information/AccountingCost.js +40 -0
- package/lib/common/components/base-information/index.js +2 -0
- package/lib/common/components/form-item/index.d.ts +1 -1
- package/lib/translations/locales/is.json +2 -0
- package/lib/translations/locales.d.ts +2 -0
- package/lib/utils/BillingLineUtility.d.ts +1 -1
- package/lib/utils/RequirementsUtility.d.ts +8 -0
- package/lib/utils/RequirementsUtility.js +90 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NewReceiverRequirements } from "../../types/NewReceiverRequirements";
|
|
3
|
+
import { FormInstance } from "antd/es/form";
|
|
4
|
+
import { InjectedIntlProps } from "react-intl";
|
|
5
|
+
interface Props extends InjectedIntlProps {
|
|
6
|
+
receiverRequirements: NewReceiverRequirements;
|
|
7
|
+
updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void;
|
|
8
|
+
formInstance: FormInstance;
|
|
9
|
+
rapiBaseUrl: string;
|
|
10
|
+
legalIdentifier: string;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: React.ComponentClass<Pick<Props, "formInstance" | "receiverRequirements" | "updateReceiverRequirementsProp" | "rapiBaseUrl" | "legalIdentifier">, any> & {
|
|
13
|
+
WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
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_1 = __importStar(require("react"));
|
|
14
|
+
var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
|
|
15
|
+
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
16
|
+
var form_item_1 = __importDefault(require("../form-item"));
|
|
17
|
+
var react_intl_1 = require("react-intl");
|
|
18
|
+
var translationMessages = react_intl_1.defineMessages({
|
|
19
|
+
baseInformation_accountingCostLabel: {
|
|
20
|
+
id: "baseInformation_accountingCostLabel",
|
|
21
|
+
defaultMessage: "Accounting cost"
|
|
22
|
+
},
|
|
23
|
+
baseInformation_accountingCostLabel_helpText: {
|
|
24
|
+
id: "baseInformation_accountingCostLabel_helpText",
|
|
25
|
+
defaultMessage: "Accounting cost is a code provided by the buyer, either via phone or e-mail or taken directly from the an order associated with the invoice"
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
var AccountingCost = function (props) {
|
|
29
|
+
var _a = react_1.useState(""), accountingCostHandlingValidationStatus = _a[0], setAccountingCostHandlingValidationStatus = _a[1];
|
|
30
|
+
var _b = react_1.useState({}), accountingCostFieldProps = _b[0], setAccountingCostFieldProps = _b[1];
|
|
31
|
+
var _c = react_1.useState(false), loadingAccountingCostValues = _c[0], setLoadingAccountingCostValues = _c[1];
|
|
32
|
+
var accountingCostFieldDefinition = RequirementsUtility_1.getFieldRequirements(props.receiverRequirements, ReceiverRequirements_1.AvailableFields.accountingCost);
|
|
33
|
+
if (accountingCostFieldDefinition) {
|
|
34
|
+
return (react_1.default.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.accountingCost, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_accountingCostLabel), defaultLabelTooltip: props.intl.formatMessage(translationMessages.baseInformation_accountingCostLabel_helpText), defaultIsRequired: false, fieldName: ["invoice", "accountingCost"], validateStatus: accountingCostHandlingValidationStatus, hasFeedback: true }, RequirementsUtility_1.getInput(accountingCostFieldDefinition, ["invoice", "accountingCost"], "handleAccountingCostValidation", props.legalIdentifier, props.formInstance, props.rapiBaseUrl, props.receiverRequirements, props.updateReceiverRequirementsProp, setAccountingCostFieldProps, accountingCostFieldProps, setLoadingAccountingCostValues, loadingAccountingCostValues, setAccountingCostHandlingValidationStatus)));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.default = react_intl_1.injectIntl(AccountingCost);
|
|
@@ -20,6 +20,7 @@ var ReferenceIdentifiers_1 = __importStar(require("./ReferenceIdentifiers"));
|
|
|
20
20
|
var icons_1 = require("@ant-design/icons");
|
|
21
21
|
var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
|
|
22
22
|
var OrderReference_1 = __importDefault(require("./OrderReference"));
|
|
23
|
+
var AccountingCost_1 = __importDefault(require("./AccountingCost"));
|
|
23
24
|
var translationMessages = react_intl_1.defineMessages({
|
|
24
25
|
baseInformation_title: {
|
|
25
26
|
id: "baseInformation_title",
|
|
@@ -187,6 +188,7 @@ var BaseInformation = function (props) {
|
|
|
187
188
|
React.createElement(form_item_1.default, { shouldUpdate: true, dependencies: [["invoice", "orderReference", "documentNo"]], receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.buyerReference, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_buyerReferenceLabel), defaultLabelTooltip: props.intl.formatMessage(translationMessages.baseInformation_buyerReferenceLabel_helpText), defaultIsRequired: !(props.form.getFieldValue(["invoice", "orderReference", "documentNo"])), fieldName: ["invoice", "buyerReference"] },
|
|
188
189
|
React.createElement(antd_1.Input, null)),
|
|
189
190
|
React.createElement(ReferenceIdentifiers_1.default, { receiverRequirements: props.receiverRequirements, formInstance: props.form, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: props.legalIdentifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: props.referenceIdentifierValidateStatus, setReferenceIdentifierValidateStatus: props.setReferenceIdentifierValidateStatus }),
|
|
191
|
+
React.createElement(AccountingCost_1.default, { formInstance: props.form, rapiBaseUrl: props.rapiBaseUrl, receiverRequirements: props.receiverRequirements, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, legalIdentifier: props.legalIdentifier }),
|
|
190
192
|
React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.notes, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_notes), defaultIsRequired: false, fieldName: ["invoice", "notes"] },
|
|
191
193
|
React.createElement(antd_1.Input.TextArea, null)),
|
|
192
194
|
React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.currencyCode, defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_currencyCode), defaultIsRequired: true, fieldName: ["invoice", "currencyCode"], initialValue: getCurrencies(props.receiverRequirements)[0].key },
|
|
@@ -22,7 +22,7 @@ interface Props extends InjectedIntlProps, FormItemProps {
|
|
|
22
22
|
onlyLabelOnFirstInList?: boolean;
|
|
23
23
|
index?: number;
|
|
24
24
|
}
|
|
25
|
-
declare const _default: React.ComponentClass<Pick<Props, "normalize" | "required" | "label" | "style" | "help" | "children" | "name" | "validateTrigger" | "dependencies" | "getValueFromEvent" | "rules" | "shouldUpdate" | "trigger" | "validateFirst" | "valuePropName" | "getValueProps" | "messageVariables" | "initialValue" | "onReset" | "className" | "id" | "prefixCls" | "isListField" | "colon" | "extra" | "htmlFor" | "index" | "fieldName" | "
|
|
25
|
+
declare const _default: React.ComponentClass<Pick<Props, "normalize" | "required" | "label" | "style" | "help" | "children" | "name" | "validateTrigger" | "dependencies" | "getValueFromEvent" | "rules" | "shouldUpdate" | "trigger" | "validateFirst" | "valuePropName" | "getValueProps" | "messageVariables" | "initialValue" | "onReset" | "className" | "id" | "prefixCls" | "isListField" | "colon" | "extra" | "htmlFor" | "index" | "fieldName" | "noStyle" | "hasFeedback" | "validateStatus" | "fieldKey" | "labelAlign" | "labelCol" | "wrapperCol" | "receiverRequirements" | "receiverRequirementsKey" | "defaultLabel" | "defaultLabelTooltip" | "defaultIsRequired" | "additionalRules" | "verticalLabels" | "onlyLabelOnFirstInList">, any> & {
|
|
26
26
|
WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
|
|
27
27
|
};
|
|
28
28
|
export default _default;
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"baseInformation_notes": "Athugasemdir",
|
|
23
23
|
"baseInformation_currencyCode": "Gjaldmiðill",
|
|
24
24
|
"baseInformation_costCenter": "Kostnaðarstöð",
|
|
25
|
+
"baseInformation_accountingCostLabel": "Bókunarlykill",
|
|
26
|
+
"baseInformation_accountingCostLabel_helpText": "Bókunarlykill er kóti gefinn upp af kaupanda, gegnum tölvupóst eða síma eða fenginn beint úr pöntun sem tengist þessum reikningi",
|
|
25
27
|
"billingCalculations_labels_TaxAmountWithoutVat": "Samtals án VSK",
|
|
26
28
|
"billingCalculations_labels_TotalVatAmount": "Samtals VSK upphæð",
|
|
27
29
|
"billingCalculations_labels_TotalAmountWithVat": "Samtals með VSK",
|
|
@@ -24,6 +24,8 @@ declare const _default: {
|
|
|
24
24
|
"baseInformation_notes": string;
|
|
25
25
|
"baseInformation_currencyCode": string;
|
|
26
26
|
"baseInformation_costCenter": string;
|
|
27
|
+
"baseInformation_accountingCostLabel": string;
|
|
28
|
+
"baseInformation_accountingCostLabel_helpText": string;
|
|
27
29
|
"billingCalculations_labels_TaxAmountWithoutVat": string;
|
|
28
30
|
"billingCalculations_labels_TotalVatAmount": string;
|
|
29
31
|
"billingCalculations_labels_TotalAmountWithVat": string;
|
|
@@ -8,4 +8,4 @@ export declare const calculateTaxableAmount: (discountValue: string | null | und
|
|
|
8
8
|
export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
|
|
9
9
|
export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum | undefined) => number;
|
|
10
10
|
export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum | undefined, taxCategoryTypeTranslated: string) => string;
|
|
11
|
-
export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "referenceIdentifiers" | "
|
|
11
|
+
export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "referenceIdentifiers" | "accountingCost" | "notes" | "billingPeriod" | "unitOfMeasure" | "taxCategoryType" | "itemNo" | "quantity" | "unitPriceAmount" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "orderLineReference", intl: InjectedIntl) => React.ReactChild;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { AvailableFields } from "../common/types/ReceiverRequirements";
|
|
3
4
|
import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
|
|
5
|
+
import { FormItemProps } from "antd/lib/form/FormItem";
|
|
6
|
+
import { FormInstance } from "antd/es/form";
|
|
4
7
|
export declare const getFieldRequirements: (receiverRequirements: NewReceiverRequirements, key: AvailableFields) => FieldDefinition | undefined;
|
|
5
8
|
export declare const getFieldLabelOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabel: React.ReactNode) => React.ReactNode;
|
|
6
9
|
export declare const getFieldLabelTooltipOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabelTooltip: React.ReactNode) => React.ReactNode;
|
|
7
10
|
export declare const getFieldIsRequired: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean) => boolean;
|
|
11
|
+
export interface FormItemPropsWithoutChildren extends Omit<FormItemProps, "children"> {
|
|
12
|
+
}
|
|
13
|
+
export declare const handleValueValidation: ((isoNumber: string, fieldName: string, value: string, rapiBaseUrl: string, namePath: string | number | (string | number)[], setValidationStatus: (validationStatus: "" | "error" | "success" | "validating" | "warning") => void, formInstance: FormInstance, callName: string) => void) & import("lodash").Cancelable;
|
|
14
|
+
export declare const debouncedHandleSearchValues: ((searchValue: string, fieldDefinition: FieldDefinition, setLoadingValues: (loadingValues: boolean) => void, loadingValues: boolean, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (newReceiverRequirements: NewReceiverRequirements) => void, callName: string, rapiBaseUrl: string, overwrittenFieldDefinitionKey?: string | undefined) => void) & import("lodash").Cancelable;
|
|
15
|
+
export declare const getInput: (fieldDefinition: FieldDefinition, namePath: string | number | (string | number)[], validationCallName: string, legalIdentifier: string, formInstance: FormInstance, rapiBaseUrl: string, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void, setAccountingCostFieldProps: (accountingCostFiledProps: FormItemPropsWithoutChildren) => void, accountingCostFieldProps: FormItemPropsWithoutChildren, setLoadingAccountingCostValues: (loadingAccountingCostValues: boolean) => void, loadingAccountingCostValues: boolean, setHandlingValidationStatus: (handlingValidationStatus: "" | "error" | "success" | "validating" | "warning") => void) => React.ReactNode;
|
|
@@ -1,5 +1,24 @@
|
|
|
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
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
18
|
+
var lodash_1 = require("lodash");
|
|
19
|
+
var axios_1 = __importDefault(require("axios"));
|
|
20
|
+
var ApiUtility_1 = require("./ApiUtility");
|
|
21
|
+
var antd_1 = require("antd");
|
|
3
22
|
// export const getReceiverRequirements = (recRequirements: ReceiverRequirements, key: AvailableFields): FieldRequirement => {
|
|
4
23
|
// return recRequirements[key]!;
|
|
5
24
|
// };
|
|
@@ -60,3 +79,74 @@ var cardinalityToRequired = function (cardinality) {
|
|
|
60
79
|
throw new Error("Cardinality \"" + cardinality + "\" is not supported");
|
|
61
80
|
}
|
|
62
81
|
};
|
|
82
|
+
exports.handleValueValidation = lodash_1.debounce(function (isoNumber, fieldName, value, rapiBaseUrl, namePath, setValidationStatus, formInstance, callName) {
|
|
83
|
+
if (value.length === 0) {
|
|
84
|
+
setValidationStatus("");
|
|
85
|
+
formInstance.resetFields([namePath]);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
var searchUrl = rapiBaseUrl + ("/api/v1/requirements/" + isoNumber + "/" + fieldName + "/values/validate?value=" + encodeURIComponent(value));
|
|
89
|
+
setValidationStatus("validating");
|
|
90
|
+
axios_1.default.get(searchUrl, { cancelToken: ApiUtility_1.getCancelToken(callName) })
|
|
91
|
+
.then(function (response) {
|
|
92
|
+
response.data ? setValidationStatus("success") : setValidationStatus("error");
|
|
93
|
+
})
|
|
94
|
+
.catch(function (error) {
|
|
95
|
+
setValidationStatus("error");
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, 500);
|
|
99
|
+
var handleValueSearch = function (searchValue, fieldDefinition, setLoadingValues, loadingValues, receiverRequirements, updateReceiverRequirementsProp, callName, rapiBaseUrl, overwrittenFieldDefinitionKey) {
|
|
100
|
+
if (fieldDefinition.properties.href) {
|
|
101
|
+
var searchUrl = rapiBaseUrl + fieldDefinition.properties.href.replace("%7BtextFilter%7D", encodeURIComponent(searchValue)).replace("%7Boffset%7D", "0").replace("%7Blimit%7D", "15");
|
|
102
|
+
if (!loadingValues) {
|
|
103
|
+
setLoadingValues(true);
|
|
104
|
+
}
|
|
105
|
+
axios_1.default.get(searchUrl, { cancelToken: ApiUtility_1.getCancelToken(callName) })
|
|
106
|
+
.then(function (response) {
|
|
107
|
+
setLoadingValues(false);
|
|
108
|
+
var updatedFieldDefinitions = receiverRequirements.fieldDefinitions.slice();
|
|
109
|
+
var key = overwrittenFieldDefinitionKey ? overwrittenFieldDefinitionKey : fieldDefinition.key;
|
|
110
|
+
var index = updatedFieldDefinitions.findIndex(function (x) { return x.key === key; });
|
|
111
|
+
var updatedFieldDefinition = __assign({}, updatedFieldDefinitions[index], { properties: __assign({}, updatedFieldDefinitions[index].properties, { values: response.data.value }) });
|
|
112
|
+
updatedFieldDefinitions.splice(index, 1, updatedFieldDefinition);
|
|
113
|
+
var newReceiverRequirements = __assign({}, receiverRequirements, { fieldDefinitions: updatedFieldDefinitions });
|
|
114
|
+
updateReceiverRequirementsProp(newReceiverRequirements);
|
|
115
|
+
})
|
|
116
|
+
.catch(function (error) {
|
|
117
|
+
setLoadingValues(false);
|
|
118
|
+
// tslint:disable-next-line:no-console
|
|
119
|
+
console.log(error);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
exports.debouncedHandleSearchValues = lodash_1.debounce(handleValueSearch, 500);
|
|
124
|
+
exports.getInput = function (fieldDefinition, namePath, validationCallName, legalIdentifier, formInstance, rapiBaseUrl, receiverRequirements, updateReceiverRequirementsProp, setAccountingCostFieldProps, accountingCostFieldProps, setLoadingAccountingCostValues, loadingAccountingCostValues, setHandlingValidationStatus) {
|
|
125
|
+
var handling = null;
|
|
126
|
+
if (fieldDefinition.properties.handling) {
|
|
127
|
+
handling = JSON.parse(fieldDefinition.properties.handling);
|
|
128
|
+
}
|
|
129
|
+
if (handling && handling.shouldBeValidated) {
|
|
130
|
+
return (react_1.default.createElement(antd_1.Input, { onBlur: function (event) {
|
|
131
|
+
exports.handleValueValidation(legalIdentifier, fieldDefinition.name, event.currentTarget.value, rapiBaseUrl, namePath, setHandlingValidationStatus, formInstance, validationCallName);
|
|
132
|
+
} }));
|
|
133
|
+
}
|
|
134
|
+
else if (fieldDefinition.properties.values) {
|
|
135
|
+
var selectProps = fieldDefinition.properties.hasOwnProperty("href")
|
|
136
|
+
? {
|
|
137
|
+
showSearch: true,
|
|
138
|
+
filterOption: false,
|
|
139
|
+
onSearch: function (searchValue) {
|
|
140
|
+
exports.debouncedHandleSearchValues(searchValue, fieldDefinition, setLoadingAccountingCostValues, loadingAccountingCostValues, receiverRequirements, updateReceiverRequirementsProp, "getAccountingCOstValues", rapiBaseUrl);
|
|
141
|
+
},
|
|
142
|
+
loading: loadingAccountingCostValues,
|
|
143
|
+
}
|
|
144
|
+
: {};
|
|
145
|
+
return (react_1.default.createElement(antd_1.Select, __assign({ dropdownMatchSelectWidth: false }, selectProps), fieldDefinition.properties.values.map(function (op) {
|
|
146
|
+
return react_1.default.createElement(antd_1.Select.Option, { key: op.key, value: op.key }, op.name);
|
|
147
|
+
})));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return (react_1.default.createElement(antd_1.Input, null));
|
|
151
|
+
}
|
|
152
|
+
};
|