@unimaze/billing 0.1.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.
- package/LICENSE.txt +1 -0
- package/README.md +14 -0
- package/lib/common/components/attachments/Attachment.d.ts +15 -0
- package/lib/common/components/attachments/Attachment.js +78 -0
- package/lib/common/components/attachments/index.d.ts +3 -0
- package/lib/common/components/attachments/index.js +22 -0
- package/lib/common/components/base-information/index.d.ts +9 -0
- package/lib/common/components/base-information/index.js +112 -0
- package/lib/common/components/billing-lines/index.d.ts +27 -0
- package/lib/common/components/billing-lines/index.js +186 -0
- package/lib/common/components/component-container/Content.d.ts +7 -0
- package/lib/common/components/component-container/Content.js +13 -0
- package/lib/common/components/component-container/Header.d.ts +9 -0
- package/lib/common/components/component-container/Header.js +28 -0
- package/lib/common/components/component-container/index.d.ts +10 -0
- package/lib/common/components/component-container/index.js +20 -0
- package/lib/common/components/delivery-location/index.d.ts +3 -0
- package/lib/common/components/delivery-location/index.js +28 -0
- package/lib/common/components/editable-cell/index.d.ts +11 -0
- package/lib/common/components/editable-cell/index.js +76 -0
- package/lib/common/components/editable-row/index.d.ts +6 -0
- package/lib/common/components/editable-row/index.js +41 -0
- package/lib/common/components/index.d.ts +5 -0
- package/lib/common/components/index.js +10 -0
- package/lib/common/components/issuer/index.d.ts +7 -0
- package/lib/common/components/issuer/index.js +28 -0
- package/lib/common/components/payer/index.d.ts +3 -0
- package/lib/common/components/payer/index.js +50 -0
- package/lib/common/components/payment-method/index.d.ts +3 -0
- package/lib/common/components/payment-method/index.js +73 -0
- package/lib/common/consts/validationRules.d.ts +7 -0
- package/lib/common/consts/validationRules.js +67 -0
- package/lib/common/enums/DocumentTypeEnum.d.ts +5 -0
- package/lib/common/enums/DocumentTypeEnum.js +8 -0
- package/lib/common/enums/index.d.ts +1 -0
- package/lib/common/enums/index.js +6 -0
- package/lib/common/types/BillingLineMetadataOverride.d.ts +4 -0
- package/lib/common/types/BillingLineMetadataOverride.js +2 -0
- package/lib/common/types/CommonProps.d.ts +7 -0
- package/lib/common/types/CommonProps.js +2 -0
- package/lib/common/types/InvoiceFormFields.d.ts +1 -0
- package/lib/common/types/InvoiceFormFields.js +2 -0
- package/lib/common/types/index.d.ts +1 -0
- package/lib/common/types/index.js +2 -0
- package/lib/create-credit-note/index.d.ts +9 -0
- package/lib/create-credit-note/index.js +75 -0
- package/lib/create-invoice/index.d.ts +15 -0
- package/lib/create-invoice/index.js +89 -0
- package/lib/example/src/index.d.ts +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +9 -0
- package/lib/style/index.css +1269 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +164 -0
- package/package.json +82 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Unimaze license
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
## Components ##
|
|
4
|
+
### `<CreateInvoice>` ###
|
|
5
|
+
|
|
6
|
+
Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
|
|
7
|
+
|
|
8
|
+
|Property |Description |Type |Default |
|
|
9
|
+
|:----------------------|:------------------------------------------------------|:------------------------------------------------------|:----------|
|
|
10
|
+
|issuer |Sets the Invoice issuer |Object `ProfileOutput` | |
|
|
11
|
+
|language |Sets the language of the component |`en` `is` `pl` `undefined` |`en` |
|
|
12
|
+
|mapiBaseUrl |Url of the MAPI |string | |
|
|
13
|
+
|rapiBaseUrl |Url of the RAPI |string | |
|
|
14
|
+
|apiKey |MAPI api key |string | |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import '@ant-design/compatible/assets/index.css';
|
|
3
|
+
interface Props {
|
|
4
|
+
fieldName: string;
|
|
5
|
+
}
|
|
6
|
+
interface States {
|
|
7
|
+
file: any[];
|
|
8
|
+
}
|
|
9
|
+
declare class Attachment extends React.Component<Props, States> {
|
|
10
|
+
constructor(props: Props);
|
|
11
|
+
handleRemoveFile: () => void;
|
|
12
|
+
normFile: (e: any) => any;
|
|
13
|
+
render(): JSX.Element;
|
|
14
|
+
}
|
|
15
|
+
export default Attachment;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
30
|
+
result["default"] = mod;
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
var React = __importStar(require("react"));
|
|
35
|
+
require("@ant-design/compatible/assets/index.css");
|
|
36
|
+
var antd_1 = require("antd");
|
|
37
|
+
var Attachment = /** @class */ (function (_super) {
|
|
38
|
+
__extends(Attachment, _super);
|
|
39
|
+
function Attachment(props) {
|
|
40
|
+
var _this = _super.call(this, props) || this;
|
|
41
|
+
_this.handleRemoveFile = function () {
|
|
42
|
+
_this.setState(function (prevStates) { return (__assign({}, prevStates, { file: [] })); });
|
|
43
|
+
};
|
|
44
|
+
_this.normFile = function (e) {
|
|
45
|
+
if (Array.isArray(e)) {
|
|
46
|
+
return e;
|
|
47
|
+
}
|
|
48
|
+
_this.setState(function (prevStates) { return (__assign({}, prevStates, { file: e && e.fileList })); });
|
|
49
|
+
return e && e.fileList;
|
|
50
|
+
};
|
|
51
|
+
_this.state = {
|
|
52
|
+
file: [],
|
|
53
|
+
};
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
Attachment.prototype.render = function () {
|
|
57
|
+
return (React.createElement(React.Fragment, null,
|
|
58
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: "Reference", name: "attachment:" + this.props.fieldName + ":reference", rules: [
|
|
59
|
+
{
|
|
60
|
+
required: this.state.file.length > 0,
|
|
61
|
+
message: 'Please input the reference',
|
|
62
|
+
}
|
|
63
|
+
] },
|
|
64
|
+
React.createElement(antd_1.Input, null)),
|
|
65
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "30%" }, label: "Description", name: "attachment:" + this.props.fieldName + ":description", rules: [
|
|
66
|
+
{
|
|
67
|
+
required: this.state.file.length > 0,
|
|
68
|
+
message: 'Please input the description',
|
|
69
|
+
}
|
|
70
|
+
] },
|
|
71
|
+
React.createElement(antd_1.Input, null)),
|
|
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
|
+
",")));
|
|
75
|
+
};
|
|
76
|
+
return Attachment;
|
|
77
|
+
}(React.Component));
|
|
78
|
+
exports.default = Attachment;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 Attachment_1 = __importDefault(require("./Attachment"));
|
|
16
|
+
var AttachmentsGroup = function (props) {
|
|
17
|
+
return (React.createElement(component_container_1.default, { title: "Attachments" },
|
|
18
|
+
React.createElement(Attachment_1.default, { fieldName: "file1" }),
|
|
19
|
+
React.createElement(Attachment_1.default, { fieldName: "file2" }),
|
|
20
|
+
React.createElement(Attachment_1.default, { fieldName: "file3" })));
|
|
21
|
+
};
|
|
22
|
+
exports.default = AttachmentsGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import '@ant-design/compatible/assets/index.css';
|
|
3
|
+
import { FormInstance } from "antd/es/form";
|
|
4
|
+
interface Props {
|
|
5
|
+
form: FormInstance;
|
|
6
|
+
documentType: "creditNote" | "invoice";
|
|
7
|
+
}
|
|
8
|
+
declare const BaseInformation: React.FC<Props>;
|
|
9
|
+
export default BaseInformation;
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
require("@ant-design/compatible/assets/index.css");
|
|
16
|
+
var antd_1 = require("antd");
|
|
17
|
+
var BaseInformation = function (props) {
|
|
18
|
+
var currencies = [
|
|
19
|
+
{
|
|
20
|
+
value: "ISK",
|
|
21
|
+
display: "Icelandic krona (ISK)"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "DKK",
|
|
25
|
+
display: "Danish krona (DKK)"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "NOK",
|
|
29
|
+
display: "Norwegian krona (NOK)"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: "SEK",
|
|
33
|
+
display: "Swedish krona (SEK)"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: "EUR",
|
|
37
|
+
display: "Euro (EUR)"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: "USD",
|
|
41
|
+
display: "US dollar (USD)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: "GBP",
|
|
45
|
+
display: "British pound (GBP)"
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
var disabledDate = function (dueDate, issueDate) {
|
|
49
|
+
return dueDate < issueDate;
|
|
50
|
+
};
|
|
51
|
+
var checkIfEmpty = function (date) {
|
|
52
|
+
if (!date) {
|
|
53
|
+
props.form.resetFields(["baseInformation:dueDate"]);
|
|
54
|
+
props.form.validateFields(["baseInformation:dueDate"]).then(function (values) {
|
|
55
|
+
// console.log(values);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var getDocumentNoLabel = function (documentType) {
|
|
60
|
+
switch (documentType) {
|
|
61
|
+
case "creditNote":
|
|
62
|
+
return "Credit note no.";
|
|
63
|
+
case "invoice":
|
|
64
|
+
return "Invoice no.";
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return (React.createElement(component_container_1.default, { title: "Base information" },
|
|
68
|
+
React.createElement(antd_1.Form.Item, { label: getDocumentNoLabel(props.documentType), name: "baseInformation:invoiceNo" },
|
|
69
|
+
React.createElement(antd_1.Input, null)),
|
|
70
|
+
React.createElement(antd_1.Form.Item, { label: "Issue date", rules: [
|
|
71
|
+
{
|
|
72
|
+
required: true,
|
|
73
|
+
message: 'Please input the issue date',
|
|
74
|
+
},
|
|
75
|
+
], name: "baseInformation:issueDate" },
|
|
76
|
+
React.createElement(antd_1.DatePicker, null)),
|
|
77
|
+
props.documentType === "invoice" &&
|
|
78
|
+
React.createElement(React.Fragment, null,
|
|
79
|
+
React.createElement(antd_1.Form.Item, { label: "Due date", name: "baseInformation:dueDate", rules: [
|
|
80
|
+
{
|
|
81
|
+
validator: (function (rule, value, callback) {
|
|
82
|
+
if (!value) {
|
|
83
|
+
callback();
|
|
84
|
+
}
|
|
85
|
+
var issueDate = props.form.getFieldValue("baseInformation:issueDate");
|
|
86
|
+
value < issueDate
|
|
87
|
+
? callback("Due date must be after the issue date")
|
|
88
|
+
: callback();
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
] },
|
|
92
|
+
React.createElement(antd_1.DatePicker, { onChange: checkIfEmpty, disabledDate: (function (current) { return disabledDate(current, props.form.getFieldValue("baseInformation:issueDate")); }) })),
|
|
93
|
+
React.createElement(antd_1.Form.Item, { label: "Last payment date", name: "baseInformation:lastPaymentDate" },
|
|
94
|
+
React.createElement(antd_1.DatePicker, null))),
|
|
95
|
+
props.documentType === "creditNote" &&
|
|
96
|
+
React.createElement(antd_1.Form.Item, { label: "Invoice no", name: "baseInformation:invoiceReferenceNo", rules: [
|
|
97
|
+
{
|
|
98
|
+
required: true,
|
|
99
|
+
message: "Please input the invoice no."
|
|
100
|
+
}
|
|
101
|
+
] },
|
|
102
|
+
React.createElement(antd_1.Input, null)),
|
|
103
|
+
React.createElement(antd_1.Form.Item, { label: "Order no", name: "baseInformation:orderNo" },
|
|
104
|
+
React.createElement(antd_1.Input, null)),
|
|
105
|
+
React.createElement(antd_1.Form.Item, { label: "Notes", name: "baseInformation:notes" },
|
|
106
|
+
React.createElement(antd_1.Input.TextArea, null)),
|
|
107
|
+
React.createElement(antd_1.Form.Item, { label: "Currency", name: "baseInformation:currency" },
|
|
108
|
+
React.createElement(antd_1.Select, { defaultActiveFirstOption: true }, currencies.map(function (currency) {
|
|
109
|
+
return React.createElement(antd_1.Select.Option, { value: currency.value, title: currency.display, key: currency.value }, currency.display);
|
|
110
|
+
})))));
|
|
111
|
+
};
|
|
112
|
+
exports.default = BaseInformation;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import '@ant-design/compatible/assets/index.css';
|
|
3
|
+
import { BillingLineMetadata } from "../../../../../npm-unimaze-api-clients/lib/mapi/models";
|
|
4
|
+
import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOverride";
|
|
5
|
+
import { FormInstance } from "antd/es/form";
|
|
6
|
+
import { ColumnType } from 'antd/es/table';
|
|
7
|
+
interface EditableColumnProps<T> extends ColumnType<T> {
|
|
8
|
+
editable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface Props {
|
|
11
|
+
form: FormInstance;
|
|
12
|
+
setBillingLineMetadata: (form: FormInstance, billingLineMetadata: BillingLineMetadata[]) => void;
|
|
13
|
+
}
|
|
14
|
+
interface States {
|
|
15
|
+
dataSource: BillingLineMetadataOverride[];
|
|
16
|
+
editableIndex: number | null;
|
|
17
|
+
}
|
|
18
|
+
declare class BillingLines extends React.Component<Props, States> {
|
|
19
|
+
columns: EditableColumnProps<BillingLineMetadataOverride>[];
|
|
20
|
+
constructor(props: Props);
|
|
21
|
+
renderCurrencyColumn: (text: string) => string;
|
|
22
|
+
handleDelete: (index: number) => void;
|
|
23
|
+
handleAdd: () => void;
|
|
24
|
+
handleSave: (row: BillingLineMetadataOverride, form: FormInstance) => void;
|
|
25
|
+
render(): JSX.Element;
|
|
26
|
+
}
|
|
27
|
+
export default BillingLines;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
30
|
+
result["default"] = mod;
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
var React = __importStar(require("react"));
|
|
38
|
+
var component_container_1 = __importDefault(require("../component-container"));
|
|
39
|
+
var icons_1 = require("@ant-design/icons");
|
|
40
|
+
require("@ant-design/compatible/assets/index.css");
|
|
41
|
+
var antd_1 = require("antd");
|
|
42
|
+
var models_1 = require("../../../../../npm-unimaze-api-clients/lib/mapi/models");
|
|
43
|
+
var editable_cell_1 = __importDefault(require("../editable-cell"));
|
|
44
|
+
var editable_row_1 = __importDefault(require("../editable-row"));
|
|
45
|
+
var BillingLines = /** @class */ (function (_super) {
|
|
46
|
+
__extends(BillingLines, _super);
|
|
47
|
+
function BillingLines(props) {
|
|
48
|
+
var _this = _super.call(this, props) || this;
|
|
49
|
+
_this.renderCurrencyColumn = function (text) {
|
|
50
|
+
var currency = _this.props.form.getFieldValue("baseInformation:currency") ? _this.props.form.getFieldValue("baseInformation:currency") : "";
|
|
51
|
+
return text + " " + currency;
|
|
52
|
+
};
|
|
53
|
+
_this.handleDelete = function (index) {
|
|
54
|
+
var newDataSource = _this.state.dataSource;
|
|
55
|
+
newDataSource.splice(index, 1);
|
|
56
|
+
_this.setState(function (prevState) { return (__assign({}, prevState, { dataSource: newDataSource })); });
|
|
57
|
+
};
|
|
58
|
+
_this.handleAdd = function () {
|
|
59
|
+
var dataSource = _this.state.dataSource;
|
|
60
|
+
var newData = {
|
|
61
|
+
itemNo: "Item No.",
|
|
62
|
+
quantity: 0,
|
|
63
|
+
taxAmount: 0,
|
|
64
|
+
name: "New item",
|
|
65
|
+
unitOfMeasure: models_1.UnitOfMeasureMetadataUnitEnum.Piece,
|
|
66
|
+
unitPriceAmount: 0,
|
|
67
|
+
taxCategoryType: models_1.BillingLineMetadataTaxCategoryTypeEnum.StandardRated,
|
|
68
|
+
discountValue: "0",
|
|
69
|
+
taxableAmount: 0,
|
|
70
|
+
taxPercentage: null
|
|
71
|
+
};
|
|
72
|
+
_this.setState(function (prevState) { return (__assign({}, prevState, { dataSource: prevState.dataSource.concat([newData]), editableIndex: prevState.dataSource.length + 1 })); });
|
|
73
|
+
};
|
|
74
|
+
_this.handleSave = function (row, form) {
|
|
75
|
+
var newData = _this.state.dataSource.slice();
|
|
76
|
+
var index = newData.findIndex(function (i) {
|
|
77
|
+
return row.itemNo === i.itemNo;
|
|
78
|
+
});
|
|
79
|
+
var item = newData[index];
|
|
80
|
+
newData.splice(index, 1, __assign({}, item, row));
|
|
81
|
+
var billingLineMetadata = newData.map(function (current) {
|
|
82
|
+
return __assign({}, current, { unitOfMeasure: {
|
|
83
|
+
unit: current.unitOfMeasure,
|
|
84
|
+
} });
|
|
85
|
+
});
|
|
86
|
+
_this.setState({ dataSource: newData });
|
|
87
|
+
_this.props.setBillingLineMetadata(form, billingLineMetadata);
|
|
88
|
+
};
|
|
89
|
+
_this.state = {
|
|
90
|
+
dataSource: [],
|
|
91
|
+
editableIndex: null,
|
|
92
|
+
};
|
|
93
|
+
_this.columns = [
|
|
94
|
+
{
|
|
95
|
+
title: "Item No",
|
|
96
|
+
dataIndex: 'itemNo',
|
|
97
|
+
editable: true,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
title: "Name",
|
|
101
|
+
dataIndex: 'name',
|
|
102
|
+
editable: true,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
title: "Quantity",
|
|
106
|
+
dataIndex: 'quantity',
|
|
107
|
+
editable: true,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: "Unit of measure",
|
|
111
|
+
dataIndex: 'unitOfMeasure',
|
|
112
|
+
editable: true,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
title: "Unit price amount",
|
|
116
|
+
dataIndex: 'unitPriceAmount',
|
|
117
|
+
editable: true,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
title: "Tax category",
|
|
121
|
+
dataIndex: 'taxCategoryType',
|
|
122
|
+
editable: true,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
title: "Discount",
|
|
126
|
+
dataIndex: 'discountValue',
|
|
127
|
+
editable: true,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
title: "Line amount",
|
|
131
|
+
dataIndex: 'taxableAmount',
|
|
132
|
+
render: function (text, record) {
|
|
133
|
+
var lineAmount = 0;
|
|
134
|
+
if (record.quantity && record.unitPriceAmount) {
|
|
135
|
+
lineAmount = record.quantity * record.unitPriceAmount;
|
|
136
|
+
}
|
|
137
|
+
return (React.createElement("span", null, lineAmount));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
title: "",
|
|
142
|
+
render: function (text, record, index) {
|
|
143
|
+
return React.createElement(React.Fragment, null,
|
|
144
|
+
React.createElement(icons_1.DeleteOutlined, { onClick: function () {
|
|
145
|
+
_this.handleDelete(index);
|
|
146
|
+
} }));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
return _this;
|
|
151
|
+
}
|
|
152
|
+
BillingLines.prototype.render = function () {
|
|
153
|
+
var _this = this;
|
|
154
|
+
var dataSource = this.state.dataSource;
|
|
155
|
+
// console.log(dataSource);
|
|
156
|
+
var components = {
|
|
157
|
+
body: {
|
|
158
|
+
row: editable_row_1.default,
|
|
159
|
+
cell: editable_cell_1.default,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
var columns = this.columns.map(function (col) {
|
|
163
|
+
if (!col.editable) {
|
|
164
|
+
return col;
|
|
165
|
+
}
|
|
166
|
+
return __assign({}, col, { onCell: function (record) { return ({
|
|
167
|
+
record: record,
|
|
168
|
+
editable: col.editable,
|
|
169
|
+
dataIndex: col.dataIndex,
|
|
170
|
+
title: col.title ? col.title.toString() : "",
|
|
171
|
+
handleSave: _this.handleSave,
|
|
172
|
+
}); } });
|
|
173
|
+
});
|
|
174
|
+
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
|
+
} })));
|
|
183
|
+
};
|
|
184
|
+
return BillingLines;
|
|
185
|
+
}(React.Component));
|
|
186
|
+
exports.default = BillingLines;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var Content = function (props) {
|
|
8
|
+
var cssStyle = {
|
|
9
|
+
height: props.height ? props.height : undefined,
|
|
10
|
+
};
|
|
11
|
+
return (react_1.default.createElement("div", { className: "component_body", style: cssStyle }, props.children));
|
|
12
|
+
};
|
|
13
|
+
exports.default = Content;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
18
|
+
var compatible_1 = require("@ant-design/compatible");
|
|
19
|
+
var Header = function (props) {
|
|
20
|
+
return (react_1.default.createElement("div", { className: "component_header" },
|
|
21
|
+
react_1.default.createElement("div", null,
|
|
22
|
+
react_1.default.createElement("span", null, props.iconProps
|
|
23
|
+
? react_1.default.createElement(compatible_1.Icon, __assign({}, props.iconProps, { className: "header_icon" }))
|
|
24
|
+
: null),
|
|
25
|
+
react_1.default.createElement("span", { className: "component_header_title" }, props.title)),
|
|
26
|
+
react_1.default.createElement("div", { className: "header_right" }, props.action)));
|
|
27
|
+
};
|
|
28
|
+
exports.default = Header;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconProps } from "@ant-design/compatible/es/icon";
|
|
3
|
+
interface Props {
|
|
4
|
+
iconProps?: IconProps;
|
|
5
|
+
title?: string;
|
|
6
|
+
action?: React.ReactNode;
|
|
7
|
+
noPadding?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const ComponentContainer: React.FC<Props>;
|
|
10
|
+
export default ComponentContainer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var antd_1 = require("antd");
|
|
8
|
+
var Header_1 = __importDefault(require("./Header"));
|
|
9
|
+
var Content_1 = __importDefault(require("./Content"));
|
|
10
|
+
var ComponentContainer = function (props) {
|
|
11
|
+
var iconProps = props.iconProps, title = props.title, action = props.action, noPadding = props.noPadding;
|
|
12
|
+
return (react_1.default.createElement("div", { className: "component_wrapper" },
|
|
13
|
+
react_1.default.createElement(antd_1.Row, { align: "stretch" },
|
|
14
|
+
react_1.default.createElement(antd_1.Col, { span: 24 },
|
|
15
|
+
react_1.default.createElement(Header_1.default, { iconProps: iconProps, title: title, action: action }))),
|
|
16
|
+
react_1.default.createElement(antd_1.Row, null,
|
|
17
|
+
react_1.default.createElement(antd_1.Col, { span: 24, className: "" + (noPadding ? '' : 'component_wrapper_padding') },
|
|
18
|
+
react_1.default.createElement(Content_1.default, null, props.children)))));
|
|
19
|
+
};
|
|
20
|
+
exports.default = ComponentContainer;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 DeliveryLocation = function () {
|
|
17
|
+
return (React.createElement(component_container_1.default, { title: "Delivery location" },
|
|
18
|
+
React.createElement(antd_1.Form.Item, { label: "Description", name: "deliveryLocation:description" },
|
|
19
|
+
React.createElement(antd_1.Input, null)),
|
|
20
|
+
React.createElement(antd_1.Form.Item, { label: "Address", name: "deliveryLocation:address" },
|
|
21
|
+
React.createElement(antd_1.Input, null)),
|
|
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: "deliveryLocation:postNo" },
|
|
24
|
+
React.createElement(antd_1.Input, null)),
|
|
25
|
+
React.createElement(antd_1.Form.Item, { style: { display: 'inline-block', width: "70%", paddingLeft: "3px" }, name: "deliveryLocation:city" },
|
|
26
|
+
React.createElement(antd_1.Input, null)))));
|
|
27
|
+
};
|
|
28
|
+
exports.default = DeliveryLocation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOverride";
|
|
3
|
+
interface EditableCellProps {
|
|
4
|
+
record: BillingLineMetadataOverride;
|
|
5
|
+
handleSave: (billingLineMetadata: BillingLineMetadataOverride) => void;
|
|
6
|
+
dataIndex: keyof BillingLineMetadataOverride;
|
|
7
|
+
editable: boolean;
|
|
8
|
+
index: number;
|
|
9
|
+
}
|
|
10
|
+
declare const EditableCell: React.FC<EditableCellProps>;
|
|
11
|
+
export default EditableCell;
|