@unimaze/billing 0.21.62 → 0.21.64

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.
@@ -155,7 +155,7 @@ var CostCenter = function (props) {
155
155
  var _c = (0, react_1.useState)(false), loadingCostCenterValues = _c[0], setLoadingCostCenterValues = _c[1];
156
156
  var costCenterFieldDefinition = (0, RequirementsUtility_1.getFieldRequirements)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"]);
157
157
  if (costCenterFieldDefinition) {
158
- return (react_1.default.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"], defaultLabel: props.intl.formatMessage(exports.translationMessages.baseInformation_costCenter), defaultIsRequired: false, fieldName: ["invoice", "customer", "locationIdentifier"], validateStatus: costCenterHandlingValidationStatus }, (0, RequirementsUtility_1.getInput)(costCenterFieldDefinition, ["invoice", "customer", "locationIdentifier"], "handleCostCenterValidation", props.legalIdentifier, props.formInstance, props.rapiBaseUrl, props.receiverRequirements, props.updateReceiverRequirementsProp, setCostCenterFieldProps, costCenterFieldProps, setLoadingCostCenterValues, loadingCostCenterValues, setCostCenterHandlingValidationStatus, props.intl.formatMessage(exports.translationMessages.baseInformation_costCenter), true)));
158
+ return (react_1.default.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"], defaultLabel: props.intl.formatMessage(exports.translationMessages.baseInformation_costCenter), defaultIsRequired: false, fieldName: ["invoice", "customer", "locationIdentifier"], validateStatus: costCenterHandlingValidationStatus }, (0, RequirementsUtility_1.getInput)(costCenterFieldDefinition, ["invoice", "customer", "locationIdentifier"], "handleCostCenterValidation", props.legalIdentifier, props.formInstance, props.rapiBaseUrl, props.receiverRequirements, props.updateReceiverRequirementsProp, setCostCenterFieldProps, costCenterFieldProps, setLoadingCostCenterValues, loadingCostCenterValues, setCostCenterHandlingValidationStatus, props.intl.formatMessage(exports.translationMessages.baseInformation_costCenter), true, true)));
159
159
  }
160
160
  else {
161
161
  return null;
@@ -14,26 +14,6 @@ var SubmittingStatus;
14
14
  SubmittingStatus["Done"] = "DONE";
15
15
  SubmittingStatus["Failed"] = "FAILED";
16
16
  })(SubmittingStatus = exports.SubmittingStatus || (exports.SubmittingStatus = {}));
17
- // const getSubmittingStatusIcon = (_name: string, _numberOfSuccessCalls: number, _namesOfFailedUploads: string[], _attachments: string[]) => {
18
- // const _index = _attachments.findIndex((att) => att === _name);
19
- // if (_namesOfFailedUploads.includes(_name)) return <CloseCircleTwoTone twoToneColor={"red"} style={{marginRight: 5}}/>
20
- // if (_index <= _numberOfSuccessCalls && !_namesOfFailedUploads.includes(_name)) return <CheckCircleTwoTone twoToneColor={"green"} style={{marginRight: 5}}/>
21
- // if (_index < _numberOfSuccessCalls || _index > _numberOfSuccessCalls) return <LoadingOutlined style={{marginRight: 5}}/>
22
- // }
23
- // const SingleSubmittingStatus: React.FC<AttachmentUploadStatusProps> = (props) => {
24
- //
25
- // const {name, index, numberOfSuccessCalls, namesOfFailedUploads, attachments, otherNameForDisplay} = props;
26
- //
27
- // return <Flex gap={5} align={"center"}>
28
- // <>{getSubmittingStatusIcon(name, numberOfSuccessCalls - 1, namesOfFailedUploads, attachments)}</>
29
- // <Typography.Text>
30
- // { otherNameForDisplay
31
- // ? otherNameForDisplay
32
- // : `${props.intl.formatMessage(translationMessages.submitConfirmation_SuccessfullyUploadedAttachment)} ${name}`
33
- // }
34
- // </Typography.Text>
35
- // </Flex>
36
- // };
37
17
  var SingleSubmittingStatus = function (props) {
38
18
  var name = props.name, status = props.status;
39
19
  var iconStyle = {
@@ -347,8 +347,9 @@ var CreateInvoiceConstructor = function (props) {
347
347
  var customerFromLocalStorage = (_c = savedValuesObject.invoice) === null || _c === void 0 ? void 0 : _c.customer;
348
348
  setChosenCustomer(customerFromLocalStorage);
349
349
  }
350
- var issueDate = savedValuesObject.issueDate, rest = __rest(savedValuesObject, ["issueDate"]);
351
- form.setFieldsValue(rest);
350
+ var invoice = savedValuesObject.invoice, rest = __rest(savedValuesObject, ["invoice"]);
351
+ var issueDate = invoice.issueDate, restOfInvoice = __rest(invoice, ["issueDate"]);
352
+ form.setFieldsValue(__assign({ invoice: restOfInvoice }, rest));
352
353
  }
353
354
  }, []);
354
355
  (0, react_1.useEffect)(function () {
@@ -1,4 +1,4 @@
1
1
  import { SubmittingStatus } from "../common/components/submit-confirmation/AttachmentUploadStatus";
2
2
  declare const getSubmittingStatus: (name: string, failedUploads: string[], attachments: string[], numberOfAttemptedCalls: number) => SubmittingStatus;
3
- declare const isRetryButtonVisible: (numberOfAttemptedCalls: number, totalNumberOfCalls: number, numberOfSuccessfulCalls: number, failedAttachments: string[], alreadyRetried: boolean) => boolean;
3
+ declare const isRetryButtonVisible: (numberOfAttemptedCalls: number, totalNumberOfCalls: number, numberOfSuccessfulCalls: number, numberOfFailedUploads: number, alreadyRetried: boolean, invoiceSubmittingStatus: SubmittingStatus) => boolean;
4
4
  export { getSubmittingStatus, isRetryButtonVisible };
@@ -12,9 +12,11 @@ var getSubmittingStatus = function (name, failedUploads, attachments, numberOfAt
12
12
  return AttachmentUploadStatus_1.SubmittingStatus.Pending;
13
13
  };
14
14
  exports.getSubmittingStatus = getSubmittingStatus;
15
- var isRetryButtonVisible = function (numberOfAttemptedCalls, totalNumberOfCalls, numberOfSuccessfulCalls, failedAttachments, alreadyRetried) {
16
- if (numberOfAttemptedCalls === totalNumberOfCalls && (numberOfSuccessfulCalls + (failedAttachments === null || failedAttachments === void 0 ? void 0 : failedAttachments.length) === totalNumberOfCalls)) {
17
- return (failedAttachments === null || failedAttachments === void 0 ? void 0 : failedAttachments.length) > 0 && !alreadyRetried;
15
+ var isRetryButtonVisible = function (numberOfAttemptedCalls, totalNumberOfCalls, numberOfSuccessfulCalls, numberOfFailedUploads, alreadyRetried, invoiceSubmittingStatus) {
16
+ if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed)
17
+ return true;
18
+ if (numberOfAttemptedCalls === (totalNumberOfCalls + 1) && ((numberOfSuccessfulCalls + numberOfFailedUploads) === totalNumberOfCalls)) {
19
+ return numberOfFailedUploads > 0 && !alreadyRetried;
18
20
  }
19
21
  };
20
22
  exports.isRetryButtonVisible = isRetryButtonVisible;
@@ -17,7 +17,7 @@ export interface FormItemPropsWithoutChildren extends Omit<FormItemProps, "child
17
17
  }
18
18
  export declare const handleValueValidation: import("lodash").DebouncedFunc<(isoNumber: string, fieldName: string, value: string, rapiBaseUrl: string, namePath: NamePath, setValidationStatus: (validationStatus: ValidateStatus) => void, formInstance: FormInstance, callName: string) => void>;
19
19
  export declare const debouncedHandleSearchValues: import("lodash").DebouncedFunc<(searchValue: string, fieldDefinition: FieldDefinition, setLoadingValues: (loadingValues: boolean) => void, loadingValues: boolean, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (newReceiverRequirements: NewReceiverRequirements) => void, callName: string, rapiBaseUrl: string, overwrittenFieldDefinitionKey?: string) => void>;
20
- export declare const getInput: (fieldDefinition: FieldDefinition, namePath: NamePath, 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: ValidateStatus) => void, defaultPlaceholder: string, allowClearSelect?: boolean) => React.ReactNode;
20
+ export declare const getInput: (fieldDefinition: FieldDefinition, namePath: NamePath, 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: ValidateStatus) => void, defaultPlaceholder: string, allowClearSelect?: boolean, allowLocalSearch?: boolean) => React.ReactNode;
21
21
  export declare const getRequiredTooltipMessage: (title: string, fieldNames: string[]) => React.ReactNode;
22
22
  export declare const getRequiredTooltipErrorMessages: (errors: Record<string, ValidationErrorDisplayObject[]>) => React.ReactNode;
23
23
  export declare const paymentMeansTypeFieldHasValues: (paymentMeansTypeFieldDefinition: FieldDefinition | undefined) => boolean | undefined;
@@ -147,7 +147,7 @@ var handleValueSearch = function (searchValue, fieldDefinition, setLoadingValues
147
147
  }
148
148
  };
149
149
  exports.debouncedHandleSearchValues = (0, lodash_1.debounce)(handleValueSearch, 500);
150
- var getInput = function (fieldDefinition, namePath, validationCallName, legalIdentifier, formInstance, rapiBaseUrl, receiverRequirements, updateReceiverRequirementsProp, setAccountingCostFieldProps, accountingCostFieldProps, setLoadingAccountingCostValues, loadingAccountingCostValues, setHandlingValidationStatus, defaultPlaceholder, allowClearSelect) {
150
+ var getInput = function (fieldDefinition, namePath, validationCallName, legalIdentifier, formInstance, rapiBaseUrl, receiverRequirements, updateReceiverRequirementsProp, setAccountingCostFieldProps, accountingCostFieldProps, setLoadingAccountingCostValues, loadingAccountingCostValues, setHandlingValidationStatus, defaultPlaceholder, allowClearSelect, allowLocalSearch) {
151
151
  var handling = null;
152
152
  if (fieldDefinition.properties.handling) {
153
153
  handling = JSON.parse(fieldDefinition.properties.handling);
@@ -168,10 +168,16 @@ var getInput = function (fieldDefinition, namePath, validationCallName, legalIde
168
168
  },
169
169
  loading: loadingAccountingCostValues,
170
170
  }
171
- : {};
172
- return (react_1.default.createElement(antd_1.Select, __assign({ popupMatchSelectWidth: false, allowClear: allowClearSelect }, selectProps, { placeholder: placeholder }), fieldDefinition.properties.values.map(function (op) {
173
- return react_1.default.createElement(antd_1.Select.Option, { key: op.key, value: op.key }, op.name);
174
- })));
171
+ : __assign({}, (allowLocalSearch ? {
172
+ showSearch: true,
173
+ optionFilterProp: 'label'
174
+ } : {}));
175
+ return (react_1.default.createElement(antd_1.Select, __assign({ popupMatchSelectWidth: false, allowClear: allowClearSelect }, selectProps, { placeholder: placeholder, options: fieldDefinition.properties.values.map(function (op) {
176
+ return {
177
+ value: op.key,
178
+ label: op.name,
179
+ };
180
+ }) })));
175
181
  }
176
182
  else {
177
183
  return (react_1.default.createElement(antd_1.Input, { allowClear: allowClearSelect, placeholder: placeholder }));
@@ -0,0 +1,13 @@
1
+ import { IntlShape } from "react-intl";
2
+ import { SubmittingStatus } from "../common/components/submit-confirmation/AttachmentUploadStatus";
3
+ import { AttachmentProps } from "../create-invoice";
4
+ declare const getAttachmentsText: (_status: SubmittingStatus, _name: string, intl: IntlShape) => string;
5
+ declare const getInvoiceText: (_status: SubmittingStatus, intl: IntlShape) => string;
6
+ declare const getSuccessPercent: (allAttachments: AttachmentProps[], percentUnit: number, invoiceSubmittingStatus: SubmittingStatus) => number;
7
+ declare const getProgressPercent: (numberOfSuccessfulCalls: number, numberOfFailedUploads: number, totalNumberOfCalls: number, percentUnit: number, invoiceSubmittingStatus: SubmittingStatus, numberOfAttemptedCalls: number) => number;
8
+ declare const getNumberOfFailedAttachments: (attachments: AttachmentProps[]) => number;
9
+ declare const getNumberOfUploadedAttachments: (attachments: AttachmentProps[]) => number;
10
+ declare const getStatusOfAttachment: (attachments: AttachmentProps[], name: string) => SubmittingStatus;
11
+ declare const getAllFailedUploads: (allAttachmentsWithStatuses: AttachmentProps[]) => AttachmentProps[];
12
+ declare const getAllSuccessfulUploads: (allAttachmentsWithStatuses: AttachmentProps[]) => AttachmentProps[];
13
+ export { getAttachmentsText, getInvoiceText, getSuccessPercent, getProgressPercent, getNumberOfFailedAttachments, getNumberOfUploadedAttachments, getStatusOfAttachment, getAllFailedUploads, getAllSuccessfulUploads };
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllSuccessfulUploads = exports.getAllFailedUploads = exports.getStatusOfAttachment = exports.getNumberOfUploadedAttachments = exports.getNumberOfFailedAttachments = exports.getProgressPercent = exports.getSuccessPercent = exports.getInvoiceText = exports.getAttachmentsText = void 0;
4
+ var AttachmentUploadStatus_1 = require("../common/components/submit-confirmation/AttachmentUploadStatus");
5
+ var submit_confirmation_1 = require("../common/components/submit-confirmation");
6
+ var getAttachmentsText = function (_status, _name, intl) {
7
+ switch (_status) {
8
+ case AttachmentUploadStatus_1.SubmittingStatus.Failed:
9
+ return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_attachmentFailedToUpload), " ").concat(_name);
10
+ case AttachmentUploadStatus_1.SubmittingStatus.Done:
11
+ return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_successfullyUploadedAttachment), " ").concat(_name);
12
+ case AttachmentUploadStatus_1.SubmittingStatus.Pending:
13
+ return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingAttachment), " ").concat(_name);
14
+ default:
15
+ return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingAttachment), " ").concat(_name);
16
+ }
17
+ };
18
+ exports.getAttachmentsText = getAttachmentsText;
19
+ var getInvoiceText = function (_status, intl) {
20
+ switch (_status) {
21
+ case AttachmentUploadStatus_1.SubmittingStatus.Failed:
22
+ return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoiceFailed);
23
+ case AttachmentUploadStatus_1.SubmittingStatus.Done:
24
+ return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoiceSuccessful);
25
+ case AttachmentUploadStatus_1.SubmittingStatus.Pending:
26
+ return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoice);
27
+ default:
28
+ return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoice);
29
+ }
30
+ };
31
+ exports.getInvoiceText = getInvoiceText;
32
+ var getSuccessPercent = function (allAttachments, percentUnit, invoiceSubmittingStatus) {
33
+ if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Pending) {
34
+ return 0;
35
+ }
36
+ else {
37
+ var successfulAttachments = getNumberOfUploadedAttachments(allAttachments);
38
+ var numberOfSuccessfulCalls = invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed ? successfulAttachments : successfulAttachments + 1;
39
+ return numberOfSuccessfulCalls * percentUnit;
40
+ }
41
+ };
42
+ exports.getSuccessPercent = getSuccessPercent;
43
+ var getProgressPercent = function (numberOfSuccessfulCalls, numberOfFailedUploads, totalNumberOfCalls, percentUnit, invoiceSubmittingStatus, numberOfAttemptedCalls) {
44
+ if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed) {
45
+ return 0;
46
+ }
47
+ else if ((numberOfSuccessfulCalls + numberOfFailedUploads) === totalNumberOfCalls) {
48
+ return numberOfSuccessfulCalls * percentUnit;
49
+ }
50
+ else {
51
+ return numberOfAttemptedCalls * percentUnit;
52
+ }
53
+ };
54
+ exports.getProgressPercent = getProgressPercent;
55
+ var getNumberOfFailedAttachments = function (attachments) {
56
+ return attachments.filter(function (attachment) { return attachment.status === AttachmentUploadStatus_1.SubmittingStatus.Failed; }).length;
57
+ };
58
+ exports.getNumberOfFailedAttachments = getNumberOfFailedAttachments;
59
+ var getNumberOfUploadedAttachments = function (attachments) {
60
+ return attachments.filter(function (attachment) { return attachment.status === AttachmentUploadStatus_1.SubmittingStatus.Done; }).length;
61
+ };
62
+ exports.getNumberOfUploadedAttachments = getNumberOfUploadedAttachments;
63
+ var getStatusOfAttachment = function (attachments, name) {
64
+ var attachment = attachments === null || attachments === void 0 ? void 0 : attachments.find(function (att) { return att.description === name; });
65
+ return attachment ? attachment.status : AttachmentUploadStatus_1.SubmittingStatus.Pending;
66
+ };
67
+ exports.getStatusOfAttachment = getStatusOfAttachment;
68
+ var getAllFailedUploads = function (allAttachmentsWithStatuses) {
69
+ var failedAttachments = [];
70
+ allAttachmentsWithStatuses.forEach(function (at) {
71
+ if (at.status === AttachmentUploadStatus_1.SubmittingStatus.Failed) {
72
+ failedAttachments.push(at);
73
+ }
74
+ });
75
+ return failedAttachments;
76
+ };
77
+ exports.getAllFailedUploads = getAllFailedUploads;
78
+ var getAllSuccessfulUploads = function (allAttachmentsWithStatuses) {
79
+ var successfulUploads = [];
80
+ allAttachmentsWithStatuses.forEach(function (at) {
81
+ if (at.status === AttachmentUploadStatus_1.SubmittingStatus.Done) {
82
+ successfulUploads.push(at);
83
+ }
84
+ });
85
+ return successfulUploads;
86
+ };
87
+ exports.getAllSuccessfulUploads = getAllSuccessfulUploads;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.62",
3
+ "version": "0.21.64",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",