@unimaze/billing 0.21.68 → 0.21.69

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.
@@ -91,6 +91,7 @@ var DiscountTypeSelector_1 = __importDefault(require("./DiscountTypeSelector"));
91
91
  var formLayout_1 = require("../../consts/formLayout");
92
92
  var icons_1 = require("@ant-design/icons");
93
93
  var NewBillingLines_1 = require("./NewBillingLines");
94
+ var index_1 = require("../form-item/index");
94
95
  var BillingLinePreview_1 = __importDefault(require("./BillingLinePreview"));
95
96
  var lodash_1 = require("lodash");
96
97
  var Form_1 = require("antd/es/form/Form");
@@ -248,9 +249,17 @@ var SingleBillingLine = function (props) {
248
249
  ] }, (0, BillingLineUtility_1.getCorrectInputNode)("name", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_name), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.name"], true))),
249
250
  React.createElement(antd_1.Row, { gutter: 20 },
250
251
  React.createElement(antd_1.Col, { span: isMobile ? 24 : 12 },
251
- React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.quantity"], defaultIsRequired: true, fieldName: [fieldName, "quantity"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_quantity), verticalLabels: true, onlyLabelOnFirstInList: true, index: index }, (0, BillingLineUtility_1.getCorrectInputNode)("quantity", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_quantity), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.quantity"], true), React.createElement(UnitOfMeasureSelector_1.default, { receiverRequirements: props.receiverRequirements, fieldName: fieldName, mobile: isMobile })))),
252
+ React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.quantity"], defaultIsRequired: true, fieldName: [fieldName, "quantity"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_quantity), verticalLabels: true, onlyLabelOnFirstInList: true, index: index, additionalRules: [
253
+ {
254
+ validator: function (_, value) {
255
+ return value === 0
256
+ ? Promise.reject(new Error(props.intl.formatMessage(index_1.translationMessages.formItem_valueCannotBeZero_errorMessage)))
257
+ : Promise.resolve();
258
+ },
259
+ }
260
+ ] }, (0, BillingLineUtility_1.getCorrectInputNode)("quantity", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_quantity), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.quantity"], true), React.createElement(UnitOfMeasureSelector_1.default, { receiverRequirements: props.receiverRequirements, fieldName: fieldName, mobile: isMobile })))),
252
261
  React.createElement(antd_1.Col, { span: isMobile ? 24 : 12 },
253
- React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.unitPriceAmount"], defaultIsRequired: true, fieldName: [fieldName, "unitPriceAmount"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_unitPriceAmount), verticalLabels: true, onlyLabelOnFirstInList: true, index: index }, (0, BillingLineUtility_1.getCorrectInputNode)("unitPriceAmount", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_unitPriceAmount), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.unitPriceAmount"], true), React.createElement(CurrencySelector_1.default, { receiverRequirements: props.receiverRequirements, fieldName: fieldName, invoiceLinesFormInstance: props.invoiceLinesFormInstance, formInstance: props.formInstance, mobile: isMobile, onSelect: currencySelectorOnSelect, disabled: isCurrencyDisabled }))))),
262
+ React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.unitPriceAmount"], defaultIsRequired: true, fieldName: [fieldName, "unitPriceAmount"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_unitPriceAmount), verticalLabels: true, onlyLabelOnFirstInList: true, index: index }, (0, BillingLineUtility_1.getCorrectInputNode)("unitPriceAmount", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_unitPriceAmount), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.unitPriceAmount"], true), React.createElement(CurrencySelector_1.default, { receiverRequirements: props.receiverRequirements, fieldName: fieldName, invoiceLinesFormInstance: props.invoiceLinesFormInstance, formInstance: props.formInstance, mobile: isMobile, onSelect: currencySelectorOnSelect, disabled: isCurrencyDisabled }), undefined, undefined, 0)))),
254
263
  React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.taxableAmount"], defaultIsRequired: false, fieldName: [fieldName, "taxableAmount"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_lineAmount), verticalLabels: true, onlyLabelOnFirstInList: true, index: index },
255
264
  React.createElement(antd_1.InputNumber, { style: { width: "100%" }, disabled: true, defaultValue: (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(getTaxableAmount(), props.intl) })),
256
265
  React.createElement(antd_1.Row, { gutter: 20 },
@@ -9,6 +9,10 @@ export declare const translationMessages: {
9
9
  id: string;
10
10
  defaultMessage: string;
11
11
  };
12
+ formItem_valueCannotBeZero_errorMessage: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ };
12
16
  };
13
17
  interface StringMap {
14
18
  [key: string]: string;
@@ -46,6 +46,10 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
46
46
  id: "formItem_required_errorMessage",
47
47
  defaultMessage: "This field is required",
48
48
  },
49
+ formItem_valueCannotBeZero_errorMessage: {
50
+ id: "formItem_valueCannotBeZero_errorMessage",
51
+ defaultMessage: "Value cannot be 0",
52
+ },
49
53
  });
50
54
  var UmzFormItem = function (props) {
51
55
  var children = props.children, onlyLabelOnFirstInList = props.onlyLabelOnFirstInList, index = props.index, defaultLabel = props.defaultLabel, defaultIsRequired = props.defaultIsRequired, initialValue = props.initialValue, additionalRules = props.additionalRules, verticalLabels = props.verticalLabels, fieldName = props.fieldName, receiverRequirementsKey = props.receiverRequirementsKey, style = props.style, defaultLabelTooltip = props.defaultLabelTooltip, intl = props.intl, receiverRequirements = props.receiverRequirements, rest = __rest(props, ["children", "onlyLabelOnFirstInList", "index", "defaultLabel", "defaultIsRequired", "initialValue", "additionalRules", "verticalLabels", "fieldName", "receiverRequirementsKey", "style", "defaultLabelTooltip", "intl", "receiverRequirements"]);
@@ -122,6 +122,7 @@
122
122
  "deliveryLocation_streetNameAndNumber": "Address",
123
123
  "deliveryLocation_title": "Delivery location",
124
124
  "formItem_required_errorMessage": "This field is required",
125
+ "formItem_valueCannotBeZero_errorMessage": "Value cannot be 0",
125
126
  "invoicePreview.headerTitle": "Invoice",
126
127
  "invoicePreview_VAT": "VAT",
127
128
  "invoicePreview_VATof": "VAT of",
@@ -122,6 +122,7 @@
122
122
  "deliveryLocation_streetNameAndNumber": "Heimilisfang",
123
123
  "deliveryLocation_title": "Afhendingarstaður",
124
124
  "formItem_required_errorMessage": "Það þarf að fylla út í þennan reit",
125
+ "formItem_valueCannotBeZero_errorMessage": "Gildi getur ekki verið 0",
125
126
  "invoicePreview.headerTitle": "Reikningur",
126
127
  "invoicePreview_VAT": "VSK",
127
128
  "invoicePreview_VATof": "VSK af",
@@ -123,6 +123,7 @@ declare const _default: {
123
123
  deliveryLocation_streetNameAndNumber: string;
124
124
  deliveryLocation_title: string;
125
125
  formItem_required_errorMessage: string;
126
+ formItem_valueCannotBeZero_errorMessage: string;
126
127
  "invoicePreview.headerTitle": string;
127
128
  invoicePreview_VAT: string;
128
129
  invoicePreview_VATof: string;
@@ -332,6 +333,7 @@ declare const _default: {
332
333
  deliveryLocation_streetNameAndNumber: string;
333
334
  deliveryLocation_title: string;
334
335
  formItem_required_errorMessage: string;
336
+ formItem_valueCannotBeZero_errorMessage: string;
335
337
  "invoicePreview.headerTitle": string;
336
338
  invoicePreview_VAT: string;
337
339
  invoicePreview_VATof: string;
@@ -18,7 +18,7 @@ export declare const calculateTaxableAmount: (discountValue: string | null | und
18
18
  export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
19
19
  export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum | undefined) => number;
20
20
  export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum | undefined, taxCategoryTypeTranslated: string) => string;
21
- export declare const getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOverride, intl: IntlShape, placeholder: string, required: boolean, addonAfter?: React.ReactNode, mobile?: boolean, value?: any) => React.ReactChild;
21
+ export declare const getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOverride, intl: IntlShape, placeholder: string, required: boolean, addonAfter?: React.ReactNode, mobile?: boolean, value?: any, min?: number) => React.ReactChild;
22
22
  export declare const getTotals: (invoiceLines: BillingLineMetadataOverride[]) => Totals;
23
23
  export declare const getTaxCategoryDisabled: (taxCategoryType: AvailableTaxCategoryTypeEnum, outsideVatScope: boolean) => boolean;
24
24
  export declare const getFieldNames: (keys: string[], intl: IntlShape) => string[];
@@ -113,12 +113,12 @@ var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTransla
113
113
  return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
114
114
  };
115
115
  exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
116
- var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile, value) {
116
+ var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile, value, min) {
117
117
  switch (dataIdx) {
118
118
  case "quantity":
119
119
  case "unitPriceAmount":
120
120
  case "discountValue":
121
- return (react_1.default.createElement(antd_1.InputNumber, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, step: 1, style: { width: "100%" }, placeholder: placeholder, addonAfter: addonAfter, value: value, min: 0 }));
121
+ return (react_1.default.createElement(antd_1.InputNumber, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, step: 1, style: { width: "100%" }, placeholder: placeholder, addonAfter: addonAfter, value: value, min: min }));
122
122
  case "unitOfMeasure":
123
123
  return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder, style: { width: "auto" } }, Object.keys(api_1.Units).map(function (unitOfMeasure) {
124
124
  if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.68",
3
+ "version": "0.21.69",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",