@stssocialst-stp/fe-payroll 0.1.1 → 0.1.3

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.es.js CHANGED
@@ -2,22 +2,22 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import React, { useState, useRef, useEffect, forwardRef } from 'react';
3
3
  import { PinDrop } from '@material-ui/icons';
4
4
  import MonetizationOnIcon from '@material-ui/icons/MonetizationOn';
5
- import { dispatchMutationResp, dispatchMutationErr, dispatchMutationReq, formatServerError, formatGraphQLError, parseData, pageInfo, decodeId, formatPageQueryWithCount, graphql, formatQuery, formatGQLString, formatMutation, withModulesManager, PublishedComponent, TextInput, FormPanel, useModulesManager, useHistory, useTranslations, journalize, Form, coreConfirm, clearConfirm, ControlledField, Searcher, Helmet, withTooltip, CustomFilterFieldStatusPicker, CustomFilterTypeStatusPicker, NumberInput, SelectInput, formatMessage, fetchCustomFilter, ConstantBasedPicker, FormattedMessage, apiHeaders, baseApiUrl, Contributions, createFieldsBasedOnJSON, renderInputComponent, useGraphqlQuery, Autocomplete } from '@stssocialst-stp/fe-core';
5
+ import { dispatchMutationResp, dispatchMutationErr, dispatchMutationReq, formatServerError, formatGraphQLError, parseData, pageInfo, decodeId, formatPageQueryWithCount, graphql, formatQuery, formatGQLString, formatMutation, withModulesManager, PublishedComponent, TextInput, FormPanel, useModulesManager, useHistory, useTranslations, journalize, Form, coreConfirm, clearConfirm, ControlledField, Searcher, Helmet, withTooltip, CustomFilterFieldStatusPicker, CustomFilterTypeStatusPicker, NumberInput, SelectInput, formatMessage as formatMessage$1, fetchCustomFilter, ConstantBasedPicker, FormattedMessage, apiHeaders, baseApiUrl, createFieldsBasedOnJSON, renderInputComponent, Contributions, useGraphqlQuery, Autocomplete } from '@stssocialst-stp/fe-core';
6
6
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
7
7
  import { bindActionCreators } from 'redux';
8
8
  import { connect, useSelector } from 'react-redux';
9
9
  import { makeStyles } from '@material-ui/styles';
10
10
  import DeleteIcon from '@material-ui/icons/Delete';
11
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
11
12
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
12
13
  import _createClass from '@babel/runtime/helpers/createClass';
13
14
  import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
14
15
  import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
15
16
  import _inherits from '@babel/runtime/helpers/inherits';
16
17
  import { injectIntl } from 'react-intl';
17
- import { Grid, FormControlLabel, Checkbox, Tooltip, IconButton, Fab, Divider, Typography, Input, Paper, Modal, Backdrop, Fade, Box, Button as Button$1, TextField, Tab } from '@material-ui/core';
18
+ import { Grid, FormControlLabel, Checkbox, Tooltip, IconButton, Fab, Divider, Typography, Input, Modal, Backdrop, Fade, Box, Button as Button$1, Paper, TextField, Tab } from '@material-ui/core';
18
19
  import { withTheme, withStyles } from '@material-ui/core/styles';
19
20
  import AddIcon from '@material-ui/icons/Add';
20
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
21
21
  import VisibilityIcon from '@material-ui/icons/Visibility';
22
22
  import _debounce from 'lodash/debounce';
23
23
  import Button from '@material-ui/core/Button';
@@ -34,7 +34,9 @@ import { useReactToPrint } from 'react-to-print';
34
34
  import PrintIcon from '@material-ui/icons/Print';
35
35
  import DialogContentText from '@material-ui/core/DialogContentText';
36
36
  import PhotoCameraOutlinedIcon from '@material-ui/icons/PhotoCameraOutlined';
37
+ import LinearProgress from '@material-ui/core/LinearProgress';
37
38
  import DownloadIcon from '@material-ui/icons/CloudDownload';
39
+ import Chip from '@material-ui/core/Chip';
38
40
 
39
41
  // TODO: Change to proper rights after BE implementation
40
42
  var RIGHT_PAYROLL_SEARCH = 202001;
@@ -102,6 +104,11 @@ var PAYROLL_PAYMENT_FILE_STATUS = {
102
104
  };
103
105
  var BENEFIT_CONSUMPTION_STATUS_LIST = [BENEFIT_CONSUMPTION_STATUS.ACCEPTED, BENEFIT_CONSUMPTION_STATUS.CREATED, BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT, BENEFIT_CONSUMPTION_STATUS.REJECTED, BENEFIT_CONSUMPTION_STATUS.DUPLICATE, BENEFIT_CONSUMPTION_STATUS.RECONCILED];
104
106
  var PAYROLL_FROM_FAILED_INVOICES_URL_PARAM = 'createPayrollFromFailedInvoices=true';
107
+ var PAYMENT_METHOD = {
108
+ STRATEGY_OFFLINE_PAYMENT: 'StrategyOfflinePayment',
109
+ STRATEGY_ONLINE_PAYMENT: 'StrategyOnlinePayment',
110
+ STRATEGY_BISTP_PAYMENT: 'StrategyBistpPayment'
111
+ };
105
112
 
106
113
  var REQUEST = function REQUEST(actionTypeName) {
107
114
  return "".concat(actionTypeName, "_REQ");
@@ -348,13 +355,13 @@ function reducer() {
348
355
  return _objectSpread$6(_objectSpread$6({}, state), {}, {
349
356
  fetchingBenefitConsumptions: false,
350
357
  fetchedBenefitConsumptions: true,
351
- benefitConsumptions: (_parseData5 = parseData(action.payload.data.benefitConsumptionByPayroll)) === null || _parseData5 === void 0 ? void 0 : _parseData5.map(function (benefitConsumption) {
358
+ benefitConsumptions: (_parseData5 = parseData(action.payload.data.benefitConsumption)) === null || _parseData5 === void 0 ? void 0 : _parseData5.map(function (benefitConsumption) {
352
359
  return _objectSpread$6(_objectSpread$6({}, benefitConsumption), {}, {
353
360
  id: decodeId(benefitConsumption.id)
354
361
  });
355
362
  }),
356
- benefitConsumptionsPageInfo: pageInfo(action.payload.data.benefitConsumptionByPayroll),
357
- benefitConsumptionsTotalCount: (_action$payload$data$5 = (_action$payload$data$6 = action.payload.data.benefitConsumptionByPayroll) === null || _action$payload$data$6 === void 0 ? void 0 : _action$payload$data$6.totalCount) !== null && _action$payload$data$5 !== void 0 ? _action$payload$data$5 : 0,
363
+ benefitConsumptionsPageInfo: pageInfo(action.payload.data.benefitConsumption),
364
+ benefitConsumptionsTotalCount: (_action$payload$data$5 = (_action$payload$data$6 = action.payload.data.benefitConsumption) === null || _action$payload$data$6 === void 0 ? void 0 : _action$payload$data$6.totalCount) !== null && _action$payload$data$5 !== void 0 ? _action$payload$data$5 : 0,
358
365
  errorBenefitConsumptions: formatGraphQLError(action.payload)
359
366
  });
360
367
  case ERROR(ACTION_TYPE.GET_BENEFIT_CONSUMPTION):
@@ -664,7 +671,21 @@ var messages_en = {
664
671
  "payroll.additonalFields.label": "Additional Fields",
665
672
  "payroll.additonalFields.showAdditionalFields": "Show Additional Fields",
666
673
  "payroll.additonalFields.close": "Close",
667
- "payroll.summaryUpload": "Summary Upload"
674
+ "payroll.summaryUpload": "Summary Upload",
675
+ "payroll.benefitConsumption.nib": "NIB",
676
+ "payroll.bistp.viewSummary": "BISTP Payment Summary",
677
+ "payroll.bistp.submitPayment": "Submit BISTP Payment",
678
+ "payroll.bistp.reconciled": "Reconciled",
679
+ "payroll.bistp.pending": "Pending (Bank)",
680
+ "payroll.bistp.rejected": "Rejected",
681
+ "payroll.bistp.skippedNib": "Skipped (No NIB)",
682
+ "payroll.bistp.sendFailed": "Send Failed",
683
+ "payroll.bistp.status.reconciled": "Paid",
684
+ "payroll.bistp.status.rejected": "Rejected",
685
+ "payroll.bistp.status.pending": "Sent to Bank",
686
+ "payroll.bistp.status.skippedNib": "No NIB",
687
+ "payroll.bistp.status.sendFailed": "Send Failed",
688
+ "payroll.bistp.progress": "BISTP Progress"
668
689
  };
669
690
 
670
691
  // eslint-disable-next-line import/prefer-default-export
@@ -674,12 +695,11 @@ function isBase64Encoded(str) {
674
695
  return base64RegExp.test(str);
675
696
  }
676
697
 
677
- /* eslint-disable max-len */
678
698
  var PAYMENT_POINT_PROJECTION = function PAYMENT_POINT_PROJECTION(modulesManager) {
679
699
  return ['id', 'name', 'isDeleted', "location ".concat(modulesManager.getProjection('location.Location.FlatProjection')), "ppm ".concat(modulesManager.getProjection('admin.UserPicker.projection'))];
680
700
  };
681
701
  var BENEFIT_CONSUMPTION_PROJECTION = function BENEFIT_CONSUMPTION_PROJECTION() {
682
- return ['id', 'isDeleted', 'jsonExt', 'dateCreated', 'dateUpdated', 'dateValidFrom', 'dateValidTo', 'id', 'code', 'individual {firstName, lastName}', 'benefitAttachment {bill {id, code, terms, datePayed}}', 'receipt', 'photo', 'amount', 'type', 'status', 'dateDue'];
702
+ return ['id', 'jsonExt', 'code', 'individual {firstName, lastName, nib}', 'benefitAttachment {bill {id, code, terms, amountTotal, datePayed}}', 'receipt', 'photo', 'amount', 'type', 'status', 'dateDue'];
683
703
  };
684
704
  var PAYROLL_BENEFIT_CONSUMPTION_PROJECTION = function PAYROLL_BENEFIT_CONSUMPTION_PROJECTION() {
685
705
  return ['id',
@@ -692,13 +712,14 @@ var BENEFIT_CONSUMPTION_SUMMARY_PROJECTION = function BENEFIT_CONSUMPTION_SUMMAR
692
712
  var BENEFIT_ATTACHMENT_PROJECTION = function BENEFIT_ATTACHMENT_PROJECTION() {
693
713
  return ['benefit{id, status, code, dateDue, receipt, individual {firstName, lastName}, jsonExt, type, status, amount, receipt}', 'bill{id, code, terms, amountTotal, datePayed}'];
694
714
  };
715
+ var BISTP_SUMMARY_PROJECTION = function BISTP_SUMMARY_PROJECTION() {
716
+ return ['bistpSummary { total reconciled rejected pending skippedNib sendFailed }'];
717
+ };
695
718
  var PAYROLL_PROJECTION = function PAYROLL_PROJECTION(modulesManager) {
696
- return ['id', 'name', 'paymentMethod', 'paymentPlan { code, id, name, benefitPlan }', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }',
697
- // eslint-disable-next-line max-len
698
- 'benefitConsumption{id, status, code, dateDue, receipt, individual {firstName, lastName}, benefitAttachment{bill{id, code, terms, amountTotal}}}', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'];
719
+ return ['id', 'name', 'paymentMethod', 'paymentPlan { code, id, name, benefitPlan }', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'].concat(_toConsumableArray(BISTP_SUMMARY_PROJECTION()));
699
720
  };
700
721
  var PAYROLL_SEARCHER_PROJECTION = function PAYROLL_SEARCHER_PROJECTION(modulesManager) {
701
- return ['id', 'name', 'paymentMethod', 'paymentPlan { code, id, name, benefitPlan }', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'];
722
+ return ['id', 'name', 'paymentMethod', 'paymentPlan { code, id, name, benefitPlan }', "paymentPoint { ".concat(PAYMENT_POINT_PROJECTION(modulesManager).join(' '), " }"), 'paymentCycle { code, startDate, endDate }', 'jsonExt', 'status', 'dateValidFrom', 'dateValidTo', 'isDeleted'].concat(_toConsumableArray(BISTP_SUMMARY_PROJECTION()));
702
723
  };
703
724
  var CSV_RECONCILIATION_PROJECTION = function CSV_RECONCILIATION_PROJECTION() {
704
725
  return ['fileName', 'status', 'error', 'jsonExt'];
@@ -773,7 +794,7 @@ function createPayroll(payroll, clientMutationLabel) {
773
794
  return PERFORM_MUTATION(MUTATION_SERVICE.PAYROLL.CREATE, formatPayrollGQL(payroll), ACTION_TYPE.CREATE_PAYROLL, clientMutationLabel);
774
795
  }
775
796
  function fetchBenefitConsumptions(modulesManager, params) {
776
- var payload = formatPageQueryWithCount('benefitConsumptionByPayroll', params, BENEFIT_CONSUMPTION_PROJECTION());
797
+ var payload = formatPageQueryWithCount('benefitConsumption', params, BENEFIT_CONSUMPTION_PROJECTION());
777
798
  return graphql(payload, ACTION_TYPE.GET_BENEFIT_CONSUMPTION);
778
799
  }
779
800
  function fetchBenefitAttachments(modulesManager, params) {
@@ -1641,7 +1662,7 @@ function AdvancedFiltersDialog(_ref) {
1641
1662
  fontSize: '0.8rem'
1642
1663
  },
1643
1664
  disabled: readOnly || confirmed
1644
- }, formatMessage(intl, 'payroll', 'payroll.advancedFilters.button.addFilters'))) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement("div", null, !readOnly && !confirmed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1665
+ }, formatMessage$1(intl, 'payroll', 'payroll.advancedFilters.button.addFilters'))) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement("div", null, !readOnly && !confirmed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1645
1666
  style: {
1646
1667
  "float": 'left'
1647
1668
  }
@@ -1651,7 +1672,7 @@ function AdvancedFiltersDialog(_ref) {
1651
1672
  style: {
1652
1673
  border: '0px'
1653
1674
  }
1654
- }, formatMessage(intl, 'payroll', 'payroll.advancedFilters.button.clearAllFilters'))), /*#__PURE__*/React.createElement("div", {
1675
+ }, formatMessage$1(intl, 'payroll', 'payroll.advancedFilters.button.clearAllFilters'))), /*#__PURE__*/React.createElement("div", {
1655
1676
  style: {
1656
1677
  "float": 'right',
1657
1678
  paddingRight: '16px'
@@ -1662,7 +1683,7 @@ function AdvancedFiltersDialog(_ref) {
1662
1683
  color: "primary",
1663
1684
  autoFocus: true,
1664
1685
  disabled: !object || confirmed || readOnly
1665
- }, formatMessage(intl, 'payroll', 'payroll.advancedFilters.button.filter')))) : /*#__PURE__*/React.createElement(React.Fragment, null)));
1686
+ }, formatMessage$1(intl, 'payroll', 'payroll.advancedFilters.button.filter')))) : /*#__PURE__*/React.createElement(React.Fragment, null)));
1666
1687
  }
1667
1688
  var mapStateToProps$f = function mapStateToProps(state, props) {
1668
1689
  return {
@@ -1875,7 +1896,7 @@ var PayrollHeadPanel = /*#__PURE__*/function (_FormPanel) {
1875
1896
  className: classes.item
1876
1897
  }, /*#__PURE__*/React.createElement(TextInput, {
1877
1898
  module: "payroll",
1878
- label: formatMessage(intl, 'payroll', 'paymentPoint.name'),
1899
+ label: formatMessage$1(intl, 'payroll', 'paymentPoint.name'),
1879
1900
  value: payroll === null || payroll === void 0 ? void 0 : payroll.name,
1880
1901
  required: true,
1881
1902
  onChange: function onChange(name) {
@@ -1932,7 +1953,7 @@ var PayrollHeadPanel = /*#__PURE__*/function (_FormPanel) {
1932
1953
  onChange: function onChange(paymentMethod) {
1933
1954
  return _this2.updateAttribute('paymentMethod', paymentMethod);
1934
1955
  },
1935
- label: formatMessage(intl, 'payroll', 'paymentMethod')
1956
+ label: formatMessage$1(intl, 'payroll', 'paymentMethod')
1936
1957
  }))), /*#__PURE__*/React.createElement(Divider, null), !isPayrollFromFailedInvoices && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, null, /*#__PURE__*/React.createElement("div", {
1937
1958
  className: classes.item
1938
1959
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -2056,7 +2077,7 @@ function PayrollPaymentDataUploadDialog(_ref) {
2056
2077
  border: '0px',
2057
2078
  marginTop: '6px'
2058
2079
  }
2059
- }, formatMessage(intl, 'payroll', 'payroll.paymentData.upload.label')), /*#__PURE__*/React.createElement(Dialog, {
2080
+ }, formatMessage$1(intl, 'payroll', 'payroll.paymentData.upload.label')), /*#__PURE__*/React.createElement(Dialog, {
2060
2081
  open: isOpen,
2061
2082
  onClose: handleClose,
2062
2083
  PaperProps: {
@@ -2071,7 +2092,7 @@ function PayrollPaymentDataUploadDialog(_ref) {
2071
2092
  style: {
2072
2093
  marginTop: '10px'
2073
2094
  }
2074
- }, formatMessage(intl, 'payroll', 'payroll.paymentData.upload.label')), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement("div", {
2095
+ }, formatMessage$1(intl, 'payroll', 'payroll.paymentData.upload.label')), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement("div", {
2075
2096
  style: {
2076
2097
  backgroundColor: '#DFEDEF',
2077
2098
  paddingLeft: '10px',
@@ -2130,7 +2151,7 @@ function PayrollPaymentDataUploadDialog(_ref) {
2130
2151
  return onSubmit(forms.paymentData);
2131
2152
  },
2132
2153
  disabled: !((_forms$paymentData = forms.paymentData) !== null && _forms$paymentData !== void 0 && _forms$paymentData.file && payrollUuid)
2133
- }, formatMessage(intl, 'payroll', 'payroll.paymentData.upload.label'))))))));
2154
+ }, formatMessage$1(intl, 'payroll', 'payroll.paymentData.upload.label'))))))));
2134
2155
  }
2135
2156
  var mapStateToProps$d = function mapStateToProps(state) {
2136
2157
  return {
@@ -2143,603 +2164,614 @@ var mapDispatchToProps$d = function mapDispatchToProps(dispatch) {
2143
2164
  };
2144
2165
  var PayrollPaymentDataUploadDialog$1 = injectIntl(withTheme(withStyles(styles$1)(connect(mapStateToProps$d, mapDispatchToProps$d)(PayrollPaymentDataUploadDialog))));
2145
2166
 
2146
- function downloadPayroll(payrollId, payrollFileName) {
2147
- var blank = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2148
- var url = new URL("".concat(window.location.origin).concat(baseApiUrl, "/payroll/csv_reconciliation/"));
2149
- url.searchParams.append('payroll_id', payrollId);
2150
- url.searchParams.append('blank', blank);
2151
- url.searchParams.append('payroll_file_name', payrollFileName);
2152
- fetch(url).then(function (response) {
2153
- return response.blob();
2154
- }).then(function (blob) {
2155
- var link = document.createElement('a');
2156
- link.href = URL.createObjectURL(blob);
2157
- link.download = blank ? "reconciliation_".concat(payrollFileName, ".csv") : payrollFileName;
2158
- document.body.appendChild(link);
2159
- link.click();
2160
- document.body.removeChild(link);
2161
- })["catch"](function (error) {
2162
- // eslint-disable-next-line no-console
2163
- console.error('Export failed, reason: ', error);
2164
- });
2165
- }
2166
-
2167
2167
  var useStyles$b = makeStyles(function (theme) {
2168
2168
  return {
2169
- paper: theme.paper.paper,
2170
- tableTitle: theme.table.title,
2171
- tabs: {
2172
- display: 'flex',
2173
- alignItems: 'center'
2174
- },
2175
- selectedTab: {
2176
- borderBottom: '4px solid white'
2177
- },
2178
- unselectedTab: {
2179
- borderBottom: '4px solid transparent'
2169
+ form: {
2170
+ padding: 0
2180
2171
  },
2181
- button: {
2182
- marginLeft: 'auto',
2183
- padding: theme.spacing(1),
2184
- fontSize: '0.875rem',
2185
- textTransform: 'none'
2172
+ item: {
2173
+ padding: theme.spacing(1)
2186
2174
  }
2187
2175
  };
2188
2176
  });
2189
- function PayrollTab(_ref) {
2190
- var rights = _ref.rights,
2191
- setConfirmedAction = _ref.setConfirmedAction,
2192
- payrollUuid = _ref.payrollUuid,
2193
- isInTask = _ref.isInTask,
2194
- payroll = _ref.payroll,
2195
- isPayrollFromFailedInvoices = _ref.isPayrollFromFailedInvoices;
2177
+ function BenefitConsumptionFilterModal(_ref) {
2178
+ var filters = _ref.filters,
2179
+ onChangeFilters = _ref.onChangeFilters;
2180
+ var modulesManager = useModulesManager();
2196
2181
  var classes = useStyles$b();
2197
- var _useState = useState(BENEFIT_CONSUMPTION_LIST_TAB_VALUE),
2198
- _useState2 = _slicedToArray(_useState, 2),
2199
- activeTab = _useState2[0],
2200
- setActiveTab = _useState2[1];
2201
- var isSelected = function isSelected(tab) {
2202
- return tab === activeTab;
2182
+ var _useTranslations = useTranslations('payroll', modulesManager),
2183
+ formatMessage = _useTranslations.formatMessage;
2184
+ var debouncedOnChangeFilters = _debounce(onChangeFilters, DEFAULT_DEBOUNCE_TIME);
2185
+ var filterTextFieldValue = function filterTextFieldValue(filterName) {
2186
+ var _filters$filterName$v, _filters$filterName;
2187
+ return (_filters$filterName$v = filters === null || filters === void 0 || (_filters$filterName = filters[filterName]) === null || _filters$filterName === void 0 ? void 0 : _filters$filterName.value) !== null && _filters$filterName$v !== void 0 ? _filters$filterName$v : EMPTY_STRING;
2203
2188
  };
2204
- var tabStyle = function tabStyle(tab) {
2205
- return isSelected(tab) ? classes.selectedTab : classes.unselectedTab;
2189
+ var filterValue = function filterValue(filterName) {
2190
+ var _filters$filterName$v2, _filters$filterName2;
2191
+ return (_filters$filterName$v2 = filters === null || filters === void 0 || (_filters$filterName2 = filters[filterName]) === null || _filters$filterName2 === void 0 ? void 0 : _filters$filterName2.value) !== null && _filters$filterName$v2 !== void 0 ? _filters$filterName$v2 : null;
2206
2192
  };
2207
- var handleChange = function handleChange(_, tab) {
2208
- return setActiveTab(tab);
2193
+ var onChangeFilter = function onChangeFilter(filterName) {
2194
+ return function (value) {
2195
+ debouncedOnChangeFilters([{
2196
+ id: filterName,
2197
+ value: value || null,
2198
+ filter: "".concat(filterName, ": ").concat(value)
2199
+ }]);
2200
+ };
2209
2201
  };
2210
- var modulesManager = useModulesManager();
2211
- var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
2212
- formatMessage = _useTranslations.formatMessage;
2213
- var downloadPayrollData = function downloadPayrollData(payrollUuid, payrollName) {
2214
- downloadPayroll(payrollUuid, payrollName);
2202
+ var onChangeStringFilter = function onChangeStringFilter(filterName) {
2203
+ var lookup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2204
+ return function (value) {
2205
+ if (lookup) {
2206
+ debouncedOnChangeFilters([{
2207
+ id: filterName,
2208
+ value: value,
2209
+ filter: "".concat(filterName, "_").concat(lookup, ": \"").concat(value, "\"")
2210
+ }]);
2211
+ } else {
2212
+ debouncedOnChangeFilters([{
2213
+ id: filterName,
2214
+ value: value,
2215
+ filter: "".concat(filterName, ": \"").concat(value, "\"")
2216
+ }]);
2217
+ }
2218
+ };
2215
2219
  };
2216
- return /*#__PURE__*/React.createElement(Paper, {
2217
- className: classes.paper
2218
- }, /*#__PURE__*/React.createElement(Grid, {
2220
+ return /*#__PURE__*/React.createElement(Grid, {
2219
2221
  container: true,
2220
- className: "".concat(classes.tableTitle, " ").concat(classes.tabs)
2221
- }, /*#__PURE__*/React.createElement("div", {
2222
- style: {
2223
- width: '100%'
2224
- }
2225
- }, /*#__PURE__*/React.createElement("div", {
2226
- style: {
2227
- "float": 'left'
2228
- }
2229
- }, /*#__PURE__*/React.createElement(Contributions, {
2230
- contributionKey: PAYROLL_TABS_LABEL_CONTRIBUTION_KEY,
2231
- rights: rights,
2232
- value: activeTab,
2233
- onChange: handleChange,
2234
- isSelected: isSelected,
2235
- tabStyle: tabStyle,
2236
- payrollUuid: payrollUuid,
2237
- isInTask: isInTask,
2238
- isPayrollFromFailedInvoices: isPayrollFromFailedInvoices
2239
- })), /*#__PURE__*/React.createElement("div", {
2240
- style: {
2241
- "float": 'right',
2242
- paddingRight: '16px'
2222
+ className: classes.form
2223
+ }, /*#__PURE__*/React.createElement(Grid, {
2224
+ item: true,
2225
+ xs: 2,
2226
+ className: classes.item
2227
+ }, /*#__PURE__*/React.createElement(TextInput, {
2228
+ module: "payroll",
2229
+ label: "benefitConsumption.individual.firstName",
2230
+ value: filterTextFieldValue('benefit_Individual_FirstName'),
2231
+ onChange: onChangeStringFilter('benefit_Individual_FirstName', CONTAINS_LOOKUP)
2232
+ })), /*#__PURE__*/React.createElement(Grid, {
2233
+ item: true,
2234
+ xs: 2,
2235
+ className: classes.item
2236
+ }, /*#__PURE__*/React.createElement(TextInput, {
2237
+ module: "payroll",
2238
+ label: "benefitConsumption.individual.lastName",
2239
+ value: filterTextFieldValue('benefit_Individual_LastName'),
2240
+ onChange: onChangeStringFilter('benefit_Individual_LastName', CONTAINS_LOOKUP)
2241
+ })), /*#__PURE__*/React.createElement(Grid, {
2242
+ item: true,
2243
+ xs: 2,
2244
+ className: classes.item
2245
+ }, /*#__PURE__*/React.createElement(NumberInput, {
2246
+ module: "payroll",
2247
+ label: formatMessage('benefitConsumption.amount'),
2248
+ min: 0,
2249
+ value: filterValue('bill_AmountTotal'),
2250
+ onChange: onChangeFilter('bill_AmountTotal')
2251
+ })), /*#__PURE__*/React.createElement(Grid, {
2252
+ item: true,
2253
+ xs: 2,
2254
+ className: classes.item
2255
+ }, /*#__PURE__*/React.createElement(TextInput, {
2256
+ module: "payroll",
2257
+ label: "benefitConsumption.receipt",
2258
+ value: filterTextFieldValue('benefit_Receipt'),
2259
+ onChange: onChangeStringFilter('benefit_Receipt', CONTAINS_LOOKUP)
2260
+ })), /*#__PURE__*/React.createElement(Grid, {
2261
+ item: true,
2262
+ xs: 2,
2263
+ className: classes.item
2264
+ }, /*#__PURE__*/React.createElement(PublishedComponent, {
2265
+ pubRef: "core.DatePicker",
2266
+ module: "payroll",
2267
+ label: formatMessage('benefitConsumption.dateDue'),
2268
+ value: filterValue('benefit_DateDue'),
2269
+ onChange: function onChange(v) {
2270
+ return onChangeFilters([{
2271
+ id: 'benefit_DateDue',
2272
+ value: v,
2273
+ filter: "benefit_DateDue: \"".concat(v, "\"")
2274
+ }]);
2243
2275
  }
2244
- }, payrollUuid && !isPayrollFromFailedInvoices && /*#__PURE__*/React.createElement(Button, {
2245
- onClick: function onClick() {
2246
- return downloadPayrollData(payrollUuid, payroll.name);
2247
- },
2248
- color: "#DFEDEF",
2249
- className: classes.button,
2250
- style: {
2251
- border: '0px',
2252
- marginTop: '6px',
2253
- textTransform: 'uppercase'
2276
+ })), /*#__PURE__*/React.createElement(Grid, {
2277
+ item: true,
2278
+ xs: 2,
2279
+ className: classes.item
2280
+ }, /*#__PURE__*/React.createElement(PublishedComponent, {
2281
+ pubRef: "core.DatePicker",
2282
+ module: "payroll",
2283
+ label: formatMessage('benefitConsumption.paymentDate'),
2284
+ value: filterValue('bill_DatePayed_Gte'),
2285
+ onChange: function onChange(v) {
2286
+ return onChangeFilters([{
2287
+ id: 'bill_DatePayed_Gte',
2288
+ value: v,
2289
+ filter: "bill_DatePayed_Gte: \"".concat(v, "\"")
2290
+ }]);
2254
2291
  }
2255
- }, formatMessage('payroll.summary.download')), payrollUuid && (payroll === null || payroll === void 0 ? void 0 : payroll.status) === PAYROLL_STATUS.APPROVE_FOR_PAYMENT && payroll.paymentMethod === 'StrategyOfflinePayment' && /*#__PURE__*/React.createElement(PayrollPaymentDataUploadDialog$1, {
2256
- payrollUuid: payrollUuid
2257
- })))), /*#__PURE__*/React.createElement(Contributions, {
2258
- contributionKey: PAYROLL_TABS_PANEL_CONTRIBUTION_KEY,
2259
- rights: rights,
2260
- value: activeTab,
2261
- setConfirmedAction: setConfirmedAction,
2262
- payrollUuid: payrollUuid,
2263
- isInTask: isInTask,
2264
- isPayrollFromFailedInvoices: isPayrollFromFailedInvoices
2265
- }));
2292
+ })));
2266
2293
  }
2267
2294
 
2268
- function ownKeys$1(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; }
2269
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2270
- var useStyles$a = makeStyles(function (theme) {
2271
- return {
2272
- page: theme.page
2273
- };
2274
- });
2275
- function PayrollPage(_ref) {
2276
- var statePayrollUuid = _ref.statePayrollUuid,
2277
- taskPayrollUuid = _ref.taskPayrollUuid,
2278
- rights = _ref.rights,
2279
- confirmed = _ref.confirmed,
2280
- submittingMutation = _ref.submittingMutation,
2281
- mutation = _ref.mutation,
2282
- payroll = _ref.payroll,
2283
- fetchPayroll = _ref.fetchPayroll,
2284
- createPayroll = _ref.createPayroll,
2285
- clearPayroll = _ref.clearPayroll,
2286
- clearConfirm = _ref.clearConfirm,
2287
- createPayrollFromFailedInvoices = _ref.createPayrollFromFailedInvoices,
2288
- journalize = _ref.journalize,
2289
- benefitPlanId = _ref.benefitPlanId;
2295
+ function ErrorSummaryModal(_ref) {
2296
+ var _benefitAttachment$be;
2297
+ var open = _ref.open,
2298
+ onClose = _ref.onClose,
2299
+ benefitAttachment = _ref.benefitAttachment;
2290
2300
  var modulesManager = useModulesManager();
2291
- var classes = useStyles$a();
2292
- var history = useHistory();
2293
- var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
2294
- formatMessage = _useTranslations.formatMessage,
2295
- formatMessageWithValues = _useTranslations.formatMessageWithValues;
2296
- var _useState = useState({}),
2297
- _useState2 = _slicedToArray(_useState, 2),
2298
- editedPayroll = _useState2[0],
2299
- setEditedPayroll = _useState2[1];
2300
- var _useState3 = useState(null),
2301
- _useState4 = _slicedToArray(_useState3, 2),
2302
- payrollUuid = _useState4[0],
2303
- setPayrollUuid = _useState4[1];
2304
- var _useState5 = useState(false),
2305
- _useState6 = _slicedToArray(_useState5, 2),
2306
- isInTask = _useState6[0],
2307
- setIsInTask = _useState6[1];
2308
- var _useState7 = useState(false),
2309
- _useState8 = _slicedToArray(_useState7, 2),
2310
- readOnly = _useState8[0],
2311
- setReadOnly = _useState8[1];
2312
- var _useState9 = useState(false),
2313
- _useState0 = _slicedToArray(_useState9, 2),
2314
- isPayrollFromFailedInvoices = _useState0[0],
2315
- setIsPayrollFromFailedInvoices = _useState0[1];
2316
- var _useState1 = useState(function () {
2317
- return null;
2318
- }),
2319
- _useState10 = _slicedToArray(_useState1, 2),
2320
- confirmedAction = _useState10[0],
2321
- setConfirmedAction = _useState10[1];
2322
- var prevSubmittingMutationRef = useRef();
2323
- var back = function back() {
2324
- return history.goBack();
2325
- };
2326
- useEffect(function () {
2327
- if (createPayrollFromFailedInvoices === PAYROLL_FROM_FAILED_INVOICES_URL_PARAM) {
2328
- setIsPayrollFromFailedInvoices(true);
2301
+ var _useTranslations = useTranslations('payroll', modulesManager),
2302
+ formatMessage = _useTranslations.formatMessage;
2303
+ var jsonExt = benefitAttachment !== null && benefitAttachment !== void 0 && (_benefitAttachment$be = benefitAttachment.benefit) !== null && _benefitAttachment$be !== void 0 && _benefitAttachment$be.jsonExt ? JSON.parse(benefitAttachment.benefit.jsonExt) : {};
2304
+ var outputGateway = "".concat(jsonExt === null || jsonExt === void 0 ? void 0 : jsonExt.output_gateway);
2305
+ return /*#__PURE__*/React.createElement(Modal, {
2306
+ open: open,
2307
+ onClose: onClose,
2308
+ closeAfterTransition: true,
2309
+ BackdropComponent: Backdrop,
2310
+ BackdropProps: {
2311
+ timeout: 500
2329
2312
  }
2330
- }, [createPayrollFromFailedInvoices, payrollUuid]);
2331
- useEffect(function () {
2332
- setPayrollUuid(statePayrollUuid !== null && statePayrollUuid !== void 0 ? statePayrollUuid : taskPayrollUuid);
2333
- setIsInTask(!!taskPayrollUuid);
2334
- }, [taskPayrollUuid, statePayrollUuid]);
2335
- useEffect(function () {
2336
- if (payrollUuid) {
2337
- fetchPayroll(modulesManager, ["id: \"".concat(payrollUuid, "\"")]);
2313
+ }, /*#__PURE__*/React.createElement(Fade, {
2314
+ "in": open
2315
+ }, /*#__PURE__*/React.createElement(Box, {
2316
+ p: 4,
2317
+ style: {
2318
+ backgroundColor: 'white',
2319
+ margin: 'auto',
2320
+ maxWidth: 400,
2321
+ outline: 'none'
2338
2322
  }
2339
- }, [payrollUuid]);
2340
- useEffect(function () {
2341
- if (confirmed && typeof confirmed === 'function') confirmedAction();
2342
- return function () {
2343
- return confirmed && clearConfirm(null);
2344
- };
2345
- }, [confirmed]);
2346
- useEffect(function () {
2347
- if (prevSubmittingMutationRef.current && !submittingMutation) {
2348
- journalize(mutation);
2349
- if ((mutation === null || mutation === void 0 ? void 0 : mutation.actionType) === ACTION_TYPE.DELETE_PAYROLL) {
2350
- back();
2351
- }
2352
- if (mutation !== null && mutation !== void 0 && mutation.clientMutationId && (!payrollUuid || isPayrollFromFailedInvoices)) {
2353
- fetchPayroll(modulesManager, ["clientMutationId: \"".concat(mutation.clientMutationId, "\"")]);
2354
- setIsPayrollFromFailedInvoices(false);
2355
- }
2323
+ }, /*#__PURE__*/React.createElement(Typography, {
2324
+ variant: "h6"
2325
+ }, formatMessage('payroll.errorSummary.title')), outputGateway === null || outputGateway === 'undefined' ? /*#__PURE__*/React.createElement(Typography, null, formatMessage('payroll.errorSummary.outputGateway.noInfo')) : /*#__PURE__*/React.createElement(Typography, null, outputGateway), /*#__PURE__*/React.createElement(Box, {
2326
+ display: "flex",
2327
+ justifyContent: "center",
2328
+ mt: 2
2329
+ }, /*#__PURE__*/React.createElement(Button$1, {
2330
+ onClick: onClose,
2331
+ variant: "contained",
2332
+ color: "primary"
2333
+ }, formatMessage('payroll.errorSummary.close'))))));
2334
+ }
2335
+
2336
+ var styles = function styles(theme) {
2337
+ return {
2338
+ item: theme.paper.item
2339
+ };
2340
+ };
2341
+ function AdditionalFieldsDialog(_ref) {
2342
+ var intl = _ref.intl,
2343
+ classes = _ref.classes,
2344
+ jsonExt = _ref.jsonExt,
2345
+ buttonLabel = _ref.buttonLabel,
2346
+ title = _ref.title;
2347
+ // eslint-disable-next-line no-param-reassign
2348
+ if (!jsonExt) jsonExt = '{}';
2349
+ var _useState = useState(false),
2350
+ _useState2 = _slicedToArray(_useState, 2),
2351
+ isOpen = _useState2[0],
2352
+ setIsOpen = _useState2[1];
2353
+ var handleOpen = function handleOpen() {
2354
+ setIsOpen(true);
2355
+ };
2356
+ var handleClose = function handleClose() {
2357
+ setIsOpen(false);
2358
+ };
2359
+ var jsonExtFields = createFieldsBasedOnJSON(JSON.stringify(JSON.parse(jsonExt).extra_info));
2360
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
2361
+ onClick: handleOpen,
2362
+ variant: "outlined",
2363
+ color: "#DFEDEF",
2364
+ className: classes.button,
2365
+ style: {
2366
+ border: '0px',
2367
+ marginTop: '6px'
2356
2368
  }
2357
- }, [submittingMutation]);
2358
- useEffect(function () {
2359
- prevSubmittingMutationRef.current = submittingMutation;
2360
- });
2361
- useEffect(function () {
2362
- if (payroll) {
2363
- setReadOnly(payroll === null || payroll === void 0 ? void 0 : payroll.id);
2364
- if (isPayrollFromFailedInvoices) {
2365
- setEditedPayroll(_objectSpread$1(_objectSpread$1({}, payroll), {}, {
2366
- id: null,
2367
- name: null,
2368
- paymentCycle: null,
2369
- status: null,
2370
- fromFailedInvoicesPayrollId: payroll === null || payroll === void 0 ? void 0 : payroll.id
2371
- }));
2372
- } else {
2373
- setEditedPayroll(payroll);
2374
- }
2375
- if (!payrollUuid && payroll !== null && payroll !== void 0 && payroll.id && !isPayrollFromFailedInvoices) {
2376
- var payrollRouteRef = modulesManager.getRef('payroll.route.payroll');
2377
- history.replace("/".concat(payrollRouteRef, "/").concat(payroll.id));
2369
+ }, formatMessage$1(intl, 'payroll', buttonLabel)), /*#__PURE__*/React.createElement(Dialog, {
2370
+ open: isOpen,
2371
+ onClose: handleClose,
2372
+ PaperProps: {
2373
+ style: {
2374
+ width: 1200,
2375
+ maxWidth: 1200,
2376
+ maxHeight: 900
2378
2377
  }
2379
2378
  }
2380
- }, [payroll]);
2381
- useEffect(function () {
2382
- return function () {
2383
- return clearPayroll();
2384
- };
2385
- }, []);
2386
- var mandatoryFieldsEmpty = function mandatoryFieldsEmpty() {
2387
- 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;
2388
- return true;
2389
- };
2390
- var canSave = function canSave() {
2391
- return !mandatoryFieldsEmpty() && (!readOnly || isPayrollFromFailedInvoices);
2392
- };
2393
- var handleSave = function handleSave() {
2394
- createPayroll(editedPayroll, formatMessageWithValues('payroll.mutation.create', mutationLabel(payroll)));
2395
- if (benefitPlanId) {
2396
- back();
2379
+ }, /*#__PURE__*/React.createElement("form", {
2380
+ noValidate: true
2381
+ }, /*#__PURE__*/React.createElement(DialogTitle, {
2382
+ style: {
2383
+ marginTop: '10px'
2397
2384
  }
2398
- };
2399
- var actions = [];
2400
- return rights.includes(RIGHT_PAYROLL_CREATE) && /*#__PURE__*/React.createElement("div", {
2401
- className: classes.page
2402
- }, /*#__PURE__*/React.createElement(Form, {
2403
- key: payrollUuid,
2404
- module: "payroll",
2405
- title: formatMessageWithValues('payrollPage.title', pageTitle(payroll)),
2406
- titleParams: pageTitle(payroll),
2407
- openDirty: isPayrollFromFailedInvoices ? true : !payrollUuid,
2408
- benefitPlan: editedPayroll,
2409
- edited: editedPayroll,
2410
- onEditedChanged: setEditedPayroll,
2411
- back: !isInTask && back,
2412
- mandatoryFieldsEmpty: mandatoryFieldsEmpty,
2413
- canSave: canSave,
2414
- save: handleSave,
2415
- HeadPanel: PayrollHeadPanel$1,
2416
- Panels: [PayrollTab],
2417
- rights: rights,
2418
- actions: actions,
2419
- setConfirmedAction: setConfirmedAction,
2420
- payrollUuid: payrollUuid,
2421
- saveTooltip: formatMessage('tooltip.save'),
2422
- isInTask: !!taskPayrollUuid,
2423
- payroll: payroll,
2424
- readOnly: readOnly,
2425
- isPayrollFromFailedInvoices: isPayrollFromFailedInvoices,
2426
- benefitPlanId: benefitPlanId
2427
- }));
2385
+ }, formatMessage$1(intl, 'payroll', title)), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement("div", {
2386
+ style: {
2387
+ backgroundColor: '#DFEDEF',
2388
+ paddingLeft: '10px',
2389
+ paddingBottom: '10px'
2390
+ }
2391
+ }, /*#__PURE__*/React.createElement(Grid, {
2392
+ container: true,
2393
+ className: classes.item
2394
+ }, jsonExtFields === null || jsonExtFields === void 0 ? void 0 : jsonExtFields.map(function (jsonExtField) {
2395
+ return /*#__PURE__*/React.createElement(Grid, {
2396
+ item: true,
2397
+ xs: 6,
2398
+ className: classes.item
2399
+ }, renderInputComponent(MODULE_NAME, jsonExtField));
2400
+ })))), /*#__PURE__*/React.createElement(DialogActions, {
2401
+ style: {
2402
+ display: 'inline',
2403
+ paddingLeft: '10px',
2404
+ marginTop: '25px',
2405
+ marginBottom: '15px'
2406
+ }
2407
+ }, /*#__PURE__*/React.createElement("div", {
2408
+ style: {
2409
+ maxWidth: '1000px'
2410
+ }
2411
+ }, /*#__PURE__*/React.createElement("div", {
2412
+ style: {
2413
+ "float": 'left'
2414
+ }
2415
+ }, /*#__PURE__*/React.createElement(Button, {
2416
+ onClick: handleClose,
2417
+ variant: "outlined",
2418
+ autoFocus: true,
2419
+ style: {
2420
+ margin: '0 16px',
2421
+ marginBottom: '15px'
2422
+ }
2423
+ }, formatMessage$1(intl, 'payroll', 'payroll.additonalFields.close'))), /*#__PURE__*/React.createElement("div", {
2424
+ style: {
2425
+ "float": 'right',
2426
+ paddingRight: '16px'
2427
+ }
2428
+ }))))));
2428
2429
  }
2430
+ var mapStateToProps$c = function mapStateToProps(state) {
2431
+ return {
2432
+ rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : []
2433
+ };
2434
+ };
2429
2435
  var mapDispatchToProps$c = function mapDispatchToProps(dispatch) {
2430
- return bindActionCreators({
2431
- fetchPayroll: fetchPayroll,
2432
- createPayroll: createPayroll,
2433
- clearPayroll: clearPayroll,
2434
- coreConfirm: coreConfirm,
2435
- clearConfirm: clearConfirm,
2436
- journalize: journalize
2437
- }, dispatch);
2436
+ return bindActionCreators({}, dispatch);
2438
2437
  };
2439
- var mapStateToProps$c = function mapStateToProps(state, props) {
2440
- var _props$match, _props$match2, _props$match3, _props$match4, _state$core$user$i_us, _state$core;
2441
- return {
2442
- statePayrollUuid: (props === null || props === void 0 || (_props$match = props.match) === null || _props$match === void 0 || (_props$match = _props$match.params) === null || _props$match === void 0 ? void 0 : _props$match.payroll_uuid) === 'null' ? null : props === null || props === void 0 || (_props$match2 = props.match) === null || _props$match2 === void 0 ? void 0 : _props$match2.params.payroll_uuid,
2443
- createPayrollFromFailedInvoices: props === null || props === void 0 || (_props$match3 = props.match) === null || _props$match3 === void 0 || (_props$match3 = _props$match3.params) === null || _props$match3 === void 0 ? void 0 : _props$match3.createPayrollFromFailedInvoices,
2444
- benefitPlanId: props === null || props === void 0 || (_props$match4 = props.match) === null || _props$match4 === void 0 || (_props$match4 = _props$match4.params) === null || _props$match4 === void 0 ? void 0 : _props$match4.benefitPlanId,
2445
- rights: (_state$core$user$i_us = (_state$core = state.core) === null || _state$core === void 0 || (_state$core = _state$core.user) === null || _state$core === void 0 || (_state$core = _state$core.i_user) === null || _state$core === void 0 ? void 0 : _state$core.rights) !== null && _state$core$user$i_us !== void 0 ? _state$core$user$i_us : [],
2446
- confirmed: state.core.confirmed,
2447
- submittingMutation: state.payroll.submittingMutation,
2448
- mutation: state.payroll.mutation,
2449
- payroll: state.payroll.payroll
2450
- };
2451
- };
2452
- var PayrollPage$1 = connect(mapStateToProps$c, mapDispatchToProps$c)(PayrollPage);
2438
+ var AdditionalFieldsDialog$1 = injectIntl(withTheme(withStyles(styles)(connect(mapStateToProps$c, mapDispatchToProps$c)(AdditionalFieldsDialog))));
2453
2439
 
2454
- var useStyles$9 = makeStyles(function (theme) {
2440
+ /* eslint-disable max-len */
2441
+ var useStyles$a = makeStyles(function () {
2455
2442
  return {
2456
- form: {
2457
- padding: '0 0 10px 0',
2443
+ topHeader: {
2444
+ display: 'flex',
2445
+ justifyContent: 'start',
2446
+ alignItems: 'center',
2447
+ width: '100%',
2448
+ '& img': {
2449
+ minWidth: '250px',
2450
+ maxWidth: '300px',
2451
+ width: 'auto',
2452
+ height: 'auto'
2453
+ }
2454
+ },
2455
+ printContainer: {
2456
+ display: 'flex',
2457
+ flexDirection: 'column',
2458
+ alignItems: 'center',
2459
+ justifyContent: 'center',
2460
+ padding: '20px',
2461
+ fontWeight: '500'
2462
+ },
2463
+ date: {
2464
+ fontSize: '16px'
2465
+ },
2466
+ detailsContainer: {
2467
+ display: 'flex',
2468
+ flexDirection: 'column',
2469
+ padding: '12px',
2458
2470
  width: '100%'
2459
2471
  },
2460
- item: {
2461
- padding: theme.spacing(1)
2472
+ detailRow: {
2473
+ display: 'flex',
2474
+ flexDirection: 'row',
2475
+ alignItems: 'center',
2476
+ justifyContent: 'space-between',
2477
+ padding: '4px'
2478
+ },
2479
+ detailName: {
2480
+ fontWeight: '600',
2481
+ fontSize: '16px',
2482
+ textTransform: 'uppercase'
2483
+ },
2484
+ detailValue: {
2485
+ fontWeight: '500',
2486
+ backgroundColor: '#f5f5f5',
2487
+ padding: '6px',
2488
+ borderRadius: '8px',
2489
+ fontSize: '15px'
2490
+ },
2491
+ containerPadding: {
2492
+ padding: '32px'
2493
+ },
2494
+ dividerMargin: {
2495
+ margin: '12px 0'
2496
+ },
2497
+ sectionTitle: {
2498
+ fontWeight: '700',
2499
+ fontSize: '18px',
2500
+ textTransform: 'uppercase',
2501
+ marginBottom: '12px'
2462
2502
  }
2463
2503
  };
2464
2504
  });
2465
- function PayrollFilter(_ref) {
2466
- var _filters$isDeleted;
2467
- var filters = _ref.filters,
2468
- onChangeFilters = _ref.onChangeFilters,
2469
- _ref$statusReadOnly = _ref.statusReadOnly,
2470
- statusReadOnly = _ref$statusReadOnly === void 0 ? false : _ref$statusReadOnly;
2471
- var classes = useStyles$9();
2505
+ var PayrollBenefitPrintTemplate = /*#__PURE__*/forwardRef(function (_ref, ref) {
2506
+ var benefitAttachments = _ref.benefitAttachments;
2507
+ if (!benefitAttachments) return null;
2508
+ var classes = useStyles$a();
2472
2509
  var modulesManager = useModulesManager();
2473
- var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
2510
+ var _useTranslations = useTranslations(modulesManager, MODULE_NAME),
2474
2511
  formatMessage = _useTranslations.formatMessage;
2475
- var debouncedOnChangeFilters = _debounce(onChangeFilters, DEFAULT_DEBOUNCE_TIME);
2476
- var filterTextFieldValue = function filterTextFieldValue(filterName) {
2477
- var _filters$filterName$v, _filters$filterName;
2478
- return (_filters$filterName$v = filters === null || filters === void 0 || (_filters$filterName = filters[filterName]) === null || _filters$filterName === void 0 ? void 0 : _filters$filterName.value) !== null && _filters$filterName$v !== void 0 ? _filters$filterName$v : EMPTY_STRING;
2479
- };
2480
- var filterValue = function filterValue(filterName) {
2481
- var _filters$filterName$v2, _filters$filterName2;
2482
- return (_filters$filterName$v2 = filters === null || filters === void 0 || (_filters$filterName2 = filters[filterName]) === null || _filters$filterName2 === void 0 ? void 0 : _filters$filterName2.value) !== null && _filters$filterName$v2 !== void 0 ? _filters$filterName$v2 : null;
2512
+ return /*#__PURE__*/React.createElement("div", {
2513
+ ref: ref,
2514
+ className: classes.printContainer
2515
+ }, benefitAttachments.map(function (benefitAttachment, index) {
2516
+ var _benefitAttachment$bi;
2517
+ return /*#__PURE__*/React.createElement("div", {
2518
+ key: index,
2519
+ className: classes.detailsContainer
2520
+ }, /*#__PURE__*/React.createElement("div", {
2521
+ className: classes.sectionTitle
2522
+ }, "Payment: ".concat(benefitAttachment.benefit.code, " - ").concat(benefitAttachment.benefit.individual.firstName, ", ").concat(benefitAttachment.benefit.individual.lastName)), /*#__PURE__*/React.createElement("div", {
2523
+ className: classes.detailRow
2524
+ }, /*#__PURE__*/React.createElement("div", {
2525
+ className: classes.detailName
2526
+ }, formatMessage('payroll.benefitConsumption.individual.firstName')), /*#__PURE__*/React.createElement("div", {
2527
+ className: classes.detailValue
2528
+ }, benefitAttachment.benefit.individual.firstName)), /*#__PURE__*/React.createElement("div", {
2529
+ className: classes.detailRow
2530
+ }, /*#__PURE__*/React.createElement("div", {
2531
+ className: classes.detailName
2532
+ }, formatMessage('payroll.benefitConsumption.individual.lastName')), /*#__PURE__*/React.createElement("div", {
2533
+ className: classes.detailValue
2534
+ }, benefitAttachment.benefit.individual.lastName)), /*#__PURE__*/React.createElement("div", {
2535
+ className: classes.detailRow
2536
+ }, /*#__PURE__*/React.createElement("div", {
2537
+ className: classes.detailName
2538
+ }, formatMessage('payroll.benefitConsumption.code')), /*#__PURE__*/React.createElement("div", {
2539
+ className: classes.detailValue
2540
+ }, benefitAttachment.benefit.code)), /*#__PURE__*/React.createElement("div", {
2541
+ className: classes.detailRow
2542
+ }, /*#__PURE__*/React.createElement("div", {
2543
+ className: classes.detailName
2544
+ }, formatMessage('payroll.benefitConsumption.dateDue')), /*#__PURE__*/React.createElement("div", {
2545
+ className: classes.detailValue
2546
+ }, benefitAttachment.benefit.dateDue)), /*#__PURE__*/React.createElement("div", {
2547
+ className: classes.detailRow
2548
+ }, /*#__PURE__*/React.createElement("div", {
2549
+ className: classes.detailName
2550
+ }, formatMessage('payroll.benefitConsumption.receipt')), /*#__PURE__*/React.createElement("div", {
2551
+ className: classes.detailValue
2552
+ }, benefitAttachment.benefit.receipt)), /*#__PURE__*/React.createElement("div", {
2553
+ className: classes.detailRow
2554
+ }, /*#__PURE__*/React.createElement("div", {
2555
+ className: classes.detailName
2556
+ }, formatMessage('payroll.benefitConsumption.amount')), /*#__PURE__*/React.createElement("div", {
2557
+ className: classes.detailValue
2558
+ }, benefitAttachment.benefit.amount)), /*#__PURE__*/React.createElement("div", {
2559
+ className: classes.detailRow
2560
+ }, /*#__PURE__*/React.createElement("div", {
2561
+ className: classes.detailName
2562
+ }, formatMessage('payroll.benefitConsumption.type')), /*#__PURE__*/React.createElement("div", {
2563
+ className: classes.detailValue
2564
+ }, benefitAttachment.benefit.type)), /*#__PURE__*/React.createElement("div", {
2565
+ className: classes.detailRow
2566
+ }, /*#__PURE__*/React.createElement("div", {
2567
+ className: classes.detailName
2568
+ }, formatMessage('payroll.benefitConsumption.status')), /*#__PURE__*/React.createElement("div", {
2569
+ className: classes.detailValue
2570
+ }, benefitAttachment.benefit.status)), /*#__PURE__*/React.createElement("div", {
2571
+ className: classes.detailRow
2572
+ }, /*#__PURE__*/React.createElement("div", {
2573
+ className: classes.detailName
2574
+ }, formatMessage('payroll.benefitConsumption.payedOnTime')), /*#__PURE__*/React.createElement("div", {
2575
+ className: classes.detailValue
2576
+ }, benefitAttachment.benefit.payedOnTime ? 'Yes' : 'No')), /*#__PURE__*/React.createElement("div", {
2577
+ className: classes.detailRow
2578
+ }, /*#__PURE__*/React.createElement("div", {
2579
+ className: classes.detailName
2580
+ }, formatMessage('payroll.benefitConsumption.paymentDate')), /*#__PURE__*/React.createElement("div", {
2581
+ className: classes.detailValue
2582
+ }, !benefitAttachment.benefit.receipt ? '' : benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$bi = benefitAttachment.bill) === null || _benefitAttachment$bi === void 0 ? void 0 : _benefitAttachment$bi.datePayed)), /*#__PURE__*/React.createElement(Divider, {
2583
+ className: classes.dividerMargin
2584
+ }));
2585
+ }));
2586
+ });
2587
+
2588
+ function BenefitConsumptionSearcherModal(_ref) {
2589
+ var fetchBenefitAttachments = _ref.fetchBenefitAttachments,
2590
+ fetchingBenefitAttachments = _ref.fetchingBenefitAttachments,
2591
+ fetchedBenefitAttachments = _ref.fetchedBenefitAttachments,
2592
+ errorBenefitAttachments = _ref.errorBenefitAttachments,
2593
+ benefitAttachments = _ref.benefitAttachments,
2594
+ benefitAttachmentsPageInfo = _ref.benefitAttachmentsPageInfo,
2595
+ benefitAttachmentsTotalCount = _ref.benefitAttachmentsTotalCount,
2596
+ payrollUuid = _ref.payrollUuid,
2597
+ reconciledMode = _ref.reconciledMode,
2598
+ payrollDetail = _ref.payrollDetail,
2599
+ deleteBenefitConsumption = _ref.deleteBenefitConsumption;
2600
+ var modulesManager = useModulesManager();
2601
+ var _useTranslations = useTranslations('payroll', modulesManager),
2602
+ formatMessage = _useTranslations.formatMessage,
2603
+ formatMessageWithValues = _useTranslations.formatMessageWithValues;
2604
+ var _useState = useState(null),
2605
+ _useState2 = _slicedToArray(_useState, 2),
2606
+ selectedBenefitAttachment = _useState2[0],
2607
+ setSelectedBenefitAttachment = _useState2[1];
2608
+ var _useState3 = useState(false),
2609
+ _useState4 = _slicedToArray(_useState3, 2),
2610
+ openConfirmDialog = _useState4[0],
2611
+ setOpenConfirmDialog = _useState4[1];
2612
+ var _useState5 = useState(null),
2613
+ _useState6 = _slicedToArray(_useState5, 2),
2614
+ benefitToDelete = _useState6[0],
2615
+ setBenefitToDelete = _useState6[1];
2616
+ var payrollPrintTemplateRef = useRef(null);
2617
+ var handlePrint = useReactToPrint({
2618
+ documentTitle: "".concat(payrollUuid)
2619
+ });
2620
+ var fetch = function fetch(params) {
2621
+ fetchBenefitAttachments(modulesManager, params);
2483
2622
  };
2484
- var onChangeStringFilter = function onChangeStringFilter(filterName) {
2485
- var lookup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2486
- return function (value) {
2487
- if (lookup) {
2488
- debouncedOnChangeFilters([{
2489
- id: filterName,
2490
- value: value,
2491
- filter: "".concat(filterName, "_").concat(lookup, ": \"").concat(value, "\"")
2492
- }]);
2493
- } else {
2494
- debouncedOnChangeFilters([{
2495
- id: filterName,
2496
- value: value,
2497
- filter: "".concat(filterName, ": \"").concat(value, "\"")
2498
- }]);
2623
+ var defaultFilters = function defaultFilters() {
2624
+ var filters = {
2625
+ isDeleted: {
2626
+ value: false,
2627
+ filter: 'isDeleted: false'
2628
+ },
2629
+ payrollUuid: {
2630
+ value: payrollUuid,
2631
+ filter: "payrollUuid: \"".concat(payrollUuid, "\"")
2499
2632
  }
2500
2633
  };
2634
+ if (reconciledMode && payrollDetail.paymentMethod !== PAYMENT_METHOD.STRATEGY_ONLINE_PAYMENT && payrollDetail.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) {
2635
+ filters.benefit_Status = {
2636
+ value: 'RECONCILED',
2637
+ filter: "benefit_Status: ".concat(PAYROLL_STATUS.RECONCILED)
2638
+ };
2639
+ }
2640
+ return filters;
2501
2641
  };
2502
- return /*#__PURE__*/React.createElement(Grid, {
2503
- container: true,
2504
- className: classes.form
2505
- }, /*#__PURE__*/React.createElement(Grid, {
2506
- item: true,
2507
- xs: 3,
2508
- className: classes.item
2509
- }, /*#__PURE__*/React.createElement(TextInput, {
2510
- module: "payroll",
2511
- label: formatMessage('payroll.name'),
2512
- value: filterTextFieldValue('name'),
2513
- onChange: onChangeStringFilter('name', CONTAINS_LOOKUP)
2514
- })), /*#__PURE__*/React.createElement(Grid, {
2515
- item: true,
2516
- xs: 3,
2517
- className: classes.item
2518
- }, /*#__PURE__*/React.createElement(PublishedComponent, {
2519
- pubRef: "contributionPlan.PaymentPlanPicker",
2520
- filters: filters,
2521
- value: filterValue('paymentPlan_Id'),
2522
- onChange: function onChange(paymentPlan) {
2523
- return onChangeFilters([{
2524
- id: 'paymentPlan_Id',
2525
- value: paymentPlan,
2526
- filter: "paymentPlan_Id: \"".concat((paymentPlan === null || paymentPlan === void 0 ? void 0 : paymentPlan.id) && decodeId(paymentPlan.id), "\"")
2527
- }]);
2528
- }
2529
- })), /*#__PURE__*/React.createElement(Grid, {
2530
- item: true,
2531
- xs: 3,
2532
- className: classes.item
2533
- }, /*#__PURE__*/React.createElement(PublishedComponent, {
2534
- pubRef: "paymentCycle.PaymentCyclePicker",
2535
- withLabel: true,
2536
- withPlaceholder: true,
2537
- filters: filters,
2538
- value: filterValue('paymentCycle_Id'),
2539
- onChange: function onChange(paymentCycle) {
2540
- return onChangeFilters([{
2541
- id: 'paymentCycle_Id',
2542
- value: paymentCycle,
2543
- filter: "paymentCycle_Id: \"".concat((paymentCycle === null || paymentCycle === void 0 ? void 0 : paymentCycle.id) && decodeId(paymentCycle.id), "\"")
2544
- }]);
2545
- }
2546
- })), /*#__PURE__*/React.createElement(Grid, {
2547
- item: true,
2548
- xs: 2,
2549
- className: classes.item
2550
- }, /*#__PURE__*/React.createElement(PayrollStatusPicker, {
2551
- withNull: true,
2552
- nullLabel: formatMessage('any'),
2553
- label: formatMessage('paymentMethod'),
2554
- value: filterValue('status'),
2555
- readOnly: statusReadOnly,
2556
- onChange: function onChange(value) {
2557
- return onChangeFilters([{
2558
- id: 'status',
2559
- value: value,
2560
- filter: value ? "status: ".concat(value) : EMPTY_STRING
2561
- }]);
2562
- }
2563
- })), /*#__PURE__*/React.createElement(Grid, {
2564
- item: true,
2565
- xs: 2,
2566
- className: classes.item
2567
- }, /*#__PURE__*/React.createElement(PaymentMethodPicker$1, {
2568
- withNull: true,
2569
- nullLabel: formatMessage('any'),
2570
- label: formatMessage('payroll.paymentMethod'),
2571
- value: filterValue('paymentMethod'),
2572
- onChange: function onChange(value) {
2573
- return onChangeFilters([{
2574
- id: 'paymentMethod',
2575
- value: value,
2576
- filter: "paymentMethod: \"".concat(value, "\"")
2577
- }]);
2642
+ var defaultFiltersArray = function defaultFiltersArray() {
2643
+ var filters = ['isDeleted: false', "first: ".concat(DEFAULT_PAGE_SIZE), "payrollUuid: \"".concat(payrollUuid, "\"")];
2644
+ if (reconciledMode && payrollDetail.paymentMethod !== PAYMENT_METHOD.STRATEGY_ONLINE_PAYMENT && payrollDetail.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) {
2645
+ filters.push("benefit_Status: ".concat(PAYROLL_STATUS.RECONCILED));
2578
2646
  }
2579
- })), /*#__PURE__*/React.createElement(ControlledField, {
2580
- module: "payroll",
2581
- id: "payrollFilter.showHistory",
2582
- field: /*#__PURE__*/React.createElement(Grid, {
2583
- item: true,
2584
- xs: 12,
2585
- className: classes.item
2586
- }, /*#__PURE__*/React.createElement(FormControlLabel, {
2587
- control: /*#__PURE__*/React.createElement(Checkbox, {
2588
- color: "primary",
2589
- checked: filters === null || filters === void 0 || (_filters$isDeleted = filters.isDeleted) === null || _filters$isDeleted === void 0 ? void 0 : _filters$isDeleted.value,
2590
- onChange: function onChange() {
2591
- var _filters$isDeleted2, _filters$isDeleted3;
2592
- return onChangeFilters([{
2593
- id: 'isDeleted',
2594
- value: !(filters !== null && filters !== void 0 && (_filters$isDeleted2 = filters.isDeleted) !== null && _filters$isDeleted2 !== void 0 && _filters$isDeleted2.value),
2595
- filter: "isDeleted: ".concat(!(filters !== null && filters !== void 0 && (_filters$isDeleted3 = filters.isDeleted) !== null && _filters$isDeleted3 !== void 0 && _filters$isDeleted3.value))
2596
- }]);
2597
- }
2598
- }),
2599
- label: formatMessage('tooltip.isDeleted')
2600
- }))
2601
- }));
2602
- }
2603
-
2604
- function PayrollSearcher(_ref) {
2605
- var deletePayrolls = _ref.deletePayrolls,
2606
- fetchingPayrolls = _ref.fetchingPayrolls,
2607
- fetchedPayrolls = _ref.fetchedPayrolls,
2608
- errorPayrolls = _ref.errorPayrolls,
2609
- payrolls = _ref.payrolls,
2610
- pageInfo = _ref.pageInfo,
2611
- totalCount = _ref.totalCount,
2612
- fetchPayrolls = _ref.fetchPayrolls,
2613
- coreConfirm = _ref.coreConfirm,
2614
- clearConfirm = _ref.clearConfirm,
2615
- confirmed = _ref.confirmed,
2616
- submittingMutation = _ref.submittingMutation,
2617
- mutation = _ref.mutation;
2618
- var history = useHistory();
2619
- var modulesManager = useModulesManager();
2620
- var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
2621
- formatMessage = _useTranslations.formatMessage,
2622
- formatMessageWithValues = _useTranslations.formatMessageWithValues;
2623
- var rights = useSelector(function (store) {
2624
- var _store$core$user$i_us;
2625
- return (_store$core$user$i_us = store.core.user.i_user.rights) !== null && _store$core$user$i_us !== void 0 ? _store$core$user$i_us : [];
2626
- });
2627
- var _useState = useState(null),
2628
- _useState2 = _slicedToArray(_useState, 2),
2629
- payrollToDelete = _useState2[0],
2630
- setPayrollToDelete = _useState2[1];
2631
- var _useState3 = useState([]),
2632
- _useState4 = _slicedToArray(_useState3, 2),
2633
- deletedPayrollUuids = _useState4[0],
2634
- setDeletedPayrollUuids = _useState4[1];
2635
- var prevSubmittingMutationRef = useRef();
2636
- var openDeletePayrollConfirmDialog = function openDeletePayrollConfirmDialog() {
2637
- coreConfirm(formatMessageWithValues('payroll.delete.confirm.title', pageTitle(payrollToDelete)), formatMessage('payroll.delete.confirm.message'));
2647
+ return filters;
2638
2648
  };
2639
- useEffect(function () {
2640
- return payrollToDelete && openDeletePayrollConfirmDialog();
2641
- }, [payrollToDelete]);
2642
- useEffect(function () {
2643
- if (payrollToDelete && confirmed) {
2644
- deletePayrolls(payrollToDelete, formatMessageWithValues('payroll.mutation.deleteLabel', mutationLabel(payrollToDelete)));
2645
- setDeletedPayrollUuids([].concat(_toConsumableArray(deletedPayrollUuids), [payrollToDelete.id]));
2646
- }
2647
- if (payrollToDelete && confirmed !== null) {
2648
- setPayrollToDelete(null);
2649
- }
2650
- return function () {
2651
- return confirmed && clearConfirm(false);
2652
- };
2653
- }, [confirmed]);
2654
- useEffect(function () {
2655
- if (prevSubmittingMutationRef.current && !submittingMutation) {
2656
- journalize(mutation);
2657
- }
2658
- }, [submittingMutation]);
2659
- useEffect(function () {
2660
- prevSubmittingMutationRef.current = submittingMutation;
2661
- });
2662
2649
  var headers = function headers() {
2663
- return ['payroll.name', 'payroll.benefitPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'emptyLabel'];
2664
- };
2665
- var sorts = function sorts() {
2666
- return [['name', true], ['benefitPlan', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true]];
2667
- };
2668
- var defaultFilters = function defaultFilters() {
2669
- return {
2670
- isDeleted: {
2671
- value: false,
2672
- filter: 'isDeleted: false'
2673
- }
2674
- };
2675
- };
2676
- var fetch = function fetch(params) {
2677
- return fetchPayrolls(modulesManager, params);
2650
+ return ['benefitConsumption.photo', 'benefitConsumption.individual.firstName', 'benefitConsumption.individual.lastName', 'benefitConsumption.amount', 'benefitConsumption.receipt', 'benefitConsumption.dateDue', 'benefitConsumption.payedOnTime', 'benefitConsumption.paymentDate', 'benefitConsumption.status', '', ''];
2678
2651
  };
2679
- var rowIdentifier = function rowIdentifier(payroll) {
2680
- return payroll.id;
2652
+ var confirmDeleteBenefitConsumption = function confirmDeleteBenefitConsumption(benefit) {
2653
+ setBenefitToDelete(benefit);
2654
+ setOpenConfirmDialog(true);
2681
2655
  };
2682
- var openPayroll = function openPayroll(payroll) {
2683
- return rights.includes(RIGHT_PAYROLL_SEARCH) && history.push("/".concat(modulesManager.getRef(PAYROLL_PAYROLL_ROUTE), "/").concat(payroll === null || payroll === void 0 ? void 0 : payroll.id));
2656
+ var handleDeleteBenefitConsumption = function handleDeleteBenefitConsumption() {
2657
+ deleteBenefitConsumption(benefitToDelete.benefit, formatMessageWithValues('payroll.mutation.deleteLabel', mutationLabel(benefitToDelete.benefit.code)));
2658
+ setOpenConfirmDialog(false);
2659
+ setBenefitToDelete(null);
2660
+ var filters = defaultFiltersArray();
2661
+ fetchBenefitAttachments(modulesManager, filters); // Refresh the searcher after deletion
2684
2662
  };
2685
- var onDelete = function onDelete(payroll) {
2686
- return setPayrollToDelete(payroll);
2663
+ var checkBenefitDueDate = function checkBenefitDueDate(benefitAttachment) {
2664
+ if (!benefitAttachment.benefit.receipt) {
2665
+ return ''; // return empty string if datePayed is null
2666
+ }
2667
+ return benefitAttachment.benefit && benefitAttachment.benefit.dateDue >= benefitAttachment.bill.datePayed ? 'True' : 'False';
2687
2668
  };
2688
2669
  var itemFormatters = function itemFormatters() {
2689
- return [function (payroll) {
2690
- return payroll.name;
2691
- }, function (payroll) {
2692
- return payroll.benefitPlan ? "".concat(payroll.benefitPlan.code, " ").concat(payroll.benefitPlan.name) : '';
2693
- }, function (payroll) {
2694
- return payroll.paymentPoint ? "".concat(payroll.paymentPoint.name) : '';
2695
- }, function (payroll) {
2696
- return payroll.status ? "".concat(payroll.status) : '';
2697
- }, function (payroll) {
2698
- return payroll.paymentMethod ? "".concat(payroll.paymentMethod) : '';
2699
- }, function (payroll) {
2700
- return /*#__PURE__*/React.createElement(Tooltip, {
2701
- title: formatMessage('tooltip.viewDetails')
2702
- }, /*#__PURE__*/React.createElement(IconButton, {
2670
+ return [function (benefitAttachment) {
2671
+ return benefitAttachment.benefit.receipt ? /*#__PURE__*/React.createElement(PhotoCameraOutlinedIcon, {
2672
+ style: {
2673
+ fontSize: 150
2674
+ }
2675
+ }) : null;
2676
+ }, function (benefitAttachment) {
2677
+ var _benefitAttachment$be;
2678
+ return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be = benefitAttachment.benefit) === null || _benefitAttachment$be === void 0 || (_benefitAttachment$be = _benefitAttachment$be.individual) === null || _benefitAttachment$be === void 0 ? void 0 : _benefitAttachment$be.firstName;
2679
+ }, function (benefitAttachment) {
2680
+ var _benefitAttachment$be2;
2681
+ return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be2 = benefitAttachment.benefit) === null || _benefitAttachment$be2 === void 0 || (_benefitAttachment$be2 = _benefitAttachment$be2.individual) === null || _benefitAttachment$be2 === void 0 ? void 0 : _benefitAttachment$be2.lastName;
2682
+ }, function (benefitAttachment) {
2683
+ var _benefitAttachment$bi;
2684
+ return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$bi = benefitAttachment.bill) === null || _benefitAttachment$bi === void 0 ? void 0 : _benefitAttachment$bi.amountTotal;
2685
+ }, function (benefitAttachment) {
2686
+ var _benefitAttachment$be3;
2687
+ return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be3 = benefitAttachment.benefit) === null || _benefitAttachment$be3 === void 0 ? void 0 : _benefitAttachment$be3.receipt;
2688
+ }, function (benefitAttachment) {
2689
+ var _benefitAttachment$be4;
2690
+ return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be4 = benefitAttachment.benefit) === null || _benefitAttachment$be4 === void 0 ? void 0 : _benefitAttachment$be4.dateDue;
2691
+ }, function (benefitAttachment) {
2692
+ return checkBenefitDueDate(benefitAttachment);
2693
+ }, function (benefitAttachment) {
2694
+ var _benefitAttachment$bi2;
2695
+ return !benefitAttachment.benefit.receipt ? '' : benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$bi2 = benefitAttachment.bill) === null || _benefitAttachment$bi2 === void 0 ? void 0 : _benefitAttachment$bi2.datePayed;
2696
+ }, function (benefitAttachment) {
2697
+ var _benefitAttachment$be5;
2698
+ return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be5 = benefitAttachment.benefit) === null || _benefitAttachment$be5 === void 0 ? void 0 : _benefitAttachment$be5.status;
2699
+ }, function (benefitAttachment) {
2700
+ var _benefitAttachment$be6;
2701
+ return /*#__PURE__*/React.createElement(AdditionalFieldsDialog$1, {
2702
+ jsonExt: benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be6 = benefitAttachment.benefit) === null || _benefitAttachment$be6 === void 0 ? void 0 : _benefitAttachment$be6.jsonExt,
2703
+ buttonLabel: "payroll.additonalFields.showAdditionalFields",
2704
+ title: "payroll.additonalFields.label"
2705
+ });
2706
+ }, function (benefitAttachment) {
2707
+ return /*#__PURE__*/React.createElement(Button, {
2708
+ onClick: function onClick() {},
2709
+ variant: "contained",
2710
+ color: "primary",
2711
+ disabled: !!benefitAttachment.benefit.receipt
2712
+ }, formatMessage('payroll.summary.confirm'));
2713
+ }, function (benefitAttachment) {
2714
+ return (payrollDetail.paymentMethod === PAYMENT_METHOD.STRATEGY_ONLINE_PAYMENT || payrollDetail.paymentMethod === PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) && payrollDetail.status === PAYROLL_STATUS.RECONCILED && benefitAttachment.benefit.status !== 'RECONCILED' && /*#__PURE__*/React.createElement(Button, {
2703
2715
  onClick: function onClick() {
2704
- return openPayroll(payroll);
2716
+ return setSelectedBenefitAttachment(benefitAttachment);
2717
+ },
2718
+ variant: "contained",
2719
+ style: {
2720
+ backgroundColor: '#b80000',
2721
+ color: 'white'
2705
2722
  }
2706
- }, /*#__PURE__*/React.createElement(VisibilityIcon, null)));
2707
- }, function (payroll) {
2708
- return /*#__PURE__*/React.createElement(Tooltip, {
2709
- title: formatMessage('tooltip.delete')
2710
- }, /*#__PURE__*/React.createElement(IconButton, {
2723
+ }, formatMessage('payroll.summary.benefit_error'));
2724
+ }, function (benefitAttachment) {
2725
+ return payrollDetail.status === PAYROLL_STATUS.PENDING_APPROVAL && benefitAttachment.benefit.status !== 'PENDING_DELETION' && /*#__PURE__*/React.createElement(Button, {
2711
2726
  onClick: function onClick() {
2712
- return onDelete(payroll);
2727
+ return confirmDeleteBenefitConsumption(benefitAttachment);
2713
2728
  },
2714
- disabled: deletedPayrollUuids.includes(payroll.id) || payroll.status !== PAYROLL_STATUS.PENDING_APPROVAL
2715
- }, /*#__PURE__*/React.createElement(DeleteIcon, null)));
2716
- }];
2717
- };
2718
- var onDoubleClick = function onDoubleClick(payroll) {
2719
- return openPayroll(payroll);
2729
+ variant: "contained",
2730
+ style: {
2731
+ backgroundColor: '#b80000',
2732
+ color: 'white'
2733
+ }
2734
+ }, formatMessage('payroll.summary.benefit_delete'));
2735
+ }];
2720
2736
  };
2721
- var payrollFilter = function payrollFilter(_ref2) {
2737
+ var rowIdentifier = function rowIdentifier(benefitAttachment) {
2738
+ return benefitAttachment.id;
2739
+ };
2740
+ var sorts = function sorts() {
2741
+ return [['benefit_photo', false], ['benefit_individual_FirstName', true], ['benefit_individual_LastName', true], ['bill_amountTotal', true], ['benefit_receipt', true], ['benefit_dateDue', true]];
2742
+ };
2743
+ var benefitConsumptionFilterModal = function benefitConsumptionFilterModal(_ref2) {
2722
2744
  var filters = _ref2.filters,
2723
2745
  onChangeFilters = _ref2.onChangeFilters;
2724
- return /*#__PURE__*/React.createElement(PayrollFilter, {
2746
+ return /*#__PURE__*/React.createElement(BenefitConsumptionFilterModal, {
2725
2747
  filters: filters,
2726
2748
  onChangeFilters: onChangeFilters
2727
2749
  });
2728
2750
  };
2729
- var isRowDisabled = function isRowDisabled(_, payroll) {
2730
- return deletedPayrollUuids.includes(payroll.id);
2731
- };
2732
- return /*#__PURE__*/React.createElement(Searcher, {
2751
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
2752
+ size: "small",
2753
+ variant: "contained",
2754
+ color: "primary",
2755
+ startIcon: /*#__PURE__*/React.createElement(PrintIcon, null),
2756
+ onClick: function onClick(e) {
2757
+ e.preventDefault();
2758
+ handlePrint(null, function () {
2759
+ return payrollPrintTemplateRef.current;
2760
+ });
2761
+ }
2762
+ }, /*#__PURE__*/React.createElement(Typography$1, {
2763
+ variant: "subtitle1"
2764
+ }, "Print"))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Searcher, {
2733
2765
  module: "payroll",
2734
- FilterPane: payrollFilter,
2766
+ FilterPane: benefitConsumptionFilterModal,
2735
2767
  fetch: fetch,
2736
- items: payrolls,
2737
- itemsPageInfo: pageInfo,
2738
- fetchedItems: fetchedPayrolls,
2739
- fetchingItems: fetchingPayrolls,
2740
- errorItems: errorPayrolls,
2741
- tableTitle: formatMessageWithValues('payrollSearcher.results', {
2742
- totalCount: totalCount
2768
+ items: benefitAttachments,
2769
+ itemsPageInfo: benefitAttachmentsPageInfo,
2770
+ fetchingItems: fetchingBenefitAttachments,
2771
+ fetchedItems: fetchedBenefitAttachments,
2772
+ errorItems: errorBenefitAttachments,
2773
+ tableTitle: formatMessageWithValues('benefitAttachment.searcherResultsTitle', {
2774
+ benefitAttachmentsTotalCount: benefitAttachmentsTotalCount
2743
2775
  }),
2744
2776
  headers: headers,
2745
2777
  itemFormatters: itemFormatters,
@@ -2747,989 +2779,1089 @@ function PayrollSearcher(_ref) {
2747
2779
  rowsPerPageOptions: ROWS_PER_PAGE_OPTIONS,
2748
2780
  defaultPageSize: DEFAULT_PAGE_SIZE,
2749
2781
  rowIdentifier: rowIdentifier,
2750
- onDoubleClick: onDoubleClick,
2751
- defaultFilters: defaultFilters(),
2752
- rowDisabled: isRowDisabled,
2753
- rowLocked: isRowDisabled
2754
- });
2782
+ defaultFilters: defaultFilters()
2783
+ }), selectedBenefitAttachment && /*#__PURE__*/React.createElement(ErrorSummaryModal, {
2784
+ open: !!selectedBenefitAttachment,
2785
+ onClose: function onClose() {
2786
+ return setSelectedBenefitAttachment(null);
2787
+ },
2788
+ benefitAttachment: selectedBenefitAttachment
2789
+ }), /*#__PURE__*/React.createElement(Dialog, {
2790
+ open: openConfirmDialog,
2791
+ onClose: function onClose() {
2792
+ return setOpenConfirmDialog(false);
2793
+ }
2794
+ }, /*#__PURE__*/React.createElement(DialogTitle, null, formatMessage('benefitConsumption.delete.confirm.title')), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(DialogContentText, null, formatMessage('benefitConsumption.delete.confirm.message'))), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
2795
+ onClick: function onClick() {
2796
+ return setOpenConfirmDialog(false);
2797
+ },
2798
+ color: "primary"
2799
+ }, formatMessage('benefitConsumption.cancel')), /*#__PURE__*/React.createElement(Button, {
2800
+ onClick: handleDeleteBenefitConsumption,
2801
+ color: "primary",
2802
+ autoFocus: true
2803
+ }, formatMessage('benefitConsumption.confirm')))), /*#__PURE__*/React.createElement("div", {
2804
+ style: {
2805
+ display: 'none'
2806
+ }
2807
+ }, /*#__PURE__*/React.createElement(PayrollBenefitPrintTemplate, {
2808
+ ref: payrollPrintTemplateRef,
2809
+ benefitAttachments: benefitAttachments
2810
+ }))));
2755
2811
  }
2756
2812
  var mapStateToProps$b = function mapStateToProps(state) {
2757
2813
  return {
2758
- fetchingPayrolls: state.payroll.fetchingPayrolls,
2759
- fetchedPayrolls: state.payroll.fetchedPayrolls,
2760
- errorPayrolls: state.payroll.errorPayrolls,
2761
- payrolls: state.payroll.payrolls,
2762
- pageInfo: state.payroll.payrollsPageInfo,
2763
- totalCount: state.payroll.payrollsTotalCount,
2764
- confirmed: state.core.confirmed,
2765
- submittingMutation: state.payroll.submittingMutation,
2766
- mutation: state.payroll.mutation
2814
+ fetchingBenefitAttachments: state.payroll.fetchingBenefitAttachments,
2815
+ fetchedBenefitAttachments: state.payroll.fetchedBenefitAttachments,
2816
+ errorBenefitAttachments: state.payroll.errorBenefitAttachments,
2817
+ benefitAttachments: state.payroll.benefitAttachments,
2818
+ benefitAttachmentsPageInfo: state.payroll.benefitAttachmentsPageInfo,
2819
+ benefitAttachmentsTotalCount: state.payroll.benefitAttachmentsTotalCount
2767
2820
  };
2768
2821
  };
2769
2822
  var mapDispatchToProps$b = function mapDispatchToProps(dispatch) {
2770
2823
  return bindActionCreators({
2771
- fetchPayrolls: fetchPayrolls,
2772
- deletePayrolls: deletePayrolls,
2773
- journalize: journalize,
2774
- clearConfirm: clearConfirm,
2775
- coreConfirm: coreConfirm
2824
+ fetchBenefitAttachments: fetchBenefitAttachments,
2825
+ deleteBenefitConsumption: deleteBenefitConsumption
2776
2826
  }, dispatch);
2777
2827
  };
2778
- var PayrollSearcher$1 = connect(mapStateToProps$b, mapDispatchToProps$b)(PayrollSearcher);
2828
+ var BenefitConsumptionSearcherModal$1 = connect(mapStateToProps$b, mapDispatchToProps$b)(BenefitConsumptionSearcherModal);
2779
2829
 
2780
- var useStyles$8 = makeStyles(function (theme) {
2781
- return {
2782
- page: theme.page,
2783
- fab: theme.fab
2784
- };
2785
- });
2786
- function PayrollsPage() {
2787
- var modulesManager = useModulesManager();
2788
- var classes = useStyles$8();
2789
- var history = useHistory();
2790
- var rights = useSelector(function (store) {
2791
- var _store$core$user$i_us;
2792
- return (_store$core$user$i_us = store.core.user.i_user.rights) !== null && _store$core$user$i_us !== void 0 ? _store$core$user$i_us : [];
2830
+ function downloadPayroll(payrollId, payrollFileName) {
2831
+ var blank = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2832
+ var url = new URL("".concat(window.location.origin).concat(baseApiUrl, "/payroll/csv_reconciliation/"));
2833
+ url.searchParams.append('payroll_id', payrollId);
2834
+ url.searchParams.append('blank', blank);
2835
+ url.searchParams.append('payroll_file_name', payrollFileName);
2836
+ fetch(url).then(function (response) {
2837
+ return response.blob();
2838
+ }).then(function (blob) {
2839
+ var link = document.createElement('a');
2840
+ link.href = URL.createObjectURL(blob);
2841
+ link.download = blank ? "reconciliation_".concat(payrollFileName, ".csv") : payrollFileName;
2842
+ document.body.appendChild(link);
2843
+ link.click();
2844
+ document.body.removeChild(link);
2845
+ })["catch"](function (error) {
2846
+ // eslint-disable-next-line no-console
2847
+ console.error('Export failed, reason: ', error);
2793
2848
  });
2794
- var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
2795
- formatMessage = _useTranslations.formatMessage;
2796
- var onCreate = function onCreate() {
2797
- return history.push("/".concat(modulesManager.getRef(PAYROLL_PAYROLL_ROUTE)));
2798
- };
2799
- return /*#__PURE__*/React.createElement("div", {
2800
- className: classes.page
2801
- }, /*#__PURE__*/React.createElement(Helmet, {
2802
- title: formatMessage('paymentPoint.page.title')
2803
- }), rights.includes(RIGHT_PAYROLL_SEARCH) && /*#__PURE__*/React.createElement(PayrollSearcher$1, null), rights.includes(RIGHT_PAYROLL_CREATE) && withTooltip(/*#__PURE__*/React.createElement("div", {
2804
- className: classes.fab
2805
- }, /*#__PURE__*/React.createElement(Fab, {
2806
- color: "primary",
2807
- onClick: onCreate
2808
- }, /*#__PURE__*/React.createElement(AddIcon, null))), formatMessage('createButton.tooltip')));
2809
2849
  }
2810
2850
 
2811
- var useStyles$7 = makeStyles(function (theme) {
2812
- return {
2813
- form: {
2814
- padding: 0
2815
- },
2816
- item: {
2817
- padding: theme.spacing(1)
2818
- }
2819
- };
2820
- });
2821
- function BenefitConsumptionFilterModal(_ref) {
2822
- var filters = _ref.filters,
2823
- onChangeFilters = _ref.onChangeFilters;
2851
+ function PaymentApproveForPaymentDialog(_ref) {
2852
+ var _payrollDetail$id, _bistpSummary$reconci, _bistpSummary$total, _bistpSummary$pending, _bistpSummary$rejecte, _bistpSummary$skipped, _bistpSummary$sendFai;
2853
+ var classes = _ref.classes,
2854
+ payroll = _ref.payroll,
2855
+ closePayroll = _ref.closePayroll,
2856
+ rejectPayroll = _ref.rejectPayroll,
2857
+ payrollDetail = _ref.payrollDetail,
2858
+ fetchPayroll = _ref.fetchPayroll,
2859
+ makePaymentForPayroll = _ref.makePaymentForPayroll;
2824
2860
  var modulesManager = useModulesManager();
2825
- var classes = useStyles$7();
2826
- var _useTranslations = useTranslations('payroll', modulesManager),
2827
- formatMessage = _useTranslations.formatMessage;
2828
- var debouncedOnChangeFilters = _debounce(onChangeFilters, DEFAULT_DEBOUNCE_TIME);
2829
- var filterTextFieldValue = function filterTextFieldValue(filterName) {
2830
- var _filters$filterName$v, _filters$filterName;
2831
- return (_filters$filterName$v = filters === null || filters === void 0 || (_filters$filterName = filters[filterName]) === null || _filters$filterName === void 0 ? void 0 : _filters$filterName.value) !== null && _filters$filterName$v !== void 0 ? _filters$filterName$v : EMPTY_STRING;
2832
- };
2833
- var filterValue = function filterValue(filterName) {
2834
- var _filters$filterName$v2, _filters$filterName2;
2835
- return (_filters$filterName$v2 = filters === null || filters === void 0 || (_filters$filterName2 = filters[filterName]) === null || _filters$filterName2 === void 0 ? void 0 : _filters$filterName2.value) !== null && _filters$filterName$v2 !== void 0 ? _filters$filterName$v2 : null;
2836
- };
2837
- var onChangeFilter = function onChangeFilter(filterName) {
2838
- return function (value) {
2839
- debouncedOnChangeFilters([{
2840
- id: filterName,
2841
- value: value || null,
2842
- filter: "".concat(filterName, ": ").concat(value)
2843
- }]);
2844
- };
2861
+ var _useState = useState((_payrollDetail$id = payrollDetail === null || payrollDetail === void 0 ? void 0 : payrollDetail.id) !== null && _payrollDetail$id !== void 0 ? _payrollDetail$id : null),
2862
+ _useState2 = _slicedToArray(_useState, 1),
2863
+ payrollUuid = _useState2[0];
2864
+ var _useState3 = useState(false),
2865
+ _useState4 = _slicedToArray(_useState3, 2),
2866
+ isOpen = _useState4[0],
2867
+ setIsOpen = _useState4[1];
2868
+ var _useState5 = useState(0),
2869
+ _useState6 = _slicedToArray(_useState5, 2),
2870
+ totalBeneficiaries = _useState6[0],
2871
+ setTotalBeneficiaries = _useState6[1];
2872
+ var _useState7 = useState(0),
2873
+ _useState8 = _slicedToArray(_useState7, 2),
2874
+ selectedBeneficiaries = _useState8[0],
2875
+ setSelectedBeneficiaries = _useState8[1];
2876
+ var _useState9 = useState(0),
2877
+ _useState0 = _slicedToArray(_useState9, 2),
2878
+ approvedBeneficiaries = _useState0[0],
2879
+ setApprovedBeneficiaries = _useState0[1];
2880
+ var _useState1 = useState(0),
2881
+ _useState10 = _slicedToArray(_useState1, 2),
2882
+ totalBillAmount = _useState10[0],
2883
+ setTotalBillAmount = _useState10[1];
2884
+ var _useState11 = useState(0),
2885
+ _useState12 = _slicedToArray(_useState11, 2),
2886
+ totalReconciledBillAmount = _useState12[0],
2887
+ setTotalReconciledBillAmount = _useState12[1];
2888
+ var handleOpen = function handleOpen() {
2889
+ if (payrollUuid) {
2890
+ fetchPayroll(modulesManager, ["id: \"".concat(payrollUuid, "\"")]);
2891
+ }
2892
+ setIsOpen(true);
2845
2893
  };
2846
- var onChangeStringFilter = function onChangeStringFilter(filterName) {
2847
- var lookup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2848
- return function (value) {
2849
- if (lookup) {
2850
- debouncedOnChangeFilters([{
2851
- id: filterName,
2852
- value: value,
2853
- filter: "".concat(filterName, "_").concat(lookup, ": \"").concat(value, "\"")
2854
- }]);
2855
- } else {
2856
- debouncedOnChangeFilters([{
2857
- id: filterName,
2858
- value: value,
2859
- filter: "".concat(filterName, ": \"").concat(value, "\"")
2860
- }]);
2861
- }
2862
- };
2894
+ var handleClose = function handleClose() {
2895
+ setIsOpen(false);
2863
2896
  };
2864
- return /*#__PURE__*/React.createElement(Grid, {
2865
- container: true,
2866
- className: classes.form
2867
- }, /*#__PURE__*/React.createElement(Grid, {
2868
- item: true,
2869
- xs: 2,
2870
- className: classes.item
2871
- }, /*#__PURE__*/React.createElement(TextInput, {
2872
- module: "payroll",
2873
- label: "benefitConsumption.individual.firstName",
2874
- value: filterTextFieldValue('benefit_Individual_FirstName'),
2875
- onChange: onChangeStringFilter('benefit_Individual_FirstName', CONTAINS_LOOKUP)
2876
- })), /*#__PURE__*/React.createElement(Grid, {
2877
- item: true,
2878
- xs: 2,
2879
- className: classes.item
2880
- }, /*#__PURE__*/React.createElement(TextInput, {
2881
- module: "payroll",
2882
- label: "benefitConsumption.individual.lastName",
2883
- value: filterTextFieldValue('benefit_Individual_LastName'),
2884
- onChange: onChangeStringFilter('benefit_Individual_LastName', CONTAINS_LOOKUP)
2885
- })), /*#__PURE__*/React.createElement(Grid, {
2886
- item: true,
2887
- xs: 2,
2888
- className: classes.item
2889
- }, /*#__PURE__*/React.createElement(NumberInput, {
2890
- module: "payroll",
2891
- label: formatMessage('benefitConsumption.amount'),
2892
- min: 0,
2893
- value: filterValue('bill_AmountTotal'),
2894
- onChange: onChangeFilter('bill_AmountTotal')
2895
- })), /*#__PURE__*/React.createElement(Grid, {
2896
- item: true,
2897
- xs: 2,
2898
- className: classes.item
2899
- }, /*#__PURE__*/React.createElement(TextInput, {
2900
- module: "payroll",
2901
- label: "benefitConsumption.receipt",
2902
- value: filterTextFieldValue('benefit_Receipt'),
2903
- onChange: onChangeStringFilter('benefit_Receipt', CONTAINS_LOOKUP)
2904
- })), /*#__PURE__*/React.createElement(Grid, {
2905
- item: true,
2906
- xs: 2,
2907
- className: classes.item
2908
- }, /*#__PURE__*/React.createElement(PublishedComponent, {
2909
- pubRef: "core.DatePicker",
2910
- module: "payroll",
2911
- label: formatMessage('benefitConsumption.dateDue'),
2912
- value: filterValue('benefit_DateDue'),
2913
- onChange: function onChange(v) {
2914
- return onChangeFilters([{
2915
- id: 'benefit_DateDue',
2916
- value: v,
2917
- filter: "benefit_DateDue: \"".concat(v, "\"")
2918
- }]);
2919
- }
2920
- })), /*#__PURE__*/React.createElement(Grid, {
2921
- item: true,
2922
- xs: 2,
2923
- className: classes.item
2924
- }, /*#__PURE__*/React.createElement(PublishedComponent, {
2925
- pubRef: "core.DatePicker",
2926
- module: "payroll",
2927
- label: formatMessage('benefitConsumption.paymentDate'),
2928
- value: filterValue('bill_DatePayed_Gte'),
2929
- onChange: function onChange(v) {
2930
- return onChangeFilters([{
2931
- id: 'bill_DatePayed_Gte',
2932
- value: v,
2933
- filter: "bill_DatePayed_Gte: \"".concat(v, "\"")
2934
- }]);
2935
- }
2936
- })));
2937
- }
2938
-
2939
- function ErrorSummaryModal(_ref) {
2940
- var _benefitAttachment$be;
2941
- var open = _ref.open,
2942
- onClose = _ref.onClose,
2943
- benefitAttachment = _ref.benefitAttachment;
2944
- var modulesManager = useModulesManager();
2945
- var _useTranslations = useTranslations('payroll', modulesManager),
2946
- formatMessage = _useTranslations.formatMessage;
2947
- var jsonExt = benefitAttachment !== null && benefitAttachment !== void 0 && (_benefitAttachment$be = benefitAttachment.benefit) !== null && _benefitAttachment$be !== void 0 && _benefitAttachment$be.jsonExt ? JSON.parse(benefitAttachment.benefit.jsonExt) : {};
2948
- var outputGateway = "".concat(jsonExt === null || jsonExt === void 0 ? void 0 : jsonExt.output_gateway);
2949
- return /*#__PURE__*/React.createElement(Modal, {
2950
- open: open,
2951
- onClose: onClose,
2952
- closeAfterTransition: true,
2953
- BackdropComponent: Backdrop,
2954
- BackdropProps: {
2955
- timeout: 500
2956
- }
2957
- }, /*#__PURE__*/React.createElement(Fade, {
2958
- "in": open
2959
- }, /*#__PURE__*/React.createElement(Box, {
2960
- p: 4,
2961
- style: {
2962
- backgroundColor: 'white',
2963
- margin: 'auto',
2964
- maxWidth: 400,
2965
- outline: 'none'
2897
+ var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
2898
+ formatMessage = _useTranslations.formatMessage,
2899
+ formatMessageWithValues = _useTranslations.formatMessageWithValues;
2900
+ useEffect(function () {
2901
+ if (isOpen && Object.keys(payroll).length > 0) {
2902
+ // Calculate total benefits and reconciled benefits
2903
+ var total = payroll.benefitConsumption.length;
2904
+ var selected = payroll.benefitConsumption.filter(function (benefit) {
2905
+ return benefit.status === BENEFIT_CONSUMPTION_STATUS.RECONCILED;
2906
+ }).length;
2907
+ var approved = payroll.benefitConsumption.filter(function (benefit) {
2908
+ return benefit.status === BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT;
2909
+ }).length;
2910
+ setTotalBeneficiaries(total);
2911
+ setSelectedBeneficiaries(selected);
2912
+ setApprovedBeneficiaries(approved);
2913
+ var totalAmount = 0;
2914
+ var reconciledAmount = 0;
2915
+ if (payroll && payroll.benefitConsumption) {
2916
+ payroll.benefitConsumption.forEach(function (benefit) {
2917
+ if (benefit.benefitAttachment && benefit.benefitAttachment.length > 0) {
2918
+ benefit.benefitAttachment.forEach(function (attachment) {
2919
+ if (attachment.bill && attachment.bill.amountTotal) {
2920
+ totalAmount += parseFloat(attachment.bill.amountTotal);
2921
+ if (benefit.status === BENEFIT_CONSUMPTION_STATUS.RECONCILED) {
2922
+ reconciledAmount += parseFloat(attachment.bill.amountTotal);
2923
+ }
2924
+ }
2925
+ });
2926
+ }
2927
+ });
2928
+ }
2929
+ setTotalBillAmount(totalAmount);
2930
+ setTotalReconciledBillAmount(reconciledAmount);
2966
2931
  }
2967
- }, /*#__PURE__*/React.createElement(Typography, {
2968
- variant: "h6"
2969
- }, formatMessage('payroll.errorSummary.title')), outputGateway === null || outputGateway === 'undefined' ? /*#__PURE__*/React.createElement(Typography, null, formatMessage('payroll.errorSummary.outputGateway.noInfo')) : /*#__PURE__*/React.createElement(Typography, null, outputGateway), /*#__PURE__*/React.createElement(Box, {
2970
- display: "flex",
2971
- justifyContent: "center",
2972
- mt: 2
2973
- }, /*#__PURE__*/React.createElement(Button$1, {
2974
- onClick: onClose,
2975
- variant: "contained",
2976
- color: "primary"
2977
- }, formatMessage('payroll.errorSummary.close'))))));
2978
- }
2979
-
2980
- var styles = function styles(theme) {
2981
- return {
2982
- item: theme.paper.item
2932
+ }, [isOpen, payroll]);
2933
+ var closePayrollCallback = function closePayrollCallback() {
2934
+ handleClose();
2935
+ closePayroll(payrollDetail, formatMessageWithValues('payroll.mutation.closeLabel', mutationLabel(payrollDetail)));
2983
2936
  };
2984
- };
2985
- function AdditionalFieldsDialog(_ref) {
2986
- var intl = _ref.intl,
2987
- classes = _ref.classes,
2988
- jsonExt = _ref.jsonExt,
2989
- buttonLabel = _ref.buttonLabel,
2990
- title = _ref.title;
2991
- // eslint-disable-next-line no-param-reassign
2992
- if (!jsonExt) jsonExt = '{}';
2993
- var _useState = useState(false),
2994
- _useState2 = _slicedToArray(_useState, 2),
2995
- isOpen = _useState2[0],
2996
- setIsOpen = _useState2[1];
2997
- var handleOpen = function handleOpen() {
2998
- setIsOpen(true);
2937
+ var rejectPayrollCallback = function rejectPayrollCallback() {
2938
+ handleClose();
2939
+ rejectPayroll(payrollDetail, formatMessageWithValues('payroll.mutation.closeLabel', mutationLabel(payrollDetail)));
2999
2940
  };
3000
- var handleClose = function handleClose() {
3001
- setIsOpen(false);
2941
+ var makePaymentForPayrollCallback = function makePaymentForPayrollCallback() {
2942
+ handleClose();
2943
+ makePaymentForPayroll(payrollDetail, formatMessageWithValues('payroll.mutation.closeLabel', mutationLabel(payrollDetail)));
3002
2944
  };
3003
- var jsonExtFields = createFieldsBasedOnJSON(JSON.stringify(JSON.parse(jsonExt).extra_info));
2945
+ var downloadPayrollData = function downloadPayrollData(payrollUuid, payrollName) {
2946
+ downloadPayroll(payrollUuid, payrollName);
2947
+ };
2948
+ var isBistp = (payrollDetail === null || payrollDetail === void 0 ? void 0 : payrollDetail.paymentMethod) === PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT;
2949
+ var bistpSummary = (payroll === null || payroll === void 0 ? void 0 : payroll.bistpSummary) || {};
3004
2950
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
3005
2951
  onClick: handleOpen,
3006
- variant: "outlined",
3007
- color: "#DFEDEF",
3008
- className: classes.button,
3009
- style: {
3010
- border: '0px',
3011
- marginTop: '6px'
3012
- }
3013
- }, formatMessage(intl, 'payroll', buttonLabel)), /*#__PURE__*/React.createElement(Dialog, {
2952
+ variant: "contained",
2953
+ color: "primary",
2954
+ className: classes.button
2955
+ }, isBistp ? formatMessage('payroll.bistp.viewSummary') : formatMessage('payroll.viewReconciliationSummary')), /*#__PURE__*/React.createElement(Dialog, {
3014
2956
  open: isOpen,
3015
2957
  onClose: handleClose,
3016
2958
  PaperProps: {
3017
2959
  style: {
3018
- width: 1200,
3019
- maxWidth: 1200,
3020
- maxHeight: 900
2960
+ position: 'absolute',
2961
+ top: '50%',
2962
+ left: '50%',
2963
+ transform: 'translate(-50%,-50%)',
2964
+ width: '75%',
2965
+ maxWidth: '75%'
3021
2966
  }
3022
2967
  }
3023
- }, /*#__PURE__*/React.createElement("form", {
3024
- noValidate: true
3025
2968
  }, /*#__PURE__*/React.createElement(DialogTitle, {
3026
2969
  style: {
3027
2970
  marginTop: '10px'
3028
2971
  }
3029
- }, formatMessage(intl, 'payroll', title)), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement("div", {
3030
- style: {
3031
- backgroundColor: '#DFEDEF',
3032
- paddingLeft: '10px',
3033
- paddingBottom: '10px'
3034
- }
3035
- }, /*#__PURE__*/React.createElement(Grid, {
2972
+ }, formatMessageWithValues('payroll.reconciliationSummary', {
2973
+ payrollName: payrollDetail.name
2974
+ })), /*#__PURE__*/React.createElement(DialogContent, null, isBistp ? /*#__PURE__*/React.createElement(Grid, {
3036
2975
  container: true,
3037
- className: classes.item
3038
- }, jsonExtFields === null || jsonExtFields === void 0 ? void 0 : jsonExtFields.map(function (jsonExtField) {
3039
- return /*#__PURE__*/React.createElement(Grid, {
3040
- item: true,
3041
- xs: 6,
3042
- className: classes.item
3043
- }, renderInputComponent(MODULE_NAME, jsonExtField));
3044
- })))), /*#__PURE__*/React.createElement(DialogActions, {
2976
+ spacing: 2,
3045
2977
  style: {
3046
- display: 'inline',
3047
- paddingLeft: '10px',
3048
- marginTop: '25px',
3049
- marginBottom: '15px'
2978
+ marginBottom: 16
3050
2979
  }
3051
- }, /*#__PURE__*/React.createElement("div", {
2980
+ }, /*#__PURE__*/React.createElement(Grid, {
2981
+ item: true,
2982
+ xs: 3
2983
+ }, /*#__PURE__*/React.createElement(Paper, {
2984
+ elevation: 3,
3052
2985
  style: {
3053
- maxWidth: '1000px'
2986
+ padding: '20px',
2987
+ backgroundColor: '#e8f5e9'
3054
2988
  }
3055
- }, /*#__PURE__*/React.createElement("div", {
2989
+ }, /*#__PURE__*/React.createElement(Typography$1, {
2990
+ variant: "h6",
2991
+ gutterBottom: true
2992
+ }, formatMessage('payroll.bistp.reconciled')), /*#__PURE__*/React.createElement(Typography$1, {
2993
+ variant: "body1"
2994
+ }, (_bistpSummary$reconci = bistpSummary.reconciled) !== null && _bistpSummary$reconci !== void 0 ? _bistpSummary$reconci : 0, " / ", (_bistpSummary$total = bistpSummary.total) !== null && _bistpSummary$total !== void 0 ? _bistpSummary$total : 0))), /*#__PURE__*/React.createElement(Grid, {
2995
+ item: true,
2996
+ xs: 3
2997
+ }, /*#__PURE__*/React.createElement(Paper, {
2998
+ elevation: 3,
3056
2999
  style: {
3057
- "float": 'left'
3000
+ padding: '20px',
3001
+ backgroundColor: '#fff3e0'
3058
3002
  }
3059
- }, /*#__PURE__*/React.createElement(Button, {
3060
- onClick: handleClose,
3061
- variant: "outlined",
3062
- autoFocus: true,
3003
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3004
+ variant: "h6",
3005
+ gutterBottom: true
3006
+ }, formatMessage('payroll.bistp.pending')), /*#__PURE__*/React.createElement(Typography$1, {
3007
+ variant: "body1"
3008
+ }, (_bistpSummary$pending = bistpSummary.pending) !== null && _bistpSummary$pending !== void 0 ? _bistpSummary$pending : 0))), /*#__PURE__*/React.createElement(Grid, {
3009
+ item: true,
3010
+ xs: 3
3011
+ }, /*#__PURE__*/React.createElement(Paper, {
3012
+ elevation: 3,
3063
3013
  style: {
3064
- margin: '0 16px',
3065
- marginBottom: '15px'
3014
+ padding: '20px',
3015
+ backgroundColor: '#ffebee'
3066
3016
  }
3067
- }, formatMessage(intl, 'payroll', 'payroll.additonalFields.close'))), /*#__PURE__*/React.createElement("div", {
3017
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3018
+ variant: "h6",
3019
+ gutterBottom: true
3020
+ }, formatMessage('payroll.bistp.rejected')), /*#__PURE__*/React.createElement(Typography$1, {
3021
+ variant: "body1"
3022
+ }, (_bistpSummary$rejecte = bistpSummary.rejected) !== null && _bistpSummary$rejecte !== void 0 ? _bistpSummary$rejecte : 0))), /*#__PURE__*/React.createElement(Grid, {
3023
+ item: true,
3024
+ xs: 3
3025
+ }, /*#__PURE__*/React.createElement(Paper, {
3026
+ elevation: 3,
3068
3027
  style: {
3069
- "float": 'right',
3070
- paddingRight: '16px'
3028
+ padding: '20px',
3029
+ backgroundColor: '#e3f2fd'
3071
3030
  }
3072
- }))))));
3073
- }
3074
- var mapStateToProps$a = function mapStateToProps(state) {
3075
- return {
3076
- rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : []
3077
- };
3078
- };
3079
- var mapDispatchToProps$a = function mapDispatchToProps(dispatch) {
3080
- return bindActionCreators({}, dispatch);
3081
- };
3082
- var AdditionalFieldsDialog$1 = injectIntl(withTheme(withStyles(styles)(connect(mapStateToProps$a, mapDispatchToProps$a)(AdditionalFieldsDialog))));
3083
-
3084
- /* eslint-disable max-len */
3085
- var useStyles$6 = makeStyles(function () {
3086
- return {
3087
- topHeader: {
3088
- display: 'flex',
3089
- justifyContent: 'start',
3090
- alignItems: 'center',
3091
- width: '100%',
3092
- '& img': {
3093
- minWidth: '250px',
3094
- maxWidth: '300px',
3095
- width: 'auto',
3096
- height: 'auto'
3097
- }
3098
- },
3099
- printContainer: {
3100
- display: 'flex',
3101
- flexDirection: 'column',
3102
- alignItems: 'center',
3103
- justifyContent: 'center',
3031
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3032
+ variant: "h6",
3033
+ gutterBottom: true
3034
+ }, formatMessage('payroll.bistp.skippedNib')), /*#__PURE__*/React.createElement(Typography$1, {
3035
+ variant: "body1"
3036
+ }, (_bistpSummary$skipped = bistpSummary.skippedNib) !== null && _bistpSummary$skipped !== void 0 ? _bistpSummary$skipped : 0))), /*#__PURE__*/React.createElement(Grid, {
3037
+ item: true,
3038
+ xs: 3
3039
+ }, /*#__PURE__*/React.createElement(Paper, {
3040
+ elevation: 3,
3041
+ style: {
3104
3042
  padding: '20px',
3105
- fontWeight: '500'
3106
- },
3107
- date: {
3108
- fontSize: '16px'
3109
- },
3110
- detailsContainer: {
3111
- display: 'flex',
3112
- flexDirection: 'column',
3113
- padding: '12px',
3114
- width: '100%'
3115
- },
3116
- detailRow: {
3117
- display: 'flex',
3118
- flexDirection: 'row',
3119
- alignItems: 'center',
3120
- justifyContent: 'space-between',
3121
- padding: '4px'
3122
- },
3123
- detailName: {
3124
- fontWeight: '600',
3125
- fontSize: '16px',
3126
- textTransform: 'uppercase'
3127
- },
3128
- detailValue: {
3129
- fontWeight: '500',
3130
- backgroundColor: '#f5f5f5',
3131
- padding: '6px',
3132
- borderRadius: '8px',
3133
- fontSize: '15px'
3134
- },
3135
- containerPadding: {
3136
- padding: '32px'
3137
- },
3138
- dividerMargin: {
3139
- margin: '12px 0'
3140
- },
3141
- sectionTitle: {
3142
- fontWeight: '700',
3143
- fontSize: '18px',
3144
- textTransform: 'uppercase',
3145
- marginBottom: '12px'
3146
- }
3147
- };
3148
- });
3149
- var PayrollBenefitPrintTemplate = /*#__PURE__*/forwardRef(function (_ref, ref) {
3150
- var benefitAttachments = _ref.benefitAttachments;
3151
- if (!benefitAttachments) return null;
3152
- var classes = useStyles$6();
3153
- var modulesManager = useModulesManager();
3154
- var _useTranslations = useTranslations(modulesManager, MODULE_NAME),
3155
- formatMessage = _useTranslations.formatMessage;
3156
- return /*#__PURE__*/React.createElement("div", {
3157
- ref: ref,
3158
- className: classes.printContainer
3159
- }, benefitAttachments.map(function (benefitAttachment, index) {
3160
- var _benefitAttachment$bi;
3161
- return /*#__PURE__*/React.createElement("div", {
3162
- key: index,
3163
- className: classes.detailsContainer
3164
- }, /*#__PURE__*/React.createElement("div", {
3165
- className: classes.sectionTitle
3166
- }, "Payment: ".concat(benefitAttachment.benefit.code, " - ").concat(benefitAttachment.benefit.individual.firstName, ", ").concat(benefitAttachment.benefit.individual.lastName)), /*#__PURE__*/React.createElement("div", {
3167
- className: classes.detailRow
3168
- }, /*#__PURE__*/React.createElement("div", {
3169
- className: classes.detailName
3170
- }, formatMessage('payroll.benefitConsumption.individual.firstName')), /*#__PURE__*/React.createElement("div", {
3171
- className: classes.detailValue
3172
- }, benefitAttachment.benefit.individual.firstName)), /*#__PURE__*/React.createElement("div", {
3173
- className: classes.detailRow
3174
- }, /*#__PURE__*/React.createElement("div", {
3175
- className: classes.detailName
3176
- }, formatMessage('payroll.benefitConsumption.individual.lastName')), /*#__PURE__*/React.createElement("div", {
3177
- className: classes.detailValue
3178
- }, benefitAttachment.benefit.individual.lastName)), /*#__PURE__*/React.createElement("div", {
3179
- className: classes.detailRow
3180
- }, /*#__PURE__*/React.createElement("div", {
3181
- className: classes.detailName
3182
- }, formatMessage('payroll.benefitConsumption.code')), /*#__PURE__*/React.createElement("div", {
3183
- className: classes.detailValue
3184
- }, benefitAttachment.benefit.code)), /*#__PURE__*/React.createElement("div", {
3185
- className: classes.detailRow
3186
- }, /*#__PURE__*/React.createElement("div", {
3187
- className: classes.detailName
3188
- }, formatMessage('payroll.benefitConsumption.dateDue')), /*#__PURE__*/React.createElement("div", {
3189
- className: classes.detailValue
3190
- }, benefitAttachment.benefit.dateDue)), /*#__PURE__*/React.createElement("div", {
3191
- className: classes.detailRow
3192
- }, /*#__PURE__*/React.createElement("div", {
3193
- className: classes.detailName
3194
- }, formatMessage('payroll.benefitConsumption.receipt')), /*#__PURE__*/React.createElement("div", {
3195
- className: classes.detailValue
3196
- }, benefitAttachment.benefit.receipt)), /*#__PURE__*/React.createElement("div", {
3197
- className: classes.detailRow
3198
- }, /*#__PURE__*/React.createElement("div", {
3199
- className: classes.detailName
3200
- }, formatMessage('payroll.benefitConsumption.amount')), /*#__PURE__*/React.createElement("div", {
3201
- className: classes.detailValue
3202
- }, benefitAttachment.benefit.amount)), /*#__PURE__*/React.createElement("div", {
3203
- className: classes.detailRow
3204
- }, /*#__PURE__*/React.createElement("div", {
3205
- className: classes.detailName
3206
- }, formatMessage('payroll.benefitConsumption.type')), /*#__PURE__*/React.createElement("div", {
3207
- className: classes.detailValue
3208
- }, benefitAttachment.benefit.type)), /*#__PURE__*/React.createElement("div", {
3209
- className: classes.detailRow
3210
- }, /*#__PURE__*/React.createElement("div", {
3211
- className: classes.detailName
3212
- }, formatMessage('payroll.benefitConsumption.status')), /*#__PURE__*/React.createElement("div", {
3213
- className: classes.detailValue
3214
- }, benefitAttachment.benefit.status)), /*#__PURE__*/React.createElement("div", {
3215
- className: classes.detailRow
3216
- }, /*#__PURE__*/React.createElement("div", {
3217
- className: classes.detailName
3218
- }, formatMessage('payroll.benefitConsumption.payedOnTime')), /*#__PURE__*/React.createElement("div", {
3219
- className: classes.detailValue
3220
- }, benefitAttachment.benefit.payedOnTime ? 'Yes' : 'No')), /*#__PURE__*/React.createElement("div", {
3221
- className: classes.detailRow
3222
- }, /*#__PURE__*/React.createElement("div", {
3223
- className: classes.detailName
3224
- }, formatMessage('payroll.benefitConsumption.paymentDate')), /*#__PURE__*/React.createElement("div", {
3225
- className: classes.detailValue
3226
- }, !benefitAttachment.benefit.receipt ? '' : benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$bi = benefitAttachment.bill) === null || _benefitAttachment$bi === void 0 ? void 0 : _benefitAttachment$bi.datePayed)), /*#__PURE__*/React.createElement(Divider, {
3227
- className: classes.dividerMargin
3228
- }));
3229
- }));
3230
- });
3231
-
3232
- function BenefitConsumptionSearcherModal(_ref) {
3233
- var fetchBenefitAttachments = _ref.fetchBenefitAttachments,
3234
- fetchingBenefitAttachments = _ref.fetchingBenefitAttachments,
3235
- fetchedBenefitAttachments = _ref.fetchedBenefitAttachments,
3236
- errorBenefitAttachments = _ref.errorBenefitAttachments,
3237
- benefitAttachments = _ref.benefitAttachments,
3238
- benefitAttachmentsPageInfo = _ref.benefitAttachmentsPageInfo,
3239
- benefitAttachmentsTotalCount = _ref.benefitAttachmentsTotalCount,
3240
- payrollUuid = _ref.payrollUuid,
3241
- reconciledMode = _ref.reconciledMode,
3242
- payrollDetail = _ref.payrollDetail,
3243
- deleteBenefitConsumption = _ref.deleteBenefitConsumption;
3244
- var modulesManager = useModulesManager();
3245
- var _useTranslations = useTranslations('payroll', modulesManager),
3246
- formatMessage = _useTranslations.formatMessage,
3247
- formatMessageWithValues = _useTranslations.formatMessageWithValues;
3248
- var _useState = useState(null),
3249
- _useState2 = _slicedToArray(_useState, 2),
3250
- selectedBenefitAttachment = _useState2[0],
3251
- setSelectedBenefitAttachment = _useState2[1];
3252
- var _useState3 = useState(false),
3253
- _useState4 = _slicedToArray(_useState3, 2),
3254
- openConfirmDialog = _useState4[0],
3255
- setOpenConfirmDialog = _useState4[1];
3256
- var _useState5 = useState(null),
3257
- _useState6 = _slicedToArray(_useState5, 2),
3258
- benefitToDelete = _useState6[0],
3259
- setBenefitToDelete = _useState6[1];
3260
- var payrollPrintTemplateRef = useRef(null);
3261
- var handlePrint = useReactToPrint({
3262
- documentTitle: "".concat(payrollUuid)
3263
- });
3264
- var fetch = function fetch(params) {
3265
- fetchBenefitAttachments(modulesManager, params);
3266
- };
3267
- var defaultFilters = function defaultFilters() {
3268
- var filters = {
3269
- isDeleted: {
3270
- value: false,
3271
- filter: 'isDeleted: false'
3272
- },
3273
- payrollUuid: {
3274
- value: payrollUuid,
3275
- filter: "payrollUuid: \"".concat(payrollUuid, "\"")
3276
- }
3277
- };
3278
- if (reconciledMode && payrollDetail.paymentMethod !== 'StrategyOnlinePayment') {
3279
- filters.benefit_Status = {
3280
- value: 'RECONCILED',
3281
- filter: "benefit_Status: ".concat(PAYROLL_STATUS.RECONCILED)
3282
- };
3043
+ backgroundColor: '#fce4ec'
3283
3044
  }
3284
- return filters;
3285
- };
3286
- var defaultFiltersArray = function defaultFiltersArray() {
3287
- var filters = ['isDeleted: false', "first: ".concat(DEFAULT_PAGE_SIZE), "payrollUuid: \"".concat(payrollUuid, "\"")];
3288
- if (reconciledMode && payrollDetail.paymentMethod !== 'StrategyOnlinePayment') {
3289
- filters.push("benefit_Status: ".concat(PAYROLL_STATUS.RECONCILED));
3045
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3046
+ variant: "h6",
3047
+ gutterBottom: true
3048
+ }, formatMessage('payroll.bistp.sendFailed')), /*#__PURE__*/React.createElement(Typography$1, {
3049
+ variant: "body1"
3050
+ }, (_bistpSummary$sendFai = bistpSummary.sendFailed) !== null && _bistpSummary$sendFai !== void 0 ? _bistpSummary$sendFai : 0)))) : /*#__PURE__*/React.createElement(Grid, {
3051
+ container: true,
3052
+ spacing: 2
3053
+ }, /*#__PURE__*/React.createElement(Grid, {
3054
+ item: true,
3055
+ xs: 4
3056
+ }, /*#__PURE__*/React.createElement(Paper, {
3057
+ elevation: 3,
3058
+ style: {
3059
+ padding: '20px'
3290
3060
  }
3291
- return filters;
3292
- };
3293
- var headers = function headers() {
3294
- return ['benefitConsumption.photo', 'benefitConsumption.individual.firstName', 'benefitConsumption.individual.lastName', 'benefitConsumption.amount', 'benefitConsumption.receipt', 'benefitConsumption.dateDue', 'benefitConsumption.payedOnTime', 'benefitConsumption.paymentDate', 'benefitConsumption.status', '', ''];
3295
- };
3296
- var confirmDeleteBenefitConsumption = function confirmDeleteBenefitConsumption(benefit) {
3297
- setBenefitToDelete(benefit);
3298
- setOpenConfirmDialog(true);
3299
- };
3300
- var handleDeleteBenefitConsumption = function handleDeleteBenefitConsumption() {
3301
- deleteBenefitConsumption(benefitToDelete.benefit, formatMessageWithValues('payroll.mutation.deleteLabel', mutationLabel(benefitToDelete.benefit.code)));
3302
- setOpenConfirmDialog(false);
3303
- setBenefitToDelete(null);
3304
- var filters = defaultFiltersArray();
3305
- fetchBenefitAttachments(modulesManager, filters); // Refresh the searcher after deletion
3306
- };
3307
- var checkBenefitDueDate = function checkBenefitDueDate(benefitAttachment) {
3308
- if (!benefitAttachment.benefit.receipt) {
3309
- return ''; // return empty string if datePayed is null
3061
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3062
+ variant: "h6",
3063
+ gutterBottom: true
3064
+ }, formatMessage('payroll.summary.selectedBeneficiaries')), /*#__PURE__*/React.createElement(Typography$1, {
3065
+ variant: "body1"
3066
+ }, formatMessageWithValues('payroll.summary.beneficiariesCount', {
3067
+ selectedBeneficiaries: selectedBeneficiaries,
3068
+ totalBeneficiaries: totalBeneficiaries
3069
+ })))), /*#__PURE__*/React.createElement(Grid, {
3070
+ item: true,
3071
+ xs: 4
3072
+ }, /*#__PURE__*/React.createElement(Paper, {
3073
+ elevation: 3,
3074
+ style: {
3075
+ padding: '20px'
3310
3076
  }
3311
- return benefitAttachment.benefit && benefitAttachment.benefit.dateDue >= benefitAttachment.bill.datePayed ? 'True' : 'False';
3312
- };
3313
- var itemFormatters = function itemFormatters() {
3314
- return [function (benefitAttachment) {
3315
- return benefitAttachment.benefit.receipt ? /*#__PURE__*/React.createElement(PhotoCameraOutlinedIcon, {
3316
- style: {
3317
- fontSize: 150
3318
- }
3319
- }) : null;
3320
- }, function (benefitAttachment) {
3321
- var _benefitAttachment$be;
3322
- return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be = benefitAttachment.benefit) === null || _benefitAttachment$be === void 0 || (_benefitAttachment$be = _benefitAttachment$be.individual) === null || _benefitAttachment$be === void 0 ? void 0 : _benefitAttachment$be.firstName;
3323
- }, function (benefitAttachment) {
3324
- var _benefitAttachment$be2;
3325
- return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be2 = benefitAttachment.benefit) === null || _benefitAttachment$be2 === void 0 || (_benefitAttachment$be2 = _benefitAttachment$be2.individual) === null || _benefitAttachment$be2 === void 0 ? void 0 : _benefitAttachment$be2.lastName;
3326
- }, function (benefitAttachment) {
3327
- var _benefitAttachment$bi;
3328
- return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$bi = benefitAttachment.bill) === null || _benefitAttachment$bi === void 0 ? void 0 : _benefitAttachment$bi.amountTotal;
3329
- }, function (benefitAttachment) {
3330
- var _benefitAttachment$be3;
3331
- return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be3 = benefitAttachment.benefit) === null || _benefitAttachment$be3 === void 0 ? void 0 : _benefitAttachment$be3.receipt;
3332
- }, function (benefitAttachment) {
3333
- var _benefitAttachment$be4;
3334
- return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be4 = benefitAttachment.benefit) === null || _benefitAttachment$be4 === void 0 ? void 0 : _benefitAttachment$be4.dateDue;
3335
- }, function (benefitAttachment) {
3336
- return checkBenefitDueDate(benefitAttachment);
3337
- }, function (benefitAttachment) {
3338
- var _benefitAttachment$bi2;
3339
- return !benefitAttachment.benefit.receipt ? '' : benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$bi2 = benefitAttachment.bill) === null || _benefitAttachment$bi2 === void 0 ? void 0 : _benefitAttachment$bi2.datePayed;
3340
- }, function (benefitAttachment) {
3341
- var _benefitAttachment$be5;
3342
- return benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be5 = benefitAttachment.benefit) === null || _benefitAttachment$be5 === void 0 ? void 0 : _benefitAttachment$be5.status;
3343
- }, function (benefitAttachment) {
3344
- var _benefitAttachment$be6;
3345
- return /*#__PURE__*/React.createElement(AdditionalFieldsDialog$1, {
3346
- jsonExt: benefitAttachment === null || benefitAttachment === void 0 || (_benefitAttachment$be6 = benefitAttachment.benefit) === null || _benefitAttachment$be6 === void 0 ? void 0 : _benefitAttachment$be6.jsonExt,
3347
- buttonLabel: "payroll.additonalFields.showAdditionalFields",
3348
- title: "payroll.additonalFields.label"
3349
- });
3350
- }, function (benefitAttachment) {
3351
- return /*#__PURE__*/React.createElement(Button, {
3352
- onClick: function onClick() {},
3353
- variant: "contained",
3354
- color: "primary",
3355
- disabled: !!benefitAttachment.benefit.receipt
3356
- }, formatMessage('payroll.summary.confirm'));
3357
- }, function (benefitAttachment) {
3358
- return payrollDetail.paymentMethod === 'StrategyOnlinePayment' && payrollDetail.status === PAYROLL_STATUS.RECONCILED && benefitAttachment.benefit.status !== 'RECONCILED' && /*#__PURE__*/React.createElement(Button, {
3359
- onClick: function onClick() {
3360
- return setSelectedBenefitAttachment(benefitAttachment);
3361
- },
3362
- variant: "contained",
3363
- style: {
3364
- backgroundColor: '#b80000',
3365
- color: 'white'
3366
- }
3367
- }, formatMessage('payroll.summary.benefit_error'));
3368
- }, function (benefitAttachment) {
3369
- return payrollDetail.status === PAYROLL_STATUS.PENDING_APPROVAL && benefitAttachment.benefit.status !== 'PENDING_DELETION' && /*#__PURE__*/React.createElement(Button, {
3370
- onClick: function onClick() {
3371
- return confirmDeleteBenefitConsumption(benefitAttachment);
3372
- },
3373
- variant: "contained",
3374
- style: {
3375
- backgroundColor: '#b80000',
3376
- color: 'white'
3377
- }
3378
- }, formatMessage('payroll.summary.benefit_delete'));
3379
- }];
3380
- };
3381
- var rowIdentifier = function rowIdentifier(benefitAttachment) {
3382
- return benefitAttachment.id;
3383
- };
3384
- var sorts = function sorts() {
3385
- return [['benefit_photo', false], ['benefit_individual_FirstName', true], ['benefit_individual_LastName', true], ['bill_amountTotal', true], ['benefit_receipt', true], ['benefit_dateDue', true]];
3386
- };
3387
- var benefitConsumptionFilterModal = function benefitConsumptionFilterModal(_ref2) {
3388
- var filters = _ref2.filters,
3389
- onChangeFilters = _ref2.onChangeFilters;
3390
- return /*#__PURE__*/React.createElement(BenefitConsumptionFilterModal, {
3391
- filters: filters,
3392
- onChangeFilters: onChangeFilters
3393
- });
3394
- };
3395
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
3396
- size: "small",
3077
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3078
+ variant: "h6",
3079
+ gutterBottom: true
3080
+ }, formatMessage('payroll.summary.totalAmountForInvoice')), /*#__PURE__*/React.createElement(Typography$1, {
3081
+ variant: "body1"
3082
+ }, totalBillAmount))), /*#__PURE__*/React.createElement(Grid, {
3083
+ item: true,
3084
+ xs: 4
3085
+ }, /*#__PURE__*/React.createElement(Paper, {
3086
+ elevation: 3,
3087
+ style: {
3088
+ padding: '20px'
3089
+ }
3090
+ }, /*#__PURE__*/React.createElement(Typography$1, {
3091
+ variant: "h6",
3092
+ gutterBottom: true
3093
+ }, formatMessage('payroll.summary.deliveredReconciliation')), /*#__PURE__*/React.createElement(Typography$1, {
3094
+ variant: "body1"
3095
+ }, totalReconciledBillAmount)))), /*#__PURE__*/React.createElement("div", {
3096
+ style: {
3097
+ backgroundColor: '#DFEDEF'
3098
+ }
3099
+ }, /*#__PURE__*/React.createElement(BenefitConsumptionSearcherModal$1, {
3100
+ payrollUuid: payrollDetail.id,
3101
+ payrollDetail: payrollDetail
3102
+ }))), /*#__PURE__*/React.createElement(DialogActions, {
3103
+ style: {
3104
+ display: 'inline',
3105
+ paddingLeft: '10px',
3106
+ marginTop: '25px',
3107
+ marginBottom: '15px',
3108
+ width: '100%'
3109
+ }
3110
+ }, /*#__PURE__*/React.createElement("div", {
3111
+ style: {
3112
+ maxWidth: '3000px'
3113
+ }
3114
+ }, /*#__PURE__*/React.createElement("div", {
3115
+ style: {
3116
+ "float": 'left'
3117
+ }
3118
+ }, /*#__PURE__*/React.createElement(Button, {
3119
+ onClick: function onClick() {
3120
+ return closePayrollCallback();
3121
+ },
3397
3122
  variant: "contained",
3398
3123
  color: "primary",
3399
- startIcon: /*#__PURE__*/React.createElement(PrintIcon, null),
3400
- onClick: function onClick(e) {
3401
- e.preventDefault();
3402
- handlePrint(null, function () {
3403
- return payrollPrintTemplateRef.current;
3404
- });
3124
+ disabled: payrollDetail.paymentMethod === PAYMENT_METHOD.STRATEGY_ONLINE_PAYMENT ? approvedBeneficiaries === 0 : selectedBeneficiaries === 0,
3125
+ style: {
3126
+ margin: '0 16px',
3127
+ marginBottom: '15px'
3405
3128
  }
3406
- }, /*#__PURE__*/React.createElement(Typography$1, {
3407
- variant: "subtitle1"
3408
- }, "Print"))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Searcher, {
3409
- module: "payroll",
3410
- FilterPane: benefitConsumptionFilterModal,
3411
- fetch: fetch,
3412
- items: benefitAttachments,
3413
- itemsPageInfo: benefitAttachmentsPageInfo,
3414
- fetchingItems: fetchingBenefitAttachments,
3415
- fetchedItems: fetchedBenefitAttachments,
3416
- errorItems: errorBenefitAttachments,
3417
- tableTitle: formatMessageWithValues('benefitAttachment.searcherResultsTitle', {
3418
- benefitAttachmentsTotalCount: benefitAttachmentsTotalCount
3419
- }),
3420
- headers: headers,
3421
- itemFormatters: itemFormatters,
3422
- sorts: sorts,
3423
- rowsPerPageOptions: ROWS_PER_PAGE_OPTIONS,
3424
- defaultPageSize: DEFAULT_PAGE_SIZE,
3425
- rowIdentifier: rowIdentifier,
3426
- defaultFilters: defaultFilters()
3427
- }), selectedBenefitAttachment && /*#__PURE__*/React.createElement(ErrorSummaryModal, {
3428
- open: !!selectedBenefitAttachment,
3429
- onClose: function onClose() {
3430
- return setSelectedBenefitAttachment(null);
3129
+ }, formatMessage('payroll.summary.approveAndClose')), /*#__PURE__*/React.createElement(Button, {
3130
+ onClick: function onClick() {
3131
+ return downloadPayrollData(payrollDetail.id, payrollDetail.name);
3431
3132
  },
3432
- benefitAttachment: selectedBenefitAttachment
3433
- }), /*#__PURE__*/React.createElement(Dialog, {
3434
- open: openConfirmDialog,
3435
- onClose: function onClose() {
3436
- return setOpenConfirmDialog(false);
3133
+ variant: "contained",
3134
+ color: "primary",
3135
+ style: {
3136
+ margin: '0 16px',
3137
+ marginBottom: '15px'
3437
3138
  }
3438
- }, /*#__PURE__*/React.createElement(DialogTitle, null, formatMessage('benefitConsumption.delete.confirm.title')), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(DialogContentText, null, formatMessage('benefitConsumption.delete.confirm.message'))), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
3139
+ }, formatMessage('payroll.summary.download')), /*#__PURE__*/React.createElement(Button, {
3439
3140
  onClick: function onClick() {
3440
- return setOpenConfirmDialog(false);
3141
+ return rejectPayrollCallback();
3441
3142
  },
3442
- color: "primary"
3443
- }, formatMessage('benefitConsumption.cancel')), /*#__PURE__*/React.createElement(Button, {
3444
- onClick: handleDeleteBenefitConsumption,
3143
+ variant: "contained",
3445
3144
  color: "primary",
3446
- autoFocus: true
3447
- }, formatMessage('benefitConsumption.confirm')))), /*#__PURE__*/React.createElement("div", {
3448
3145
  style: {
3449
- display: 'none'
3146
+ margin: '0 16px',
3147
+ marginBottom: '15px'
3450
3148
  }
3451
- }, /*#__PURE__*/React.createElement(PayrollBenefitPrintTemplate, {
3452
- ref: payrollPrintTemplateRef,
3453
- benefitAttachments: benefitAttachments
3454
- }))));
3149
+ }, formatMessage('payroll.summary.reject'))), /*#__PURE__*/React.createElement("div", {
3150
+ style: {
3151
+ "float": 'right',
3152
+ paddingRight: '16px'
3153
+ }
3154
+ }, (payrollDetail.paymentMethod === PAYMENT_METHOD.STRATEGY_ONLINE_PAYMENT || payrollDetail.paymentMethod === PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) && /*#__PURE__*/React.createElement(Button, {
3155
+ onClick: function onClick() {
3156
+ return makePaymentForPayrollCallback();
3157
+ },
3158
+ variant: "contained",
3159
+ color: "primary",
3160
+ style: {
3161
+ margin: '0 16px'
3162
+ }
3163
+ }, payrollDetail.paymentMethod === PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT ? formatMessage('payroll.bistp.submitPayment') : formatMessage('payroll.summary.makePayment')), /*#__PURE__*/React.createElement(Button, {
3164
+ onClick: handleClose,
3165
+ variant: "outlined",
3166
+ autoFocus: true,
3167
+ style: {
3168
+ margin: '0 16px'
3169
+ }
3170
+ }, formatMessage('payroll.summary.close')))))));
3455
3171
  }
3456
- var mapStateToProps$9 = function mapStateToProps(state) {
3172
+ var mapStateToProps$a = function mapStateToProps(state) {
3457
3173
  return {
3458
- fetchingBenefitAttachments: state.payroll.fetchingBenefitAttachments,
3459
- fetchedBenefitAttachments: state.payroll.fetchedBenefitAttachments,
3460
- errorBenefitAttachments: state.payroll.errorBenefitAttachments,
3461
- benefitAttachments: state.payroll.benefitAttachments,
3462
- benefitAttachmentsPageInfo: state.payroll.benefitAttachmentsPageInfo,
3463
- benefitAttachmentsTotalCount: state.payroll.benefitAttachmentsTotalCount
3174
+ rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [],
3175
+ confirmed: state.core.confirmed,
3176
+ payroll: state.payroll.payroll
3464
3177
  };
3465
3178
  };
3466
- var mapDispatchToProps$9 = function mapDispatchToProps(dispatch) {
3179
+ var mapDispatchToProps$a = function mapDispatchToProps(dispatch) {
3467
3180
  return bindActionCreators({
3468
- fetchBenefitAttachments: fetchBenefitAttachments,
3469
- deleteBenefitConsumption: deleteBenefitConsumption
3181
+ closePayroll: closePayroll,
3182
+ rejectPayroll: rejectPayroll,
3183
+ fetchPayroll: fetchPayroll,
3184
+ makePaymentForPayroll: makePaymentForPayroll
3470
3185
  }, dispatch);
3471
3186
  };
3472
- var BenefitConsumptionSearcherModal$1 = connect(mapStateToProps$9, mapDispatchToProps$9)(BenefitConsumptionSearcherModal);
3187
+ var PaymentApproveForPaymentSummary = connect(mapStateToProps$a, mapDispatchToProps$a)(PaymentApproveForPaymentDialog);
3473
3188
 
3474
- function PaymentApproveForPaymentDialog(_ref) {
3475
- var _payrollDetail$id;
3476
- var classes = _ref.classes,
3189
+ var useStyles$9 = makeStyles(function (theme) {
3190
+ return {
3191
+ paper: theme.paper.paper,
3192
+ tableTitle: theme.table.title,
3193
+ tabs: {
3194
+ display: 'flex',
3195
+ alignItems: 'center'
3196
+ },
3197
+ selectedTab: {
3198
+ borderBottom: '4px solid white'
3199
+ },
3200
+ unselectedTab: {
3201
+ borderBottom: '4px solid transparent'
3202
+ },
3203
+ button: {
3204
+ marginLeft: 'auto',
3205
+ padding: theme.spacing(1),
3206
+ fontSize: '0.875rem',
3207
+ textTransform: 'none'
3208
+ }
3209
+ };
3210
+ });
3211
+ function PayrollTab(_ref) {
3212
+ var rights = _ref.rights,
3213
+ setConfirmedAction = _ref.setConfirmedAction,
3214
+ payrollUuid = _ref.payrollUuid,
3215
+ isInTask = _ref.isInTask,
3216
+ payroll = _ref.payroll,
3217
+ isPayrollFromFailedInvoices = _ref.isPayrollFromFailedInvoices;
3218
+ var classes = useStyles$9();
3219
+ var _useState = useState(BENEFIT_CONSUMPTION_LIST_TAB_VALUE),
3220
+ _useState2 = _slicedToArray(_useState, 2),
3221
+ activeTab = _useState2[0],
3222
+ setActiveTab = _useState2[1];
3223
+ var isSelected = function isSelected(tab) {
3224
+ return tab === activeTab;
3225
+ };
3226
+ var tabStyle = function tabStyle(tab) {
3227
+ return isSelected(tab) ? classes.selectedTab : classes.unselectedTab;
3228
+ };
3229
+ var handleChange = function handleChange(_, tab) {
3230
+ return setActiveTab(tab);
3231
+ };
3232
+ var modulesManager = useModulesManager();
3233
+ var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
3234
+ formatMessage = _useTranslations.formatMessage;
3235
+ var downloadPayrollData = function downloadPayrollData(payrollUuid, payrollName) {
3236
+ downloadPayroll(payrollUuid, payrollName);
3237
+ };
3238
+ return /*#__PURE__*/React.createElement(Paper, {
3239
+ className: classes.paper
3240
+ }, /*#__PURE__*/React.createElement(Grid, {
3241
+ container: true,
3242
+ className: "".concat(classes.tableTitle, " ").concat(classes.tabs)
3243
+ }, /*#__PURE__*/React.createElement("div", {
3244
+ style: {
3245
+ width: '100%'
3246
+ }
3247
+ }, /*#__PURE__*/React.createElement("div", {
3248
+ style: {
3249
+ "float": 'left'
3250
+ }
3251
+ }, /*#__PURE__*/React.createElement(Contributions, {
3252
+ contributionKey: PAYROLL_TABS_LABEL_CONTRIBUTION_KEY,
3253
+ rights: rights,
3254
+ value: activeTab,
3255
+ onChange: handleChange,
3256
+ isSelected: isSelected,
3257
+ tabStyle: tabStyle,
3258
+ payrollUuid: payrollUuid,
3259
+ isInTask: isInTask,
3260
+ isPayrollFromFailedInvoices: isPayrollFromFailedInvoices
3261
+ })), /*#__PURE__*/React.createElement("div", {
3262
+ style: {
3263
+ "float": 'right',
3264
+ paddingRight: '16px'
3265
+ }
3266
+ }, payrollUuid && !isPayrollFromFailedInvoices && /*#__PURE__*/React.createElement(Button, {
3267
+ onClick: function onClick() {
3268
+ return downloadPayrollData(payrollUuid, payroll.name);
3269
+ },
3270
+ color: "#DFEDEF",
3271
+ className: classes.button,
3272
+ style: {
3273
+ border: '0px',
3274
+ marginTop: '6px',
3275
+ textTransform: 'uppercase'
3276
+ }
3277
+ }, formatMessage('payroll.summary.download')), payrollUuid && (payroll === null || payroll === void 0 ? void 0 : payroll.status) === PAYROLL_STATUS.APPROVE_FOR_PAYMENT && payroll.paymentMethod === PAYMENT_METHOD.STRATEGY_OFFLINE_PAYMENT && /*#__PURE__*/React.createElement(PayrollPaymentDataUploadDialog$1, {
3278
+ payrollUuid: payrollUuid
3279
+ }), payrollUuid && (payroll === null || payroll === void 0 ? void 0 : payroll.status) === PAYROLL_STATUS.APPROVE_FOR_PAYMENT && payroll.paymentMethod === PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT && /*#__PURE__*/React.createElement(PaymentApproveForPaymentSummary, {
3280
+ classes: {},
3281
+ payrollDetail: payroll
3282
+ })))), /*#__PURE__*/React.createElement(Contributions, {
3283
+ contributionKey: PAYROLL_TABS_PANEL_CONTRIBUTION_KEY,
3284
+ rights: rights,
3285
+ value: activeTab,
3286
+ setConfirmedAction: setConfirmedAction,
3287
+ payrollUuid: payrollUuid,
3288
+ isInTask: isInTask,
3289
+ isPayrollFromFailedInvoices: isPayrollFromFailedInvoices
3290
+ }));
3291
+ }
3292
+
3293
+ function ownKeys$1(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; }
3294
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3295
+ var useStyles$8 = makeStyles(function (theme) {
3296
+ return {
3297
+ page: theme.page
3298
+ };
3299
+ });
3300
+ function PayrollPage(_ref) {
3301
+ var statePayrollUuid = _ref.statePayrollUuid,
3302
+ taskPayrollUuid = _ref.taskPayrollUuid,
3303
+ rights = _ref.rights,
3304
+ confirmed = _ref.confirmed,
3305
+ submittingMutation = _ref.submittingMutation,
3306
+ mutation = _ref.mutation,
3477
3307
  payroll = _ref.payroll,
3478
- closePayroll = _ref.closePayroll,
3479
- rejectPayroll = _ref.rejectPayroll,
3480
- payrollDetail = _ref.payrollDetail,
3481
3308
  fetchPayroll = _ref.fetchPayroll,
3482
- makePaymentForPayroll = _ref.makePaymentForPayroll;
3309
+ createPayroll = _ref.createPayroll,
3310
+ clearPayroll = _ref.clearPayroll,
3311
+ clearConfirm = _ref.clearConfirm,
3312
+ createPayrollFromFailedInvoices = _ref.createPayrollFromFailedInvoices,
3313
+ journalize = _ref.journalize,
3314
+ benefitPlanId = _ref.benefitPlanId;
3483
3315
  var modulesManager = useModulesManager();
3484
- var _useState = useState((_payrollDetail$id = payrollDetail === null || payrollDetail === void 0 ? void 0 : payrollDetail.id) !== null && _payrollDetail$id !== void 0 ? _payrollDetail$id : null),
3485
- _useState2 = _slicedToArray(_useState, 1),
3486
- payrollUuid = _useState2[0];
3487
- var _useState3 = useState(false),
3316
+ var classes = useStyles$8();
3317
+ var history = useHistory();
3318
+ var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
3319
+ formatMessage = _useTranslations.formatMessage,
3320
+ formatMessageWithValues = _useTranslations.formatMessageWithValues;
3321
+ var _useState = useState({}),
3322
+ _useState2 = _slicedToArray(_useState, 2),
3323
+ editedPayroll = _useState2[0],
3324
+ setEditedPayroll = _useState2[1];
3325
+ var _useState3 = useState(null),
3488
3326
  _useState4 = _slicedToArray(_useState3, 2),
3489
- isOpen = _useState4[0],
3490
- setIsOpen = _useState4[1];
3491
- var _useState5 = useState(0),
3327
+ payrollUuid = _useState4[0],
3328
+ setPayrollUuid = _useState4[1];
3329
+ var _useState5 = useState(false),
3492
3330
  _useState6 = _slicedToArray(_useState5, 2),
3493
- totalBeneficiaries = _useState6[0],
3494
- setTotalBeneficiaries = _useState6[1];
3495
- var _useState7 = useState(0),
3331
+ isInTask = _useState6[0],
3332
+ setIsInTask = _useState6[1];
3333
+ var _useState7 = useState(false),
3496
3334
  _useState8 = _slicedToArray(_useState7, 2),
3497
- selectedBeneficiaries = _useState8[0],
3498
- setSelectedBeneficiaries = _useState8[1];
3499
- var _useState9 = useState(0),
3335
+ readOnly = _useState8[0],
3336
+ setReadOnly = _useState8[1];
3337
+ var _useState9 = useState(false),
3500
3338
  _useState0 = _slicedToArray(_useState9, 2),
3501
- approvedBeneficiaries = _useState0[0],
3502
- setApprovedBeneficiaries = _useState0[1];
3503
- var _useState1 = useState(0),
3339
+ isPayrollFromFailedInvoices = _useState0[0],
3340
+ setIsPayrollFromFailedInvoices = _useState0[1];
3341
+ var _useState1 = useState(function () {
3342
+ return null;
3343
+ }),
3504
3344
  _useState10 = _slicedToArray(_useState1, 2),
3505
- totalBillAmount = _useState10[0],
3506
- setTotalBillAmount = _useState10[1];
3507
- var _useState11 = useState(0),
3508
- _useState12 = _slicedToArray(_useState11, 2),
3509
- totalReconciledBillAmount = _useState12[0],
3510
- setTotalReconciledBillAmount = _useState12[1];
3511
- var handleOpen = function handleOpen() {
3345
+ confirmedAction = _useState10[0],
3346
+ setConfirmedAction = _useState10[1];
3347
+ var prevSubmittingMutationRef = useRef();
3348
+ var back = function back() {
3349
+ return history.goBack();
3350
+ };
3351
+ useEffect(function () {
3352
+ if (createPayrollFromFailedInvoices === PAYROLL_FROM_FAILED_INVOICES_URL_PARAM) {
3353
+ setIsPayrollFromFailedInvoices(true);
3354
+ }
3355
+ }, [createPayrollFromFailedInvoices, payrollUuid]);
3356
+ useEffect(function () {
3357
+ setPayrollUuid(statePayrollUuid !== null && statePayrollUuid !== void 0 ? statePayrollUuid : taskPayrollUuid);
3358
+ setIsInTask(!!taskPayrollUuid);
3359
+ }, [taskPayrollUuid, statePayrollUuid]);
3360
+ useEffect(function () {
3512
3361
  if (payrollUuid) {
3513
3362
  fetchPayroll(modulesManager, ["id: \"".concat(payrollUuid, "\"")]);
3514
3363
  }
3515
- setIsOpen(true);
3516
- };
3517
- var handleClose = function handleClose() {
3518
- setIsOpen(false);
3519
- };
3520
- var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
3521
- formatMessage = _useTranslations.formatMessage,
3522
- formatMessageWithValues = _useTranslations.formatMessageWithValues;
3364
+ }, [payrollUuid]);
3523
3365
  useEffect(function () {
3524
- if (isOpen && Object.keys(payroll).length > 0) {
3525
- // Calculate total benefits and reconciled benefits
3526
- var total = payroll.benefitConsumption.length;
3527
- var selected = payroll.benefitConsumption.filter(function (benefit) {
3528
- return benefit.status === BENEFIT_CONSUMPTION_STATUS.RECONCILED;
3529
- }).length;
3530
- var approved = payroll.benefitConsumption.filter(function (benefit) {
3531
- return benefit.status === BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT;
3532
- }).length;
3533
- setTotalBeneficiaries(total);
3534
- setSelectedBeneficiaries(selected);
3535
- setApprovedBeneficiaries(approved);
3536
- var totalAmount = 0;
3537
- var reconciledAmount = 0;
3538
- if (payroll && payroll.benefitConsumption) {
3539
- payroll.benefitConsumption.forEach(function (benefit) {
3540
- if (benefit.benefitAttachment && benefit.benefitAttachment.length > 0) {
3541
- benefit.benefitAttachment.forEach(function (attachment) {
3542
- if (attachment.bill && attachment.bill.amountTotal) {
3543
- totalAmount += parseFloat(attachment.bill.amountTotal);
3544
- if (benefit.status === BENEFIT_CONSUMPTION_STATUS.RECONCILED) {
3545
- reconciledAmount += parseFloat(attachment.bill.amountTotal);
3546
- }
3547
- }
3548
- });
3549
- }
3550
- });
3366
+ if (confirmed && typeof confirmed === 'function') confirmedAction();
3367
+ return function () {
3368
+ return confirmed && clearConfirm(null);
3369
+ };
3370
+ }, [confirmed]);
3371
+ useEffect(function () {
3372
+ if (prevSubmittingMutationRef.current && !submittingMutation) {
3373
+ journalize(mutation);
3374
+ if ((mutation === null || mutation === void 0 ? void 0 : mutation.actionType) === ACTION_TYPE.DELETE_PAYROLL) {
3375
+ back();
3376
+ }
3377
+ if (mutation !== null && mutation !== void 0 && mutation.clientMutationId && (!payrollUuid || isPayrollFromFailedInvoices)) {
3378
+ fetchPayroll(modulesManager, ["clientMutationId: \"".concat(mutation.clientMutationId, "\"")]);
3379
+ setIsPayrollFromFailedInvoices(false);
3551
3380
  }
3552
- setTotalBillAmount(totalAmount);
3553
- setTotalReconciledBillAmount(reconciledAmount);
3554
3381
  }
3555
- }, [isOpen, payroll]);
3556
- var closePayrollCallback = function closePayrollCallback() {
3557
- handleClose();
3558
- closePayroll(payrollDetail, formatMessageWithValues('payroll.mutation.closeLabel', mutationLabel(payrollDetail)));
3382
+ }, [submittingMutation]);
3383
+ useEffect(function () {
3384
+ prevSubmittingMutationRef.current = submittingMutation;
3385
+ });
3386
+ useEffect(function () {
3387
+ if (payroll) {
3388
+ setReadOnly(payroll === null || payroll === void 0 ? void 0 : payroll.id);
3389
+ if (isPayrollFromFailedInvoices) {
3390
+ setEditedPayroll(_objectSpread$1(_objectSpread$1({}, payroll), {}, {
3391
+ id: null,
3392
+ name: null,
3393
+ paymentCycle: null,
3394
+ status: null,
3395
+ fromFailedInvoicesPayrollId: payroll === null || payroll === void 0 ? void 0 : payroll.id
3396
+ }));
3397
+ } else {
3398
+ setEditedPayroll(payroll);
3399
+ }
3400
+ if (!payrollUuid && payroll !== null && payroll !== void 0 && payroll.id && !isPayrollFromFailedInvoices) {
3401
+ var payrollRouteRef = modulesManager.getRef('payroll.route.payroll');
3402
+ history.replace("/".concat(payrollRouteRef, "/").concat(payroll.id));
3403
+ }
3404
+ }
3405
+ }, [payroll]);
3406
+ useEffect(function () {
3407
+ return function () {
3408
+ return clearPayroll();
3409
+ };
3410
+ }, []);
3411
+ var mandatoryFieldsEmpty = function mandatoryFieldsEmpty() {
3412
+ 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;
3413
+ return true;
3559
3414
  };
3560
- var rejectPayrollCallback = function rejectPayrollCallback() {
3561
- handleClose();
3562
- rejectPayroll(payrollDetail, formatMessageWithValues('payroll.mutation.closeLabel', mutationLabel(payrollDetail)));
3415
+ var canSave = function canSave() {
3416
+ return !mandatoryFieldsEmpty() && (!readOnly || isPayrollFromFailedInvoices);
3563
3417
  };
3564
- var makePaymentForPayrollCallback = function makePaymentForPayrollCallback() {
3565
- handleClose();
3566
- makePaymentForPayroll(payrollDetail, formatMessageWithValues('payroll.mutation.closeLabel', mutationLabel(payrollDetail)));
3418
+ var handleSave = function handleSave() {
3419
+ createPayroll(editedPayroll, formatMessageWithValues('payroll.mutation.create', mutationLabel(payroll)));
3420
+ if (benefitPlanId) {
3421
+ back();
3422
+ }
3423
+ };
3424
+ var actions = [];
3425
+ return rights.includes(RIGHT_PAYROLL_CREATE) && /*#__PURE__*/React.createElement("div", {
3426
+ className: classes.page
3427
+ }, /*#__PURE__*/React.createElement(Form, {
3428
+ key: payrollUuid,
3429
+ module: "payroll",
3430
+ title: formatMessageWithValues('payrollPage.title', pageTitle(payroll)),
3431
+ titleParams: pageTitle(payroll),
3432
+ openDirty: isPayrollFromFailedInvoices ? true : !payrollUuid,
3433
+ benefitPlan: editedPayroll,
3434
+ edited: editedPayroll,
3435
+ onEditedChanged: setEditedPayroll,
3436
+ back: !isInTask && back,
3437
+ mandatoryFieldsEmpty: mandatoryFieldsEmpty,
3438
+ canSave: canSave,
3439
+ save: handleSave,
3440
+ HeadPanel: PayrollHeadPanel$1,
3441
+ Panels: [PayrollTab],
3442
+ rights: rights,
3443
+ actions: actions,
3444
+ setConfirmedAction: setConfirmedAction,
3445
+ payrollUuid: payrollUuid,
3446
+ saveTooltip: formatMessage('tooltip.save'),
3447
+ isInTask: !!taskPayrollUuid,
3448
+ payroll: payroll,
3449
+ readOnly: readOnly,
3450
+ isPayrollFromFailedInvoices: isPayrollFromFailedInvoices,
3451
+ benefitPlanId: benefitPlanId
3452
+ }));
3453
+ }
3454
+ var mapDispatchToProps$9 = function mapDispatchToProps(dispatch) {
3455
+ return bindActionCreators({
3456
+ fetchPayroll: fetchPayroll,
3457
+ createPayroll: createPayroll,
3458
+ clearPayroll: clearPayroll,
3459
+ coreConfirm: coreConfirm,
3460
+ clearConfirm: clearConfirm,
3461
+ journalize: journalize
3462
+ }, dispatch);
3463
+ };
3464
+ var mapStateToProps$9 = function mapStateToProps(state, props) {
3465
+ var _props$match, _props$match2, _props$match3, _props$match4, _state$core$user$i_us, _state$core;
3466
+ return {
3467
+ statePayrollUuid: (props === null || props === void 0 || (_props$match = props.match) === null || _props$match === void 0 || (_props$match = _props$match.params) === null || _props$match === void 0 ? void 0 : _props$match.payroll_uuid) === 'null' ? null : props === null || props === void 0 || (_props$match2 = props.match) === null || _props$match2 === void 0 ? void 0 : _props$match2.params.payroll_uuid,
3468
+ createPayrollFromFailedInvoices: props === null || props === void 0 || (_props$match3 = props.match) === null || _props$match3 === void 0 || (_props$match3 = _props$match3.params) === null || _props$match3 === void 0 ? void 0 : _props$match3.createPayrollFromFailedInvoices,
3469
+ benefitPlanId: props === null || props === void 0 || (_props$match4 = props.match) === null || _props$match4 === void 0 || (_props$match4 = _props$match4.params) === null || _props$match4 === void 0 ? void 0 : _props$match4.benefitPlanId,
3470
+ rights: (_state$core$user$i_us = (_state$core = state.core) === null || _state$core === void 0 || (_state$core = _state$core.user) === null || _state$core === void 0 || (_state$core = _state$core.i_user) === null || _state$core === void 0 ? void 0 : _state$core.rights) !== null && _state$core$user$i_us !== void 0 ? _state$core$user$i_us : [],
3471
+ confirmed: state.core.confirmed,
3472
+ submittingMutation: state.payroll.submittingMutation,
3473
+ mutation: state.payroll.mutation,
3474
+ payroll: state.payroll.payroll
3475
+ };
3476
+ };
3477
+ var PayrollPage$1 = connect(mapStateToProps$9, mapDispatchToProps$9)(PayrollPage);
3478
+
3479
+ var useStyles$7 = makeStyles(function (theme) {
3480
+ return {
3481
+ form: {
3482
+ padding: '0 0 10px 0',
3483
+ width: '100%'
3484
+ },
3485
+ item: {
3486
+ padding: theme.spacing(1)
3487
+ }
3488
+ };
3489
+ });
3490
+ function PayrollFilter(_ref) {
3491
+ var _filters$isDeleted;
3492
+ var filters = _ref.filters,
3493
+ onChangeFilters = _ref.onChangeFilters,
3494
+ _ref$statusReadOnly = _ref.statusReadOnly,
3495
+ statusReadOnly = _ref$statusReadOnly === void 0 ? false : _ref$statusReadOnly;
3496
+ var classes = useStyles$7();
3497
+ var modulesManager = useModulesManager();
3498
+ var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
3499
+ formatMessage = _useTranslations.formatMessage;
3500
+ var debouncedOnChangeFilters = _debounce(onChangeFilters, DEFAULT_DEBOUNCE_TIME);
3501
+ var filterTextFieldValue = function filterTextFieldValue(filterName) {
3502
+ var _filters$filterName$v, _filters$filterName;
3503
+ return (_filters$filterName$v = filters === null || filters === void 0 || (_filters$filterName = filters[filterName]) === null || _filters$filterName === void 0 ? void 0 : _filters$filterName.value) !== null && _filters$filterName$v !== void 0 ? _filters$filterName$v : EMPTY_STRING;
3567
3504
  };
3568
- var downloadPayrollData = function downloadPayrollData(payrollUuid, payrollName) {
3569
- downloadPayroll(payrollUuid, payrollName);
3505
+ var filterValue = function filterValue(filterName) {
3506
+ var _filters$filterName$v2, _filters$filterName2;
3507
+ return (_filters$filterName$v2 = filters === null || filters === void 0 || (_filters$filterName2 = filters[filterName]) === null || _filters$filterName2 === void 0 ? void 0 : _filters$filterName2.value) !== null && _filters$filterName$v2 !== void 0 ? _filters$filterName$v2 : null;
3570
3508
  };
3571
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
3572
- onClick: handleOpen,
3573
- variant: "contained",
3574
- color: "primary",
3575
- className: classes.button
3576
- }, formatMessage('payroll.viewReconciliationSummary')), /*#__PURE__*/React.createElement(Dialog, {
3577
- open: isOpen,
3578
- onClose: handleClose,
3579
- PaperProps: {
3580
- style: {
3581
- position: 'absolute',
3582
- top: '50%',
3583
- left: '50%',
3584
- transform: 'translate(-50%,-50%)',
3585
- width: '75%',
3586
- maxWidth: '75%'
3509
+ var onChangeStringFilter = function onChangeStringFilter(filterName) {
3510
+ var lookup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
3511
+ return function (value) {
3512
+ if (lookup) {
3513
+ debouncedOnChangeFilters([{
3514
+ id: filterName,
3515
+ value: value,
3516
+ filter: "".concat(filterName, "_").concat(lookup, ": \"").concat(value, "\"")
3517
+ }]);
3518
+ } else {
3519
+ debouncedOnChangeFilters([{
3520
+ id: filterName,
3521
+ value: value,
3522
+ filter: "".concat(filterName, ": \"").concat(value, "\"")
3523
+ }]);
3587
3524
  }
3588
- }
3589
- }, /*#__PURE__*/React.createElement(DialogTitle, {
3590
- style: {
3591
- marginTop: '10px'
3592
- }
3593
- }, formatMessageWithValues('payroll.reconciliationSummary', {
3594
- payrollName: payrollDetail.name
3595
- })), /*#__PURE__*/React.createElement(DialogContent, null, /*#__PURE__*/React.createElement(Grid, {
3525
+ };
3526
+ };
3527
+ return /*#__PURE__*/React.createElement(Grid, {
3596
3528
  container: true,
3597
- spacing: 2
3529
+ className: classes.form
3598
3530
  }, /*#__PURE__*/React.createElement(Grid, {
3599
3531
  item: true,
3600
- xs: 4
3601
- }, /*#__PURE__*/React.createElement(Paper, {
3602
- elevation: 3,
3603
- style: {
3604
- padding: '20px'
3605
- }
3606
- }, /*#__PURE__*/React.createElement(Typography$1, {
3607
- variant: "h6",
3608
- gutterBottom: true
3609
- }, formatMessage('payroll.summary.selectedBeneficiaries')), /*#__PURE__*/React.createElement(Typography$1, {
3610
- variant: "body1"
3611
- }, formatMessageWithValues('payroll.summary.beneficiariesCount', {
3612
- selectedBeneficiaries: selectedBeneficiaries,
3613
- totalBeneficiaries: totalBeneficiaries
3614
- })))), /*#__PURE__*/React.createElement(Grid, {
3532
+ xs: 3,
3533
+ className: classes.item
3534
+ }, /*#__PURE__*/React.createElement(TextInput, {
3535
+ module: "payroll",
3536
+ label: formatMessage('payroll.name'),
3537
+ value: filterTextFieldValue('name'),
3538
+ onChange: onChangeStringFilter('name', CONTAINS_LOOKUP)
3539
+ })), /*#__PURE__*/React.createElement(Grid, {
3615
3540
  item: true,
3616
- xs: 4
3617
- }, /*#__PURE__*/React.createElement(Paper, {
3618
- elevation: 3,
3619
- style: {
3620
- padding: '20px'
3541
+ xs: 3,
3542
+ className: classes.item
3543
+ }, /*#__PURE__*/React.createElement(PublishedComponent, {
3544
+ pubRef: "contributionPlan.PaymentPlanPicker",
3545
+ filters: filters,
3546
+ value: filterValue('paymentPlan_Id'),
3547
+ onChange: function onChange(paymentPlan) {
3548
+ return onChangeFilters([{
3549
+ id: 'paymentPlan_Id',
3550
+ value: paymentPlan,
3551
+ filter: "paymentPlan_Id: \"".concat((paymentPlan === null || paymentPlan === void 0 ? void 0 : paymentPlan.id) && decodeId(paymentPlan.id), "\"")
3552
+ }]);
3621
3553
  }
3622
- }, /*#__PURE__*/React.createElement(Typography$1, {
3623
- variant: "h6",
3624
- gutterBottom: true
3625
- }, formatMessage('payroll.summary.totalAmountForInvoice')), /*#__PURE__*/React.createElement(Typography$1, {
3626
- variant: "body1"
3627
- }, totalBillAmount))), /*#__PURE__*/React.createElement(Grid, {
3554
+ })), /*#__PURE__*/React.createElement(Grid, {
3628
3555
  item: true,
3629
- xs: 4
3630
- }, /*#__PURE__*/React.createElement(Paper, {
3631
- elevation: 3,
3632
- style: {
3633
- padding: '20px'
3634
- }
3635
- }, /*#__PURE__*/React.createElement(Typography$1, {
3636
- variant: "h6",
3637
- gutterBottom: true
3638
- }, formatMessage('payroll.summary.deliveredReconciliation')), /*#__PURE__*/React.createElement(Typography$1, {
3639
- variant: "body1"
3640
- }, totalReconciledBillAmount)))), /*#__PURE__*/React.createElement("div", {
3641
- style: {
3642
- backgroundColor: '#DFEDEF'
3643
- }
3644
- }, /*#__PURE__*/React.createElement(BenefitConsumptionSearcherModal$1, {
3645
- payrollUuid: payrollDetail.id,
3646
- payrollDetail: payrollDetail
3647
- }))), /*#__PURE__*/React.createElement(DialogActions, {
3648
- style: {
3649
- display: 'inline',
3650
- paddingLeft: '10px',
3651
- marginTop: '25px',
3652
- marginBottom: '15px',
3653
- width: '100%'
3654
- }
3655
- }, /*#__PURE__*/React.createElement("div", {
3656
- style: {
3657
- maxWidth: '3000px'
3658
- }
3659
- }, /*#__PURE__*/React.createElement("div", {
3660
- style: {
3661
- "float": 'left'
3662
- }
3663
- }, /*#__PURE__*/React.createElement(Button, {
3664
- onClick: function onClick() {
3665
- return closePayrollCallback();
3666
- },
3667
- variant: "contained",
3668
- color: "primary",
3669
- disabled: payrollDetail.paymentMethod === 'StrategyOnlinePayment' ? approvedBeneficiaries === 0 : selectedBeneficiaries === 0,
3670
- style: {
3671
- margin: '0 16px',
3672
- marginBottom: '15px'
3556
+ xs: 3,
3557
+ className: classes.item
3558
+ }, /*#__PURE__*/React.createElement(PublishedComponent, {
3559
+ pubRef: "paymentCycle.PaymentCyclePicker",
3560
+ withLabel: true,
3561
+ withPlaceholder: true,
3562
+ filters: filters,
3563
+ value: filterValue('paymentCycle_Id'),
3564
+ onChange: function onChange(paymentCycle) {
3565
+ return onChangeFilters([{
3566
+ id: 'paymentCycle_Id',
3567
+ value: paymentCycle,
3568
+ filter: "paymentCycle_Id: \"".concat((paymentCycle === null || paymentCycle === void 0 ? void 0 : paymentCycle.id) && decodeId(paymentCycle.id), "\"")
3569
+ }]);
3673
3570
  }
3674
- }, formatMessage('payroll.summary.approveAndClose')), /*#__PURE__*/React.createElement(Button, {
3675
- onClick: function onClick() {
3676
- return downloadPayrollData(payrollDetail.id, payrollDetail.name);
3677
- },
3678
- variant: "contained",
3679
- color: "primary",
3680
- style: {
3681
- margin: '0 16px',
3682
- marginBottom: '15px'
3571
+ })), /*#__PURE__*/React.createElement(Grid, {
3572
+ item: true,
3573
+ xs: 2,
3574
+ className: classes.item
3575
+ }, /*#__PURE__*/React.createElement(PayrollStatusPicker, {
3576
+ withNull: true,
3577
+ nullLabel: formatMessage('any'),
3578
+ label: formatMessage('paymentMethod'),
3579
+ value: filterValue('status'),
3580
+ readOnly: statusReadOnly,
3581
+ onChange: function onChange(value) {
3582
+ return onChangeFilters([{
3583
+ id: 'status',
3584
+ value: value,
3585
+ filter: value ? "status: ".concat(value) : EMPTY_STRING
3586
+ }]);
3683
3587
  }
3684
- }, formatMessage('payroll.summary.download')), /*#__PURE__*/React.createElement(Button, {
3685
- onClick: function onClick() {
3686
- return rejectPayrollCallback();
3687
- },
3688
- variant: "contained",
3689
- color: "primary",
3690
- style: {
3691
- margin: '0 16px',
3692
- marginBottom: '15px'
3588
+ })), /*#__PURE__*/React.createElement(Grid, {
3589
+ item: true,
3590
+ xs: 2,
3591
+ className: classes.item
3592
+ }, /*#__PURE__*/React.createElement(PaymentMethodPicker$1, {
3593
+ withNull: true,
3594
+ nullLabel: formatMessage('any'),
3595
+ label: formatMessage('payroll.paymentMethod'),
3596
+ value: filterValue('paymentMethod'),
3597
+ onChange: function onChange(value) {
3598
+ return onChangeFilters([{
3599
+ id: 'paymentMethod',
3600
+ value: value,
3601
+ filter: "paymentMethod: \"".concat(value, "\"")
3602
+ }]);
3693
3603
  }
3694
- }, formatMessage('payroll.summary.reject'))), /*#__PURE__*/React.createElement("div", {
3695
- style: {
3696
- "float": 'right',
3697
- paddingRight: '16px'
3604
+ })), /*#__PURE__*/React.createElement(ControlledField, {
3605
+ module: "payroll",
3606
+ id: "payrollFilter.showHistory",
3607
+ field: /*#__PURE__*/React.createElement(Grid, {
3608
+ item: true,
3609
+ xs: 12,
3610
+ className: classes.item
3611
+ }, /*#__PURE__*/React.createElement(FormControlLabel, {
3612
+ control: /*#__PURE__*/React.createElement(Checkbox, {
3613
+ color: "primary",
3614
+ checked: filters === null || filters === void 0 || (_filters$isDeleted = filters.isDeleted) === null || _filters$isDeleted === void 0 ? void 0 : _filters$isDeleted.value,
3615
+ onChange: function onChange() {
3616
+ var _filters$isDeleted2, _filters$isDeleted3;
3617
+ return onChangeFilters([{
3618
+ id: 'isDeleted',
3619
+ value: !(filters !== null && filters !== void 0 && (_filters$isDeleted2 = filters.isDeleted) !== null && _filters$isDeleted2 !== void 0 && _filters$isDeleted2.value),
3620
+ filter: "isDeleted: ".concat(!(filters !== null && filters !== void 0 && (_filters$isDeleted3 = filters.isDeleted) !== null && _filters$isDeleted3 !== void 0 && _filters$isDeleted3.value))
3621
+ }]);
3622
+ }
3623
+ }),
3624
+ label: formatMessage('tooltip.isDeleted')
3625
+ }))
3626
+ }));
3627
+ }
3628
+
3629
+ function PayrollSearcher(_ref) {
3630
+ var deletePayrolls = _ref.deletePayrolls,
3631
+ fetchingPayrolls = _ref.fetchingPayrolls,
3632
+ fetchedPayrolls = _ref.fetchedPayrolls,
3633
+ errorPayrolls = _ref.errorPayrolls,
3634
+ payrolls = _ref.payrolls,
3635
+ pageInfo = _ref.pageInfo,
3636
+ totalCount = _ref.totalCount,
3637
+ fetchPayrolls = _ref.fetchPayrolls,
3638
+ coreConfirm = _ref.coreConfirm,
3639
+ clearConfirm = _ref.clearConfirm,
3640
+ confirmed = _ref.confirmed,
3641
+ submittingMutation = _ref.submittingMutation,
3642
+ mutation = _ref.mutation;
3643
+ var history = useHistory();
3644
+ var modulesManager = useModulesManager();
3645
+ var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
3646
+ formatMessage = _useTranslations.formatMessage,
3647
+ formatMessageWithValues = _useTranslations.formatMessageWithValues;
3648
+ var rights = useSelector(function (store) {
3649
+ var _store$core$user$i_us;
3650
+ return (_store$core$user$i_us = store.core.user.i_user.rights) !== null && _store$core$user$i_us !== void 0 ? _store$core$user$i_us : [];
3651
+ });
3652
+ var _useState = useState(null),
3653
+ _useState2 = _slicedToArray(_useState, 2),
3654
+ payrollToDelete = _useState2[0],
3655
+ setPayrollToDelete = _useState2[1];
3656
+ var _useState3 = useState([]),
3657
+ _useState4 = _slicedToArray(_useState3, 2),
3658
+ deletedPayrollUuids = _useState4[0],
3659
+ setDeletedPayrollUuids = _useState4[1];
3660
+ var prevSubmittingMutationRef = useRef();
3661
+ var openDeletePayrollConfirmDialog = function openDeletePayrollConfirmDialog() {
3662
+ coreConfirm(formatMessageWithValues('payroll.delete.confirm.title', pageTitle(payrollToDelete)), formatMessage('payroll.delete.confirm.message'));
3663
+ };
3664
+ useEffect(function () {
3665
+ return payrollToDelete && openDeletePayrollConfirmDialog();
3666
+ }, [payrollToDelete]);
3667
+ useEffect(function () {
3668
+ if (payrollToDelete && confirmed) {
3669
+ deletePayrolls(payrollToDelete, formatMessageWithValues('payroll.mutation.deleteLabel', mutationLabel(payrollToDelete)));
3670
+ setDeletedPayrollUuids([].concat(_toConsumableArray(deletedPayrollUuids), [payrollToDelete.id]));
3698
3671
  }
3699
- }, payrollDetail.paymentMethod === 'StrategyOnlinePayment' && /*#__PURE__*/React.createElement(Button, {
3700
- onClick: function onClick() {
3701
- return makePaymentForPayrollCallback();
3702
- },
3703
- variant: "contained",
3704
- color: "primary",
3705
- style: {
3706
- margin: '0 16px'
3672
+ if (payrollToDelete && confirmed !== null) {
3673
+ setPayrollToDelete(null);
3707
3674
  }
3708
- }, formatMessage('payroll.summary.makePayment')), /*#__PURE__*/React.createElement(Button, {
3709
- onClick: handleClose,
3710
- variant: "outlined",
3711
- autoFocus: true,
3712
- style: {
3713
- margin: '0 16px'
3675
+ return function () {
3676
+ return confirmed && clearConfirm(false);
3677
+ };
3678
+ }, [confirmed]);
3679
+ useEffect(function () {
3680
+ if (prevSubmittingMutationRef.current && !submittingMutation) {
3681
+ journalize(mutation);
3714
3682
  }
3715
- }, formatMessage('payroll.summary.close')))))));
3683
+ }, [submittingMutation]);
3684
+ useEffect(function () {
3685
+ prevSubmittingMutationRef.current = submittingMutation;
3686
+ });
3687
+ var headers = function headers() {
3688
+ return ['payroll.name', 'payroll.benefitPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'payroll.bistp.progress', 'emptyLabel'];
3689
+ };
3690
+ var sorts = function sorts() {
3691
+ return [['name', true], ['benefitPlan', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true]];
3692
+ };
3693
+ var renderBistpProgress = function renderBistpProgress(payroll) {
3694
+ if (payroll.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) return null;
3695
+ var summary = payroll.bistpSummary || {};
3696
+ var total = summary.total || 0;
3697
+ var reconciled = summary.reconciled || 0;
3698
+ var progress = total > 0 ? reconciled / total * 100 : 0;
3699
+ return /*#__PURE__*/React.createElement("div", {
3700
+ style: {
3701
+ display: 'flex',
3702
+ alignItems: 'center',
3703
+ gap: 8,
3704
+ minWidth: 120
3705
+ }
3706
+ }, /*#__PURE__*/React.createElement(LinearProgress, {
3707
+ variant: "determinate",
3708
+ value: progress,
3709
+ style: {
3710
+ flex: 1,
3711
+ height: 8,
3712
+ borderRadius: 4
3713
+ }
3714
+ }), /*#__PURE__*/React.createElement("span", {
3715
+ style: {
3716
+ fontSize: '0.75rem',
3717
+ whiteSpace: 'nowrap'
3718
+ }
3719
+ }, reconciled, "/", total));
3720
+ };
3721
+ var defaultFilters = function defaultFilters() {
3722
+ return {
3723
+ isDeleted: {
3724
+ value: false,
3725
+ filter: 'isDeleted: false'
3726
+ }
3727
+ };
3728
+ };
3729
+ var fetch = function fetch(params) {
3730
+ return fetchPayrolls(modulesManager, params);
3731
+ };
3732
+ var rowIdentifier = function rowIdentifier(payroll) {
3733
+ return payroll.id;
3734
+ };
3735
+ var openPayroll = function openPayroll(payroll) {
3736
+ return rights.includes(RIGHT_PAYROLL_SEARCH) && history.push("/".concat(modulesManager.getRef(PAYROLL_PAYROLL_ROUTE), "/").concat(payroll === null || payroll === void 0 ? void 0 : payroll.id));
3737
+ };
3738
+ var onDelete = function onDelete(payroll) {
3739
+ return setPayrollToDelete(payroll);
3740
+ };
3741
+ var itemFormatters = function itemFormatters() {
3742
+ return [function (payroll) {
3743
+ return payroll.name;
3744
+ }, function (payroll) {
3745
+ return payroll.benefitPlan ? "".concat(payroll.benefitPlan.code, " ").concat(payroll.benefitPlan.name) : '';
3746
+ }, function (payroll) {
3747
+ return payroll.paymentPoint ? "".concat(payroll.paymentPoint.name) : '';
3748
+ }, function (payroll) {
3749
+ return payroll.status ? "".concat(payroll.status) : '';
3750
+ }, function (payroll) {
3751
+ return payroll.paymentMethod ? "".concat(payroll.paymentMethod) : '';
3752
+ }, function (payroll) {
3753
+ return renderBistpProgress(payroll);
3754
+ }, function (payroll) {
3755
+ return /*#__PURE__*/React.createElement(Tooltip, {
3756
+ title: formatMessage('tooltip.viewDetails')
3757
+ }, /*#__PURE__*/React.createElement(IconButton, {
3758
+ onClick: function onClick() {
3759
+ return openPayroll(payroll);
3760
+ }
3761
+ }, /*#__PURE__*/React.createElement(VisibilityIcon, null)));
3762
+ }, function (payroll) {
3763
+ return /*#__PURE__*/React.createElement(Tooltip, {
3764
+ title: formatMessage('tooltip.delete')
3765
+ }, /*#__PURE__*/React.createElement(IconButton, {
3766
+ onClick: function onClick() {
3767
+ return onDelete(payroll);
3768
+ },
3769
+ disabled: deletedPayrollUuids.includes(payroll.id) || payroll.status !== PAYROLL_STATUS.PENDING_APPROVAL
3770
+ }, /*#__PURE__*/React.createElement(DeleteIcon, null)));
3771
+ }];
3772
+ };
3773
+ var onDoubleClick = function onDoubleClick(payroll) {
3774
+ return openPayroll(payroll);
3775
+ };
3776
+ var payrollFilter = function payrollFilter(_ref2) {
3777
+ var filters = _ref2.filters,
3778
+ onChangeFilters = _ref2.onChangeFilters;
3779
+ return /*#__PURE__*/React.createElement(PayrollFilter, {
3780
+ filters: filters,
3781
+ onChangeFilters: onChangeFilters
3782
+ });
3783
+ };
3784
+ var isRowDisabled = function isRowDisabled(_, payroll) {
3785
+ return deletedPayrollUuids.includes(payroll.id);
3786
+ };
3787
+ return /*#__PURE__*/React.createElement(Searcher, {
3788
+ module: "payroll",
3789
+ FilterPane: payrollFilter,
3790
+ fetch: fetch,
3791
+ items: payrolls,
3792
+ itemsPageInfo: pageInfo,
3793
+ fetchedItems: fetchedPayrolls,
3794
+ fetchingItems: fetchingPayrolls,
3795
+ errorItems: errorPayrolls,
3796
+ tableTitle: formatMessageWithValues('payrollSearcher.results', {
3797
+ totalCount: totalCount
3798
+ }),
3799
+ headers: headers,
3800
+ itemFormatters: itemFormatters,
3801
+ sorts: sorts,
3802
+ rowsPerPageOptions: ROWS_PER_PAGE_OPTIONS,
3803
+ defaultPageSize: DEFAULT_PAGE_SIZE,
3804
+ rowIdentifier: rowIdentifier,
3805
+ onDoubleClick: onDoubleClick,
3806
+ defaultFilters: defaultFilters(),
3807
+ rowDisabled: isRowDisabled,
3808
+ rowLocked: isRowDisabled
3809
+ });
3716
3810
  }
3717
3811
  var mapStateToProps$8 = function mapStateToProps(state) {
3718
3812
  return {
3719
- rights: !!state.core && !!state.core.user && !!state.core.user.i_user ? state.core.user.i_user.rights : [],
3813
+ fetchingPayrolls: state.payroll.fetchingPayrolls,
3814
+ fetchedPayrolls: state.payroll.fetchedPayrolls,
3815
+ errorPayrolls: state.payroll.errorPayrolls,
3816
+ payrolls: state.payroll.payrolls,
3817
+ pageInfo: state.payroll.payrollsPageInfo,
3818
+ totalCount: state.payroll.payrollsTotalCount,
3720
3819
  confirmed: state.core.confirmed,
3721
- payroll: state.payroll.payroll
3820
+ submittingMutation: state.payroll.submittingMutation,
3821
+ mutation: state.payroll.mutation
3722
3822
  };
3723
3823
  };
3724
3824
  var mapDispatchToProps$8 = function mapDispatchToProps(dispatch) {
3725
3825
  return bindActionCreators({
3726
- closePayroll: closePayroll,
3727
- rejectPayroll: rejectPayroll,
3728
- fetchPayroll: fetchPayroll,
3729
- makePaymentForPayroll: makePaymentForPayroll
3826
+ fetchPayrolls: fetchPayrolls,
3827
+ deletePayrolls: deletePayrolls,
3828
+ journalize: journalize,
3829
+ clearConfirm: clearConfirm,
3830
+ coreConfirm: coreConfirm
3730
3831
  }, dispatch);
3731
3832
  };
3732
- var PaymentApproveForPaymentSummary = connect(mapStateToProps$8, mapDispatchToProps$8)(PaymentApproveForPaymentDialog);
3833
+ var PayrollSearcher$1 = connect(mapStateToProps$8, mapDispatchToProps$8)(PayrollSearcher);
3834
+
3835
+ var useStyles$6 = makeStyles(function (theme) {
3836
+ return {
3837
+ page: theme.page,
3838
+ fab: theme.fab
3839
+ };
3840
+ });
3841
+ function PayrollsPage() {
3842
+ var modulesManager = useModulesManager();
3843
+ var classes = useStyles$6();
3844
+ var history = useHistory();
3845
+ var rights = useSelector(function (store) {
3846
+ var _store$core$user$i_us;
3847
+ return (_store$core$user$i_us = store.core.user.i_user.rights) !== null && _store$core$user$i_us !== void 0 ? _store$core$user$i_us : [];
3848
+ });
3849
+ var _useTranslations = useTranslations(MODULE_NAME, modulesManager),
3850
+ formatMessage = _useTranslations.formatMessage;
3851
+ var onCreate = function onCreate() {
3852
+ return history.push("/".concat(modulesManager.getRef(PAYROLL_PAYROLL_ROUTE)));
3853
+ };
3854
+ return /*#__PURE__*/React.createElement("div", {
3855
+ className: classes.page
3856
+ }, /*#__PURE__*/React.createElement(Helmet, {
3857
+ title: formatMessage('paymentPoint.page.title')
3858
+ }), rights.includes(RIGHT_PAYROLL_SEARCH) && /*#__PURE__*/React.createElement(PayrollSearcher$1, null), rights.includes(RIGHT_PAYROLL_CREATE) && withTooltip(/*#__PURE__*/React.createElement("div", {
3859
+ className: classes.fab
3860
+ }, /*#__PURE__*/React.createElement(Fab, {
3861
+ color: "primary",
3862
+ onClick: onCreate
3863
+ }, /*#__PURE__*/React.createElement(AddIcon, null))), formatMessage('createButton.tooltip')));
3864
+ }
3733
3865
 
3734
3866
  function PayrollPaymentFilesSearcher(_ref) {
3735
3867
  var fetchingPayrollFiles = _ref.fetchingPayrollFiles,
@@ -3927,8 +4059,36 @@ function PayrollSearcherApproved(_ref) {
3927
4059
  useEffect(function () {
3928
4060
  prevSubmittingMutationRef.current = submittingMutation;
3929
4061
  });
4062
+ var renderBistpProgress = function renderBistpProgress(payroll) {
4063
+ if (payroll.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) return null;
4064
+ var summary = payroll.bistpSummary || {};
4065
+ var total = summary.total || 0;
4066
+ var reconciled = summary.reconciled || 0;
4067
+ var progress = total > 0 ? reconciled / total * 100 : 0;
4068
+ return /*#__PURE__*/React.createElement("div", {
4069
+ style: {
4070
+ display: 'flex',
4071
+ alignItems: 'center',
4072
+ gap: 8,
4073
+ minWidth: 120
4074
+ }
4075
+ }, /*#__PURE__*/React.createElement(LinearProgress, {
4076
+ variant: "determinate",
4077
+ value: progress,
4078
+ style: {
4079
+ flex: 1,
4080
+ height: 8,
4081
+ borderRadius: 4
4082
+ }
4083
+ }), /*#__PURE__*/React.createElement("span", {
4084
+ style: {
4085
+ fontSize: '0.75rem',
4086
+ whiteSpace: 'nowrap'
4087
+ }
4088
+ }, reconciled, "/", total));
4089
+ };
3930
4090
  var headers = function headers() {
3931
- return ['payroll.name', 'payroll.paymentPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'emptyLabel'];
4091
+ return ['payroll.name', 'payroll.paymentPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'payroll.bistp.progress', 'emptyLabel'];
3932
4092
  };
3933
4093
  var sorts = function sorts() {
3934
4094
  return [['name', true], ['paymentPlan', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true]];
@@ -3965,6 +4125,8 @@ function PayrollSearcherApproved(_ref) {
3965
4125
  return payroll.status ? "".concat(payroll.status) : '';
3966
4126
  }, function (payroll) {
3967
4127
  return payroll.paymentMethod ? "".concat(payroll.paymentMethod) : '';
4128
+ }, function (payroll) {
4129
+ return renderBistpProgress(payroll);
3968
4130
  }, function (payroll) {
3969
4131
  return /*#__PURE__*/React.createElement(PayrollReconciliationFilesDialog, {
3970
4132
  classes: classes,
@@ -4304,8 +4466,36 @@ function PayrollSearcherReconciled(_ref) {
4304
4466
  useEffect(function () {
4305
4467
  prevSubmittingMutationRef.current = submittingMutation;
4306
4468
  });
4469
+ var renderBistpProgress = function renderBistpProgress(payroll) {
4470
+ if (payroll.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) return null;
4471
+ var summary = payroll.bistpSummary || {};
4472
+ var total = summary.total || 0;
4473
+ var reconciled = summary.reconciled || 0;
4474
+ var progress = total > 0 ? reconciled / total * 100 : 0;
4475
+ return /*#__PURE__*/React.createElement("div", {
4476
+ style: {
4477
+ display: 'flex',
4478
+ alignItems: 'center',
4479
+ gap: 8,
4480
+ minWidth: 120
4481
+ }
4482
+ }, /*#__PURE__*/React.createElement(LinearProgress, {
4483
+ variant: "determinate",
4484
+ value: progress,
4485
+ style: {
4486
+ flex: 1,
4487
+ height: 8,
4488
+ borderRadius: 4
4489
+ }
4490
+ }), /*#__PURE__*/React.createElement("span", {
4491
+ style: {
4492
+ fontSize: '0.75rem',
4493
+ whiteSpace: 'nowrap'
4494
+ }
4495
+ }, reconciled, "/", total));
4496
+ };
4307
4497
  var headers = function headers() {
4308
- return ['payroll.name', 'payroll.paymentPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'emptyLabel'];
4498
+ return ['payroll.name', 'payroll.paymentPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'payroll.bistp.progress', 'emptyLabel'];
4309
4499
  };
4310
4500
  var sorts = function sorts() {
4311
4501
  return [['name', true], ['paymentPlan', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true]];
@@ -4342,6 +4532,8 @@ function PayrollSearcherReconciled(_ref) {
4342
4532
  return payroll.status ? "".concat(payroll.status) : '';
4343
4533
  }, function (payroll) {
4344
4534
  return payroll.paymentMethod ? "".concat(payroll.paymentMethod) : '';
4535
+ }, function (payroll) {
4536
+ return renderBistpProgress(payroll);
4345
4537
  }, function (payroll) {
4346
4538
  return /*#__PURE__*/React.createElement(PayrollReconciliationFilesDialog, {
4347
4539
  classes: classes,
@@ -5259,7 +5451,8 @@ function BenefitConsumptionSearcher(_ref) {
5259
5451
  return fetchBenefitConsumptions(modulesManager, params);
5260
5452
  };
5261
5453
  var headers = function headers() {
5262
- return ['benefitConsumption.individual.firstName', 'benefitConsumption.individual.lastName', 'benefitConsumption.photo', 'benefitConsumption.code', 'benefitConsumption.dateDue', 'benefitConsumption.receipt', 'benefitConsumption.amount', 'benefitConsumption.type', 'benefitConsumption.status', 'benefitConsumption.payedOnTime', 'benefitConsumption.paymentDate', ''];
5454
+ var cols = ['benefitConsumption.individual.firstName', 'benefitConsumption.individual.lastName', 'benefitConsumption.nib', 'benefitConsumption.photo', 'benefitConsumption.code', 'benefitConsumption.dateDue', 'benefitConsumption.receipt', 'benefitConsumption.amount', 'benefitConsumption.type', 'benefitConsumption.status', 'benefitConsumption.payedOnTime', 'benefitConsumption.paymentDate', ''];
5455
+ return cols;
5263
5456
  };
5264
5457
  var checkBenefitDueDate = function checkBenefitDueDate(benefitConsumption) {
5265
5458
  if (!benefitConsumption.receipt) {
@@ -5267,6 +5460,62 @@ function BenefitConsumptionSearcher(_ref) {
5267
5460
  }
5268
5461
  return benefitConsumption && benefitConsumption.dateDue >= benefitConsumption.benefitAttachment[0].bill.datePayed ? 'True' : 'False';
5269
5462
  };
5463
+ var getBistpStatusBadge = function getBistpStatusBadge(benefitConsumption) {
5464
+ if (!benefitConsumption) return null;
5465
+ var jsonExt = benefitConsumption.jsonExt || {};
5466
+ var status = benefitConsumption.status;
5467
+ if (status === BENEFIT_CONSUMPTION_STATUS.RECONCILED) {
5468
+ return /*#__PURE__*/React.createElement(Chip, {
5469
+ label: formatMessage('payroll.bistp.status.reconciled'),
5470
+ style: {
5471
+ backgroundColor: '#4caf50',
5472
+ color: 'white'
5473
+ },
5474
+ size: "small"
5475
+ });
5476
+ }
5477
+ if (status === BENEFIT_CONSUMPTION_STATUS.REJECTED) {
5478
+ return /*#__PURE__*/React.createElement(Chip, {
5479
+ label: "".concat(formatMessage('payroll.bistp.status.rejected')).concat(jsonExt.bistp_rejection_reason ? ": ".concat(jsonExt.bistp_rejection_reason) : ''),
5480
+ style: {
5481
+ backgroundColor: '#f44336',
5482
+ color: 'white'
5483
+ },
5484
+ size: "small"
5485
+ });
5486
+ }
5487
+ if (status === BENEFIT_CONSUMPTION_STATUS.APPROVE_FOR_PAYMENT) {
5488
+ return /*#__PURE__*/React.createElement(Chip, {
5489
+ label: formatMessage('payroll.bistp.status.pending'),
5490
+ style: {
5491
+ backgroundColor: '#ff9800',
5492
+ color: 'white'
5493
+ },
5494
+ size: "small"
5495
+ });
5496
+ }
5497
+ if (jsonExt.bistp_skip_reason === 'nib_ausente') {
5498
+ return /*#__PURE__*/React.createElement(Chip, {
5499
+ label: formatMessage('payroll.bistp.status.skippedNib'),
5500
+ style: {
5501
+ backgroundColor: '#9e9e9e',
5502
+ color: 'white'
5503
+ },
5504
+ size: "small"
5505
+ });
5506
+ }
5507
+ if (jsonExt.bistp_skip_reason === 'envio_falhou') {
5508
+ return /*#__PURE__*/React.createElement(Chip, {
5509
+ label: formatMessage('payroll.bistp.status.sendFailed'),
5510
+ style: {
5511
+ backgroundColor: '#f44336',
5512
+ color: 'white'
5513
+ },
5514
+ size: "small"
5515
+ });
5516
+ }
5517
+ return null;
5518
+ };
5270
5519
  var itemFormatters = function itemFormatters() {
5271
5520
  return [function (benefitConsumption) {
5272
5521
  var _benefitConsumption$i;
@@ -5274,6 +5523,9 @@ function BenefitConsumptionSearcher(_ref) {
5274
5523
  }, function (benefitConsumption) {
5275
5524
  var _benefitConsumption$i2;
5276
5525
  return benefitConsumption === null || benefitConsumption === void 0 || (_benefitConsumption$i2 = benefitConsumption.individual) === null || _benefitConsumption$i2 === void 0 ? void 0 : _benefitConsumption$i2.lastName;
5526
+ }, function (benefitConsumption) {
5527
+ var _benefitConsumption$i3;
5528
+ return (benefitConsumption === null || benefitConsumption === void 0 || (_benefitConsumption$i3 = benefitConsumption.individual) === null || _benefitConsumption$i3 === void 0 ? void 0 : _benefitConsumption$i3.nib) || '';
5277
5529
  }, function (benefitConsumption) {
5278
5530
  return benefitConsumption.receipt ? /*#__PURE__*/React.createElement(PhotoCameraOutlinedIcon, {
5279
5531
  style: {
@@ -5298,18 +5550,26 @@ function BenefitConsumptionSearcher(_ref) {
5298
5550
  var _benefitConsumption$b;
5299
5551
  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;
5300
5552
  }, function (benefitConsumption) {
5301
- return /*#__PURE__*/React.createElement(AdditionalFieldsDialog$1, {
5553
+ var jsonExt = (benefitConsumption === null || benefitConsumption === void 0 ? void 0 : benefitConsumption.jsonExt) || {};
5554
+ var hasBistpFields = jsonExt.bistp_skip_reason || jsonExt.bistp_processed || jsonExt.bistp_rejection_reason;
5555
+ return /*#__PURE__*/React.createElement("div", {
5556
+ style: {
5557
+ display: 'flex',
5558
+ alignItems: 'center',
5559
+ gap: 4
5560
+ }
5561
+ }, hasBistpFields && getBistpStatusBadge(benefitConsumption), /*#__PURE__*/React.createElement(AdditionalFieldsDialog$1, {
5302
5562
  jsonExt: benefitConsumption === null || benefitConsumption === void 0 ? void 0 : benefitConsumption.jsonExt,
5303
5563
  buttonLabel: "payroll.additonalFields.showAdditionalFields",
5304
5564
  title: "payroll.additonalFields.label"
5305
- });
5565
+ }));
5306
5566
  }];
5307
5567
  };
5308
5568
  var rowIdentifier = function rowIdentifier(benefitConsumption) {
5309
5569
  return benefitConsumption.id;
5310
5570
  };
5311
5571
  var sorts = function sorts() {
5312
- return [['individual_FirstName', true], ['individual_LastName', true], ['photo', true], ['code', true], ['dateDue', true], ['receipt', true], ['amount', true], ['type', true], ['status', true]];
5572
+ return [['individual_FirstName', true], ['individual_LastName', true], ['individual_Nib', true], ['photo', true], ['code', true], ['dateDue', true], ['receipt', true], ['amount', true], ['type', true], ['status', true]];
5313
5573
  };
5314
5574
  var defaultFilters = function defaultFilters() {
5315
5575
  var filters = {
@@ -5317,9 +5577,9 @@ function BenefitConsumptionSearcher(_ref) {
5317
5577
  value: false,
5318
5578
  filter: 'isDeleted: false'
5319
5579
  },
5320
- payrollUuid: {
5580
+ payrollbenefitconsumptionPayrollId: {
5321
5581
  value: payrollUuid,
5322
- filter: "payrollUuid: \"".concat(payrollUuid, "\"")
5582
+ filter: "payrollbenefitconsumptionPayrollId: \"".concat(payrollUuid, "\"")
5323
5583
  }
5324
5584
  };
5325
5585
  if (isPayrollFromFailedInvoices) {
@@ -5761,8 +6021,36 @@ function PayrollSearcherPending(_ref) {
5761
6021
  useEffect(function () {
5762
6022
  prevSubmittingMutationRef.current = submittingMutation;
5763
6023
  });
6024
+ var renderBistpProgress = function renderBistpProgress(payroll) {
6025
+ if (payroll.paymentMethod !== PAYMENT_METHOD.STRATEGY_BISTP_PAYMENT) return null;
6026
+ var summary = payroll.bistpSummary || {};
6027
+ var total = summary.total || 0;
6028
+ var reconciled = summary.reconciled || 0;
6029
+ var progress = total > 0 ? reconciled / total * 100 : 0;
6030
+ return /*#__PURE__*/React.createElement("div", {
6031
+ style: {
6032
+ display: 'flex',
6033
+ alignItems: 'center',
6034
+ gap: 8,
6035
+ minWidth: 120
6036
+ }
6037
+ }, /*#__PURE__*/React.createElement(LinearProgress, {
6038
+ variant: "determinate",
6039
+ value: progress,
6040
+ style: {
6041
+ flex: 1,
6042
+ height: 8,
6043
+ borderRadius: 4
6044
+ }
6045
+ }), /*#__PURE__*/React.createElement("span", {
6046
+ style: {
6047
+ fontSize: '0.75rem',
6048
+ whiteSpace: 'nowrap'
6049
+ }
6050
+ }, reconciled, "/", total));
6051
+ };
5764
6052
  var headers = function headers() {
5765
- return ['payroll.name', 'payroll.paymentPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'emptyLabel'];
6053
+ return ['payroll.name', 'payroll.paymentPlan', 'payroll.paymentPoint', 'payroll.status', 'payroll.paymentMethod', 'payroll.bistp.progress', 'emptyLabel'];
5766
6054
  };
5767
6055
  var sorts = function sorts() {
5768
6056
  return [['name', true], ['paymentPlan', true], ['paymentPoint', true], ['status', true], ['paymentMethod', true]];
@@ -5799,6 +6087,8 @@ function PayrollSearcherPending(_ref) {
5799
6087
  return payroll.status ? "".concat(payroll.status) : '';
5800
6088
  }, function (payroll) {
5801
6089
  return payroll.paymentMethod ? "".concat(payroll.paymentMethod) : '';
6090
+ }, function (payroll) {
6091
+ return renderBistpProgress(payroll);
5802
6092
  }, function (payroll) {
5803
6093
  return /*#__PURE__*/React.createElement(PayrollReconciliationFilesDialog, {
5804
6094
  classes: classes,