@stssocialst-stp/fe-payroll 0.1.0 → 0.1.2

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