@stssocialst-stp/fe-payroll 0.3.6 → 0.3.8

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/dist/index.js CHANGED
@@ -27,12 +27,12 @@ var _debounce = require('lodash/debounce');
27
27
  var Button = require('@material-ui/core/Button');
28
28
  var _ = require('lodash');
29
29
  var _extends = require('@babel/runtime/helpers/extends');
30
- var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
31
- var _regeneratorRuntime = require('@babel/runtime/regenerator');
32
30
  var Dialog = require('@material-ui/core/Dialog');
33
31
  var DialogActions = require('@material-ui/core/DialogActions');
34
32
  var DialogContent = require('@material-ui/core/DialogContent');
35
33
  var DialogTitle = require('@material-ui/core/DialogTitle');
34
+ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
35
+ var _regeneratorRuntime = require('@babel/runtime/regenerator');
36
36
  var Typography = require('@material-ui/core/Typography');
37
37
  var reactToPrint = require('react-to-print');
38
38
  var PrintIcon = require('@material-ui/icons/Print');
@@ -69,12 +69,12 @@ var _debounce__default = /*#__PURE__*/_interopDefaultLegacy(_debounce);
69
69
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
70
70
  var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
71
71
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
72
- var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
73
- var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
74
72
  var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
75
73
  var DialogActions__default = /*#__PURE__*/_interopDefaultLegacy(DialogActions);
76
74
  var DialogContent__default = /*#__PURE__*/_interopDefaultLegacy(DialogContent);
77
75
  var DialogTitle__default = /*#__PURE__*/_interopDefaultLegacy(DialogTitle);
76
+ var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
77
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
78
78
  var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
79
79
  var PrintIcon__default = /*#__PURE__*/_interopDefaultLegacy(PrintIcon);
80
80
  var DialogContentText__default = /*#__PURE__*/_interopDefaultLegacy(DialogContentText);
@@ -196,6 +196,7 @@ var ACTION_TYPE = {
196
196
  CLOSE_PAYROLL: 'PAYROLL_MUTATION_CLOSE_PAYROLL',
197
197
  REJECT_PAYROLL: 'PAYROLL_MUTATION_REJECT_PAYROLL',
198
198
  MAKE_PAYMENT_PAYROLL: 'PAYROLL_MUTATION_MAKE_PAYMENT_PAYROLL',
199
+ UPDATE_PAYROLL_PAYMENT_DATE: 'PAYROLL_MUTATION_UPDATE_PAYROLL_PAYMENT_DATE',
199
200
  GET_PAYROLL_PAYMENT_FILES: 'GET_PAYROLL_PAYMENT_FILES',
200
201
  BENEFITS_SUMMARY: 'PAYROLL_BENEFITS_SUMMARY',
201
202
  GET_BISTP_SUMMARY: 'PAYROLL_BISTP_SUMMARY',
@@ -212,7 +213,8 @@ var MUTATION_SERVICE = {
212
213
  DELETE: 'deletePayroll',
213
214
  CLOSE: 'closePayroll',
214
215
  REJECT: 'rejectPayroll',
215
- MAKE_PAYMENT: 'makePaymentForPayroll'
216
+ MAKE_PAYMENT: 'makePaymentForPayroll',
217
+ UPDATE_PAYMENT_DATE: 'updatePayrollPaymentDate'
216
218
  },
217
219
  BENEFIT_CONSUMPTION: {
218
220
  DELETE: 'deleteBenefitConsumption'
@@ -382,7 +384,8 @@ function reducer() {
382
384
  return _objectSpread$6(_objectSpread$6({}, payroll), {}, {
383
385
  id: feCore.decodeId(payroll.id),
384
386
  dateValidTo: payroll !== null && payroll !== void 0 && payroll.dateValidTo ? payroll === null || payroll === void 0 ? void 0 : payroll.dateValidTo.split('T')[0] : null,
385
- dateValidFrom: payroll !== null && payroll !== void 0 && payroll.dateValidFrom ? payroll === null || payroll === void 0 ? void 0 : payroll.dateValidFrom.split('T')[0] : null
387
+ dateValidFrom: payroll !== null && payroll !== void 0 && payroll.dateValidFrom ? payroll === null || payroll === void 0 ? void 0 : payroll.dateValidFrom.split('T')[0] : null,
388
+ paymentDate: payroll !== null && payroll !== void 0 && payroll.paymentDate ? payroll === null || payroll === void 0 ? void 0 : payroll.paymentDate.split('T')[0] : null
386
389
  });
387
390
  })) === null || _parseData4 === void 0 ? void 0 : _parseData4[0],
388
391
  errorPayroll: feCore.formatGraphQLError(action.payload)
@@ -597,6 +600,8 @@ function reducer() {
597
600
  return feCore.dispatchMutationResp(state, MUTATION_SERVICE.PAYMENT_POINT.UPDATE, action);
598
601
  case SUCCESS(ACTION_TYPE.CREATE_PAYROLL):
599
602
  return feCore.dispatchMutationResp(state, MUTATION_SERVICE.PAYROLL.CREATE, action);
603
+ case SUCCESS(ACTION_TYPE.UPDATE_PAYROLL_PAYMENT_DATE):
604
+ return feCore.dispatchMutationResp(state, MUTATION_SERVICE.PAYROLL.UPDATE_PAYMENT_DATE, action);
600
605
  case SUCCESS(ACTION_TYPE.DELETE_PAYROLL):
601
606
  return feCore.dispatchMutationResp(state, MUTATION_SERVICE.PAYROLL.DELETE, action);
602
607
  case SUCCESS(ACTION_TYPE.DELETE_BENEFIT_CONSUMPTION):
@@ -688,6 +693,14 @@ var messages_en = {
688
693
  "payroll.payroll.payrollStatusPicker.REJECTED": "REJECTED",
689
694
  "payroll.payroll.payrollStatusPicker.RECONCILED": "RECONCILED",
690
695
  "payroll.paymentMethod": "Payment Method",
696
+ "payroll.paymentDate": "Payment Date",
697
+ "payroll.paymentDateFrom": "Payment Date From",
698
+ "payroll.paymentDateTo": "Payment Date To",
699
+ "payroll.paymentDate.update": "Update Payment Date",
700
+ "payroll.paymentDate.mutation.updateLabel": "Update payment date {id}",
701
+ "payroll.validation.payroll.payment_date_required": "Payment date is required for BISTP payments.",
702
+ "payroll.validation.payroll.payment_date_in_past": "Payment date cannot be in the past.",
703
+ "payroll.validation.payroll.payment_date_locked": "Payment date can no longer be changed (payroll already sent to BISTP).",
691
704
  "payroll.tasks.update.title": "Approve Payroll Tasks",
692
705
  "payroll.tasks.reconciliation.title": "Payroll Reconciliation Tasks",
693
706
  "payroll.payroll.includedUnpaid": "Included unpaid",
@@ -802,12 +815,12 @@ var PAYMENT_POINT_PROJECTION = function PAYMENT_POINT_PROJECTION(modulesManager)
802
815
  return ['id', 'name', 'isDeleted', "location ".concat(modulesManager.getProjection('location.Location.FlatProjection')), "ppm ".concat(modulesManager.getProjection('admin.UserPicker.projection'))];
803
816
  };
804
817
  var BENEFIT_CONSUMPTION_PROJECTION = function BENEFIT_CONSUMPTION_PROJECTION() {
805
- return ['id', 'jsonExt', 'code', 'individual {firstName, lastName, nib}', 'benefitAttachment {bill {id, code, terms, amountTotal, datePayed}}', 'receipt', 'photo', 'amount', 'type', 'status', 'dateDue'];
818
+ return ['id', 'jsonExt', 'code', 'individual {firstName, lastName, nib}', 'benefitAttachment {bill {id, code, terms, amountTotal, datePayed}}', 'receipt', 'photo', 'amount', 'type', 'status', 'dateDue', 'paymentDate'];
806
819
  };
807
820
  var PAYROLL_BENEFIT_CONSUMPTION_PROJECTION = function PAYROLL_BENEFIT_CONSUMPTION_PROJECTION() {
808
821
  return ['id',
809
822
  // eslint-disable-next-line max-len
810
- 'benefit{id,isDeleted,jsonExt,dateCreated,dateUpdated,dateValidFrom,dateValidTo,id,code,individual {firstName, lastName},benefitAttachment {bill {id, code, terms, datePayed}},receipt,photo,amount,type,status,dateDue}', 'payroll {id, name, status, paymentCycle {code, startDate, endDate}, paymentMethod, benefitPlanNameCode}'];
823
+ 'benefit{id,isDeleted,jsonExt,dateCreated,dateUpdated,dateValidFrom,dateValidTo,id,code,individual {firstName, lastName},benefitAttachment {bill {id, code, terms, datePayed}},receipt,photo,amount,type,status,dateDue,paymentDate}', 'payroll {id, name, status, paymentCycle {code, startDate, endDate}, paymentMethod, paymentDate, benefitPlanNameCode}'];
811
824
  };
812
825
  var BENEFIT_CONSUMPTION_SUMMARY_PROJECTION = function BENEFIT_CONSUMPTION_SUMMARY_PROJECTION() {
813
826
  return ['totalAmountReceived', 'totalAmountDue'];
@@ -819,10 +832,10 @@ var BISTP_SUMMARY_PROJECTION = function BISTP_SUMMARY_PROJECTION() {
819
832
  return ['bistpSummary { total reconciled rejected pending skippedNib sendFailed }'];
820
833
  };
821
834
  var PAYROLL_PROJECTION = function PAYROLL_PROJECTION(modulesManager) {
822
- return ['id', 'name', 'paymentMethod', 'paymentPlan { code, id, name, benefitPlanType }', 'benefitPlanNameCode', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'].concat(_toConsumableArray__default["default"](BISTP_SUMMARY_PROJECTION()));
835
+ return ['id', 'name', 'paymentMethod', 'paymentDate', 'paymentPlan { code, id, name, benefitPlanType }', 'benefitPlanNameCode', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'].concat(_toConsumableArray__default["default"](BISTP_SUMMARY_PROJECTION()));
823
836
  };
824
837
  var PAYROLL_SEARCHER_PROJECTION = function PAYROLL_SEARCHER_PROJECTION(modulesManager) {
825
- return ['id', 'name', 'paymentMethod', 'paymentPlan { code, id, name, benefitPlanType }', 'benefitPlanNameCode', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'].concat(_toConsumableArray__default["default"](BISTP_SUMMARY_PROJECTION()));
838
+ return ['id', 'name', 'paymentMethod', 'paymentDate', 'paymentPlan { code, id, name, benefitPlanType }', 'benefitPlanNameCode', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'].concat(_toConsumableArray__default["default"](BISTP_SUMMARY_PROJECTION()));
826
839
  };
827
840
  var CSV_RECONCILIATION_PROJECTION = function CSV_RECONCILIATION_PROJECTION() {
828
841
  return ['fileName', 'status', 'error', 'jsonExt'];
@@ -834,7 +847,7 @@ var formatPaymentPointGQL = function formatPaymentPointGQL(paymentPoint) {
834
847
  return "\n ".concat(paymentPoint !== null && paymentPoint !== void 0 && paymentPoint.id ? "id: \"".concat(paymentPoint.id, "\"") : '', "\n ").concat(paymentPoint !== null && paymentPoint !== void 0 && paymentPoint.name ? "name: \"".concat(feCore.formatGQLString(paymentPoint.name), "\"") : '', "\n ").concat(paymentPoint !== null && paymentPoint !== void 0 && paymentPoint.location ? "locationId: ".concat(feCore.decodeId(paymentPoint.location.id)) : '', "\n ").concat(paymentPoint !== null && paymentPoint !== void 0 && paymentPoint.ppm ? "ppmId: \"".concat(feCore.decodeId(paymentPoint.ppm.id), "\"") : '', "\n ");
835
848
  };
836
849
  var formatPayrollGQL = function formatPayrollGQL(payroll) {
837
- return "\n ".concat(payroll !== null && payroll !== void 0 && payroll.id ? "id: \"".concat(payroll.id, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.name ? "name: \"".concat(feCore.formatGQLString(payroll.name), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentPoint ? "paymentPointId: \"".concat(feCore.decodeId(payroll.paymentPoint.id), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentPlan ? "paymentPlanId: \"".concat(feCore.decodeId(payroll.paymentPlan.id), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentCycle ? "paymentCycleId: \"".concat(feCore.decodeId(payroll.paymentCycle.id), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentMethod ? "paymentMethod: \"".concat(payroll.paymentMethod, "\"") : '', "\n ", "status: ".concat(PAYROLL_STATUS.PENDING_APPROVAL), "\n ").concat(payroll !== null && payroll !== void 0 && payroll.jsonExt ? "jsonExt: ".concat(JSON.stringify(payroll.jsonExt)) : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.dateValidFrom ? "dateValidFrom: \"".concat(payroll.dateValidFrom, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.dateValidTo ? "dateValidTo: \"".concat(payroll.dateValidTo, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.fromFailedInvoicesPayrollId ? "fromFailedInvoicesPayrollId: \"".concat(payroll.fromFailedInvoicesPayrollId, "\"") : '', "\n ");
850
+ return "\n ".concat(payroll !== null && payroll !== void 0 && payroll.id ? "id: \"".concat(payroll.id, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.name ? "name: \"".concat(feCore.formatGQLString(payroll.name), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentPoint ? "paymentPointId: \"".concat(feCore.decodeId(payroll.paymentPoint.id), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentPlan ? "paymentPlanId: \"".concat(feCore.decodeId(payroll.paymentPlan.id), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentCycle ? "paymentCycleId: \"".concat(feCore.decodeId(payroll.paymentCycle.id), "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentMethod ? "paymentMethod: \"".concat(payroll.paymentMethod, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.paymentDate ? "paymentDate: \"".concat(payroll.paymentDate, "\"") : '', "\n ", "status: ".concat(PAYROLL_STATUS.PENDING_APPROVAL), "\n ").concat(payroll !== null && payroll !== void 0 && payroll.jsonExt ? "jsonExt: ".concat(JSON.stringify(payroll.jsonExt)) : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.dateValidFrom ? "dateValidFrom: \"".concat(payroll.dateValidFrom, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.dateValidTo ? "dateValidTo: \"".concat(payroll.dateValidTo, "\"") : '', "\n ").concat(payroll !== null && payroll !== void 0 && payroll.fromFailedInvoicesPayrollId ? "fromFailedInvoicesPayrollId: \"".concat(payroll.fromFailedInvoicesPayrollId, "\"") : '', "\n ");
838
851
  };
839
852
  var PERFORM_MUTATION = function PERFORM_MUTATION(mutationType, mutationInput, ACTION, clientMutationLabel) {
840
853
  var mutation = feCore.formatMutation(mutationType, mutationInput, clientMutationLabel);
@@ -936,6 +949,10 @@ function makePaymentForPayroll(payroll, clientMutationLabel) {
936
949
  var payrollUuids = "ids: [\"".concat(payroll === null || payroll === void 0 ? void 0 : payroll.id, "\"]");
937
950
  return PERFORM_MUTATION(MUTATION_SERVICE.PAYROLL.MAKE_PAYMENT, payrollUuids, ACTION_TYPE.MAKE_PAYMENT_PAYROLL, clientMutationLabel);
938
951
  }
952
+ function updatePayrollPaymentDate(payroll, paymentDate, clientMutationLabel) {
953
+ var mutationInput = "\n id: \"".concat(payroll === null || payroll === void 0 ? void 0 : payroll.id, "\"\n paymentDate: \"").concat(paymentDate, "\"\n ");
954
+ return PERFORM_MUTATION(MUTATION_SERVICE.PAYROLL.UPDATE_PAYMENT_DATE, mutationInput, ACTION_TYPE.UPDATE_PAYROLL_PAYMENT_DATE, clientMutationLabel);
955
+ }
939
956
  function fetchBistpSummary(payrollId) {
940
957
  var query = "\n {\n total: benefitConsumptionByPayroll(payrollUuid: \"".concat(payrollId, "\", first: 0) { totalCount }\n pendentes: benefitConsumptionByPayroll(payrollUuid: \"").concat(payrollId, "\", status: ACCEPTED, first: 0) { totalCount }\n enviados: benefitConsumptionByPayroll(payrollUuid: \"").concat(payrollId, "\", status: APPROVE_FOR_PAYMENT, first: 0) { totalCount }\n confirmados: benefitConsumptionByPayroll(payrollUuid: \"").concat(payrollId, "\", status: RECONCILED, first: 0) { totalCount }\n rejeitados: benefitConsumptionByPayroll(payrollUuid: \"").concat(payrollId, "\", status: REJECTED, first: 0) { totalCount }\n }\n ");
941
958
  return feCore.graphql(query, ACTION_TYPE.GET_BISTP_SUMMARY);
@@ -1152,7 +1169,7 @@ function PaymentPointPage(_ref) {
1152
1169
  saveTooltip: formatMessage('tooltip.save')
1153
1170
  })));
1154
1171
  }
1155
- var mapDispatchToProps$i = function mapDispatchToProps(dispatch) {
1172
+ var mapDispatchToProps$j = function mapDispatchToProps(dispatch) {
1156
1173
  return redux.bindActionCreators({
1157
1174
  clearPaymentPoint: clearPaymentPoint,
1158
1175
  createPaymentPoint: createPaymentPoint,
@@ -1164,7 +1181,7 @@ var mapDispatchToProps$i = function mapDispatchToProps(dispatch) {
1164
1181
  journalize: feCore.journalize
1165
1182
  }, dispatch);
1166
1183
  };
1167
- var mapStateToProps$i = function mapStateToProps(state, props) {
1184
+ var mapStateToProps$j = function mapStateToProps(state, props) {
1168
1185
  var _state$core$user$i_us, _state$core;
1169
1186
  return {
1170
1187
  paymentPointUuid: props.match.params.payment_point_uuid,
@@ -1175,7 +1192,7 @@ var mapStateToProps$i = function mapStateToProps(state, props) {
1175
1192
  paymentPoint: state.payroll.paymentPoint
1176
1193
  };
1177
1194
  };
1178
- var PaymentPointPage$1 = reactRedux.connect(mapStateToProps$i, mapDispatchToProps$i)(PaymentPointPage);
1195
+ var PaymentPointPage$1 = reactRedux.connect(mapStateToProps$j, mapDispatchToProps$j)(PaymentPointPage);
1179
1196
 
1180
1197
  var useStyles$f = styles$7.makeStyles(function (theme) {
1181
1198
  return {
@@ -1440,7 +1457,7 @@ function PaymentPointSearcher(_ref) {
1440
1457
  rowLocked: isRowDisabled
1441
1458
  });
1442
1459
  }
1443
- var mapStateToProps$h = function mapStateToProps(state) {
1460
+ var mapStateToProps$i = function mapStateToProps(state) {
1444
1461
  return {
1445
1462
  fetchingPaymentPoints: state.payroll.fetchingPaymentPoints,
1446
1463
  fetchedPaymentPoints: state.payroll.fetchedPaymentPoints,
@@ -1453,7 +1470,7 @@ var mapStateToProps$h = function mapStateToProps(state) {
1453
1470
  mutation: state.payroll.mutation
1454
1471
  };
1455
1472
  };
1456
- var mapDispatchToProps$h = function mapDispatchToProps(dispatch) {
1473
+ var mapDispatchToProps$i = function mapDispatchToProps(dispatch) {
1457
1474
  return redux.bindActionCreators({
1458
1475
  fetchPaymentPoints: fetchPaymentPoints,
1459
1476
  deletePaymentPoint: deletePaymentPoint,
@@ -1462,7 +1479,7 @@ var mapDispatchToProps$h = function mapDispatchToProps(dispatch) {
1462
1479
  coreConfirm: feCore.coreConfirm
1463
1480
  }, dispatch);
1464
1481
  };
1465
- var PaymentPointSearcher$1 = reactRedux.connect(mapStateToProps$h, mapDispatchToProps$h)(PaymentPointSearcher);
1482
+ var PaymentPointSearcher$1 = reactRedux.connect(mapStateToProps$i, mapDispatchToProps$i)(PaymentPointSearcher);
1466
1483
 
1467
1484
  var useStyles$e = styles$7.makeStyles(function (theme) {
1468
1485
  return {
@@ -1792,7 +1809,7 @@ function AdvancedFiltersDialog(_ref) {
1792
1809
  disabled: !object || confirmed || readOnly
1793
1810
  }, feCore.formatMessage(intl, 'payroll', 'payroll.advancedFilters.button.filter')))) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null)));
1794
1811
  }
1795
- var mapStateToProps$g = function mapStateToProps(state, props) {
1812
+ var mapStateToProps$h = function mapStateToProps(state, props) {
1796
1813
  return {
1797
1814
  rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [],
1798
1815
  confirmed: state.core.confirmed,
@@ -1802,12 +1819,12 @@ var mapStateToProps$g = function mapStateToProps(state, props) {
1802
1819
  customFilters: state.core.customFilters
1803
1820
  };
1804
1821
  };
1805
- var mapDispatchToProps$g = function mapDispatchToProps(dispatch) {
1822
+ var mapDispatchToProps$h = function mapDispatchToProps(dispatch) {
1806
1823
  return redux.bindActionCreators({
1807
1824
  fetchCustomFilter: feCore.fetchCustomFilter
1808
1825
  }, dispatch);
1809
1826
  };
1810
- var AdvancedFiltersDialog$1 = reactIntl.injectIntl(styles$6.withTheme(styles$6.withStyles(styles$3)(reactRedux.connect(mapStateToProps$g, mapDispatchToProps$g)(AdvancedFiltersDialog))));
1827
+ var AdvancedFiltersDialog$1 = reactIntl.injectIntl(styles$6.withTheme(styles$6.withStyles(styles$3)(reactRedux.connect(mapStateToProps$h, mapDispatchToProps$h)(AdvancedFiltersDialog))));
1811
1828
 
1812
1829
  function PayrollStatusPicker(_ref) {
1813
1830
  var required = _ref.required,
@@ -1875,7 +1892,7 @@ function PaymentMethodPicker(_ref) {
1875
1892
  required: required
1876
1893
  });
1877
1894
  }
1878
- var mapStateToProps$f = function mapStateToProps(state) {
1895
+ var mapStateToProps$g = function mapStateToProps(state) {
1879
1896
  return {
1880
1897
  rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [],
1881
1898
  confirmed: state.core.confirmed,
@@ -1885,12 +1902,99 @@ var mapStateToProps$f = function mapStateToProps(state) {
1885
1902
  paymentMethods: state.payroll.paymentMethods
1886
1903
  };
1887
1904
  };
1888
- var mapDispatchToProps$f = function mapDispatchToProps(dispatch) {
1905
+ var mapDispatchToProps$g = function mapDispatchToProps(dispatch) {
1889
1906
  return redux.bindActionCreators({
1890
1907
  fetchPaymentMethods: fetchPaymentMethods
1891
1908
  }, dispatch);
1892
1909
  };
1893
- var PaymentMethodPicker$1 = reactRedux.connect(mapStateToProps$f, mapDispatchToProps$f)(PaymentMethodPicker);
1910
+ var PaymentMethodPicker$1 = reactRedux.connect(mapStateToProps$g, mapDispatchToProps$g)(PaymentMethodPicker);
1911
+
1912
+ var EDITABLE_STATUSES = [PAYROLL_STATUS.PENDING_APPROVAL, PAYROLL_STATUS.APPROVE_FOR_PAYMENT];
1913
+ function PayrollPaymentDateDialog(_ref) {
1914
+ var payroll = _ref.payroll,
1915
+ updatePayrollPaymentDate = _ref.updatePayrollPaymentDate,
1916
+ fetchPayroll = _ref.fetchPayroll,
1917
+ submittingMutation = _ref.submittingMutation,
1918
+ mutation = _ref.mutation;
1919
+ var modulesManager = feCore.useModulesManager();
1920
+ var _useTranslations = feCore.useTranslations(MODULE_NAME, modulesManager),
1921
+ formatMessage = _useTranslations.formatMessage,
1922
+ formatMessageWithValues = _useTranslations.formatMessageWithValues;
1923
+ var _useState = React.useState(false),
1924
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
1925
+ isOpen = _useState2[0],
1926
+ setIsOpen = _useState2[1];
1927
+ var _useState3 = React.useState(null),
1928
+ _useState4 = _slicedToArray__default["default"](_useState3, 2),
1929
+ paymentDate = _useState4[0],
1930
+ setPaymentDate = _useState4[1];
1931
+ var handleOpen = function handleOpen() {
1932
+ var _payroll$paymentDate;
1933
+ setPaymentDate((_payroll$paymentDate = payroll === null || payroll === void 0 ? void 0 : payroll.paymentDate) !== null && _payroll$paymentDate !== void 0 ? _payroll$paymentDate : null);
1934
+ setIsOpen(true);
1935
+ };
1936
+ var handleClose = function handleClose() {
1937
+ setIsOpen(false);
1938
+ };
1939
+ var handleSave = function handleSave() {
1940
+ if (!paymentDate) return;
1941
+ updatePayrollPaymentDate(payroll, paymentDate, formatMessageWithValues('payroll.paymentDate.mutation.updateLabel', mutationLabel(payroll)));
1942
+ };
1943
+ React.useEffect(function () {
1944
+ if (!submittingMutation && (mutation === null || mutation === void 0 ? void 0 : mutation.actionType) === ACTION_TYPE.UPDATE_PAYROLL_PAYMENT_DATE && mutation !== null && mutation !== void 0 && mutation.clientMutationId && isOpen) {
1945
+ handleClose();
1946
+ if (payroll !== null && payroll !== void 0 && payroll.id) {
1947
+ fetchPayroll(modulesManager, ["id: \"".concat(payroll.id, "\"")]);
1948
+ }
1949
+ }
1950
+ }, [submittingMutation]);
1951
+ if (!(payroll !== null && payroll !== void 0 && payroll.id)) return null;
1952
+ if (!EDITABLE_STATUSES.includes(payroll === null || payroll === void 0 ? void 0 : payroll.status)) return null;
1953
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
1954
+ onClick: handleOpen,
1955
+ variant: "outlined",
1956
+ color: "primary",
1957
+ style: {
1958
+ marginTop: '16px'
1959
+ }
1960
+ }, formatMessage('payroll.paymentDate.update')), /*#__PURE__*/React__default["default"].createElement(Dialog__default["default"], {
1961
+ open: isOpen,
1962
+ onClose: handleClose
1963
+ }, /*#__PURE__*/React__default["default"].createElement(DialogTitle__default["default"], null, formatMessage('payroll.paymentDate.update')), /*#__PURE__*/React__default["default"].createElement(DialogContent__default["default"], {
1964
+ style: {
1965
+ minWidth: 400
1966
+ }
1967
+ }, /*#__PURE__*/React__default["default"].createElement(feCore.PublishedComponent, {
1968
+ pubRef: "core.DatePicker",
1969
+ module: "payroll",
1970
+ label: "payroll.paymentDate",
1971
+ value: paymentDate,
1972
+ onChange: setPaymentDate,
1973
+ required: true,
1974
+ disablePast: true
1975
+ })), /*#__PURE__*/React__default["default"].createElement(DialogActions__default["default"], null, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
1976
+ onClick: handleClose,
1977
+ color: "primary"
1978
+ }, formatMessage('payroll.beneficiaries.cancel')), /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
1979
+ onClick: handleSave,
1980
+ color: "primary",
1981
+ variant: "contained",
1982
+ disabled: !paymentDate
1983
+ }, formatMessage('payroll.beneficiaries.confirm')))));
1984
+ }
1985
+ var mapStateToProps$f = function mapStateToProps(state) {
1986
+ return {
1987
+ submittingMutation: state.payroll.submittingMutation,
1988
+ mutation: state.payroll.mutation
1989
+ };
1990
+ };
1991
+ var mapDispatchToProps$f = function mapDispatchToProps(dispatch) {
1992
+ return redux.bindActionCreators({
1993
+ updatePayrollPaymentDate: updatePayrollPaymentDate,
1994
+ fetchPayroll: fetchPayroll
1995
+ }, dispatch);
1996
+ };
1997
+ var PayrollPaymentDateDialog$1 = reactRedux.connect(mapStateToProps$f, mapDispatchToProps$f)(PayrollPaymentDateDialog);
1894
1998
 
1895
1999
  function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1896
2000
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -2060,6 +2164,28 @@ var PayrollHeadPanel = /*#__PURE__*/function (_FormPanel) {
2060
2164
  return _this2.updateAttribute('paymentMethod', paymentMethod);
2061
2165
  },
2062
2166
  label: feCore.formatMessage(intl, 'payroll', 'paymentMethod')
2167
+ })), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
2168
+ item: true,
2169
+ xs: 3,
2170
+ className: classes.item
2171
+ }, /*#__PURE__*/React__default["default"].createElement(feCore.PublishedComponent, {
2172
+ pubRef: "core.DatePicker",
2173
+ module: "payroll",
2174
+ label: "payroll.paymentDate",
2175
+ value: payroll === null || payroll === void 0 ? void 0 : payroll.paymentDate,
2176
+ required: (payroll === null || payroll === void 0 ? void 0 : payroll.paymentMethod) === PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT,
2177
+ readOnly: readOnly,
2178
+ disablePast: !readOnly,
2179
+ onChange: function onChange(paymentDate) {
2180
+ return _this2.updateAttribute('paymentDate', paymentDate);
2181
+ }
2182
+ })), readOnly && /*#__PURE__*/React__default["default"].createElement(core.Grid, {
2183
+ item: true,
2184
+ xs: 3,
2185
+ className: classes.item
2186
+ }, /*#__PURE__*/React__default["default"].createElement(PayrollPaymentDateDialog$1, {
2187
+ payroll: payroll,
2188
+ readOnly: readOnly
2063
2189
  }))), /*#__PURE__*/React__default["default"].createElement(core.Divider, null), !isPayrollFromFailedInvoices && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(core.Typography, null, /*#__PURE__*/React__default["default"].createElement("div", {
2064
2190
  className: classes.item
2065
2191
  }, /*#__PURE__*/React__default["default"].createElement(feCore.FormattedMessage, {
@@ -3587,7 +3713,7 @@ function PayrollPage(_ref) {
3587
3713
  };
3588
3714
  }, []);
3589
3715
  var mandatoryFieldsEmpty = function mandatoryFieldsEmpty() {
3590
- if (editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.name && editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentPlan && editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentCycle && editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentMethod && !(editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.isDeleted)) return false;
3716
+ if (editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.name && editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentPlan && editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentCycle && editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentMethod && ((editedPayroll === null || editedPayroll === void 0 ? void 0 : editedPayroll.paymentMethod) !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT || editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.paymentDate) && !(editedPayroll !== null && editedPayroll !== void 0 && editedPayroll.isDeleted)) return false;
3591
3717
  return true;
3592
3718
  };
3593
3719
  var canSave = function canSave() {
@@ -3779,6 +3905,38 @@ function PayrollFilter(_ref) {
3779
3905
  filter: "paymentMethod: \"".concat(value, "\"")
3780
3906
  }]);
3781
3907
  }
3908
+ })), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
3909
+ item: true,
3910
+ xs: 2,
3911
+ className: classes.item
3912
+ }, /*#__PURE__*/React__default["default"].createElement(feCore.PublishedComponent, {
3913
+ pubRef: "core.DatePicker",
3914
+ module: "payroll",
3915
+ label: "payroll.paymentDateFrom",
3916
+ value: filterValue('paymentDate_Gte'),
3917
+ onChange: function onChange(value) {
3918
+ return onChangeFilters([{
3919
+ id: 'paymentDate_Gte',
3920
+ value: value,
3921
+ filter: value ? "paymentDate_Gte: \"".concat(value, "\"") : EMPTY_STRING
3922
+ }]);
3923
+ }
3924
+ })), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
3925
+ item: true,
3926
+ xs: 2,
3927
+ className: classes.item
3928
+ }, /*#__PURE__*/React__default["default"].createElement(feCore.PublishedComponent, {
3929
+ pubRef: "core.DatePicker",
3930
+ module: "payroll",
3931
+ label: "payroll.paymentDateTo",
3932
+ value: filterValue('paymentDate_Lte'),
3933
+ onChange: function onChange(value) {
3934
+ return onChangeFilters([{
3935
+ id: 'paymentDate_Lte',
3936
+ value: value,
3937
+ filter: value ? "paymentDate_Lte: \"".concat(value, "\"") : EMPTY_STRING
3938
+ }]);
3939
+ }
3782
3940
  })), /*#__PURE__*/React__default["default"].createElement(feCore.ControlledField, {
3783
3941
  module: "payroll",
3784
3942
  id: "payrollFilter.showHistory",
@@ -3863,10 +4021,10 @@ function PayrollSearcher(_ref) {
3863
4021
  prevSubmittingMutationRef.current = submittingMutation;
3864
4022
  });
3865
4023
  var headers = function headers() {
3866
- return ['payroll.name', 'payroll.benefitPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'payroll.bistp.progress', 'emptyLabel'];
4024
+ return ['payroll.name', 'payroll.benefitPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'payroll.paymentDate', 'payroll.bistp.progress', 'emptyLabel'];
3867
4025
  };
3868
4026
  var sorts = function sorts() {
3869
- return [['name', true], ['benefitPlanNameCode', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true]];
4027
+ return [['name', true], ['benefitPlanNameCode', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true], ['paymentDate', true]];
3870
4028
  };
3871
4029
  var renderBistpProgress = function renderBistpProgress(payroll) {
3872
4030
  if (payroll.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) return null;
@@ -3928,6 +4086,9 @@ function PayrollSearcher(_ref) {
3928
4086
  return payroll.status ? "".concat(payroll.status) : '';
3929
4087
  }, function (payroll) {
3930
4088
  return payroll.paymentMethod ? "".concat(payroll.paymentMethod) : '';
4089
+ }, function (payroll) {
4090
+ var _payroll$paymentDate;
4091
+ return (_payroll$paymentDate = payroll.paymentDate) !== null && _payroll$paymentDate !== void 0 ? _payroll$paymentDate : '—';
3931
4092
  }, function (payroll) {
3932
4093
  return renderBistpProgress(payroll);
3933
4094
  }, function (payroll) {
@@ -5728,9 +5889,11 @@ function BenefitConsumptionSearcher(_ref) {
5728
5889
  return isPayrollFromFailedInvoices ? BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT : benefitConsumption === null || benefitConsumption === void 0 ? void 0 : benefitConsumption.status;
5729
5890
  }, function (benefitConsumption) {
5730
5891
  return checkBenefitDueDate(benefitConsumption);
5731
- }, function (benefitConsumption) {
5732
- var _benefitConsumption$b;
5733
- return !benefitConsumption.receipt ? '' : benefitConsumption === null || benefitConsumption === void 0 || (_benefitConsumption$b = benefitConsumption.benefitAttachment[0]) === null || _benefitConsumption$b === void 0 || (_benefitConsumption$b = _benefitConsumption$b.bill) === null || _benefitConsumption$b === void 0 ? void 0 : _benefitConsumption$b.datePayed;
5892
+ },
5893
+ // paymentDate enviada ao BISTP; fallback para bill.datePayed (offline); "—" se ainda não enviado
5894
+ function (benefitConsumption) {
5895
+ var _benefitConsumption$p, _benefitConsumption$b, _benefitConsumption$b2;
5896
+ return (_benefitConsumption$p = benefitConsumption === null || benefitConsumption === void 0 ? void 0 : benefitConsumption.paymentDate) !== null && _benefitConsumption$p !== void 0 ? _benefitConsumption$p : !benefitConsumption.receipt ? '—' : (_benefitConsumption$b = benefitConsumption === null || benefitConsumption === void 0 || (_benefitConsumption$b2 = benefitConsumption.benefitAttachment) === null || _benefitConsumption$b2 === void 0 || (_benefitConsumption$b2 = _benefitConsumption$b2[0]) === null || _benefitConsumption$b2 === void 0 || (_benefitConsumption$b2 = _benefitConsumption$b2.bill) === null || _benefitConsumption$b2 === void 0 ? void 0 : _benefitConsumption$b2.datePayed) !== null && _benefitConsumption$b !== void 0 ? _benefitConsumption$b : '—';
5734
5897
  }, function (benefitConsumption) {
5735
5898
  var jsonExt = (benefitConsumption === null || benefitConsumption === void 0 ? void 0 : benefitConsumption.jsonExt) || {};
5736
5899
  var hasBistpFields = jsonExt.bistp_skip_reason || jsonExt.bistp_processed || jsonExt.bistp_rejection_reason;
@@ -5751,7 +5914,7 @@ function BenefitConsumptionSearcher(_ref) {
5751
5914
  return benefitConsumption.id;
5752
5915
  };
5753
5916
  var sorts = function sorts() {
5754
- return [['individual_FirstName', true], ['individual_LastName', true], ['individual_Nib', true], ['photo', true], ['code', true], ['dateDue', true], ['receipt', true], ['amount', true], ['type', true], ['status', true]];
5917
+ return [['individual_FirstName', true], ['individual_LastName', true], ['individual_Nib', true], ['photo', true], ['code', true], ['dateDue', true], ['receipt', true], ['amount', true], ['type', true], ['status', true], ['paymentDate', true]];
5755
5918
  };
5756
5919
  var defaultFilters = function defaultFilters() {
5757
5920
  var filters = {
@@ -6533,11 +6696,93 @@ function useBeneficiarios() {
6533
6696
  _useState6 = _slicedToArray__default["default"](_useState5, 2),
6534
6697
  error = _useState6[0],
6535
6698
  setError = _useState6[1];
6536
- function request(_x) {
6699
+ function poll(_x) {
6700
+ return _poll.apply(this, arguments);
6701
+ }
6702
+ function _poll() {
6703
+ _poll = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(clientMutationId) {
6704
+ var INTERVAL_MS, TIMEOUT_MS, started, _result$data, _node$jsonExt$output, _node$jsonExt, resp, result, node;
6705
+ return _regeneratorRuntime__default["default"].wrap(function (_context) {
6706
+ while (1) switch (_context.prev = _context.next) {
6707
+ case 0:
6708
+ INTERVAL_MS = 5000;
6709
+ TIMEOUT_MS = 20 * 60 * 1000; // 20 minutos
6710
+ started = Date.now();
6711
+ case 1:
6712
+ if (!(Date.now() - started < TIMEOUT_MS)) {
6713
+ _context.next = 8;
6714
+ break;
6715
+ }
6716
+ _context.next = 2;
6717
+ return new Promise(function (resolve) {
6718
+ return setTimeout(resolve, INTERVAL_MS);
6719
+ });
6720
+ case 2:
6721
+ _context.next = 3;
6722
+ return fetch("".concat(feCore.baseApiUrl, "/graphql"), {
6723
+ method: 'POST',
6724
+ headers: buildHeaders(),
6725
+ credentials: 'same-origin',
6726
+ body: JSON.stringify({
6727
+ query: "\n query {\n mutationLogs(clientMutationId: \"".concat(clientMutationId, "\") {\n edges { node { status error jsonExt clientMutationLabel } }\n }\n }\n ")
6728
+ })
6729
+ });
6730
+ case 3:
6731
+ resp = _context.sent;
6732
+ _context.next = 4;
6733
+ return resp.json();
6734
+ case 4:
6735
+ result = _context.sent;
6736
+ node = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.mutationLogs) === null || _result$data === void 0 || (_result$data = _result$data.edges) === null || _result$data === void 0 || (_result$data = _result$data[0]) === null || _result$data === void 0 ? void 0 : _result$data.node;
6737
+ if (node) {
6738
+ _context.next = 5;
6739
+ break;
6740
+ }
6741
+ return _context.abrupt("continue", 1);
6742
+ case 5:
6743
+ // Update UI with label if needed
6744
+ setOutput("A processar: ".concat(node.clientMutationLabel, "..."));
6745
+ if (!(node.status === 2)) {
6746
+ _context.next = 6;
6747
+ break;
6748
+ }
6749
+ return _context.abrupt("return", {
6750
+ success: true,
6751
+ output: (_node$jsonExt$output = (_node$jsonExt = node.jsonExt) === null || _node$jsonExt === void 0 ? void 0 : _node$jsonExt.output) !== null && _node$jsonExt$output !== void 0 ? _node$jsonExt$output : null,
6752
+ error: null
6753
+ });
6754
+ case 6:
6755
+ if (!(node.status === 1)) {
6756
+ _context.next = 7;
6757
+ break;
6758
+ }
6759
+ return _context.abrupt("return", {
6760
+ success: false,
6761
+ output: null,
6762
+ error: node.error
6763
+ });
6764
+ case 7:
6765
+ _context.next = 1;
6766
+ break;
6767
+ case 8:
6768
+ return _context.abrupt("return", {
6769
+ success: false,
6770
+ output: null,
6771
+ error: 'Timeout: operação excedeu 20 minutos'
6772
+ });
6773
+ case 9:
6774
+ case "end":
6775
+ return _context.stop();
6776
+ }
6777
+ }, _callee);
6778
+ }));
6779
+ return _poll.apply(this, arguments);
6780
+ }
6781
+ function request(_x2) {
6537
6782
  return _request.apply(this, arguments);
6538
6783
  }
6539
6784
  function _request() {
6540
- _request = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(path) {
6785
+ _request = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(path) {
6541
6786
  var _ref,
6542
6787
  _ref$multipart,
6543
6788
  multipart,
@@ -6549,15 +6794,15 @@ function useBeneficiarios() {
6549
6794
  contentType,
6550
6795
  _data,
6551
6796
  message,
6552
- _args = arguments,
6797
+ _args2 = arguments,
6553
6798
  _t;
6554
- return _regeneratorRuntime__default["default"].wrap(function (_context) {
6555
- while (1) switch (_context.prev = _context.next) {
6799
+ return _regeneratorRuntime__default["default"].wrap(function (_context2) {
6800
+ while (1) switch (_context2.prev = _context2.next) {
6556
6801
  case 0:
6557
- _ref = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref$multipart = _ref.multipart, multipart = _ref$multipart === void 0 ? false : _ref$multipart, _ref$body = _ref.body, body = _ref$body === void 0 ? null : _ref$body;
6802
+ _ref = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, _ref$multipart = _ref.multipart, multipart = _ref$multipart === void 0 ? false : _ref$multipart, _ref$body = _ref.body, body = _ref$body === void 0 ? null : _ref$body;
6558
6803
  setLoading(true);
6559
6804
  setError(null);
6560
- _context.prev = 1;
6805
+ _context2.prev = 1;
6561
6806
  init = {
6562
6807
  method: 'POST',
6563
6808
  credentials: 'same-origin'
@@ -6568,54 +6813,50 @@ function useBeneficiarios() {
6568
6813
  init.headers = buildHeaders();
6569
6814
  if (body) init.body = JSON.stringify(body);
6570
6815
  }
6571
- _context.next = 2;
6816
+ _context2.next = 2;
6572
6817
  return fetch("".concat(BASE).concat(path), init);
6573
6818
  case 2:
6574
- response = _context.sent;
6819
+ response = _context2.sent;
6575
6820
  data = null;
6576
6821
  contentType = response.headers.get('content-type') || '';
6577
6822
  if (!contentType.includes('application/json')) {
6578
- _context.next = 4;
6823
+ _context2.next = 4;
6579
6824
  break;
6580
6825
  }
6581
- _context.next = 3;
6826
+ _context2.next = 3;
6582
6827
  return response.json();
6583
6828
  case 3:
6584
- data = _context.sent;
6829
+ data = _context2.sent;
6585
6830
  case 4:
6586
6831
  if (response.ok) {
6587
- _context.next = 5;
6832
+ _context2.next = 5;
6588
6833
  break;
6589
6834
  }
6590
6835
  message = ((_data = data) === null || _data === void 0 ? void 0 : _data.message) || "HTTP ".concat(response.status);
6591
6836
  setError(message);
6592
- return _context.abrupt("return", {
6837
+ return _context2.abrupt("return", {
6593
6838
  ok: false,
6594
6839
  message: message,
6595
6840
  data: data
6596
6841
  });
6597
6842
  case 5:
6598
- return _context.abrupt("return", {
6843
+ return _context2.abrupt("return", {
6599
6844
  ok: true,
6600
6845
  data: data
6601
6846
  });
6602
6847
  case 6:
6603
- _context.prev = 6;
6604
- _t = _context["catch"](1);
6848
+ _context2.prev = 6;
6849
+ _t = _context2["catch"](1);
6605
6850
  setError(_t.message);
6606
- return _context.abrupt("return", {
6851
+ return _context2.abrupt("return", {
6607
6852
  ok: false,
6608
6853
  message: _t.message
6609
6854
  });
6610
6855
  case 7:
6611
- _context.prev = 7;
6612
- setLoading(false);
6613
- return _context.finish(7);
6614
- case 8:
6615
6856
  case "end":
6616
- return _context.stop();
6857
+ return _context2.stop();
6617
6858
  }
6618
- }, _callee, null, [[1, 6, 7, 8]]);
6859
+ }, _callee2, null, [[1, 6]]);
6619
6860
  }));
6620
6861
  return _request.apply(this, arguments);
6621
6862
  }
@@ -6623,50 +6864,53 @@ function useBeneficiarios() {
6623
6864
  return _backup.apply(this, arguments);
6624
6865
  }
6625
6866
  function _backup() {
6626
- _backup = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
6867
+ _backup = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
6627
6868
  var payrollId,
6628
6869
  _yield$request,
6629
6870
  ok,
6630
6871
  data,
6631
- blob,
6632
- a,
6633
- _args2 = arguments;
6634
- return _regeneratorRuntime__default["default"].wrap(function (_context2) {
6635
- while (1) switch (_context2.prev = _context2.next) {
6872
+ pollResult,
6873
+ _args3 = arguments;
6874
+ return _regeneratorRuntime__default["default"].wrap(function (_context3) {
6875
+ while (1) switch (_context3.prev = _context3.next) {
6636
6876
  case 0:
6637
- payrollId = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
6638
- _context2.next = 1;
6877
+ payrollId = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
6878
+ _context3.next = 1;
6639
6879
  return request('/backup/', {
6640
6880
  body: payrollId ? {
6641
6881
  payroll_id: payrollId
6642
6882
  } : {}
6643
6883
  });
6644
6884
  case 1:
6645
- _yield$request = _context2.sent;
6885
+ _yield$request = _context3.sent;
6646
6886
  ok = _yield$request.ok;
6647
6887
  data = _yield$request.data;
6648
- if (ok) {
6649
- blob = new Blob([JSON.stringify(data, null, 2)], {
6650
- type: 'application/json'
6651
- });
6652
- a = document.createElement('a');
6653
- a.href = URL.createObjectURL(blob);
6654
- a.download = "backup_beneficiarios_".concat(new Date().toISOString().slice(0, 19).replace(/:/g, '-'), ".json");
6655
- document.body.appendChild(a);
6656
- a.click();
6657
- document.body.removeChild(a);
6658
- URL.revokeObjectURL(a.href);
6659
- setOutput("Backup conclu\xEDdo: ".concat(JSON.stringify(data.counts)));
6888
+ if (!ok) {
6889
+ _context3.next = 3;
6890
+ break;
6660
6891
  }
6661
- return _context2.abrupt("return", {
6892
+ setOutput('Backup iniciado. A aguardar conclusão...');
6893
+ _context3.next = 2;
6894
+ return poll(data.clientMutationId);
6895
+ case 2:
6896
+ pollResult = _context3.sent;
6897
+ if (pollResult.success) {
6898
+ setOutput("Backup conclu\xEDdo: ".concat(pollResult.output));
6899
+ // Handle download trigger if file info is in jsonExt
6900
+ } else {
6901
+ setError(pollResult.error);
6902
+ }
6903
+ case 3:
6904
+ setLoading(false);
6905
+ return _context3.abrupt("return", {
6662
6906
  ok: ok,
6663
6907
  data: data
6664
6908
  });
6665
- case 2:
6909
+ case 4:
6666
6910
  case "end":
6667
- return _context2.stop();
6911
+ return _context3.stop();
6668
6912
  }
6669
- }, _callee2);
6913
+ }, _callee3);
6670
6914
  }));
6671
6915
  return _backup.apply(this, arguments);
6672
6916
  }
@@ -6674,7 +6918,7 @@ function useBeneficiarios() {
6674
6918
  return _limpar.apply(this, arguments);
6675
6919
  }
6676
6920
  function _limpar() {
6677
- _limpar = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3() {
6921
+ _limpar = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4() {
6678
6922
  var _ref2,
6679
6923
  _ref2$dryRun,
6680
6924
  dryRun,
@@ -6683,12 +6927,13 @@ function useBeneficiarios() {
6683
6927
  _yield$request2,
6684
6928
  ok,
6685
6929
  data,
6686
- _args3 = arguments;
6687
- return _regeneratorRuntime__default["default"].wrap(function (_context3) {
6688
- while (1) switch (_context3.prev = _context3.next) {
6930
+ pollResult,
6931
+ _args4 = arguments;
6932
+ return _regeneratorRuntime__default["default"].wrap(function (_context4) {
6933
+ while (1) switch (_context4.prev = _context4.next) {
6689
6934
  case 0:
6690
- _ref2 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref2$dryRun = _ref2.dryRun, dryRun = _ref2$dryRun === void 0 ? true : _ref2$dryRun, _ref2$forceSkipFinanc = _ref2.forceSkipFinancial, forceSkipFinancial = _ref2$forceSkipFinanc === void 0 ? false : _ref2$forceSkipFinanc;
6691
- _context3.next = 1;
6935
+ _ref2 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref2$dryRun = _ref2.dryRun, dryRun = _ref2$dryRun === void 0 ? true : _ref2$dryRun, _ref2$forceSkipFinanc = _ref2.forceSkipFinancial, forceSkipFinancial = _ref2$forceSkipFinanc === void 0 ? false : _ref2$forceSkipFinanc;
6936
+ _context4.next = 1;
6692
6937
  return request('/limpar/', {
6693
6938
  body: {
6694
6939
  username: 'admin',
@@ -6697,27 +6942,42 @@ function useBeneficiarios() {
6697
6942
  }
6698
6943
  });
6699
6944
  case 1:
6700
- _yield$request2 = _context3.sent;
6945
+ _yield$request2 = _context4.sent;
6701
6946
  ok = _yield$request2.ok;
6702
6947
  data = _yield$request2.data;
6703
- if (ok) setOutput(data.output);
6704
- return _context3.abrupt("return", {
6948
+ if (!ok) {
6949
+ _context4.next = 3;
6950
+ break;
6951
+ }
6952
+ setOutput('Limpeza iniciada. A aguardar conclusão...');
6953
+ _context4.next = 2;
6954
+ return poll(data.clientMutationId);
6955
+ case 2:
6956
+ pollResult = _context4.sent;
6957
+ if (pollResult.success) {
6958
+ setOutput(pollResult.output);
6959
+ } else {
6960
+ setError(pollResult.error);
6961
+ }
6962
+ case 3:
6963
+ setLoading(false);
6964
+ return _context4.abrupt("return", {
6705
6965
  ok: ok,
6706
6966
  data: data
6707
6967
  });
6708
- case 2:
6968
+ case 4:
6709
6969
  case "end":
6710
- return _context3.stop();
6970
+ return _context4.stop();
6711
6971
  }
6712
- }, _callee3);
6972
+ }, _callee4);
6713
6973
  }));
6714
6974
  return _limpar.apply(this, arguments);
6715
6975
  }
6716
- function importar(_x2) {
6976
+ function importar(_x3) {
6717
6977
  return _importar.apply(this, arguments);
6718
6978
  }
6719
6979
  function _importar() {
6720
- _importar = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(file) {
6980
+ _importar = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(file) {
6721
6981
  var _ref3,
6722
6982
  _ref3$dryRun,
6723
6983
  dryRun,
@@ -6729,11 +6989,12 @@ function useBeneficiarios() {
6729
6989
  _yield$request3,
6730
6990
  ok,
6731
6991
  data,
6732
- _args4 = arguments;
6733
- return _regeneratorRuntime__default["default"].wrap(function (_context4) {
6734
- while (1) switch (_context4.prev = _context4.next) {
6992
+ pollResult,
6993
+ _args5 = arguments;
6994
+ return _regeneratorRuntime__default["default"].wrap(function (_context5) {
6995
+ while (1) switch (_context5.prev = _context5.next) {
6735
6996
  case 0:
6736
- _ref3 = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}, _ref3$dryRun = _ref3.dryRun, dryRun = _ref3$dryRun === void 0 ? false : _ref3$dryRun, payrollId = _ref3.payrollId, benefitPlanId = _ref3.benefitPlanId, benefitType = _ref3.benefitType, sheet = _ref3.sheet;
6997
+ _ref3 = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {}, _ref3$dryRun = _ref3.dryRun, dryRun = _ref3$dryRun === void 0 ? false : _ref3$dryRun, payrollId = _ref3.payrollId, benefitPlanId = _ref3.benefitPlanId, benefitType = _ref3.benefitType, sheet = _ref3.sheet;
6737
6998
  fd = new FormData();
6738
6999
  fd.append('file', file);
6739
7000
  fd.append('username', 'admin');
@@ -6742,33 +7003,48 @@ function useBeneficiarios() {
6742
7003
  if (benefitPlanId) fd.append('benefit_plan_id', benefitPlanId);
6743
7004
  if (benefitType) fd.append('benefit_type', benefitType);
6744
7005
  if (sheet) fd.append('sheet', sheet);
6745
- _context4.next = 1;
7006
+ _context5.next = 1;
6746
7007
  return request('/importar/', {
6747
7008
  multipart: true,
6748
7009
  body: fd
6749
7010
  });
6750
7011
  case 1:
6751
- _yield$request3 = _context4.sent;
7012
+ _yield$request3 = _context5.sent;
6752
7013
  ok = _yield$request3.ok;
6753
7014
  data = _yield$request3.data;
6754
- if (ok) setOutput(data.output);
6755
- return _context4.abrupt("return", {
7015
+ if (!ok) {
7016
+ _context5.next = 3;
7017
+ break;
7018
+ }
7019
+ setOutput('Importação iniciada. A aguardar conclusão...');
7020
+ _context5.next = 2;
7021
+ return poll(data.clientMutationId);
7022
+ case 2:
7023
+ pollResult = _context5.sent;
7024
+ if (pollResult.success) {
7025
+ setOutput(pollResult.output);
7026
+ } else {
7027
+ setError(pollResult.error);
7028
+ }
7029
+ case 3:
7030
+ setLoading(false);
7031
+ return _context5.abrupt("return", {
6756
7032
  ok: ok,
6757
7033
  data: data
6758
7034
  });
6759
- case 2:
7035
+ case 4:
6760
7036
  case "end":
6761
- return _context4.stop();
7037
+ return _context5.stop();
6762
7038
  }
6763
- }, _callee4);
7039
+ }, _callee5);
6764
7040
  }));
6765
7041
  return _importar.apply(this, arguments);
6766
7042
  }
6767
- function restore(_x3) {
7043
+ function restore(_x4) {
6768
7044
  return _restore.apply(this, arguments);
6769
7045
  }
6770
7046
  function _restore() {
6771
- _restore = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(file) {
7047
+ _restore = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(file) {
6772
7048
  var _ref4,
6773
7049
  _ref4$dryRun,
6774
7050
  dryRun,
@@ -6778,35 +7054,51 @@ function useBeneficiarios() {
6778
7054
  _yield$request4,
6779
7055
  ok,
6780
7056
  data,
6781
- _args5 = arguments;
6782
- return _regeneratorRuntime__default["default"].wrap(function (_context5) {
6783
- while (1) switch (_context5.prev = _context5.next) {
7057
+ pollResult,
7058
+ _args6 = arguments;
7059
+ return _regeneratorRuntime__default["default"].wrap(function (_context6) {
7060
+ while (1) switch (_context6.prev = _context6.next) {
6784
7061
  case 0:
6785
- _ref4 = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {}, _ref4$dryRun = _ref4.dryRun, dryRun = _ref4$dryRun === void 0 ? true : _ref4$dryRun, _ref4$skipPhases = _ref4.skipPhases, skipPhases = _ref4$skipPhases === void 0 ? [] : _ref4$skipPhases;
7062
+ _ref4 = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {}, _ref4$dryRun = _ref4.dryRun, dryRun = _ref4$dryRun === void 0 ? true : _ref4$dryRun, _ref4$skipPhases = _ref4.skipPhases, skipPhases = _ref4$skipPhases === void 0 ? [] : _ref4$skipPhases;
6786
7063
  fd = new FormData();
6787
7064
  fd.append('file', file);
6788
7065
  fd.append('username', 'admin');
6789
7066
  fd.append('dry_run', String(dryRun));
6790
7067
  if (skipPhases.length) fd.append('skip_phases', skipPhases.join(','));
6791
- _context5.next = 1;
7068
+ _context6.next = 1;
6792
7069
  return request('/restore/', {
6793
7070
  multipart: true,
6794
7071
  body: fd
6795
7072
  });
6796
7073
  case 1:
6797
- _yield$request4 = _context5.sent;
7074
+ _yield$request4 = _context6.sent;
6798
7075
  ok = _yield$request4.ok;
6799
7076
  data = _yield$request4.data;
6800
- if (ok) setOutput(data.output);
6801
- return _context5.abrupt("return", {
7077
+ if (!ok) {
7078
+ _context6.next = 3;
7079
+ break;
7080
+ }
7081
+ setOutput('Restore iniciado. A aguardar conclusão...');
7082
+ _context6.next = 2;
7083
+ return poll(data.clientMutationId);
7084
+ case 2:
7085
+ pollResult = _context6.sent;
7086
+ if (pollResult.success) {
7087
+ setOutput(pollResult.output);
7088
+ } else {
7089
+ setError(pollResult.error);
7090
+ }
7091
+ case 3:
7092
+ setLoading(false);
7093
+ return _context6.abrupt("return", {
6802
7094
  ok: ok,
6803
7095
  data: data
6804
7096
  });
6805
- case 2:
7097
+ case 4:
6806
7098
  case "end":
6807
- return _context5.stop();
7099
+ return _context6.stop();
6808
7100
  }
6809
- }, _callee5);
7101
+ }, _callee6);
6810
7102
  }));
6811
7103
  return _restore.apply(this, arguments);
6812
7104
  }