@gusto/embedded-react-sdk 0.56.0 → 0.56.1

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/components/Payroll/OffCycle/OffCycleFlow.js.map +1 -1
  3. package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +24 -18
  4. package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
  5. package/dist/components/Payroll/OffCycle/offCycleStateMachine.js +39 -21
  6. package/dist/components/Payroll/OffCycle/offCycleStateMachine.js.map +1 -1
  7. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +85 -82
  8. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
  9. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +52 -51
  10. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
  11. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.js +12 -12
  12. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerAlerts.js.map +1 -1
  13. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +40 -40
  14. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
  15. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +26 -25
  16. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  17. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +13 -16
  18. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  19. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +0 -1
  20. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
  21. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js +138 -110
  22. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js.map +1 -1
  23. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +149 -146
  24. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
  25. package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
  26. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +4 -0
  27. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
  28. package/dist/components/Payroll/PayrollFlow/PayrollFlow.js.map +1 -1
  29. package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js +22 -35
  30. package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js.map +1 -1
  31. package/dist/components/Payroll/Transition/TransitionFlow.js +49 -36
  32. package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -1
  33. package/dist/components/Payroll/Transition/TransitionFlowComponents.js +24 -47
  34. package/dist/components/Payroll/Transition/TransitionFlowComponents.js.map +1 -1
  35. package/dist/components/Payroll/Transition/transitionStateMachine.js +35 -40
  36. package/dist/components/Payroll/Transition/transitionStateMachine.js.map +1 -1
  37. package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js +48 -0
  38. package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js.map +1 -0
  39. package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js +35 -0
  40. package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js.map +1 -0
  41. package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js +23 -0
  42. package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js.map +1 -0
  43. package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js +32 -0
  44. package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js.map +1 -0
  45. package/dist/components/Payroll/index.js +7 -5
  46. package/dist/components/Payroll/index.js.map +1 -1
  47. package/dist/i18n/I18n.js +9 -4
  48. package/dist/i18n/I18n.js.map +1 -1
  49. package/dist/i18n/en/Payroll.PayrollBlocker.json.js +10 -8
  50. package/dist/i18n/en/Payroll.PayrollBlocker.json.js.map +1 -1
  51. package/dist/i18n/es_US/Company.StateTaxes.json.js +1 -1
  52. package/dist/i18n/es_US/Contractor.ContractorList.json.js +14 -12
  53. package/dist/i18n/es_US/Contractor.ContractorList.json.js.map +1 -1
  54. package/dist/i18n/es_US/Contractor.Management.Compensation.json.js +4 -4
  55. package/dist/i18n/es_US/Contractor.Management.Profile.json.js +4 -4
  56. package/dist/i18n/es_US/Contractor.ManagementContractorList.json.js +40 -38
  57. package/dist/i18n/es_US/Contractor.ManagementContractorList.json.js.map +1 -1
  58. package/dist/i18n/es_US/Contractor.Payments.PaymentsList.json.js +18 -16
  59. package/dist/i18n/es_US/Contractor.Payments.PaymentsList.json.js.map +1 -1
  60. package/dist/i18n/es_US/Contractor.Profile.json.js +5 -5
  61. package/dist/i18n/es_US/Payroll.OffCycleCreation.json.js +11 -9
  62. package/dist/i18n/es_US/Payroll.OffCycleCreation.json.js.map +1 -1
  63. package/dist/i18n/es_US/Payroll.OffCyclePayPeriodDateForm.json.js +2 -2
  64. package/dist/i18n/es_US/Payroll.OffCycleTaxWithholding.json.js +6 -6
  65. package/dist/i18n/es_US/Payroll.PayrollConfiguration.json.js +15 -15
  66. package/dist/i18n/es_US/Payroll.PayrollEditEmployee.json.js +28 -26
  67. package/dist/i18n/es_US/Payroll.PayrollEditEmployee.json.js.map +1 -1
  68. package/dist/i18n/es_US/Payroll.PayrollOverview.json.js +40 -38
  69. package/dist/i18n/es_US/Payroll.PayrollOverview.json.js.map +1 -1
  70. package/dist/i18n/es_US/Payroll.PrintChecksBanner.json.js +14 -0
  71. package/dist/i18n/es_US/Payroll.PrintChecksBanner.json.js.map +1 -0
  72. package/dist/i18n/es_US/Payroll.PrintChecksFailure.json.js +12 -0
  73. package/dist/i18n/es_US/Payroll.PrintChecksFailure.json.js.map +1 -0
  74. package/dist/i18n/es_US/Payroll.PrintChecksForm.json.js +26 -0
  75. package/dist/i18n/es_US/Payroll.PrintChecksForm.json.js.map +1 -0
  76. package/dist/i18n/es_US/Payroll.PrintChecksSummary.json.js +14 -0
  77. package/dist/i18n/es_US/Payroll.PrintChecksSummary.json.js.map +1 -0
  78. package/dist/i18n/es_US/Payroll.UNSTABLE_PayrollEditEmployee.json.js +78 -0
  79. package/dist/i18n/es_US/Payroll.UNSTABLE_PayrollEditEmployee.json.js.map +1 -0
  80. package/dist/i18n/es_US/common.json.js +1 -1
  81. package/dist/package.json.js +1 -1
  82. package/dist/shared/constants.js +21 -20
  83. package/dist/shared/constants.js.map +1 -1
  84. package/dist/src/components/Payroll/OffCycle/OffCycleFlow.d.ts +2 -0
  85. package/dist/src/components/Payroll/OffCycle/OffCycleFlowComponents.d.ts +2 -0
  86. package/dist/src/components/Payroll/OffCycle/offCycleStateMachine.d.ts +1 -0
  87. package/dist/src/components/Payroll/OffCycleCreation/OffCycleCreation.d.ts +1 -0
  88. package/dist/src/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
  89. package/dist/src/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +5 -0
  90. package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfiguration.d.ts +1 -1
  91. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.d.ts +18 -0
  92. package/dist/src/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +1 -1
  93. package/dist/src/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.d.ts +8 -0
  94. package/dist/src/components/Payroll/PayrollFlow/PayrollFlow.d.ts +1 -1
  95. package/dist/src/components/Payroll/PayrollFlow/TransitionFlowContextual.d.ts +6 -1
  96. package/dist/src/components/Payroll/Transition/TransitionFlow.d.ts +17 -15
  97. package/dist/src/components/Payroll/Transition/TransitionFlowComponents.d.ts +21 -12
  98. package/dist/src/components/Payroll/Transition/transitionStateMachine.d.ts +25 -4
  99. package/dist/src/components/Payroll/TransitionPayroll/TransitionPayroll.d.ts +55 -0
  100. package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollComponents.d.ts +24 -0
  101. package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollTypes.d.ts +23 -0
  102. package/dist/src/components/Payroll/TransitionPayroll/index.d.ts +2 -0
  103. package/dist/src/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.d.ts +15 -0
  104. package/dist/src/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.d.ts +28 -0
  105. package/dist/src/components/Payroll/index.d.ts +2 -0
  106. package/dist/src/i18n/types.d.ts +6 -0
  107. package/dist/src/shared/constants.d.ts +2 -0
  108. package/docs/guides/endpoint-inventory.json +14 -19
  109. package/package.json +4 -4
@@ -26,7 +26,7 @@ function Co(t) {
26
26
  const Ve = ({
27
27
  onEvent: t,
28
28
  companyId: c,
29
- payrollId: l,
29
+ payrollId: s,
30
30
  dictionary: $,
31
31
  alerts: J,
32
32
  withReimbursements: x = !0,
@@ -36,15 +36,15 @@ const Ve = ({
36
36
  const { t: n } = Oe("Payroll.PayrollConfiguration"), { baseSubmitHandler: f, setError: P } = qe(), p = He(), [k, G] = d(!1), u = O(!1), h = O(!1), z = De(), Q = b(
37
37
  () => ({
38
38
  companyId: c,
39
- payrollId: l,
39
+ payrollId: s,
40
40
  include: ["taxes", "benefits", "deductions", "payroll_status_meta"]
41
41
  }),
42
- [c, l]
43
- ), { data: s, refetch: X } = Ee(Q), Z = b(
44
- () => s.payrollShow?.employeeCompensations?.filter((e) => e.excluded).map((e) => e.employeeUuid).filter(Boolean) ?? [],
45
- [s.payrollShow?.employeeCompensations]
42
+ [c, s]
43
+ ), { data: l, refetch: X } = Ee(Q), Z = b(
44
+ () => l.payrollShow?.employeeCompensations?.filter((e) => e.excluded).map((e) => e.employeeUuid).filter(Boolean) ?? [],
45
+ [l.payrollShow?.employeeCompensations]
46
46
  );
47
- K(s.payrollShow?.processingRequest) && (u.current = !0);
47
+ K(l.payrollShow?.processingRequest) && (u.current = !0);
48
48
  const { data: I } = Te({
49
49
  companyUuid: c
50
50
  }), N = (I.payrollBlockers ?? []).map((e) => ({
@@ -62,7 +62,7 @@ const Ve = ({
62
62
  refetch: X,
63
63
  onCalculated: (e) => {
64
64
  t(i.RUN_PAYROLL_CALCULATED, {
65
- payrollId: l,
65
+ payrollId: s,
66
66
  alert: {
67
67
  type: "success",
68
68
  title: n("alerts.progressSaved"),
@@ -90,7 +90,7 @@ const Ve = ({
90
90
  refetch: R
91
91
  } = Ye({
92
92
  companyId: c,
93
- payrollId: l,
93
+ payrollId: s,
94
94
  // Don't prepare while calculating, or once we've seen it calculate. If the payroll was already
95
95
  // calculated when we opened (e.g. clicking Edit), we do prepare so it can be edited.
96
96
  disablePrepare: C || k || u.current,
@@ -109,16 +109,16 @@ const Ve = ({
109
109
  return;
110
110
  }
111
111
  _.current || (_.current = !0, t(i.RUN_PAYROLL_ALREADY_PROCESSED, {
112
- payrollId: l,
112
+ payrollId: s,
113
113
  alert: E,
114
- payPeriod: s.payrollShow?.payPeriod
114
+ payPeriod: l.payrollShow?.payPeriod
115
115
  }));
116
116
  }, [
117
117
  w,
118
118
  t,
119
- l,
119
+ s,
120
120
  E,
121
- s.payrollShow?.payPeriod
121
+ l.payrollShow?.payPeriod
122
122
  ]);
123
123
  const { mutateAsync: B, isPending: ne } = be(), { mutateAsync: ce } = xe(), [m, j] = d(null), [ue, D] = d(!1), v = Fe(S), g = Me(S), pe = (e) => {
124
124
  j(e), D(!0), t(i.RUN_PAYROLL_GROSS_UP_SELECTED, { employeeUuid: e });
@@ -128,7 +128,7 @@ const Ve = ({
128
128
  return await f(null, async () => {
129
129
  o = (await ce({
130
130
  request: {
131
- payrollUuid: l,
131
+ payrollUuid: s,
132
132
  payrollGrossUpRequest: {
133
133
  employeeUuid: m,
134
134
  netPay: e.toString()
@@ -180,7 +180,7 @@ const Ve = ({
180
180
  const a = await B({
181
181
  request: {
182
182
  companyId: c,
183
- payrollId: l,
183
+ payrollId: s,
184
184
  payrollUpdate: {
185
185
  employeeCompensations: [{ ...Se, excluded: !1 }]
186
186
  }
@@ -202,12 +202,12 @@ const Ve = ({
202
202
  try {
203
203
  const o = await _e(z, {
204
204
  companyId: c,
205
- payrollId: l
205
+ payrollId: s
206
206
  });
207
207
  if (!o.ok)
208
208
  throw o.error;
209
209
  A({
210
- baselineCalculatedAt: s.payrollShow?.calculatedAt?.getTime() ?? null,
210
+ baselineCalculatedAt: l.payrollShow?.calculatedAt?.getTime() ?? null,
211
211
  // We just submitted the payroll, so we haven't yet seen it return with the calculating status
212
212
  sawCalculatingThisPoll: !1
213
213
  });
@@ -221,6 +221,7 @@ const Ve = ({
221
221
  });
222
222
  }, Pe = (e) => {
223
223
  t(i.RUN_PAYROLL_EMPLOYEE_EDIT, {
224
+ payrollId: s,
224
225
  employeeId: e.uuid,
225
226
  firstName: e.firstName,
226
227
  lastName: e.lastName
@@ -245,7 +246,7 @@ const Ve = ({
245
246
  const o = W(e), r = await B({
246
247
  request: {
247
248
  companyId: c,
248
- payrollId: l,
249
+ payrollId: s,
249
250
  payrollUpdate: {
250
251
  employeeCompensations: [
251
252
  { ...o, excluded: !o.excluded }
@@ -262,25 +263,25 @@ const Ve = ({
262
263
  };
263
264
  H(() => {
264
265
  if (!C) {
265
- if (!K(s.payrollShow?.processingRequest)) {
266
+ if (!K(l.payrollShow?.processingRequest)) {
266
267
  h.current = !1;
267
268
  return;
268
269
  }
269
270
  h.current || (L(!1), P(null), A({
270
- baselineCalculatedAt: s.payrollShow?.calculatedAt?.getTime() ?? null,
271
+ baselineCalculatedAt: l.payrollShow?.calculatedAt?.getTime() ?? null,
271
272
  // We have seen the calculating status, which is why we're starting to poll now until it completes or fails.
272
273
  sawCalculatingThisPoll: !0
273
274
  }));
274
275
  }
275
276
  }, [
276
- s.payrollShow?.processingRequest,
277
- s.payrollShow?.calculatedAt,
277
+ l.payrollShow?.processingRequest,
278
+ l.payrollShow?.calculatedAt,
278
279
  C,
279
280
  A,
280
281
  P
281
282
  ]);
282
283
  const he = (() => {
283
- const e = s.payrollShow?.payrollStatusMeta;
284
+ const e = l.payrollShow?.payrollStatusMeta;
284
285
  if (e?.payrollLate && e.initialCheckDate && e.expectedDebitTime && e.expectedCheckDate)
285
286
  return {
286
287
  label: n("alerts.payrollLate", {
@@ -292,7 +293,7 @@ const Ve = ({
292
293
  }),
293
294
  variant: "warning"
294
295
  };
295
- const { payrollShow: r } = s;
296
+ const { payrollShow: r } = l;
296
297
  if (r?.checkDate && r.payrollDeadline)
297
298
  return {
298
299
  label: n("alerts.directDepositDeadline", {
@@ -308,7 +309,7 @@ const Ve = ({
308
309
  {
309
310
  className: T,
310
311
  companyId: c,
311
- payrollId: l,
312
+ payrollId: s,
312
313
  onEvent: (o, r) => {
313
314
  o === i.RUN_PAYROLL_CANCELLED && R(), t(o, r);
314
315
  },
@@ -1 +1 @@
1
- {"version":3,"file":"PayrollConfiguration.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/PayrollConfiguration.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { payrollsCalculate } from '@gusto/embedded-api/funcs/payrollsCalculate'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport type { GetV1CompaniesCompanyIdPayrollsPayrollIdRequest } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayrollspayrollid'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useTranslation } from 'react-i18next'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport { usePayrollsCalculateGrossUpMutation } from '@gusto/embedded-api/react-query/payrollsCalculateGrossUp'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate'\nimport { usePayrollsGetBlockersSuspense } from '@gusto/embedded-api/react-query/payrollsGetBlockers'\nimport { payrollSubmitHandler, type ApiPayrollBlocker } from '../PayrollBlocker/payrollHelpers'\nimport { GrossUpModal } from '../GrossUpModal'\nimport { PayrollOverview } from '../PayrollOverview/PayrollOverview'\nimport type { PayrollFlowAlert } from '../PayrollFlow/PayrollFlowComponents'\nimport { PayrollConfigurationPresentation } from './PayrollConfigurationPresentation'\nimport { usePayrollConfigurationData } from './usePayrollConfigurationData'\nimport { getGrossUpTargetCompensationName, isGrossUpEligible } from './grossUpHelpers'\nimport { useCalculationPoll, isCalculatingStatus, type PayrollShow } from './useCalculationPoll'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useBase } from '@/components/Base'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport { SDKInternalError } from '@/types/sdkError'\n\n/**\n * Props for {@link PayrollConfiguration}.\n *\n * @public\n */\nexport interface PayrollConfigurationProps extends BaseComponentInterface<'Payroll.PayrollConfiguration'> {\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /** Optional alert components to render above the configuration content. */\n alerts?: ReactNode\n /** Whether to show the reimbursements column in the compensation table. Defaults to `true`. */\n withReimbursements?: boolean\n}\n\n/**\n * Handles the configuration phase of payroll processing, allowing users to review and modify employee compensation before calculating the payroll.\n *\n * @remarks\n * If the payroll turns out to already be processed (e.g. another actor submitted it while this\n * screen was open), this component emits `runPayroll/alreadyProcessed` and then renders\n * {@link PayrollOverview} in its place — the read-only breakdown with the gated \"Cancel payroll\"\n * action — instead of the configuration table. Events from that delegated view (e.g.\n * `runPayroll/cancelled`) are emitted through this component's own `onEvent`.\n *\n * Emits the following events:\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/employee/edit` | An employee row is selected for editing | `{ employeeId, firstName, lastName }` |\n * | `runPayroll/employee/skip` | An employee is skipped or unskipped for this payroll | `{ employeeId }` |\n * | `runPayroll/employee/saved` | Employee compensation changes are persisted | `{ payrollPrepared }` |\n * | `runPayroll/calculated` | Payroll calculation completes successfully | `{ payrollId, alert, payPeriod }` |\n * | `runPayroll/alreadyProcessed` | The payroll turns out to already be processed while configuring it | `{ payrollId, alert, payPeriod }` |\n * | `runPayroll/processingFailed` | Payroll calculation fails or times out | — |\n * | `runPayroll/blockers/viewAll` | The \"view all blockers\" affordance is selected | — |\n * | `runPayroll/grossUp/selected` | The set-net-earnings menu item is selected for an employee | `{ employeeUuid }` |\n * | `runPayroll/grossUp/calculated` | A gross-up amount is calculated from a target net pay | `{ grossUp, netPay, employeeUuid }` |\n *\n * @param props - See {@link PayrollConfigurationProps}.\n * @returns The payroll configuration screen.\n * @public\n */\nexport function PayrollConfiguration(props: PayrollConfigurationProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({\n onEvent,\n companyId,\n payrollId,\n dictionary,\n alerts,\n withReimbursements = true,\n className,\n}: PayrollConfigurationProps) => {\n useComponentDictionary('Payroll.PayrollConfiguration', dictionary)\n useI18n('Payroll.PayrollConfiguration')\n const { t } = useTranslation('Payroll.PayrollConfiguration')\n const { baseSubmitHandler, setError } = useBase()\n const dateFormatter = useDateFormatter()\n\n const [isCalculatingPayroll, setIsCalculatingPayroll] = useState(false)\n // True once this screen has read a \"calculating\" status for the payroll, whether we started that\n // calc or someone else did. Calling prepare after that would wipe the result, so we use this to\n // keep prepare off.\n const hasSeenCalculatingRef = useRef(false)\n // Set when a poll ends in a non-retryable read error without confirming a calculated/failed\n // outcome. Guards the auto-pickup effect below from re-arming a poll against the same stale\n // \"Calculating\" read over and over -- it only clears once the status genuinely leaves Calculating.\n const hasTerminalPollErrorRef = useRef(false)\n const gustoClient = useGustoEmbeddedContext()\n\n const payrollRequest = useMemo<GetV1CompaniesCompanyIdPayrollsPayrollIdRequest>(\n () => ({\n companyId,\n payrollId,\n include: ['taxes', 'benefits', 'deductions', 'payroll_status_meta'],\n }),\n [companyId, payrollId],\n )\n\n const { data: payrollData, refetch: refetchPayroll } = usePayrollsGetSuspense(payrollRequest)\n\n const excludedEmployeeUuids = useMemo(\n () =>\n payrollData.payrollShow?.employeeCompensations\n ?.filter(comp => comp.excluded)\n .map(comp => comp.employeeUuid!)\n .filter(Boolean) ?? [],\n [payrollData.payrollShow?.employeeCompensations],\n )\n\n // Remember once we've seen it calculating.\n if (isCalculatingStatus(payrollData.payrollShow?.processingRequest)) {\n hasSeenCalculatingRef.current = true\n }\n\n const { data: blockersData } = usePayrollsGetBlockersSuspense({\n companyUuid: companyId,\n })\n\n const payrollBlockerList = blockersData.payrollBlockers ?? []\n\n const blockersFromApi: ApiPayrollBlocker[] = payrollBlockerList.map(blocker => ({\n key: blocker.key,\n message: blocker.message,\n }))\n\n const [payrollBlockers, setPayrollBlockers] = useState(blockersFromApi)\n // Drives the loader gate below. Deliberately separate from `error` -- `baseSubmitHandler`\n // clears `error` at the start of *any* submit (e.g. skipping an employee, applying a gross-up),\n // which would otherwise reopen this gate and get the loader stuck on with no poll running to\n // ever clear it (SDK-1276). Only the same sites that used to own the old boolean flag touch it.\n const [hasProcessingFailedAlert, setHasProcessingFailedAlert] = useState(false)\n\n const emitProcessingFailed = () => {\n onEvent(componentEvents.RUN_PAYROLL_PROCESSING_FAILED)\n setHasProcessingFailedAlert(true)\n setError({\n category: 'internal_error',\n message: `${t('alerts.processingFailed.label')}. ${t('alerts.processingFailed.message')}`,\n fieldErrors: [],\n })\n }\n\n const onProcessingFailed = (payroll: PayrollShow | undefined) => {\n emitProcessingFailed()\n // Let prepare run again on retry — but only when there is no calculation for it to wipe.\n if (payroll?.calculatedAt == null) {\n hasSeenCalculatingRef.current = false\n }\n }\n\n const { start: startCalculationPoll, isPolling } = useCalculationPoll({\n refetch: refetchPayroll,\n onCalculated: (payroll: PayrollShow | undefined) => {\n onEvent(componentEvents.RUN_PAYROLL_CALCULATED, {\n payrollId,\n alert: {\n type: 'success',\n title: t('alerts.progressSaved'),\n alertKey: 'progressSaved',\n },\n payPeriod: payroll?.payPeriod,\n })\n setPayrollBlockers([])\n },\n onProcessingFailed,\n // Unlike a real processing failure, we never confirmed whether the calculation actually\n // succeeded server-side, so this must not reset hasSeenCalculatingRef — doing so would\n // re-arm prepare and risk wiping a calculation that may have genuinely completed.\n onError: () => {\n hasTerminalPollErrorRef.current = true\n emitProcessingFailed()\n },\n })\n\n // Show the loading state the whole time we're calculating, so a second tab shows the loader\n // instead of a blank table until it moves to the overview. Once the failed/error alert is\n // showing, the poll has already reached a terminal state, so the loading UI must clear even\n // though hasSeenCalculatingRef stays true (it still guards prepare separately, below).\n const isCalculatingActive =\n !hasProcessingFailedAlert &&\n (isCalculatingPayroll || isPolling || hasSeenCalculatingRef.current)\n\n const {\n employeeDetails,\n employeeCompensations,\n paySchedule,\n payPeriod,\n payrollCategory,\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch,\n } = usePayrollConfigurationData({\n companyId,\n payrollId,\n // Don't prepare while calculating, or once we've seen it calculate. If the payroll was already\n // calculated when we opened (e.g. clicking Edit), we do prepare so it can be edited.\n disablePrepare: isPolling || isCalculatingPayroll || hasSeenCalculatingRef.current,\n excludedEmployeeUuids,\n })\n\n const alreadyProcessedAlert: PayrollFlowAlert = useMemo(\n () => ({\n type: 'error',\n title: t('alerts.alreadyProcessed'),\n alertKey: 'alreadyProcessed',\n }),\n [t],\n )\n\n const hasFiredAlreadyProcessedRef = useRef(false)\n\n useEffect(() => {\n if (!isAlreadyProcessed) {\n hasFiredAlreadyProcessedRef.current = false\n return\n }\n if (hasFiredAlreadyProcessedRef.current) return\n hasFiredAlreadyProcessedRef.current = true\n onEvent(componentEvents.RUN_PAYROLL_ALREADY_PROCESSED, {\n payrollId,\n alert: alreadyProcessedAlert,\n payPeriod: payrollData.payrollShow?.payPeriod,\n })\n }, [\n isAlreadyProcessed,\n onEvent,\n payrollId,\n alreadyProcessedAlert,\n payrollData.payrollShow?.payPeriod,\n ])\n\n const { mutateAsync: updatePayroll, isPending: isUpdatingPayroll } = usePayrollsUpdateMutation()\n\n const { mutateAsync: calculateGrossUpMutation } = usePayrollsCalculateGrossUpMutation()\n\n const [grossUpEmployeeUuid, setGrossUpEmployeeUuid] = useState<string | null>(null)\n const [isGrossUpModalOpen, setIsGrossUpModalOpen] = useState(false)\n\n const grossUpEnabled = isGrossUpEligible(payrollCategory)\n const grossUpTargetCompensation = getGrossUpTargetCompensationName(payrollCategory)\n\n const onGrossUpSelect = (employeeUuid: string) => {\n setGrossUpEmployeeUuid(employeeUuid)\n setIsGrossUpModalOpen(true)\n onEvent(componentEvents.RUN_PAYROLL_GROSS_UP_SELECTED, { employeeUuid })\n }\n\n const onCalculateGrossUp = async (netPay: number): Promise<string | null> => {\n if (!grossUpEmployeeUuid) return null\n let grossUp: string | null = null\n\n await baseSubmitHandler(null, async () => {\n const result = await calculateGrossUpMutation({\n request: {\n payrollUuid: payrollId,\n payrollGrossUpRequest: {\n employeeUuid: grossUpEmployeeUuid,\n netPay: netPay.toString(),\n },\n },\n })\n\n grossUp = result.payrollGrossUpResponse?.grossUp ?? null\n\n if (grossUp) {\n onEvent(componentEvents.RUN_PAYROLL_GROSS_UP_CALCULATED, {\n grossUp,\n netPay,\n employeeUuid: grossUpEmployeeUuid,\n })\n }\n })\n\n return grossUp\n }\n\n const onGrossUpApply = async (grossAmount: string) => {\n if (!grossUpEmployeeUuid || !grossUpTargetCompensation) {\n throw new SDKInternalError(\n 'Unable to apply gross-up: missing employee or target compensation.',\n )\n }\n\n const employeeComp = employeeCompensations.find(ec => ec.employeeUuid === grossUpEmployeeUuid)\n if (!employeeComp) {\n throw new SDKInternalError('Unable to apply gross-up: employee compensation not found.')\n }\n\n const existingFixed = employeeComp.fixedCompensations ?? []\n const hasTargetCompensation = existingFixed.some(\n fc => fc.name?.toLowerCase() === grossUpTargetCompensation.toLowerCase(),\n )\n\n const updatedFixedCompensations = existingFixed.map(fc => ({\n name: fc.name,\n jobUuid: fc.jobUuid,\n amount:\n fc.name?.toLowerCase() === grossUpTargetCompensation.toLowerCase() ? grossAmount : '0',\n }))\n\n if (!hasTargetCompensation) {\n const primaryJobUuid =\n employeeComp.hourlyCompensations?.[0]?.jobUuid ?? existingFixed[0]?.jobUuid ?? ''\n updatedFixedCompensations.push({\n name: grossUpTargetCompensation,\n jobUuid: primaryJobUuid,\n amount: grossAmount,\n })\n }\n\n const updatedHourlyCompensations = (employeeComp.hourlyCompensations ?? []).map(hc => ({\n name: hc.name,\n jobUuid: hc.jobUuid,\n hours: '0',\n }))\n\n const updatedPaidTimeOff = (employeeComp.paidTimeOff ?? []).map(pto => ({\n name: pto.name,\n hours: '0',\n }))\n\n const transformedCompensation = transformEmployeeCompensation({\n ...employeeComp,\n fixedCompensations: updatedFixedCompensations,\n hourlyCompensations: updatedHourlyCompensations,\n paidTimeOff: updatedPaidTimeOff,\n })\n\n await baseSubmitHandler({}, async () => {\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [{ ...transformedCompensation, excluded: false }],\n },\n },\n })\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n })\n await refetch()\n })\n\n setGrossUpEmployeeUuid(null)\n setIsGrossUpModalOpen(false)\n }\n\n const handleGrossUpApply = async (grossAmount: string) => {\n try {\n await onGrossUpApply(grossAmount)\n } catch {\n // Modal stays open; error is surfaced by baseSubmitHandler\n }\n }\n\n const onCalculatePayroll = async () => {\n setPayrollBlockers([])\n setHasProcessingFailedAlert(false)\n setError(null)\n // Mark it right away so prepare can't run and cancel the calculation we just started.\n hasSeenCalculatingRef.current = true\n\n await baseSubmitHandler({}, async () => {\n const result = await payrollSubmitHandler(async () => {\n setIsCalculatingPayroll(true)\n try {\n const calcResult = await payrollsCalculate(gustoClient, {\n companyId,\n payrollId,\n })\n if (!calcResult.ok) {\n throw calcResult.error\n }\n startCalculationPoll({\n baselineCalculatedAt: payrollData.payrollShow?.calculatedAt?.getTime() ?? null,\n // We just submitted the payroll, so we haven't yet seen it return with the calculating status\n sawCalculatingThisPoll: false,\n })\n } catch (error) {\n // Calculate itself failed before polling ever started (e.g. a 409 conflict), so let\n // prepare run again on retry -- otherwise hasSeenCalculatingRef stays stuck true forever\n // with no RUN_PAYROLL_CALCULATED/RUN_PAYROLL_PROCESSING_FAILED event ever firing.\n hasSeenCalculatingRef.current = false\n throw error\n } finally {\n setIsCalculatingPayroll(false)\n }\n })\n\n if (!result.success && result.blockers.length > 0) {\n setPayrollBlockers(result.blockers)\n }\n })\n }\n\n const onEdit = (employee: Employee) => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT, {\n employeeId: employee.uuid,\n firstName: employee.firstName,\n lastName: employee.lastName,\n })\n }\n\n const transformEmployeeCompensation = (\n compensation: PayrollEmployeeCompensationsType,\n ): PayrollUpdateEmployeeCompensations => {\n const { paymentMethod } = compensation\n return {\n employeeUuid: compensation.employeeUuid,\n version: compensation.version,\n excluded: compensation.excluded,\n fixedCompensations: compensation.fixedCompensations,\n hourlyCompensations: compensation.hourlyCompensations,\n paidTimeOff: compensation.paidTimeOff,\n deductions: compensation.deductions,\n ...(paymentMethod && paymentMethod !== 'Historical' ? { paymentMethod } : {}),\n memo: compensation.memo || undefined,\n }\n }\n\n const onToggleExclude = async (employeeCompensation: PayrollEmployeeCompensationsType) => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SKIP, {\n employeeId: employeeCompensation.employeeUuid,\n })\n await baseSubmitHandler({}, async () => {\n const transformedCompensation = transformEmployeeCompensation(employeeCompensation)\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [\n { ...transformedCompensation, excluded: !transformedCompensation.excluded },\n ],\n },\n },\n })\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n })\n await refetch()\n })\n }\n\n const onViewBlockers = () => {\n onEvent(componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL)\n }\n\n // Pick up a calculation this screen didn't start (another tab, another admin). Starting a poll\n // from rendered data is fine — only the decision to *finish* one must not depend on a render,\n // and that lives in the poll loop.\n useEffect(() => {\n if (isPolling) return\n if (!isCalculatingStatus(payrollData.payrollShow?.processingRequest)) {\n // The status only leaves Calculating on a genuinely fresh read, so this is where a prior\n // terminal failure stops blocking future pickups.\n hasTerminalPollErrorRef.current = false\n return\n }\n // A read error we already reported for this same stale \"Calculating\" snapshot -- retrying it\n // immediately would just spin (fail, isPolling flips false, this effect fires again, repeat)\n // instead of waiting for a genuinely new read.\n if (hasTerminalPollErrorRef.current) return\n\n // A fresh calculating status means a real calculation is in flight again -- even right after\n // this screen's own deadline reported one as failed -- so any stale failure alert must not\n // linger over it and block the loading UI.\n setHasProcessingFailedAlert(false)\n setError(null)\n startCalculationPoll({\n baselineCalculatedAt: payrollData.payrollShow?.calculatedAt?.getTime() ?? null,\n // We have seen the calculating status, which is why we're starting to poll now until it completes or fails.\n sawCalculatingThisPoll: true,\n })\n }, [\n payrollData.payrollShow?.processingRequest,\n payrollData.payrollShow?.calculatedAt,\n isPolling,\n startCalculationPoll,\n setError,\n ])\n\n const payrollAlert = (() => {\n const statusMeta = payrollData.payrollShow?.payrollStatusMeta\n\n const isLatePayroll =\n statusMeta?.payrollLate &&\n statusMeta.initialCheckDate &&\n statusMeta.expectedDebitTime &&\n statusMeta.expectedCheckDate\n\n if (isLatePayroll) {\n return {\n label: t('alerts.payrollLate', {\n initialCheckDate: dateFormatter.formatShortWithWeekday(statusMeta.initialCheckDate),\n }),\n content: t('alerts.payrollLateText', {\n ...dateFormatter.formatWithTime(statusMeta.expectedDebitTime),\n newCheckDate: dateFormatter.formatShortWithWeekday(statusMeta.expectedCheckDate),\n }),\n variant: 'warning' as const,\n }\n }\n\n const { payrollShow } = payrollData\n\n if (payrollShow?.checkDate && payrollShow.payrollDeadline) {\n return {\n label: t('alerts.directDepositDeadline', {\n payDate: dateFormatter.formatShortWithWeekday(payrollShow.checkDate),\n ...dateFormatter.formatWithTime(payrollShow.payrollDeadline),\n }),\n content: t('alerts.directDepositDeadlineText'),\n variant: 'info' as const,\n }\n }\n\n return undefined\n })()\n\n if (isAlreadyProcessed) {\n const onAlreadyProcessedOverviewEvent = (type: EventType, data?: unknown) => {\n if (type === componentEvents.RUN_PAYROLL_CANCELLED) {\n // Cancelling un-processes the payroll, making it editable again — re-run prepare so\n // this component drops back into the configuration table for the same payrollId.\n void refetch()\n }\n onEvent(type, data)\n }\n\n return (\n <PayrollOverview\n className={className}\n companyId={companyId}\n payrollId={payrollId}\n onEvent={onAlreadyProcessedOverviewEvent}\n withReimbursements={withReimbursements}\n alerts={[alreadyProcessedAlert]}\n />\n )\n }\n\n return (\n <>\n <PayrollConfigurationPresentation\n className={className}\n onCalculatePayroll={onCalculatePayroll}\n isCalculateDisabled={blockersFromApi.length > 0}\n onEdit={onEdit}\n onToggleExclude={onToggleExclude}\n onViewBlockers={onViewBlockers}\n employeeCompensations={employeeCompensations}\n employeeDetails={employeeDetails}\n payPeriod={payPeriod}\n paySchedule={paySchedule}\n payrollCategory={payrollCategory}\n alerts={alerts}\n payrollAlert={payrollAlert}\n isPending={isCalculatingActive || isLoading || isUpdatingPayroll}\n isCalculating={isCalculatingActive}\n payrollBlockers={payrollBlockers}\n pagination={pagination}\n withReimbursements={withReimbursements}\n grossUpEnabled={grossUpEnabled}\n onGrossUpSelect={onGrossUpSelect}\n />\n {grossUpEnabled && (\n <GrossUpModal\n isOpen={isGrossUpModalOpen}\n onCalculateGrossUp={onCalculateGrossUp}\n onApply={handleGrossUpApply}\n onCancel={() => {\n setIsGrossUpModalOpen(false)\n }}\n />\n )}\n </>\n )\n}\n"],"names":["PayrollConfiguration","props","jsx","BaseComponent","Root","onEvent","companyId","payrollId","dictionary","alerts","withReimbursements","className","useComponentDictionary","useI18n","t","useTranslation","baseSubmitHandler","setError","useBase","dateFormatter","useDateFormatter","isCalculatingPayroll","setIsCalculatingPayroll","useState","hasSeenCalculatingRef","useRef","hasTerminalPollErrorRef","gustoClient","useGustoEmbeddedContext","payrollRequest","useMemo","payrollData","refetchPayroll","usePayrollsGetSuspense","excludedEmployeeUuids","comp","isCalculatingStatus","blockersData","usePayrollsGetBlockersSuspense","blockersFromApi","blocker","payrollBlockers","setPayrollBlockers","hasProcessingFailedAlert","setHasProcessingFailedAlert","emitProcessingFailed","componentEvents","onProcessingFailed","payroll","startCalculationPoll","isPolling","useCalculationPoll","isCalculatingActive","employeeDetails","employeeCompensations","paySchedule","payPeriod","payrollCategory","pagination","isLoading","isAlreadyProcessed","refetch","usePayrollConfigurationData","alreadyProcessedAlert","hasFiredAlreadyProcessedRef","useEffect","updatePayroll","isUpdatingPayroll","usePayrollsUpdateMutation","calculateGrossUpMutation","usePayrollsCalculateGrossUpMutation","grossUpEmployeeUuid","setGrossUpEmployeeUuid","isGrossUpModalOpen","setIsGrossUpModalOpen","grossUpEnabled","isGrossUpEligible","grossUpTargetCompensation","getGrossUpTargetCompensationName","onGrossUpSelect","employeeUuid","onCalculateGrossUp","netPay","grossUp","onGrossUpApply","grossAmount","SDKInternalError","employeeComp","ec","existingFixed","hasTargetCompensation","fc","updatedFixedCompensations","primaryJobUuid","updatedHourlyCompensations","hc","updatedPaidTimeOff","pto","transformedCompensation","transformEmployeeCompensation","result","handleGrossUpApply","onCalculatePayroll","payrollSubmitHandler","calcResult","payrollsCalculate","error","onEdit","employee","compensation","paymentMethod","onToggleExclude","employeeCompensation","onViewBlockers","payrollAlert","statusMeta","payrollShow","PayrollOverview","type","data","jsxs","Fragment","PayrollConfigurationPresentation","Gr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AA;AAAA,QACC,QAAQlD;AAAA,QACR,oBAAAQ;AAAA,QACA,SAASoB;AAAA,QACT,UAAU,MAAM;AACd,UAAA3B,EAAsB,EAAK;AAAA,QAC7B;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"PayrollConfiguration.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/PayrollConfiguration.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { payrollsCalculate } from '@gusto/embedded-api/funcs/payrollsCalculate'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport type { GetV1CompaniesCompanyIdPayrollsPayrollIdRequest } from '@gusto/embedded-api/models/operations/getv1companiescompanyidpayrollspayrollid'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useTranslation } from 'react-i18next'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport { usePayrollsCalculateGrossUpMutation } from '@gusto/embedded-api/react-query/payrollsCalculateGrossUp'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate'\nimport { usePayrollsGetBlockersSuspense } from '@gusto/embedded-api/react-query/payrollsGetBlockers'\nimport { payrollSubmitHandler, type ApiPayrollBlocker } from '../PayrollBlocker/payrollHelpers'\nimport { GrossUpModal } from '../GrossUpModal'\nimport { PayrollOverview } from '../PayrollOverview/PayrollOverview'\nimport type { PayrollFlowAlert } from '../PayrollFlow/PayrollFlowComponents'\nimport { PayrollConfigurationPresentation } from './PayrollConfigurationPresentation'\nimport { usePayrollConfigurationData } from './usePayrollConfigurationData'\nimport { getGrossUpTargetCompensationName, isGrossUpEligible } from './grossUpHelpers'\nimport { useCalculationPoll, isCalculatingStatus, type PayrollShow } from './useCalculationPoll'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useBase } from '@/components/Base'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport { SDKInternalError } from '@/types/sdkError'\n\n/**\n * Props for {@link PayrollConfiguration}.\n *\n * @public\n */\nexport interface PayrollConfigurationProps extends BaseComponentInterface<'Payroll.PayrollConfiguration'> {\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /** Optional alert components to render above the configuration content. */\n alerts?: ReactNode\n /** Whether to show the reimbursements column in the compensation table. Defaults to `true`. */\n withReimbursements?: boolean\n}\n\n/**\n * Handles the configuration phase of payroll processing, allowing users to review and modify employee compensation before calculating the payroll.\n *\n * @remarks\n * If the payroll turns out to already be processed (e.g. another actor submitted it while this\n * screen was open), this component emits `runPayroll/alreadyProcessed` and then renders\n * {@link PayrollOverview} in its place — the read-only breakdown with the gated \"Cancel payroll\"\n * action — instead of the configuration table. Events from that delegated view (e.g.\n * `runPayroll/cancelled`) are emitted through this component's own `onEvent`.\n *\n * Emits the following events:\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/employee/edit` | An employee row is selected for editing | `{ payrollId, employeeId, firstName, lastName }` |\n * | `runPayroll/employee/skip` | An employee is skipped or unskipped for this payroll | `{ employeeId }` |\n * | `runPayroll/employee/saved` | Employee compensation changes are persisted | `{ payrollPrepared }` |\n * | `runPayroll/calculated` | Payroll calculation completes successfully | `{ payrollId, alert, payPeriod }` |\n * | `runPayroll/alreadyProcessed` | The payroll turns out to already be processed while configuring it | `{ payrollId, alert, payPeriod }` |\n * | `runPayroll/processingFailed` | Payroll calculation fails or times out | — |\n * | `runPayroll/blockers/viewAll` | The \"view all blockers\" affordance is selected | — |\n * | `runPayroll/grossUp/selected` | The set-net-earnings menu item is selected for an employee | `{ employeeUuid }` |\n * | `runPayroll/grossUp/calculated` | A gross-up amount is calculated from a target net pay | `{ grossUp, netPay, employeeUuid }` |\n *\n * @param props - See {@link PayrollConfigurationProps}.\n * @returns The payroll configuration screen.\n * @public\n */\nexport function PayrollConfiguration(props: PayrollConfigurationProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({\n onEvent,\n companyId,\n payrollId,\n dictionary,\n alerts,\n withReimbursements = true,\n className,\n}: PayrollConfigurationProps) => {\n useComponentDictionary('Payroll.PayrollConfiguration', dictionary)\n useI18n('Payroll.PayrollConfiguration')\n const { t } = useTranslation('Payroll.PayrollConfiguration')\n const { baseSubmitHandler, setError } = useBase()\n const dateFormatter = useDateFormatter()\n\n const [isCalculatingPayroll, setIsCalculatingPayroll] = useState(false)\n // True once this screen has read a \"calculating\" status for the payroll, whether we started that\n // calc or someone else did. Calling prepare after that would wipe the result, so we use this to\n // keep prepare off.\n const hasSeenCalculatingRef = useRef(false)\n // Set when a poll ends in a non-retryable read error without confirming a calculated/failed\n // outcome. Guards the auto-pickup effect below from re-arming a poll against the same stale\n // \"Calculating\" read over and over -- it only clears once the status genuinely leaves Calculating.\n const hasTerminalPollErrorRef = useRef(false)\n const gustoClient = useGustoEmbeddedContext()\n\n const payrollRequest = useMemo<GetV1CompaniesCompanyIdPayrollsPayrollIdRequest>(\n () => ({\n companyId,\n payrollId,\n include: ['taxes', 'benefits', 'deductions', 'payroll_status_meta'],\n }),\n [companyId, payrollId],\n )\n\n const { data: payrollData, refetch: refetchPayroll } = usePayrollsGetSuspense(payrollRequest)\n\n const excludedEmployeeUuids = useMemo(\n () =>\n payrollData.payrollShow?.employeeCompensations\n ?.filter(comp => comp.excluded)\n .map(comp => comp.employeeUuid!)\n .filter(Boolean) ?? [],\n [payrollData.payrollShow?.employeeCompensations],\n )\n\n // Remember once we've seen it calculating.\n if (isCalculatingStatus(payrollData.payrollShow?.processingRequest)) {\n hasSeenCalculatingRef.current = true\n }\n\n const { data: blockersData } = usePayrollsGetBlockersSuspense({\n companyUuid: companyId,\n })\n\n const payrollBlockerList = blockersData.payrollBlockers ?? []\n\n const blockersFromApi: ApiPayrollBlocker[] = payrollBlockerList.map(blocker => ({\n key: blocker.key,\n message: blocker.message,\n }))\n\n const [payrollBlockers, setPayrollBlockers] = useState(blockersFromApi)\n // Drives the loader gate below. Deliberately separate from `error` -- `baseSubmitHandler`\n // clears `error` at the start of *any* submit (e.g. skipping an employee, applying a gross-up),\n // which would otherwise reopen this gate and get the loader stuck on with no poll running to\n // ever clear it (SDK-1276). Only the same sites that used to own the old boolean flag touch it.\n const [hasProcessingFailedAlert, setHasProcessingFailedAlert] = useState(false)\n\n const emitProcessingFailed = () => {\n onEvent(componentEvents.RUN_PAYROLL_PROCESSING_FAILED)\n setHasProcessingFailedAlert(true)\n setError({\n category: 'internal_error',\n message: `${t('alerts.processingFailed.label')}. ${t('alerts.processingFailed.message')}`,\n fieldErrors: [],\n })\n }\n\n const onProcessingFailed = (payroll: PayrollShow | undefined) => {\n emitProcessingFailed()\n // Let prepare run again on retry — but only when there is no calculation for it to wipe.\n if (payroll?.calculatedAt == null) {\n hasSeenCalculatingRef.current = false\n }\n }\n\n const { start: startCalculationPoll, isPolling } = useCalculationPoll({\n refetch: refetchPayroll,\n onCalculated: (payroll: PayrollShow | undefined) => {\n onEvent(componentEvents.RUN_PAYROLL_CALCULATED, {\n payrollId,\n alert: {\n type: 'success',\n title: t('alerts.progressSaved'),\n alertKey: 'progressSaved',\n },\n payPeriod: payroll?.payPeriod,\n })\n setPayrollBlockers([])\n },\n onProcessingFailed,\n // Unlike a real processing failure, we never confirmed whether the calculation actually\n // succeeded server-side, so this must not reset hasSeenCalculatingRef — doing so would\n // re-arm prepare and risk wiping a calculation that may have genuinely completed.\n onError: () => {\n hasTerminalPollErrorRef.current = true\n emitProcessingFailed()\n },\n })\n\n // Show the loading state the whole time we're calculating, so a second tab shows the loader\n // instead of a blank table until it moves to the overview. Once the failed/error alert is\n // showing, the poll has already reached a terminal state, so the loading UI must clear even\n // though hasSeenCalculatingRef stays true (it still guards prepare separately, below).\n const isCalculatingActive =\n !hasProcessingFailedAlert &&\n (isCalculatingPayroll || isPolling || hasSeenCalculatingRef.current)\n\n const {\n employeeDetails,\n employeeCompensations,\n paySchedule,\n payPeriod,\n payrollCategory,\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch,\n } = usePayrollConfigurationData({\n companyId,\n payrollId,\n // Don't prepare while calculating, or once we've seen it calculate. If the payroll was already\n // calculated when we opened (e.g. clicking Edit), we do prepare so it can be edited.\n disablePrepare: isPolling || isCalculatingPayroll || hasSeenCalculatingRef.current,\n excludedEmployeeUuids,\n })\n\n const alreadyProcessedAlert: PayrollFlowAlert = useMemo(\n () => ({\n type: 'error',\n title: t('alerts.alreadyProcessed'),\n alertKey: 'alreadyProcessed',\n }),\n [t],\n )\n\n const hasFiredAlreadyProcessedRef = useRef(false)\n\n useEffect(() => {\n if (!isAlreadyProcessed) {\n hasFiredAlreadyProcessedRef.current = false\n return\n }\n if (hasFiredAlreadyProcessedRef.current) return\n hasFiredAlreadyProcessedRef.current = true\n onEvent(componentEvents.RUN_PAYROLL_ALREADY_PROCESSED, {\n payrollId,\n alert: alreadyProcessedAlert,\n payPeriod: payrollData.payrollShow?.payPeriod,\n })\n }, [\n isAlreadyProcessed,\n onEvent,\n payrollId,\n alreadyProcessedAlert,\n payrollData.payrollShow?.payPeriod,\n ])\n\n const { mutateAsync: updatePayroll, isPending: isUpdatingPayroll } = usePayrollsUpdateMutation()\n\n const { mutateAsync: calculateGrossUpMutation } = usePayrollsCalculateGrossUpMutation()\n\n const [grossUpEmployeeUuid, setGrossUpEmployeeUuid] = useState<string | null>(null)\n const [isGrossUpModalOpen, setIsGrossUpModalOpen] = useState(false)\n\n const grossUpEnabled = isGrossUpEligible(payrollCategory)\n const grossUpTargetCompensation = getGrossUpTargetCompensationName(payrollCategory)\n\n const onGrossUpSelect = (employeeUuid: string) => {\n setGrossUpEmployeeUuid(employeeUuid)\n setIsGrossUpModalOpen(true)\n onEvent(componentEvents.RUN_PAYROLL_GROSS_UP_SELECTED, { employeeUuid })\n }\n\n const onCalculateGrossUp = async (netPay: number): Promise<string | null> => {\n if (!grossUpEmployeeUuid) return null\n let grossUp: string | null = null\n\n await baseSubmitHandler(null, async () => {\n const result = await calculateGrossUpMutation({\n request: {\n payrollUuid: payrollId,\n payrollGrossUpRequest: {\n employeeUuid: grossUpEmployeeUuid,\n netPay: netPay.toString(),\n },\n },\n })\n\n grossUp = result.payrollGrossUpResponse?.grossUp ?? null\n\n if (grossUp) {\n onEvent(componentEvents.RUN_PAYROLL_GROSS_UP_CALCULATED, {\n grossUp,\n netPay,\n employeeUuid: grossUpEmployeeUuid,\n })\n }\n })\n\n return grossUp\n }\n\n const onGrossUpApply = async (grossAmount: string) => {\n if (!grossUpEmployeeUuid || !grossUpTargetCompensation) {\n throw new SDKInternalError(\n 'Unable to apply gross-up: missing employee or target compensation.',\n )\n }\n\n const employeeComp = employeeCompensations.find(ec => ec.employeeUuid === grossUpEmployeeUuid)\n if (!employeeComp) {\n throw new SDKInternalError('Unable to apply gross-up: employee compensation not found.')\n }\n\n const existingFixed = employeeComp.fixedCompensations ?? []\n const hasTargetCompensation = existingFixed.some(\n fc => fc.name?.toLowerCase() === grossUpTargetCompensation.toLowerCase(),\n )\n\n const updatedFixedCompensations = existingFixed.map(fc => ({\n name: fc.name,\n jobUuid: fc.jobUuid,\n amount:\n fc.name?.toLowerCase() === grossUpTargetCompensation.toLowerCase() ? grossAmount : '0',\n }))\n\n if (!hasTargetCompensation) {\n const primaryJobUuid =\n employeeComp.hourlyCompensations?.[0]?.jobUuid ?? existingFixed[0]?.jobUuid ?? ''\n updatedFixedCompensations.push({\n name: grossUpTargetCompensation,\n jobUuid: primaryJobUuid,\n amount: grossAmount,\n })\n }\n\n const updatedHourlyCompensations = (employeeComp.hourlyCompensations ?? []).map(hc => ({\n name: hc.name,\n jobUuid: hc.jobUuid,\n hours: '0',\n }))\n\n const updatedPaidTimeOff = (employeeComp.paidTimeOff ?? []).map(pto => ({\n name: pto.name,\n hours: '0',\n }))\n\n const transformedCompensation = transformEmployeeCompensation({\n ...employeeComp,\n fixedCompensations: updatedFixedCompensations,\n hourlyCompensations: updatedHourlyCompensations,\n paidTimeOff: updatedPaidTimeOff,\n })\n\n await baseSubmitHandler({}, async () => {\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [{ ...transformedCompensation, excluded: false }],\n },\n },\n })\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n })\n await refetch()\n })\n\n setGrossUpEmployeeUuid(null)\n setIsGrossUpModalOpen(false)\n }\n\n const handleGrossUpApply = async (grossAmount: string) => {\n try {\n await onGrossUpApply(grossAmount)\n } catch {\n // Modal stays open; error is surfaced by baseSubmitHandler\n }\n }\n\n const onCalculatePayroll = async () => {\n setPayrollBlockers([])\n setHasProcessingFailedAlert(false)\n setError(null)\n // Mark it right away so prepare can't run and cancel the calculation we just started.\n hasSeenCalculatingRef.current = true\n\n await baseSubmitHandler({}, async () => {\n const result = await payrollSubmitHandler(async () => {\n setIsCalculatingPayroll(true)\n try {\n const calcResult = await payrollsCalculate(gustoClient, {\n companyId,\n payrollId,\n })\n if (!calcResult.ok) {\n throw calcResult.error\n }\n startCalculationPoll({\n baselineCalculatedAt: payrollData.payrollShow?.calculatedAt?.getTime() ?? null,\n // We just submitted the payroll, so we haven't yet seen it return with the calculating status\n sawCalculatingThisPoll: false,\n })\n } catch (error) {\n // Calculate itself failed before polling ever started (e.g. a 409 conflict), so let\n // prepare run again on retry -- otherwise hasSeenCalculatingRef stays stuck true forever\n // with no RUN_PAYROLL_CALCULATED/RUN_PAYROLL_PROCESSING_FAILED event ever firing.\n hasSeenCalculatingRef.current = false\n throw error\n } finally {\n setIsCalculatingPayroll(false)\n }\n })\n\n if (!result.success && result.blockers.length > 0) {\n setPayrollBlockers(result.blockers)\n }\n })\n }\n\n const onEdit = (employee: Employee) => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_EDIT, {\n payrollId,\n employeeId: employee.uuid,\n firstName: employee.firstName,\n lastName: employee.lastName,\n })\n }\n\n const transformEmployeeCompensation = (\n compensation: PayrollEmployeeCompensationsType,\n ): PayrollUpdateEmployeeCompensations => {\n const { paymentMethod } = compensation\n return {\n employeeUuid: compensation.employeeUuid,\n version: compensation.version,\n excluded: compensation.excluded,\n fixedCompensations: compensation.fixedCompensations,\n hourlyCompensations: compensation.hourlyCompensations,\n paidTimeOff: compensation.paidTimeOff,\n deductions: compensation.deductions,\n ...(paymentMethod && paymentMethod !== 'Historical' ? { paymentMethod } : {}),\n memo: compensation.memo || undefined,\n }\n }\n\n const onToggleExclude = async (employeeCompensation: PayrollEmployeeCompensationsType) => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SKIP, {\n employeeId: employeeCompensation.employeeUuid,\n })\n await baseSubmitHandler({}, async () => {\n const transformedCompensation = transformEmployeeCompensation(employeeCompensation)\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [\n { ...transformedCompensation, excluded: !transformedCompensation.excluded },\n ],\n },\n },\n })\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n })\n await refetch()\n })\n }\n\n const onViewBlockers = () => {\n onEvent(componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL)\n }\n\n // Pick up a calculation this screen didn't start (another tab, another admin). Starting a poll\n // from rendered data is fine — only the decision to *finish* one must not depend on a render,\n // and that lives in the poll loop.\n useEffect(() => {\n if (isPolling) return\n if (!isCalculatingStatus(payrollData.payrollShow?.processingRequest)) {\n // The status only leaves Calculating on a genuinely fresh read, so this is where a prior\n // terminal failure stops blocking future pickups.\n hasTerminalPollErrorRef.current = false\n return\n }\n // A read error we already reported for this same stale \"Calculating\" snapshot -- retrying it\n // immediately would just spin (fail, isPolling flips false, this effect fires again, repeat)\n // instead of waiting for a genuinely new read.\n if (hasTerminalPollErrorRef.current) return\n\n // A fresh calculating status means a real calculation is in flight again -- even right after\n // this screen's own deadline reported one as failed -- so any stale failure alert must not\n // linger over it and block the loading UI.\n setHasProcessingFailedAlert(false)\n setError(null)\n startCalculationPoll({\n baselineCalculatedAt: payrollData.payrollShow?.calculatedAt?.getTime() ?? null,\n // We have seen the calculating status, which is why we're starting to poll now until it completes or fails.\n sawCalculatingThisPoll: true,\n })\n }, [\n payrollData.payrollShow?.processingRequest,\n payrollData.payrollShow?.calculatedAt,\n isPolling,\n startCalculationPoll,\n setError,\n ])\n\n const payrollAlert = (() => {\n const statusMeta = payrollData.payrollShow?.payrollStatusMeta\n\n const isLatePayroll =\n statusMeta?.payrollLate &&\n statusMeta.initialCheckDate &&\n statusMeta.expectedDebitTime &&\n statusMeta.expectedCheckDate\n\n if (isLatePayroll) {\n return {\n label: t('alerts.payrollLate', {\n initialCheckDate: dateFormatter.formatShortWithWeekday(statusMeta.initialCheckDate),\n }),\n content: t('alerts.payrollLateText', {\n ...dateFormatter.formatWithTime(statusMeta.expectedDebitTime),\n newCheckDate: dateFormatter.formatShortWithWeekday(statusMeta.expectedCheckDate),\n }),\n variant: 'warning' as const,\n }\n }\n\n const { payrollShow } = payrollData\n\n if (payrollShow?.checkDate && payrollShow.payrollDeadline) {\n return {\n label: t('alerts.directDepositDeadline', {\n payDate: dateFormatter.formatShortWithWeekday(payrollShow.checkDate),\n ...dateFormatter.formatWithTime(payrollShow.payrollDeadline),\n }),\n content: t('alerts.directDepositDeadlineText'),\n variant: 'info' as const,\n }\n }\n\n return undefined\n })()\n\n if (isAlreadyProcessed) {\n const onAlreadyProcessedOverviewEvent = (type: EventType, data?: unknown) => {\n if (type === componentEvents.RUN_PAYROLL_CANCELLED) {\n // Cancelling un-processes the payroll, making it editable again — re-run prepare so\n // this component drops back into the configuration table for the same payrollId.\n void refetch()\n }\n onEvent(type, data)\n }\n\n return (\n <PayrollOverview\n className={className}\n companyId={companyId}\n payrollId={payrollId}\n onEvent={onAlreadyProcessedOverviewEvent}\n withReimbursements={withReimbursements}\n alerts={[alreadyProcessedAlert]}\n />\n )\n }\n\n return (\n <>\n <PayrollConfigurationPresentation\n className={className}\n onCalculatePayroll={onCalculatePayroll}\n isCalculateDisabled={blockersFromApi.length > 0}\n onEdit={onEdit}\n onToggleExclude={onToggleExclude}\n onViewBlockers={onViewBlockers}\n employeeCompensations={employeeCompensations}\n employeeDetails={employeeDetails}\n payPeriod={payPeriod}\n paySchedule={paySchedule}\n payrollCategory={payrollCategory}\n alerts={alerts}\n payrollAlert={payrollAlert}\n isPending={isCalculatingActive || isLoading || isUpdatingPayroll}\n isCalculating={isCalculatingActive}\n payrollBlockers={payrollBlockers}\n pagination={pagination}\n withReimbursements={withReimbursements}\n grossUpEnabled={grossUpEnabled}\n onGrossUpSelect={onGrossUpSelect}\n />\n {grossUpEnabled && (\n <GrossUpModal\n isOpen={isGrossUpModalOpen}\n onCalculateGrossUp={onCalculateGrossUp}\n onApply={handleGrossUpApply}\n onCancel={() => {\n setIsGrossUpModalOpen(false)\n }}\n />\n )}\n </>\n )\n}\n"],"names":["PayrollConfiguration","props","jsx","BaseComponent","Root","onEvent","companyId","payrollId","dictionary","alerts","withReimbursements","className","useComponentDictionary","useI18n","t","useTranslation","baseSubmitHandler","setError","useBase","dateFormatter","useDateFormatter","isCalculatingPayroll","setIsCalculatingPayroll","useState","hasSeenCalculatingRef","useRef","hasTerminalPollErrorRef","gustoClient","useGustoEmbeddedContext","payrollRequest","useMemo","payrollData","refetchPayroll","usePayrollsGetSuspense","excludedEmployeeUuids","comp","isCalculatingStatus","blockersData","usePayrollsGetBlockersSuspense","blockersFromApi","blocker","payrollBlockers","setPayrollBlockers","hasProcessingFailedAlert","setHasProcessingFailedAlert","emitProcessingFailed","componentEvents","onProcessingFailed","payroll","startCalculationPoll","isPolling","useCalculationPoll","isCalculatingActive","employeeDetails","employeeCompensations","paySchedule","payPeriod","payrollCategory","pagination","isLoading","isAlreadyProcessed","refetch","usePayrollConfigurationData","alreadyProcessedAlert","hasFiredAlreadyProcessedRef","useEffect","updatePayroll","isUpdatingPayroll","usePayrollsUpdateMutation","calculateGrossUpMutation","usePayrollsCalculateGrossUpMutation","grossUpEmployeeUuid","setGrossUpEmployeeUuid","isGrossUpModalOpen","setIsGrossUpModalOpen","grossUpEnabled","isGrossUpEligible","grossUpTargetCompensation","getGrossUpTargetCompensationName","onGrossUpSelect","employeeUuid","onCalculateGrossUp","netPay","grossUp","onGrossUpApply","grossAmount","SDKInternalError","employeeComp","ec","existingFixed","hasTargetCompensation","fc","updatedFixedCompensations","primaryJobUuid","updatedHourlyCompensations","hc","updatedPaidTimeOff","pto","transformedCompensation","transformEmployeeCompensation","result","handleGrossUpApply","onCalculatePayroll","payrollSubmitHandler","calcResult","payrollsCalculate","error","onEdit","employee","compensation","paymentMethod","onToggleExclude","employeeCompensation","onViewBlockers","payrollAlert","statusMeta","payrollShow","PayrollOverview","type","data","jsxs","Fragment","PayrollConfigurationPresentation","GrossUpModal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyEO,SAASA,GAAqBC,GAAkC;AACrE,SACE,gBAAAC,EAACC,IAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,MAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,KAAO,CAAC;AAAA,EACZ,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,WAAAC;AACF,MAAiC;AAC/B,EAAAC,GAAuB,gCAAgCJ,CAAU,GACjEK,GAAQ,8BAA8B;AACtC,QAAM,EAAE,GAAAC,EAAA,IAAMC,GAAe,8BAA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iBC,MAAmB;AAC3E,QAAID,MAASxE,EAAgB,yBAGtBe,EAAA,GAEPxD,EAAQiH,GAAMC,CAAI;AAAA,MACpB;AAAA,MAQI,oBAAA7G;AAAA,MACA,QAAQ,CAACqD,CAAqB;AAAA,IAAA;AAAA,EAAA,IAMlC,gBAAAyD,GAAAC,IAAA,EACE,UAAA;AAAA,IAAA,gBAAAvH;AAAA,MAACwH;AAAA,MAAA;AAAA,QACC,WAAA/G;AAAA,QACA,oBAAA2F;AAAA,QACA,qBAAqB/D,EAAgB,SAAS;AAAA,QAC9C,QAAAoE;AAAA,QACA,iBAAAI;AAAA,QACA,gBAAAE;AAAA,QACA,uBAAA3D;AAAA,QACA,iBAAAD;AAAA,QACA,WAAAG;AAAA,QACA,aAAAD;AAAA,QACA,iBAAAE;AAAA,QACA,QAAAhD;AAAA,QACA,cAAAyG;AAAA,QACA,WAAW9D,KAAuBO,MAAaQ;AAAA,QAC/C,eAAef;AAAA,QACf,iBAAAX;AAAA,QACA,YAAAiB;AAAA,QACA,oBAAAhD;AAAA,QACA,gBAAAiE;AAAA,QACA,iBAAAI;AAAA,MAAA;AAAA,IAAA;AAAA,IAEDJ,KACC,gBAAAzE;AAAA,MAACyH;AAAA,MAAA;AAAA,QACC,QAAQlD;AAAA,QACR,oBAAAQ;AAAA,QACA,SAASoB;AAAA,QACT,UAAU,MAAM;AACd,UAAA3B,EAAsB,EAAK;AAAA,QAC7B;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GAEJ;AAEJ;"}
@@ -17,8 +17,8 @@ import { Form as Le } from "../../Common/Form/Form.js";
17
17
  import { formatNumberAsCurrency as ie, firstLastName as ke } from "../../../helpers/formattedStrings.js";
18
18
  import { getAdditionalEarningsCompensations as Ue, calculateGrossPay as re } from "../helpers.js";
19
19
  import { PayrollCategory as F, isOffCyclePayroll as me } from "../payrollTypes.js";
20
- import { COMPENSATION_NAME_REIMBURSEMENT as S, HOURS_COMPENSATION_NAMES as se, EXCLUDED_ADDITIONAL_EARNINGS as je, COMPENSATION_NAME_DOUBLE_OVERTIME as Ge, COMPENSATION_NAME_OVERTIME as He, COMPENSATION_NAME_REGULAR_HOURS as we, COMPENSATION_NAME_CASH_TIPS as $e, COMPENSATION_NAME_COMMISSION as Ve, COMPENSATION_NAME_CORRECTION_PAYMENT as Be, COMPENSATION_NAME_PAYCHECK_TIPS as qe, COMPENSATION_NAME_BONUS as ze } from "../../../shared/constants.js";
21
- import We from "../../../hooks/useContainerBreakpoints/useContainerBreakpoints.js";
20
+ import { COMPENSATION_NAME_REIMBURSEMENT as S, HOURS_COMPENSATION_NAMES as se, EXCLUDED_ADDITIONAL_EARNINGS as je, COMPENSATION_NAME_DOUBLE_OVERTIME as Ge, COMPENSATION_NAME_OVERTIME as He, COMPENSATION_NAME_REGULAR_HOURS as we, COMPENSATION_NAME_CASH_TIPS as $e, COMPENSATION_NAME_COMMISSION as Ve, COMPENSATION_NAME_CORRECTION_PAYMENT as Be, COMPENSATION_NAME_PAYCHECK_TIPS as ze, COMPENSATION_NAME_BONUS as We } from "../../../shared/constants.js";
21
+ import qe from "../../../hooks/useContainerBreakpoints/useContainerBreakpoints.js";
22
22
  import oe from "../../../assets/icons/plus-circle.svg.js";
23
23
  import Ye from "../../../assets/icons/trashcan.svg.js";
24
24
  import { TextInputField as I } from "../../Common/Fields/TextInputField/TextInputField.js";
@@ -114,7 +114,7 @@ const Ze = s.object({
114
114
  _e("Payroll.PayrollEditEmployee");
115
115
  const b = p.jobs?.find((e) => e.primary), ue = o?.hourlyCompensations?.some(
116
116
  (e) => e.jobUuid === b?.uuid
117
- ), v = b && ue ? [b] : [], B = Oe(null), g = We({
117
+ ), v = b && ue ? [b] : [], B = Oe(null), g = qe({
118
118
  ref: B
119
119
  }).includes("small");
120
120
  o?.hourlyCompensations?.forEach((e) => {
@@ -135,7 +135,7 @@ const Ze = s.object({
135
135
  (e) => e.name?.toLowerCase() === S.toLowerCase()
136
136
  ),
137
137
  [o?.fixedCompensations]
138
- ), q = O && !_ && !!b?.uuid, z = (e, i) => o?.hourlyCompensations?.find(
138
+ ), z = O && !_ && !!b?.uuid, W = (e, i) => o?.hourlyCompensations?.find(
139
139
  (d) => d.jobUuid === e && d.name?.toLowerCase() === i.toLowerCase()
140
140
  ), ce = (e) => {
141
141
  switch (e) {
@@ -148,11 +148,11 @@ const Ze = s.object({
148
148
  default:
149
149
  return e;
150
150
  }
151
- }, W = (e) => {
151
+ }, q = (e) => {
152
152
  switch (e) {
153
- case ze:
153
+ case We:
154
154
  return n("fixedCompensationNames.bonus");
155
- case qe:
155
+ case ze:
156
156
  return n("fixedCompensationNames.paycheckTips");
157
157
  case Be:
158
158
  return n("fixedCompensationNames.correctionPayment");
@@ -173,7 +173,7 @@ const Ze = s.object({
173
173
  const e = {};
174
174
  return v.forEach((i) => {
175
175
  se.forEach((d) => {
176
- const R = z(i.uuid, d);
176
+ const R = W(i.uuid, d);
177
177
  R && (e[i.uuid] || (e[i.uuid] = {}), e[i.uuid][R.name] = R.hours ? parseFloat(R.hours).toString() : "");
178
178
  });
179
179
  }), e;
@@ -194,7 +194,7 @@ const Ze = s.object({
194
194
  const e = {};
195
195
  return j.forEach((i) => {
196
196
  e[i.name] = i.amount ?? "";
197
- }), q && (e[S] = de?.amount ?? "0.00"), e;
197
+ }), z && (e[S] = de?.amount ?? "0.00"), e;
198
198
  })(),
199
199
  reimbursements: le.map((e) => ({
200
200
  uuid: e.uuid ?? null,
@@ -384,7 +384,7 @@ const Ze = s.object({
384
384
  v.map((e) => /* @__PURE__ */ a(P, { flexDirection: "column", gap: 8, children: [
385
385
  v.length > 1 && /* @__PURE__ */ t(f, { as: "h4", children: e.title }),
386
386
  /* @__PURE__ */ t(x, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: se.map((i) => {
387
- const d = z(
387
+ const d = W(
388
388
  e.uuid,
389
389
  i
390
390
  );
@@ -395,7 +395,6 @@ const Ze = s.object({
395
395
  type: "number",
396
396
  min: 0,
397
397
  adornmentEnd: n("hoursUnit"),
398
- isRequired: !0,
399
398
  label: ce(i),
400
399
  name: `hourlyCompensations.${e.uuid}.${d.name}`
401
400
  },
@@ -442,8 +441,7 @@ const Ze = s.object({
442
441
  type: "number",
443
442
  min: 0,
444
443
  adornmentStart: "$",
445
- isRequired: !0,
446
- label: W(e.name),
444
+ label: q(e.name),
447
445
  name: `fixedCompensations.${e.name}`,
448
446
  errorMessage: n("validations.negativeAmount")
449
447
  },
@@ -452,7 +450,7 @@ const Ze = s.object({
452
450
  }
453
451
  )
454
452
  ] }),
455
- q && /* @__PURE__ */ a("div", { className: c.fieldGroup, children: [
453
+ z && /* @__PURE__ */ a("div", { className: c.fieldGroup, children: [
456
454
  /* @__PURE__ */ t(f, { as: "h3", styledAs: "h4", children: n("reimbursementTitle") }),
457
455
  /* @__PURE__ */ t(x, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: /* @__PURE__ */ t(
458
456
  I,
@@ -460,8 +458,7 @@ const Ze = s.object({
460
458
  type: "number",
461
459
  min: 0,
462
460
  adornmentStart: "$",
463
- isRequired: !0,
464
- label: W(S),
461
+ label: q(S),
465
462
  name: `fixedCompensations.${S}`,
466
463
  errorMessage: n("validations.negativeAmount")
467
464
  }