@unimaze/billing 0.1.2-rc.2 → 0.1.2-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/components/attachments/Attachment.js +1 -2
- package/lib/common/components/base-information/index.js +12 -12
- package/lib/common/components/billing-lines/index.d.ts +4 -4
- package/lib/common/components/billing-lines/index.js +12 -18
- package/lib/common/components/component-container/style/index.d.ts +1 -0
- package/lib/common/components/component-container/style/index.js +3 -0
- package/lib/common/components/delivery-location/index.js +4 -4
- package/lib/common/components/editable-cell/index.d.ts +1 -1
- package/lib/common/components/editable-cell/index.js +73 -5
- package/lib/common/components/editable-row/index.d.ts +5 -5
- package/lib/common/components/editable-row/index.js +8 -6
- package/lib/common/components/payer/index.js +10 -9
- package/lib/common/consts/validationRules.d.ts +2 -3
- package/lib/common/types/BillingLineMetadataOverride.d.ts +1 -0
- package/lib/common/types/ReceiverRequirements.d.ts +27 -0
- package/lib/common/types/ReceiverRequirements.js +51 -0
- package/lib/create-credit-note/index.js +1 -3
- package/lib/create-invoice/index.js +18 -9
- package/lib/src/common/components/billing-lines/index.d.ts +4 -4
- package/lib/src/common/components/editable-cell/index.d.ts +1 -1
- package/lib/src/common/components/editable-row/index.d.ts +5 -5
- package/lib/src/common/consts/validationRules.d.ts +2 -3
- package/lib/src/common/types/ReceiverRequirements.d.ts +27 -0
- package/lib/src/utils/ApiUtility.d.ts +14 -0
- package/lib/src/utils/ConversionUtility.d.ts +5 -0
- package/lib/src/utils/index.d.ts +2 -0
- package/lib/style/index.css +1268 -1268
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +3 -0
- package/lib/utils/ApiUtility.js +1 -1
- package/lib/utils/ConversionUtility.d.ts +5 -4
- package/lib/utils/ConversionUtility.js +39 -106
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -2
- package/package.json +5 -3
- package/lib/src/common/components/attachments/Attachment.d.ts +0 -15
- package/lib/src/common/components/attachments/index.d.ts +0 -3
- package/lib/src/create-credit-note/index.d.ts +0 -9
- package/lib/src/index.d.ts +0 -4
|
@@ -70,8 +70,7 @@ var Attachment = /** @class */ (function (_super) {
|
|
|
70
70
|
] },
|
|
71
71
|
React.createElement(antd_1.Input, null)),
|
|
72
72
|
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: "File", name: "attachment:" + this.props.fieldName, valuePropName: "fileList", getValueFromEvent: this.normFile },
|
|
73
|
-
React.createElement(antd_1.Upload.Dragger, { name: "attachment:" + this.props.fieldName, multiple: false, onRemove: this.handleRemoveFile })
|
|
74
|
-
",")));
|
|
73
|
+
React.createElement(antd_1.Upload.Dragger, { name: "attachment:" + this.props.fieldName, multiple: false, onRemove: this.handleRemoveFile }))));
|
|
75
74
|
};
|
|
76
75
|
return Attachment;
|
|
77
76
|
}(React.Component));
|
|
@@ -50,8 +50,8 @@ var BaseInformation = function (props) {
|
|
|
50
50
|
};
|
|
51
51
|
var checkIfEmpty = function (date) {
|
|
52
52
|
if (!date) {
|
|
53
|
-
props.form.resetFields(["
|
|
54
|
-
props.form.validateFields(["
|
|
53
|
+
props.form.resetFields(props.documentType === "invoice" ? ["invoice", "dueDate"] : ["creditNote", "dueDate"]);
|
|
54
|
+
props.form.validateFields(props.documentType === "invoice" ? ["invoice", "dueDate"] : ["creditNote", "dueDate"]).then(function (values) {
|
|
55
55
|
// console.log(values);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
@@ -65,46 +65,46 @@ var BaseInformation = function (props) {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
return (React.createElement(component_container_1.default, { title: "Base information" },
|
|
68
|
-
React.createElement(antd_1.Form.Item, { label: getDocumentNoLabel(props.documentType), name: "
|
|
68
|
+
React.createElement(antd_1.Form.Item, { label: getDocumentNoLabel(props.documentType), name: props.documentType === "invoice" ? ["invoice", "invoiceNo"] : ["creditNote", "invoiceNo"] },
|
|
69
69
|
React.createElement(antd_1.Input, null)),
|
|
70
70
|
React.createElement(antd_1.Form.Item, { label: "Issue date", rules: [
|
|
71
71
|
{
|
|
72
72
|
required: true,
|
|
73
73
|
message: 'Please input the issue date',
|
|
74
74
|
},
|
|
75
|
-
], name: "
|
|
75
|
+
], name: props.documentType === "invoice" ? ["invoice", "issueDate"] : ["creditNote", "issueDate"] },
|
|
76
76
|
React.createElement(antd_1.DatePicker, null)),
|
|
77
77
|
props.documentType === "invoice" &&
|
|
78
78
|
React.createElement(React.Fragment, null,
|
|
79
|
-
React.createElement(antd_1.Form.Item, { label: "Due date", name: "
|
|
79
|
+
React.createElement(antd_1.Form.Item, { label: "Due date", name: props.documentType === "invoice" ? ["invoice", "dueDate"] : ["creditNote", "dueDate"], rules: [
|
|
80
80
|
{
|
|
81
81
|
validator: (function (rule, value, callback) {
|
|
82
82
|
if (!value) {
|
|
83
83
|
callback();
|
|
84
84
|
}
|
|
85
|
-
var issueDate = props.form.getFieldValue("
|
|
85
|
+
var issueDate = props.form.getFieldValue(props.documentType === "invoice" ? ["invoice", "issueDate"] : ["creditNote", "issueDate"]);
|
|
86
86
|
value < issueDate
|
|
87
87
|
? callback("Due date must be after the issue date")
|
|
88
88
|
: callback();
|
|
89
89
|
}),
|
|
90
90
|
},
|
|
91
91
|
] },
|
|
92
|
-
React.createElement(antd_1.DatePicker, { onChange: checkIfEmpty, disabledDate: (function (current) { return disabledDate(current, props.form.getFieldValue("
|
|
93
|
-
React.createElement(antd_1.Form.Item, { label: "Last payment date", name: "
|
|
92
|
+
React.createElement(antd_1.DatePicker, { onChange: checkIfEmpty, disabledDate: (function (current) { return disabledDate(current, props.form.getFieldValue(props.documentType === "invoice" ? ["invoice", "issueDate"] : ["creditNote", "issueDate"])); }) })),
|
|
93
|
+
React.createElement(antd_1.Form.Item, { label: "Last payment date", name: props.documentType === "invoice" ? ["invoice", "lastPaymentDate"] : ["creditNote", "lastPaymentDate"] },
|
|
94
94
|
React.createElement(antd_1.DatePicker, null))),
|
|
95
95
|
props.documentType === "creditNote" &&
|
|
96
|
-
React.createElement(antd_1.Form.Item, { label: "Invoice no", name: "
|
|
96
|
+
React.createElement(antd_1.Form.Item, { label: "Invoice no", name: props.documentType === "creditNote" ? ["invoice", "invoiceReferenceNo"] : ["creditNote", "invoiceReferenceNo"], rules: [
|
|
97
97
|
{
|
|
98
98
|
required: true,
|
|
99
99
|
message: "Please input the invoice no."
|
|
100
100
|
}
|
|
101
101
|
] },
|
|
102
102
|
React.createElement(antd_1.Input, null)),
|
|
103
|
-
React.createElement(antd_1.Form.Item, { label: "Order no", name: "
|
|
103
|
+
React.createElement(antd_1.Form.Item, { label: "Order no", name: props.documentType === "invoice" ? ["invoice", "orderNo"] : ["creditNote", "orderNo"] },
|
|
104
104
|
React.createElement(antd_1.Input, null)),
|
|
105
|
-
React.createElement(antd_1.Form.Item, { label: "Notes", name: "
|
|
105
|
+
React.createElement(antd_1.Form.Item, { label: "Notes", name: props.documentType === "invoice" ? ["invoice", "notes"] : ["creditNote", "notes"] },
|
|
106
106
|
React.createElement(antd_1.Input.TextArea, null)),
|
|
107
|
-
React.createElement(antd_1.Form.Item, { label: "Currency", name: "
|
|
107
|
+
React.createElement(antd_1.Form.Item, { label: "Currency", name: props.documentType === "invoice" ? ["invoice", "currency"] : ["creditNote", "currency"] },
|
|
108
108
|
React.createElement(antd_1.Select, { defaultActiveFirstOption: true }, currencies.map(function (currency) {
|
|
109
109
|
return React.createElement(antd_1.Select.Option, { value: currency.value, title: currency.display, key: currency.value }, currency.display);
|
|
110
110
|
})))));
|
|
@@ -8,12 +8,12 @@ interface EditableColumnProps<T> extends ColumnType<T> {
|
|
|
8
8
|
editable?: boolean;
|
|
9
9
|
}
|
|
10
10
|
interface Props {
|
|
11
|
-
|
|
12
|
-
setBillingLineMetadata: (
|
|
11
|
+
formInstance: FormInstance;
|
|
12
|
+
setBillingLineMetadata: (formInstance: FormInstance, billingLineMetadata: BillingLineMetadata[]) => void;
|
|
13
13
|
}
|
|
14
14
|
interface States {
|
|
15
15
|
dataSource: BillingLineMetadataOverride[];
|
|
16
|
-
editableIndex: number
|
|
16
|
+
editableIndex: number;
|
|
17
17
|
}
|
|
18
18
|
declare class BillingLines extends React.Component<Props, States> {
|
|
19
19
|
columns: EditableColumnProps<BillingLineMetadataOverride>[];
|
|
@@ -21,7 +21,7 @@ declare class BillingLines extends React.Component<Props, States> {
|
|
|
21
21
|
renderCurrencyColumn: (text: string) => string;
|
|
22
22
|
handleDelete: (index: number) => void;
|
|
23
23
|
handleAdd: () => void;
|
|
24
|
-
handleSave: (row: BillingLineMetadataOverride,
|
|
24
|
+
handleSave: (row: BillingLineMetadataOverride, formInstance: FormInstance) => void;
|
|
25
25
|
render(): JSX.Element;
|
|
26
26
|
}
|
|
27
27
|
export default BillingLines;
|
|
@@ -47,21 +47,22 @@ var BillingLines = /** @class */ (function (_super) {
|
|
|
47
47
|
function BillingLines(props) {
|
|
48
48
|
var _this = _super.call(this, props) || this;
|
|
49
49
|
_this.renderCurrencyColumn = function (text) {
|
|
50
|
-
var currency = _this.props.
|
|
50
|
+
var currency = _this.props.formInstance.getFieldValue("baseInformation:currency") ? _this.props.formInstance.getFieldValue("baseInformation:currency") : "";
|
|
51
51
|
return text + " " + currency;
|
|
52
52
|
};
|
|
53
53
|
_this.handleDelete = function (index) {
|
|
54
|
-
var newDataSource = _this.state.dataSource;
|
|
54
|
+
var newDataSource = _this.state.dataSource.slice();
|
|
55
55
|
newDataSource.splice(index, 1);
|
|
56
56
|
_this.setState(function (prevState) { return (__assign({}, prevState, { dataSource: newDataSource })); });
|
|
57
57
|
};
|
|
58
58
|
_this.handleAdd = function () {
|
|
59
59
|
var dataSource = _this.state.dataSource;
|
|
60
60
|
var newData = {
|
|
61
|
+
key: _this.state.editableIndex,
|
|
61
62
|
itemNo: "Item No.",
|
|
62
63
|
quantity: 0,
|
|
63
64
|
taxAmount: 0,
|
|
64
|
-
name: "New
|
|
65
|
+
name: "New Item",
|
|
65
66
|
unitOfMeasure: models_1.UnitOfMeasureMetadataUnitEnum.Piece,
|
|
66
67
|
unitPriceAmount: 0,
|
|
67
68
|
taxCategoryType: models_1.BillingLineMetadataTaxCategoryTypeEnum.StandardRated,
|
|
@@ -69,12 +70,12 @@ var BillingLines = /** @class */ (function (_super) {
|
|
|
69
70
|
taxableAmount: 0,
|
|
70
71
|
taxPercentage: null
|
|
71
72
|
};
|
|
72
|
-
_this.setState(
|
|
73
|
+
_this.setState(__assign({}, _this.state, { dataSource: dataSource.concat([newData]), editableIndex: _this.state.editableIndex + 1 }));
|
|
73
74
|
};
|
|
74
|
-
_this.handleSave = function (row,
|
|
75
|
+
_this.handleSave = function (row, formInstance) {
|
|
75
76
|
var newData = _this.state.dataSource.slice();
|
|
76
77
|
var index = newData.findIndex(function (i) {
|
|
77
|
-
return row.
|
|
78
|
+
return row.key === i.key;
|
|
78
79
|
});
|
|
79
80
|
var item = newData[index];
|
|
80
81
|
newData.splice(index, 1, __assign({}, item, row));
|
|
@@ -83,12 +84,12 @@ var BillingLines = /** @class */ (function (_super) {
|
|
|
83
84
|
unit: current.unitOfMeasure,
|
|
84
85
|
} });
|
|
85
86
|
});
|
|
86
|
-
_this.setState({ dataSource: newData });
|
|
87
|
-
_this.props.setBillingLineMetadata(
|
|
87
|
+
_this.setState(__assign({}, _this.state, { dataSource: newData }));
|
|
88
|
+
_this.props.setBillingLineMetadata(formInstance, billingLineMetadata);
|
|
88
89
|
};
|
|
89
90
|
_this.state = {
|
|
90
91
|
dataSource: [],
|
|
91
|
-
editableIndex:
|
|
92
|
+
editableIndex: 0,
|
|
92
93
|
};
|
|
93
94
|
_this.columns = [
|
|
94
95
|
{
|
|
@@ -168,18 +169,11 @@ var BillingLines = /** @class */ (function (_super) {
|
|
|
168
169
|
editable: col.editable,
|
|
169
170
|
dataIndex: col.dataIndex,
|
|
170
171
|
title: col.title ? col.title.toString() : "",
|
|
171
|
-
handleSave: _this.handleSave,
|
|
172
|
+
handleSave: function (billingLineMetadataOverrideRecord, rowIndex) { return _this.handleSave(billingLineMetadataOverrideRecord, _this.props.formInstance); },
|
|
172
173
|
}); } });
|
|
173
174
|
});
|
|
174
175
|
return (React.createElement(component_container_1.default, { title: "Document Lines", action: React.createElement(antd_1.Button, { onClick: this.handleAdd, type: "primary", style: { marginBottom: 16 } }, "Add a row") },
|
|
175
|
-
React.createElement(antd_1.Table, { components: components, dataSource: dataSource, columns: columns, pagination: false, rowKey: function (record, index) {
|
|
176
|
-
if (index) {
|
|
177
|
-
return (index.toString());
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
return Math.random().toString();
|
|
181
|
-
}
|
|
182
|
-
} })));
|
|
176
|
+
React.createElement(antd_1.Table, { components: components, dataSource: dataSource, columns: columns, pagination: false, rowKey: (function (record, index) { return index.toString(); }) })));
|
|
183
177
|
};
|
|
184
178
|
return BillingLines;
|
|
185
179
|
}(React.Component));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.css";
|
|
@@ -15,14 +15,14 @@ var component_container_1 = __importDefault(require("../component-container"));
|
|
|
15
15
|
var antd_1 = require("antd");
|
|
16
16
|
var DeliveryLocation = function () {
|
|
17
17
|
return (React.createElement(component_container_1.default, { title: "Delivery location" },
|
|
18
|
-
React.createElement(antd_1.Form.Item, { label: "Description", name: "
|
|
18
|
+
React.createElement(antd_1.Form.Item, { label: "Description", name: ["invoice", "delivery", "description"] },
|
|
19
19
|
React.createElement(antd_1.Input, null)),
|
|
20
|
-
React.createElement(antd_1.Form.Item, { label: "Address", name: "
|
|
20
|
+
React.createElement(antd_1.Form.Item, { label: "Address", name: ["invoice", "delivery", "address", "address"] },
|
|
21
21
|
React.createElement(antd_1.Input, null)),
|
|
22
22
|
React.createElement(antd_1.Form.Item, { label: "Post no., town/city", style: { marginBottom: 0 } },
|
|
23
|
-
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, name: "
|
|
23
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, name: ["invoice", "delivery", "locationIdentifier"] },
|
|
24
24
|
React.createElement(antd_1.Input, null)),
|
|
25
|
-
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: "
|
|
25
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: ["invoice", "delivery", "address", "city"] },
|
|
26
26
|
React.createElement(antd_1.Input, null)))));
|
|
27
27
|
};
|
|
28
28
|
exports.default = DeliveryLocation;
|
|
@@ -3,7 +3,7 @@ import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOver
|
|
|
3
3
|
interface EditableCellProps {
|
|
4
4
|
record: BillingLineMetadataOverride;
|
|
5
5
|
handleSave: (billingLineMetadata: BillingLineMetadataOverride) => void;
|
|
6
|
-
dataIndex: keyof BillingLineMetadataOverride
|
|
6
|
+
dataIndex: keyof Omit<BillingLineMetadataOverride, 'key'>;
|
|
7
7
|
editable: boolean;
|
|
8
8
|
index: number;
|
|
9
9
|
}
|
|
@@ -10,6 +10,41 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
13
48
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
49
|
var t = {};
|
|
15
50
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -28,6 +63,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
63
|
result["default"] = mod;
|
|
29
64
|
return result;
|
|
30
65
|
};
|
|
66
|
+
var _this = this;
|
|
31
67
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
68
|
var react_1 = __importStar(require("react"));
|
|
33
69
|
var antd_1 = require("antd");
|
|
@@ -40,11 +76,33 @@ var EditableCell = function (props) {
|
|
|
40
76
|
record = props.record, index = props.index, handleSave = props.handleSave, children = props.children, restProps = __rest(props, ["editable", "dataIndex", "record", "index", "handleSave", "children"]);
|
|
41
77
|
var _a = react_1.useState(false), editing = _a[0], setEditing = _a[1];
|
|
42
78
|
var input = null;
|
|
79
|
+
var form = react_1.useContext(editable_row_1.EditableContext);
|
|
43
80
|
var toggleEdit = function () {
|
|
44
81
|
setEditing(!editing);
|
|
45
82
|
if (!editing && input)
|
|
46
83
|
input.focus();
|
|
47
84
|
};
|
|
85
|
+
var save = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
86
|
+
var values, errInfo_1;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
_a.trys.push([0, 2, , 3]);
|
|
91
|
+
return [4 /*yield*/, form.validateFields()];
|
|
92
|
+
case 1:
|
|
93
|
+
values = _a.sent();
|
|
94
|
+
toggleEdit();
|
|
95
|
+
handleSave(__assign({}, record, values));
|
|
96
|
+
return [3 /*break*/, 3];
|
|
97
|
+
case 2:
|
|
98
|
+
errInfo_1 = _a.sent();
|
|
99
|
+
// tslint:disable-next-line:no-console
|
|
100
|
+
console.log('Save failed:', errInfo_1);
|
|
101
|
+
return [3 /*break*/, 3];
|
|
102
|
+
case 3: return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); };
|
|
48
106
|
var getCorrectInputNode = function (dataIdx) {
|
|
49
107
|
switch (dataIdx) {
|
|
50
108
|
case "quantity":
|
|
@@ -54,22 +112,32 @@ var EditableCell = function (props) {
|
|
|
54
112
|
case "taxPercentage":
|
|
55
113
|
case "discountValue":
|
|
56
114
|
case "accountingCost":
|
|
57
|
-
return react_1.default.createElement(antd_1.InputNumber, { step: 0.01
|
|
115
|
+
return react_1.default.createElement(antd_1.InputNumber, { step: 0.01,
|
|
116
|
+
// ref={node => (input = node)}
|
|
117
|
+
// onPressEnter={save}
|
|
118
|
+
onBlur: save });
|
|
58
119
|
case "unitOfMeasure":
|
|
59
|
-
return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true
|
|
120
|
+
return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true,
|
|
121
|
+
// onSelect={save}
|
|
122
|
+
onBlur: save }, Object.keys(models_1.UnitOfMeasureMetadataUnitEnum).map(function (unitOfMeasure) {
|
|
60
123
|
return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, unitOfMeasure));
|
|
61
124
|
})));
|
|
62
125
|
case "taxCategoryType":
|
|
63
|
-
return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true
|
|
126
|
+
return (react_1.default.createElement(antd_1.Select, { ref: function (node) { return (input = node); }, defaultActiveFirstOption: true,
|
|
127
|
+
// onSelect={save}
|
|
128
|
+
onBlur: save }, Object.keys(models_1.BillingLineMetadataTaxCategoryTypeEnum).map(function (taxCategoryType) {
|
|
64
129
|
return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
|
|
65
130
|
})));
|
|
66
131
|
default:
|
|
67
|
-
return react_1.default.createElement(antd_1.Input, { ref: function (node) { return (input = node); }
|
|
132
|
+
return react_1.default.createElement(antd_1.Input, { ref: function (node) { return (input = node); },
|
|
133
|
+
// onPressEnter={save}
|
|
134
|
+
onBlur: save });
|
|
68
135
|
}
|
|
69
136
|
};
|
|
70
137
|
var renderCell = function () {
|
|
71
138
|
var inputNode = getCorrectInputNode(dataIndex);
|
|
72
|
-
|
|
139
|
+
var rules = validationRules_1.validationRules[dataIndex];
|
|
140
|
+
return editing ? (react_1.default.createElement(antd_1.Form.Item, { style: { margin: 0 }, rules: rules, name: dataIndex, initialValue: record[dataIndex] }, inputNode)) : (react_1.default.createElement("div", { className: "editable-cell-value-wrap", style: { paddingRight: 24 }, onClick: toggleEdit }, children));
|
|
73
141
|
};
|
|
74
142
|
return (react_1.default.createElement("td", __assign({}, restProps), editable ? (react_1.default.createElement(editable_row_1.EditableContext.Consumer, null, renderCell)) : (children)));
|
|
75
143
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export declare const EditableContext: React.Context<
|
|
5
|
-
declare const
|
|
6
|
-
export default
|
|
2
|
+
import 'antd/dist/antd.css';
|
|
3
|
+
import { FormInstance } from "antd/lib/form";
|
|
4
|
+
export declare const EditableContext: React.Context<FormInstance>;
|
|
5
|
+
declare const EditableRow: ({ index, ...props }: any) => JSX.Element;
|
|
6
|
+
export default EditableRow;
|
|
@@ -30,12 +30,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
var React = __importStar(require("react"));
|
|
33
|
-
var
|
|
34
|
-
require("
|
|
33
|
+
var antd_1 = require("antd");
|
|
34
|
+
require("antd/dist/antd.css");
|
|
35
35
|
exports.EditableContext = React.createContext({});
|
|
36
36
|
var EditableRow = function (_a) {
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
var index = _a.index, props = __rest(_a, ["index"]);
|
|
38
|
+
var form = antd_1.Form.useForm()[0];
|
|
39
|
+
return React.createElement(antd_1.Form, { form: form, component: false },
|
|
40
|
+
React.createElement(exports.EditableContext.Provider, { value: form },
|
|
41
|
+
React.createElement("tr", __assign({}, props))));
|
|
40
42
|
};
|
|
41
|
-
exports.default =
|
|
43
|
+
exports.default = EditableRow;
|
|
@@ -13,33 +13,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
var React = __importStar(require("react"));
|
|
14
14
|
var component_container_1 = __importDefault(require("../component-container"));
|
|
15
15
|
var antd_1 = require("antd");
|
|
16
|
+
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
16
17
|
var Payer = function () {
|
|
17
18
|
return (React.createElement(component_container_1.default, { title: "Payer" },
|
|
18
|
-
React.createElement(antd_1.Form.Item, { label: "Name/
|
|
19
|
-
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "50%" }, name: "
|
|
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: [
|
|
20
21
|
{
|
|
21
|
-
required:
|
|
22
|
+
required: ReceiverRequirements_1.getReceiverRequirements(ReceiverRequirements_1.receiverRequirementsObject, ReceiverRequirements_1.AvailableFields["payer.name"]).isRequired,
|
|
22
23
|
message: 'Please input payer name',
|
|
23
24
|
},
|
|
24
25
|
] },
|
|
25
26
|
React.createElement(antd_1.Input, null)),
|
|
26
|
-
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "50%", paddingLeft: "3px" }, name: "
|
|
27
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "50%", paddingLeft: "3px" }, name: ["invoice", "customer", "isoIdentifier"], rules: [
|
|
27
28
|
{
|
|
28
29
|
required: true,
|
|
29
30
|
message: 'Please input payer identifier',
|
|
30
31
|
},
|
|
31
32
|
] },
|
|
32
33
|
React.createElement(antd_1.Input, null))),
|
|
33
|
-
React.createElement(antd_1.Form.Item, { label: "Address", name: "
|
|
34
|
+
React.createElement(antd_1.Form.Item, { label: "Address", name: ["invoice", "customer", "address", "address"] },
|
|
34
35
|
React.createElement(antd_1.Input, null)),
|
|
35
36
|
React.createElement(antd_1.Form.Item, { label: "Zip/City" },
|
|
36
|
-
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, name: "
|
|
37
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, name: ["invoice", "customer", "address", "zip"] },
|
|
37
38
|
React.createElement(antd_1.Input, null)),
|
|
38
|
-
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: "
|
|
39
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: ["invoice", "customer", "address", "city"] },
|
|
39
40
|
React.createElement(antd_1.Input, null))),
|
|
40
|
-
React.createElement(antd_1.Form.Item, { label: "Country", name: "
|
|
41
|
+
React.createElement(antd_1.Form.Item, { label: "Country", name: ["invoice", "customer", "address", "country"] },
|
|
41
42
|
React.createElement(antd_1.Input, null)),
|
|
42
|
-
React.createElement(antd_1.Form.Item, { label: "E-mail", name: "
|
|
43
|
+
React.createElement(antd_1.Form.Item, { label: "E-mail", name: ["invoice", "customer", "contact", "email"], rules: [
|
|
43
44
|
{
|
|
44
45
|
type: 'email',
|
|
45
46
|
message: 'The input is not valid E-mail!',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BillingLineMetadataOverride } from "../types/BillingLineMetadataOverride";
|
|
2
2
|
import { Rule } from "rc-field-form/lib/interface";
|
|
3
|
-
declare type ValidationRulesObject = {
|
|
4
|
-
[key in keyof BillingLineMetadataOverride]: Rule[];
|
|
3
|
+
export declare type ValidationRulesObject = {
|
|
4
|
+
[key in keyof Omit<BillingLineMetadataOverride, 'key'>]: Rule[];
|
|
5
5
|
};
|
|
6
6
|
export declare const validationRules: ValidationRulesObject;
|
|
7
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BillingLineMetadata, UnitOfMeasureMetadataUnitEnum } from "@unimaze/api-clients/lib/mapi/models";
|
|
2
2
|
export interface BillingLineMetadataOverride extends Omit<BillingLineMetadata, 'unitOfMeasure'> {
|
|
3
|
+
key: number;
|
|
3
4
|
unitOfMeasure: UnitOfMeasureMetadataUnitEnum;
|
|
4
5
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface KeyValuePair {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface FieldRequirement {
|
|
6
|
+
label?: string;
|
|
7
|
+
key: string;
|
|
8
|
+
isRequired: boolean;
|
|
9
|
+
values?: KeyValuePair[];
|
|
10
|
+
}
|
|
11
|
+
declare type ReceiverRequirements = {
|
|
12
|
+
[key in AvailableFields]?: FieldRequirement;
|
|
13
|
+
};
|
|
14
|
+
export declare enum AvailableFields {
|
|
15
|
+
'invoiceNo' = "invoiceNo",
|
|
16
|
+
'issueDate' = "issueDate",
|
|
17
|
+
'dueDate' = "dueDate",
|
|
18
|
+
'currencyCode' = "currencyCode",
|
|
19
|
+
'payer.name' = "payer.name",
|
|
20
|
+
'payer.identifier' = "payer.identifier",
|
|
21
|
+
'customer.name' = "customer.name",
|
|
22
|
+
'customer.identifier' = "customer.identifier"
|
|
23
|
+
}
|
|
24
|
+
export { ReceiverRequirements };
|
|
25
|
+
export declare const receiverRequirementsObject: ReceiverRequirements;
|
|
26
|
+
export declare const getReceiverRequirements: (recRequirements: ReceiverRequirements, key: AvailableFields) => FieldRequirement;
|
|
27
|
+
export declare const getReceiverRequirementsLabelWithDefault: (recRequirements: ReceiverRequirements, key: AvailableFields, defaultLabel: string) => string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var AvailableFields;
|
|
4
|
+
(function (AvailableFields) {
|
|
5
|
+
AvailableFields["invoiceNo"] = "invoiceNo";
|
|
6
|
+
AvailableFields["issueDate"] = "issueDate";
|
|
7
|
+
AvailableFields["dueDate"] = "dueDate";
|
|
8
|
+
AvailableFields["currencyCode"] = "currencyCode";
|
|
9
|
+
AvailableFields["payer.name"] = "payer.name";
|
|
10
|
+
AvailableFields["payer.identifier"] = "payer.identifier";
|
|
11
|
+
AvailableFields["customer.name"] = "customer.name";
|
|
12
|
+
AvailableFields["customer.identifier"] = "customer.identifier";
|
|
13
|
+
})(AvailableFields = exports.AvailableFields || (exports.AvailableFields = {}));
|
|
14
|
+
exports.receiverRequirementsObject = {
|
|
15
|
+
"payer.name": {
|
|
16
|
+
isRequired: true,
|
|
17
|
+
key: "",
|
|
18
|
+
label: "Payer name"
|
|
19
|
+
},
|
|
20
|
+
"payer.identifier": {
|
|
21
|
+
isRequired: true,
|
|
22
|
+
key: "",
|
|
23
|
+
label: "Identifier"
|
|
24
|
+
},
|
|
25
|
+
"customer.name": {
|
|
26
|
+
isRequired: true,
|
|
27
|
+
key: "",
|
|
28
|
+
label: "Name"
|
|
29
|
+
},
|
|
30
|
+
"customer.identifier": {
|
|
31
|
+
isRequired: true,
|
|
32
|
+
key: "",
|
|
33
|
+
label: "Identifier"
|
|
34
|
+
},
|
|
35
|
+
dueDate: {
|
|
36
|
+
isRequired: true,
|
|
37
|
+
label: "Due date",
|
|
38
|
+
key: ""
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.getReceiverRequirements = function (recRequirements, key) {
|
|
42
|
+
return recRequirements[key];
|
|
43
|
+
};
|
|
44
|
+
exports.getReceiverRequirementsLabelWithDefault = function (recRequirements, key, defaultLabel) {
|
|
45
|
+
if (recRequirements[key].label) {
|
|
46
|
+
return recRequirements[key].label;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return defaultLabel;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -21,7 +21,6 @@ var antd_1 = require("antd");
|
|
|
21
21
|
var payer_1 = __importDefault(require("../common/components/payer"));
|
|
22
22
|
var issuer_1 = __importDefault(require("../common/components/issuer"));
|
|
23
23
|
var base_information_1 = __importDefault(require("../common/components/base-information"));
|
|
24
|
-
var billing_lines_1 = __importDefault(require("../common/components/billing-lines"));
|
|
25
24
|
var attachments_1 = __importDefault(require("../common/components/attachments"));
|
|
26
25
|
// const [createCorrectWithCreditRequest, setCreateCorrectWithCreditRequest] = useState<CreateCorrectWithCreditRequest>(
|
|
27
26
|
// {
|
|
@@ -62,8 +61,7 @@ var CreateInvoice = function (props) {
|
|
|
62
61
|
react_1.default.createElement(issuer_1.default, { issuer: props.issuer })),
|
|
63
62
|
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 12 }, xl: { span: 8 } },
|
|
64
63
|
react_1.default.createElement(base_information_1.default, { form: form, documentType: "creditNote" })),
|
|
65
|
-
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 24 }, xl: { span: 16 } },
|
|
66
|
-
react_1.default.createElement(billing_lines_1.default, { setBillingLineMetadata: handleSetBillingLineMetadata, form: form })),
|
|
64
|
+
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 24 }, xl: { span: 16 } }),
|
|
67
65
|
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 24 }, xl: { span: 24 } },
|
|
68
66
|
react_1.default.createElement(attachments_1.default, null)),
|
|
69
67
|
react_1.default.createElement(antd_1.Col, { span: 24 },
|
|
@@ -24,16 +24,17 @@ var payer_1 = __importDefault(require("../common/components/payer"));
|
|
|
24
24
|
var issuer_1 = __importDefault(require("../common/components/issuer"));
|
|
25
25
|
var delivery_location_1 = __importDefault(require("../common/components/delivery-location"));
|
|
26
26
|
var payment_method_1 = __importDefault(require("../common/components/payment-method"));
|
|
27
|
-
var attachments_1 = __importDefault(require("../common/components/attachments"));
|
|
28
27
|
var base_information_1 = __importDefault(require("../common/components/base-information"));
|
|
29
28
|
var billing_lines_1 = __importDefault(require("../common/components/billing-lines"));
|
|
29
|
+
var utils_1 = require("../utils");
|
|
30
|
+
var uuid_1 = require("uuid");
|
|
30
31
|
/**
|
|
31
32
|
* Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
|
|
32
33
|
*
|
|
33
34
|
* @component
|
|
34
35
|
*/
|
|
35
36
|
var CreateInvoice = function (props) {
|
|
36
|
-
// const [submitInvoiceRequest, setSubmitInvoiceRequest] = useState<CreateSubmitInvoiceRequest>();
|
|
37
|
+
// const [submitInvoiceRequest, setSubmitInvoiceRequest] = React.useState<CreateSubmitInvoiceRequest>();
|
|
37
38
|
var form = antd_1.Form.useForm()[0];
|
|
38
39
|
var formItemLayout = {
|
|
39
40
|
labelCol: {
|
|
@@ -47,12 +48,21 @@ var CreateInvoice = function (props) {
|
|
|
47
48
|
};
|
|
48
49
|
var handleSetBillingLineMetadata = function (formInstance, billingLineMetadata) {
|
|
49
50
|
formInstance.setFieldsValue({
|
|
50
|
-
"
|
|
51
|
+
"billingLinesMetadata": billingLineMetadata
|
|
51
52
|
});
|
|
52
53
|
};
|
|
53
54
|
var handleSubmit = function (values) {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
var invoiceMetadataInput = utils_1.convertToInvoiceMetadataInput(values, props.issuer);
|
|
56
|
+
var createSubmitInvoice = {
|
|
57
|
+
invoiceMetadataInput: invoiceMetadataInput,
|
|
58
|
+
more: false,
|
|
59
|
+
messageId: uuid_1.v4(),
|
|
60
|
+
};
|
|
61
|
+
utils_1.submitInvoice(createSubmitInvoice, props.mapiBaseUrl, props.apiKey, "submitInvoice", props.language)
|
|
62
|
+
.then(antd_1.message.success("successfully submitted the invoice"))
|
|
63
|
+
.catch(function (error) {
|
|
64
|
+
antd_1.message.error(error);
|
|
65
|
+
});
|
|
56
66
|
};
|
|
57
67
|
var setLocale = function (language) {
|
|
58
68
|
switch (language) {
|
|
@@ -65,7 +75,7 @@ var CreateInvoice = function (props) {
|
|
|
65
75
|
}
|
|
66
76
|
};
|
|
67
77
|
return (react_1.default.createElement(antd_1.ConfigProvider, { locale: setLocale(props.language), componentSize: "small" },
|
|
68
|
-
react_1.default.createElement(antd_1.Form, __assign({}, formItemLayout, { onFinish: handleSubmit }),
|
|
78
|
+
react_1.default.createElement(antd_1.Form, __assign({}, formItemLayout, { form: form, onFinish: handleSubmit, initialValues: { abc: "abc" } }),
|
|
69
79
|
react_1.default.createElement("h1", null, "Invoice"),
|
|
70
80
|
react_1.default.createElement(antd_1.Row, { gutter: [16, 16] },
|
|
71
81
|
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 12 }, xl: { span: 8 } },
|
|
@@ -77,11 +87,10 @@ var CreateInvoice = function (props) {
|
|
|
77
87
|
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 12 }, xl: { span: 8 } },
|
|
78
88
|
react_1.default.createElement(base_information_1.default, { form: form, documentType: "invoice" })),
|
|
79
89
|
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 24 }, xl: { span: 16 } },
|
|
80
|
-
react_1.default.createElement(billing_lines_1.default, { setBillingLineMetadata: handleSetBillingLineMetadata,
|
|
90
|
+
react_1.default.createElement(billing_lines_1.default, { setBillingLineMetadata: handleSetBillingLineMetadata, formInstance: form })),
|
|
81
91
|
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 }, xl: { span: 8 } },
|
|
82
92
|
react_1.default.createElement(payment_method_1.default, null)),
|
|
83
|
-
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 16 }, xl: { span: 16 } },
|
|
84
|
-
react_1.default.createElement(attachments_1.default, null)),
|
|
93
|
+
react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 16 }, xl: { span: 16 } }),
|
|
85
94
|
react_1.default.createElement(antd_1.Col, { span: 24 },
|
|
86
95
|
react_1.default.createElement(antd_1.Form.Item, null,
|
|
87
96
|
react_1.default.createElement(antd_1.Button, { type: "primary", htmlType: "submit" }, "Submit")))))));
|