@unimaze/billing 0.21.31 → 0.21.33

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.
@@ -119,7 +119,7 @@ var AttachmentModal = function (props) {
119
119
  var _isSaveAttachmentsDisabled = props.attachments.length > 0 ? props.attachments.some(function (attachment) { return attachment.fieldValidation !== "success" || (!attachment.description.trim()); }) : true;
120
120
  setIsSaveAttachmentsDisabled(_isSaveAttachmentsDisabled);
121
121
  }, [props.attachments]);
122
- var verifyAttachment = function (info, uploadSizeLimit, formInstance) {
122
+ var verifyAttachment = function (info, uploadSizeLimit, onRemove) {
123
123
  if (info.file.status === "removed")
124
124
  return;
125
125
  var isValid = (0, FileUploadUtility_1.reportIfFileIsValid)(info.file, uploadSizeLimit, {
@@ -130,8 +130,7 @@ var AttachmentModal = function (props) {
130
130
  uploadFailed: props.intl.formatMessage(translationMessages.attachment_error_fileFailedToUpload),
131
131
  });
132
132
  if (!isValid) {
133
- info.file.status = "error";
134
- updateFile(info.file, { file: __assign({}, info.file), fieldValidation: "error" });
133
+ onRemove(info.file);
135
134
  }
136
135
  else {
137
136
  updateFile(info.file, { file: __assign({}, info.file), fieldValidation: "success" });
@@ -151,15 +150,25 @@ var AttachmentModal = function (props) {
151
150
  if (info.file.status === "uploading") {
152
151
  setIsUploading(true);
153
152
  var fileIndex = props.attachments.findIndex(function (attachment) { return attachment.file.uid === info.file.uid; });
154
- if (fileIndex === -1) {
153
+ var isValid = (0, FileUploadUtility_1.reportIfFileIsValid)(info.file, props.uploadSizeLimit, {
154
+ uploadErrorToLarge: props.intl.formatMessage(translationMessages.attachment_error_fileTooLarge, {
155
+ uploadSizeLimit: props.uploadSizeLimit / 1024,
156
+ }),
157
+ uploadErrorWrongType: props.intl.formatMessage(translationMessages.attachment_error_fileWrongType),
158
+ uploadFailed: props.intl.formatMessage(translationMessages.attachment_error_fileFailedToUpload),
159
+ });
160
+ if (fileIndex === -1 && isValid) {
155
161
  props.setAttachments(__spreadArray(__spreadArray([], props.attachments, true), [
156
162
  { uid: info.file.uid, file: info.file, description: "", fieldValidation: "" },
157
163
  ], false));
158
164
  }
165
+ else {
166
+ setIsUploading(false);
167
+ }
159
168
  }
160
169
  else if (info.file.status === "done" || info.file.status === "error") {
161
170
  setIsUploading(false);
162
- verifyAttachment(info, props.uploadSizeLimit, props.formInstance);
171
+ verifyAttachment(info, props.uploadSizeLimit, props.onRemove);
163
172
  }
164
173
  },
165
174
  fileList: props.attachments.map(function (attachment) { return attachment.file; }),
@@ -110,8 +110,10 @@ var SingleBillingLine = function (props) {
110
110
  (0, react_1.useEffect)(function () {
111
111
  if (props.outsideVatScope) {
112
112
  setTaxCatType(enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope);
113
+ (0, BillingLineUtility_1.assignTaxCategoryToAllLines)(props.formInstance, enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope);
113
114
  }
114
115
  else {
116
+ (0, BillingLineUtility_1.assignTaxCategoryToAllLines)(props.formInstance, enums_1.AvailableTaxCategoryTypeEnum.StandardRated);
115
117
  setTaxCatType(enums_1.AvailableTaxCategoryTypeEnum.StandardRated);
116
118
  }
117
119
  }, [props.outsideVatScope]);
@@ -29,4 +29,5 @@ interface TaxDisplay {
29
29
  export declare const combinedTaxesForLines: (invoiceLines: BillingLineMetadataOverride[]) => TaxDisplay[];
30
30
  export declare const getUnitOfMeasureUnitLabel: (unitOfMeasure: any) => string;
31
31
  export declare const getDiscountLabel: (discountValue: string, discountType: string, currencyCode: string, discountText: string) => string;
32
+ export declare const assignTaxCategoryToAllLines: (formInstance: FormInstance, taxToAssign: AvailableTaxCategoryTypeEnum) => void;
32
33
  export {};
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.getDiscountLabel = exports.getUnitOfMeasureUnitLabel = exports.combinedTaxesForLines = exports.getFieldNames = exports.getTaxCategoryDisabled = exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
28
+ exports.assignTaxCategoryToAllLines = exports.getDiscountLabel = exports.getUnitOfMeasureUnitLabel = exports.combinedTaxesForLines = exports.getFieldNames = exports.getTaxCategoryDisabled = exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
29
29
  var mapi_1 = require("@unimaze/api-clients/lib/mapi");
30
30
  var api_1 = require("@unimaze/api-clients/lib/mapi/api");
31
31
  var react_1 = __importDefault(require("react"));
@@ -220,3 +220,15 @@ var getDiscountLabel = function (discountValue, discountType, currencyCode, disc
220
220
  return "".concat(discountValue).concat(discountType === "PERCENTAGE" ? "%" : " ".concat(currencyCode), " ").concat(discountText);
221
221
  };
222
222
  exports.getDiscountLabel = getDiscountLabel;
223
+ var assignTaxCategoryToAllLines = function (formInstance, taxToAssign) {
224
+ var clonedLines = (0, lodash_1.cloneDeep)(formInstance.getFieldValue(["invoice", "invoiceLines"]));
225
+ clonedLines.forEach(function (line) {
226
+ line.taxCategoryType = taxToAssign;
227
+ });
228
+ formInstance.setFieldsValue({
229
+ invoice: {
230
+ invoiceLines: clonedLines,
231
+ },
232
+ });
233
+ };
234
+ exports.assignTaxCategoryToAllLines = assignTaxCategoryToAllLines;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.31",
3
+ "version": "0.21.33",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",