@gusto/embedded-react-sdk 0.56.2 → 0.56.4

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 (154) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/Common/FieldCaption/FieldCaption.js +19 -22
  3. package/dist/components/Common/FieldCaption/FieldCaption.js.map +1 -1
  4. package/dist/components/Common/FieldCaption/FieldCaption.module.scss.js +6 -6
  5. package/dist/components/Common/PaginationControl/PaginationControl.js +66 -62
  6. package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
  7. package/dist/components/Common/UI/Breadcrumbs/Breadcrumbs.js +1 -1
  8. package/dist/components/Common/UI/FileInput/FileInput.js +1 -1
  9. package/dist/components/Common/UI/ProgressBar/ProgressBar.js +4 -4
  10. package/dist/components/Company/PaySchedule/management/PaySchedule.js +60 -0
  11. package/dist/components/Company/PaySchedule/management/PaySchedule.js.map +1 -0
  12. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.js +67 -0
  13. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.js.map +1 -0
  14. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +59 -0
  15. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -0
  16. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +57 -0
  17. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -0
  18. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +46 -0
  19. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -0
  20. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +101 -0
  21. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -0
  22. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +81 -0
  23. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -0
  24. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.js +18 -0
  25. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.js.map +1 -0
  26. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js +56 -0
  27. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -0
  28. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +34 -0
  29. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -0
  30. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js +77 -0
  31. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -0
  32. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.module.scss.js +10 -0
  33. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.module.scss.js.map +1 -0
  34. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js +66 -0
  35. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -0
  36. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +75 -57
  37. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  38. package/dist/components/Company/StateTaxes/shared/requirementSetError.js +15 -0
  39. package/dist/components/Company/StateTaxes/shared/requirementSetError.js.map +1 -0
  40. package/dist/components/Company/exports/companyManagement.js +7 -0
  41. package/dist/components/Company/exports/companyManagement.js.map +1 -0
  42. package/dist/components/Employee/FederalTaxes/shared/FederalTaxesView.js +1 -1
  43. package/dist/components/Employee/PaymentMethod/management/PaymentMethodBankForm.js +4 -4
  44. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +4 -4
  45. package/dist/components/Flow/Flow.js +1 -1
  46. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +28 -28
  47. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  48. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +51 -58
  49. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
  50. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js +12 -7
  51. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js.map +1 -1
  52. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +87 -85
  53. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  54. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +1 -1
  55. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  56. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +55 -54
  57. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
  58. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +66 -62
  59. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
  60. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +129 -125
  61. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  62. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +30 -27
  63. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
  64. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js +41 -30
  65. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js.map +1 -1
  66. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.js.map +1 -1
  67. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +159 -152
  68. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
  69. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +61 -59
  70. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
  71. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +32 -31
  72. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
  73. package/dist/components/Payroll/PayrollList/PayrollList.js +16 -16
  74. package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
  75. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
  76. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +61 -61
  77. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
  78. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +192 -193
  79. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  80. package/dist/components/Payroll/Transition/TransitionFlow.js +27 -22
  81. package/dist/components/Payroll/Transition/TransitionFlow.js.map +1 -1
  82. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js +55 -53
  83. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js.map +1 -1
  84. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +44 -41
  85. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
  86. package/dist/components/Payroll/helpers.js +72 -67
  87. package/dist/components/Payroll/helpers.js.map +1 -1
  88. package/dist/components/Payroll/usePreparedPayrollData.js +34 -25
  89. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  90. package/dist/contexts/ApiProvider/ApiProvider.js +23 -22
  91. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  92. package/dist/contexts/ApiProvider/informationRequestEnumHook.js +30 -0
  93. package/dist/contexts/ApiProvider/informationRequestEnumHook.js.map +1 -0
  94. package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js.map +1 -1
  95. package/dist/helpers/dateFormatting.js.map +1 -1
  96. package/dist/helpers/formattedStrings.js +9 -8
  97. package/dist/helpers/formattedStrings.js.map +1 -1
  98. package/dist/i18n/I18n.js +2 -0
  99. package/dist/i18n/I18n.js.map +1 -1
  100. package/dist/i18n/en/Company.Management.PaySchedule.json.js +24 -0
  101. package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -0
  102. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +18 -0
  103. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -0
  104. package/dist/i18n/en/Company.StateTaxes.json.js +1 -1
  105. package/dist/i18n/en/Payroll.GrossUpModal.json.js +12 -14
  106. package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -1
  107. package/dist/i18n/en/Payroll.PayrollOverview.json.js +1 -1
  108. package/dist/i18n/en/common.json.js +36 -38
  109. package/dist/i18n/en/common.json.js.map +1 -1
  110. package/dist/index.js +137 -135
  111. package/dist/index.js.map +1 -1
  112. package/dist/package.json.js +1 -1
  113. package/dist/shared/constants.js +39 -31
  114. package/dist/shared/constants.js.map +1 -1
  115. package/dist/src/components/Company/PaySchedule/management/PaySchedule.d.ts +24 -0
  116. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentReviewStepPresentation.d.ts +10 -0
  117. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +11 -0
  118. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +9 -0
  119. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +35 -0
  120. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +29 -0
  121. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/index.d.ts +1 -0
  122. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.d.ts +7 -0
  123. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/stripNullAssignmentPreviewFields.d.ts +12 -0
  124. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +9 -0
  125. package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +20 -0
  126. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverview.d.ts +11 -0
  127. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +18 -0
  128. package/dist/src/components/Company/PaySchedule/management/index.d.ts +1 -0
  129. package/dist/src/components/Company/PaySchedule/management/payScheduleManagementStateMachine.d.ts +12 -0
  130. package/dist/src/components/Company/StateTaxes/shared/requirementSetError.d.ts +18 -0
  131. package/dist/src/components/Company/StateTaxes/shared/requirementSetError.test.d.ts +1 -0
  132. package/dist/src/components/Company/exports/companyManagement.d.ts +2 -0
  133. package/dist/src/components/Payroll/PayrollBlocker/payrollHelpers.d.ts +12 -0
  134. package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +6 -1
  135. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.d.ts +2 -2
  136. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.d.ts +6 -1
  137. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.d.ts +7 -1
  138. package/dist/src/components/Payroll/helpers.d.ts +34 -0
  139. package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +6 -1
  140. package/dist/src/components/index.d.ts +12 -0
  141. package/dist/src/contexts/ApiProvider/informationRequestEnumHook.d.ts +14 -0
  142. package/dist/src/contexts/ApiProvider/informationRequestEnumHook.test.d.ts +1 -0
  143. package/dist/src/contexts/UnstableFeaturesProvider/useUnstableFeature.d.ts +2 -0
  144. package/dist/src/helpers/dateFormatting.d.ts +2 -2
  145. package/dist/src/helpers/formattedStrings.d.ts +15 -0
  146. package/dist/src/i18n/en/common.json.d.ts +0 -1
  147. package/dist/src/i18n/types.d.ts +96 -6
  148. package/dist/src/models/external.d.ts +12 -0
  149. package/dist/src/shared/constants.d.ts +16 -0
  150. package/dist/style.css +1 -1
  151. package/dist/types/sdkError.js +32 -21
  152. package/dist/types/sdkError.js.map +1 -1
  153. package/docs/guides/endpoint-inventory.json +59 -10
  154. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdatePaymentMethod } from '@gusto/embedded-api/models/components/payrollupdate'\nimport type { NormalizedWorkweek } from './payrollEditEmployeeHelpers'\nimport type { PayrollEditEmployeeErrorCode } from './payrollEditEmployeeSchema'\nimport { TextInputField } from '@/components/Common/Fields/TextInputField/TextInputField'\nimport { useFieldErrorMessage } from '@/partner-hook-utils/form/useFieldErrorMessage'\nimport { RadioGroupHookField } from '@/partner-hook-utils/form/fields'\nimport type { RadioGroupHookFieldProps } from '@/partner-hook-utils/form/fields/RadioGroupHookField'\nimport type { HookFieldProps, ValidationMessages } from '@/partner-hook-utils/types'\nimport type { TextInputProps } from '@/components/Common/UI/TextInput/TextInputTypes'\nimport { PayrollCategory } from '@/components/Payroll/payrollTypes'\nimport { COMPENSATION_NAME_DOUBLE_OVERTIME, COMPENSATION_NAME_OVERTIME } from '@/shared/constants'\n\n/**\n * Display copy for each validation error code a bound field can surface, so the\n * consumer supplies error text once (keyed by code) rather than reconstructing\n * form paths or hardcoding which rule each field can fail. Partial: a missing\n * code falls back to the raw error code.\n *\n * @public\n */\nexport type PayrollEditEmployeeErrorMessages = Partial<Record<PayrollEditEmployeeErrorCode, string>>\n\n/**\n * Presentation props accepted by a bound numeric field in the payroll editor.\n *\n * @remarks\n * The hook binds the react-hook-form `name`, forces `type=\"number\"`, and\n * resolves the field's own validation message internally; the UI supplies copy\n * and layout props (label, adornments, `shouldVisuallyHideLabel`, required\n * state, `description`).\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type' | 'min' | 'errorMessage'\n>\n\n/**\n * A numeric field component pre-bound by the hook to a specific form path.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldComponent = ComponentType<PayrollEditEmployeeFieldProps>\n\n/**\n * Presentation props accepted by the bound payment-method field.\n *\n * @remarks\n * The hook binds the `name` and publishes the option values on\n * `fieldsMetadata.paymentMethod`; the UI passes `getOptionLabel` to translate\n * each {@link PayrollUpdatePaymentMethod} value, rather than passing `options`.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodFieldProps = HookFieldProps<\n RadioGroupHookFieldProps<never, PayrollUpdatePaymentMethod>\n>\n\n/**\n * The payment-method radio field component pre-bound by the hook.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodField =\n ComponentType<PayrollEditEmployeePaymentMethodFieldProps>\n\n/**\n * One hours input within the hours section.\n *\n * @remarks\n * `key` is an opaque, stable React key. `jobUuid`, `name`, and (when the pay\n * period is multi-workweek) `workweekStart` are reach-in handles the UI uses to\n * group and label entries. When the section is a flat array, `workweekStart` is\n * omitted (single-workweek degenerate case); when it is a `Record` keyed by\n * workweek start, each entry carries its `workweekStart`.\n *\n * @public\n */\nexport interface HourEntry {\n /** Opaque, stable React key. */\n key: string\n /** The job this hours line belongs to. */\n jobUuid: string\n /** The compensation name (e.g. the API hours-compensation name). */\n name: string\n /** The workweek start date (`YYYY-MM-DD`) when the section is workweek-keyed. */\n workweekStart?: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * One earning input, used by the additional-earnings section.\n *\n * @remarks\n * Same shape as {@link HourEntry}. Whether an earning feeds the overtime\n * (regular rate of pay) calculation is decided by the hook, which sorts it into\n * the workweek-breakdown additional-earnings section or the flat other\n * section. The UI just renders whichever section an entry appears in.\n *\n * @public\n */\nexport type EarningEntry = HourEntry\n\n/**\n * One time-off or final-payout input.\n *\n * @remarks\n * Time off is never workweek-breakdown, so this section is always a flat array.\n *\n * @public\n */\nexport interface TimeOffEntry {\n /** Opaque, stable React key. */\n key: string\n /** The time-off policy compensation name. */\n name: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n /**\n * The policy's remaining balance after the entered hours are subtracted,\n * recomputed live as the user edits. `null` when the policy has no tracked\n * accrual balance (e.g. final-payout rows). Feed it into the field's own\n * `description` to render it as the input's help text.\n */\n remaining: number | null\n}\n\n/**\n * One entry in the flat `overtimeExcludedEarnings` section.\n *\n * @remarks\n * Intentionally opaque: `overtimeExcludedEarnings` collects earnings that are not overtime-affecting\n * and whose input type the partner does not need to reason about. Render each\n * entry's `Field` keyed by `key`; use `id` as a reach-in handle for labeling.\n *\n * @public\n */\nexport interface OtherEntry {\n /** Opaque, stable React key. */\n key: string\n /** Reach-in handle identifying the underlying earning (its compensation name). */\n id: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A single job's hours section.\n *\n * @remarks\n * An employee can hold multiple jobs, each with its own hourly lines. `hours` is\n * either a flat `Entry[]` (single-workweek, or an overtime-ineligible employee)\n * OR a `Record<workweekStart, Entry[]>` (multi-workweek and overtime-eligible).\n * The value type is the signal — array is flat, object is split by workweek; use\n * {@link isSplitByWorkweek} to discriminate. `title` is the job's display title\n * (entity data, not copy) for rendering a per-job heading. Earnings are not\n * job-scoped: they live in the employee-level `overtimeIncludedEarnings` and\n * `overtimeExcludedEarnings` sections on {@link PayrollEditEmployeeFields}.\n *\n * @public\n */\nexport interface JobFields {\n /** The job identifier. */\n jobUuid: string\n /** The job's display title, when available, for a per-job heading. */\n title?: string\n /**\n * Hours inputs for this job. Excludes Overtime/Double-overtime rows while\n * `data.withOvertime` is `false`.\n */\n hours: HourEntry[] | Record<string, HourEntry[]>\n}\n\n/**\n * Presentation props accepted by a bound reimbursement description (text) field.\n *\n * @remarks\n * The hook binds the react-hook-form `name` internally; the UI supplies copy and\n * layout props (label, placeholder, `shouldVisuallyHideLabel`).\n *\n * @public\n */\nexport type ReimbursementDescriptionFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type'\n>\n\n/**\n * The draft \"add reimbursement\" field group exposed on\n * `form.Fields.reimbursementDraft`.\n *\n * @remarks\n * A single in-progress row the UI reveals when the user starts adding a\n * reimbursement. `Description` and `Amount` bind to `reimbursementDraft.description`\n * / `reimbursementDraft.amount`. The UI shows them while `form.reimbursementDraft.isAdding`\n * is `true`, then calls `actions.saveReimbursement` (commits to the list) or\n * `actions.cancelReimbursement` (discards). Committed rows are rendered from\n * `data.reimbursements`, not from bound fields.\n *\n * @public\n */\nexport interface ReimbursementDraftFields {\n /** Description field pre-bound to the draft's form path. */\n Description: ComponentType<ReimbursementDescriptionFieldProps>\n /** Amount field pre-bound to the draft's form path. */\n Amount: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A committed reimbursement row for display in the consumer's table.\n *\n * @remarks\n * Exposed on `data.reimbursements`, seeded from the employee's existing\n * reimbursements and appended to as the user saves drafts. Display-only: the UI\n * renders `description`, `amount`, and the recurring/one-time `type`, plus a\n * remove control wired to `actions.removeReimbursement(index)`. `index` is the\n * row's position in the underlying form array (the removal handle); `uuid` is\n * present for rows that already exist server-side.\n *\n * @public\n */\nexport interface ReimbursementRow {\n /** Opaque, stable React key. */\n key: string\n /** The row's index in the reimbursements form array; pass to `removeReimbursement`. */\n index: number\n /** The reimbursement's server UUID, when it already exists. */\n uuid?: string\n /** The reimbursement description (may be blank; the UI supplies a fallback). */\n description: string\n /** The reimbursement amount as a decimal string. */\n amount: string\n /** Whether this reimbursement recurs. Recurring rows are managed outside payroll. */\n recurring: boolean\n}\n\n/**\n * The render-ready field collections exposed on `form.Fields`.\n *\n * @remarks\n * Hours are grouped under `jobs`, one entry per job, so multi-job employees\n * render correctly. All earnings and the remaining sections are employee-scoped\n * and stay top-level: `overtimeIncludedEarnings` (overtime-affecting) and\n * `overtimeExcludedEarnings` (non-overtime) each render as a single section spanning every\n * job, alongside time off, final payout, payment method, and reimbursements.\n *\n * @public\n */\nexport interface PayrollEditEmployeeFields {\n /** Per-job hours sections; one entry per job. */\n jobs: JobFields[]\n /**\n * Overtime-affecting earnings across all jobs, as a single employee-level\n * section. Flat `Entry[]` when unsplit, or `Record<workweekStart, Entry[]>`\n * when split by workweek; use {@link isSplitByWorkweek} to discriminate.\n */\n overtimeIncludedEarnings: EarningEntry[] | Record<string, EarningEntry[]>\n /** Non-overtime earnings (e.g. tips), always flat; opaque render entries. */\n overtimeExcludedEarnings: OtherEntry[]\n /** Time-off inputs (never workweek-breakdown). */\n timeOff: TimeOffEntry[]\n /** Final-payout inputs, present only for dismissal payrolls. */\n finalPayout?: TimeOffEntry[]\n /** Payment-method selector, present only when the employee has direct deposit set up. */\n paymentMethod?: PayrollEditEmployeePaymentMethodField\n /**\n * The draft \"add reimbursement\" field group, present only for itemized\n * (non-off-cycle) payrolls. Render while `form.reimbursementDraft.isAdding` is\n * `true`; committed rows come from `data.reimbursements`.\n */\n reimbursementDraft?: ReimbursementDraftFields\n}\n\n/**\n * Discriminates a workweek-breakdown section: `false` for the flat\n * (single-workweek) `Entry[]` form, `true` for the workweek-keyed\n * `Record<workweekStart, Entry[]>` form.\n *\n * @typeParam TEntry - The section's entry type.\n * @param section - A `form.Fields` section that may be flat or workweek-keyed.\n * @returns `true` when the section is keyed by workweek start date.\n * @public\n */\nexport function isSplitByWorkweek<TEntry>(\n section: TEntry[] | Record<string, TEntry[]>,\n): section is Record<string, TEntry[]> {\n return !Array.isArray(section)\n}\n\n// ── Bound field factories ──────────────────────────────────────────────\n\nfunction createNumberField(\n name: string,\n errorMessages?: PayrollEditEmployeeErrorMessages,\n): PayrollEditEmployeeFieldComponent {\n return function BoundNumberField(props: PayrollEditEmployeeFieldProps) {\n // The field resolves its own validation copy from its bound path, so the\n // consumer supplies error copy once (keyed by code) and never reconstructs\n // form paths or guesses which rule a field can fail. name, type, min, and\n // errorMessage are applied after the spread so callers can't override the\n // binding or the non-negative numeric contract via custom props.\n const errorMessage = useFieldErrorMessage(\n name,\n errorMessages as ValidationMessages<PayrollEditEmployeeErrorCode> | undefined,\n )\n return (\n <TextInputField {...props} name={name} type=\"number\" min={0} errorMessage={errorMessage} />\n )\n }\n}\n\nfunction createPaymentMethodField(): PayrollEditEmployeePaymentMethodField {\n return function BoundPaymentMethodField(props: PayrollEditEmployeePaymentMethodFieldProps) {\n return (\n <RadioGroupHookField<never, PayrollUpdatePaymentMethod> {...props} name=\"paymentMethod\" />\n )\n }\n}\n\nfunction createTextField(name: string): ComponentType<ReimbursementDescriptionFieldProps> {\n return function BoundTextField(props: ReimbursementDescriptionFieldProps) {\n return <TextInputField {...props} name={name} />\n }\n}\n\n/**\n * Builds the draft \"add reimbursement\" field group, binding its Description and\n * Amount fields to the `reimbursementDraft` form path.\n *\n * @param errorMessages - Copy for each validation error code, baked into the amount field so it self-resolves.\n * @returns The pre-bound draft field group for `form.Fields.reimbursementDraft`.\n * @internal\n */\nexport function createReimbursementDraftFields(\n errorMessages?: PayrollEditEmployeeErrorMessages,\n): ReimbursementDraftFields {\n return {\n Description: createTextField('reimbursementDraft.description'),\n Amount: createNumberField('reimbursementDraft.amount', errorMessages),\n }\n}\n\n// ── Builders ───────────────────────────────────────────────────────────\n\n/** @internal */\nexport interface CreatePayrollEditEmployeeFieldsOptions {\n employeeCompensation: PayrollEmployeeCompensationsType | undefined\n /**\n * Fixed compensations to render, already merged with blank placeholders for\n * every company earning type (see `resolveEditableFixedCompensations`).\n */\n fixedCompensations: NonNullable<PayrollEmployeeCompensationsType['fixedCompensations']>\n workweeks: NormalizedWorkweek[]\n payrollCategory: PayrollCategory\n hasDirectDepositSetup: boolean\n /** Names of earning types included in the regular-rate-of-pay overtime calculation. */\n overtimeEarningNames: Set<string>\n /** Whether the employee is overtime-eligible (nonexempt family). Gates per-workweek splitting. */\n isOvertimeEligible: boolean\n /**\n * Gates per-workweek splitting\n * alongside `isOvertimeEligible`, and whether Overtime/Double-overtime rows\n * are included in `hours`.\n */\n withOvertime: boolean\n /** Job title lookup by job UUID, for per-job section headings. */\n jobTitlesByUuid: Map<string, string>\n /** Accrual balance by time-off policy name, for the remaining-balance display. */\n timeOffAccrualByName: Map<string, string>\n /** Copy for each validation error code, baked into every bound field so it self-resolves. */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * A time-off policy's remaining balance: its accrual balance minus the entered\n * hours. `null` when the policy has no tracked accrual balance (final-payout\n * rows). Shared by the field builder (seeding the initial value) and the hook\n * (recomputing it live as the user edits).\n *\n * @param accrualBalance - The policy's accrual balance, or `undefined` when untracked.\n * @param enteredHours - The currently entered hours for the policy.\n * @returns The remaining balance, or `null` when untracked.\n * @internal\n */\nexport function computeTimeOffRemaining(\n accrualBalance: string | undefined,\n enteredHours: string | null | undefined,\n): number | null {\n if (accrualBalance == null) return null\n return parseFloat(accrualBalance) - (parseFloat(enteredHours ?? '') || 0)\n}\n\nfunction buildBreakdownSection(\n compensations: Array<{ jobUuid?: string; name?: string }>,\n workweeks: NormalizedWorkweek[],\n pathPrefix: 'hours' | 'overtimeIncludedEarnings',\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n errorMessages: PayrollEditEmployeeErrorMessages | undefined,\n): HourEntry[] | Record<string, HourEntry[]> {\n const rows = compensations.filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n\n const toEntry = (\n row: { jobUuid: string; name: string },\n weekStart: string,\n includeWorkweek: boolean,\n ): HourEntry => ({\n key: includeWorkweek ? `${row.jobUuid}:${row.name}:${weekStart}` : `${row.jobUuid}:${row.name}`,\n jobUuid: row.jobUuid,\n name: row.name,\n ...(includeWorkweek ? { workweekStart: weekStart } : {}),\n Field: createNumberField(\n `${pathPrefix}.${row.jobUuid}.${row.name}.${weekStart}`,\n errorMessages,\n ),\n })\n\n // Split into per-workweek columns only for overtime-eligible employees while\n // `withOvertime` is on; workweek breakdowns exist solely to compute overtime\n // premiums, so an ineligible employee renders flat even on a multi-workweek\n // payroll, and an eligible one stays flat until `withOvertime` is set.\n if (workweeks.length > 1 && isOvertimeEligible && withOvertime) {\n const byWeek: Record<string, HourEntry[]> = {}\n for (const workweek of workweeks) {\n byWeek[workweek.startDate] = rows.map(row => toEntry(row, workweek.startDate, true))\n }\n return byWeek\n }\n\n const weekStart = workweeks[0]?.startDate ?? ''\n return rows.map(row => toEntry(row, weekStart, false))\n}\n\n/**\n * Builds the render-ready {@link PayrollEditEmployeeFields} from the prepared\n * compensation.\n *\n * @remarks\n * Hours and overtime-affecting earnings are grouped per job into `jobs` (a job\n * appears if it has hourly lines or overtime-affecting earnings). Fixed\n * compensations are split by whether their earning type is included in the\n * regular-rate-of-pay overtime calculation (`overtimeEarningNames`): included\n * earnings become each job's additional earnings, the rest become the flat,\n * employee-level `overtimeExcludedEarnings` section. Time off comes from the paid-time-off list,\n * final payout is added only for dismissal payrolls, and the payment-method\n * selector appears only when direct deposit is set up.\n *\n * @param options - The prepared compensation, normalized workweeks, payroll category, direct-deposit flag, overtime earning names, eligibility, the `withOvertime` flag, job titles, time-off accrual balances and entered values, and error copy.\n * @returns The populated field collections.\n * @internal\n */\nexport function createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n}: CreatePayrollEditEmployeeFieldsOptions): PayrollEditEmployeeFields {\n const hourlyCompensations = employeeCompensation?.hourlyCompensations ?? []\n const overtimeAffecting = fixedCompensations.filter(\n compensation => compensation.name != null && overtimeEarningNames.has(compensation.name),\n )\n const nonOvertime = fixedCompensations.filter(\n compensation => compensation.name == null || !overtimeEarningNames.has(compensation.name),\n )\n\n // A job appears if it has hourly lines or overtime-affecting earnings, in first\n // appearance order across those two sources.\n const jobUuids: string[] = []\n for (const compensation of [...hourlyCompensations, ...overtimeAffecting]) {\n if (compensation.jobUuid && !jobUuids.includes(compensation.jobUuid)) {\n jobUuids.push(compensation.jobUuid)\n }\n }\n\n const isOvertimeName = (name: string | null | undefined) =>\n name === COMPENSATION_NAME_OVERTIME || name === COMPENSATION_NAME_DOUBLE_OVERTIME\n\n const jobs: JobFields[] = jobUuids.map(jobUuid => {\n const jobHourlyCompensations = hourlyCompensations.filter(\n compensation => compensation.jobUuid === jobUuid,\n )\n // Overtime/Double-overtime rows stay out of `hours` entirely while\n // `withOvertime` is off — their underlying form values are untouched\n // (still whatever the prepared compensation carried), so hiding the row\n // can't lose or corrupt data. Driven by the single, employee-level flag —\n // no per-job hidden state.\n const visibleHourlyCompensations = withOvertime\n ? jobHourlyCompensations\n : jobHourlyCompensations.filter(compensation => !isOvertimeName(compensation.name))\n\n return {\n jobUuid,\n title: jobTitlesByUuid.get(jobUuid),\n hours: buildBreakdownSection(\n visibleHourlyCompensations,\n workweeks,\n 'hours',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n ),\n }\n })\n\n // Overtime-affecting earnings render as one employee-level section spanning\n // every job. Each entry keeps its per-job form path\n // (`overtimeIncludedEarnings.<jobUuid>.<name>`), so the flat section still binds and\n // submits per job.\n const overtimeIncludedEarnings = buildBreakdownSection(\n overtimeAffecting,\n workweeks,\n 'overtimeIncludedEarnings',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n )\n\n const overtimeExcludedEarnings: OtherEntry[] = nonOvertime\n .filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n .map(compensation => ({\n key: `${compensation.jobUuid}:${compensation.name}`,\n id: compensation.name,\n Field: createNumberField(\n `overtimeExcludedEarnings.${compensation.jobUuid}.${compensation.name}`,\n errorMessages,\n ),\n }))\n\n const timeOffRows = (employeeCompensation?.paidTimeOff ?? []).filter(entry => entry.name)\n const timeOff: TimeOffEntry[] = timeOffRows.map(entry => ({\n key: `timeOff:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`timeOff.${entry.name!}`, errorMessages),\n // Seeded from the initial entered hours; the hook recomputes it live.\n remaining: computeTimeOffRemaining(timeOffAccrualByName.get(entry.name!), entry.hours),\n }))\n\n // Final-payout rows never show a remaining balance.\n const finalPayout =\n payrollCategory === PayrollCategory.Dismissal\n ? timeOffRows.map(entry => ({\n key: `finalPayout:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`finalPayout.${entry.name!}`, errorMessages),\n remaining: null,\n }))\n : undefined\n\n return {\n jobs,\n overtimeIncludedEarnings,\n overtimeExcludedEarnings,\n timeOff,\n finalPayout,\n paymentMethod: hasDirectDepositSetup ? createPaymentMethodField() : undefined,\n }\n}\n"],"names":["isSplitByWorkweek","section","createNumberField","name","errorMessages","props","errorMessage","useFieldErrorMessage","jsx","TextInputField","createPaymentMethodField","RadioGroupHookField","createTextField","createReimbursementDraftFields","computeTimeOffRemaining","accrualBalance","enteredHours","buildBreakdownSection","compensations","workweeks","pathPrefix","isOvertimeEligible","withOvertime","rows","compensation","toEntry","row","weekStart","includeWorkweek","byWeek","workweek","createPayrollEditEmployeeFields","employeeCompensation","fixedCompensations","payrollCategory","hasDirectDepositSetup","overtimeEarningNames","jobTitlesByUuid","timeOffAccrualByName","hourlyCompensations","overtimeAffecting","nonOvertime","jobUuids","isOvertimeName","COMPENSATION_NAME_OVERTIME","COMPENSATION_NAME_DOUBLE_OVERTIME","jobs","jobUuid","jobHourlyCompensations","visibleHourlyCompensations","overtimeIncludedEarnings","overtimeExcludedEarnings","timeOffRows","entry","timeOff","finalPayout","PayrollCategory"],"mappings":";;;;;;AA+RO,SAASA,EACdC,GACqC;AACrC,SAAO,CAAC,MAAM,QAAQA,CAAO;AAC/B;AAIA,SAASC,EACPC,GACAC,GACmC;AACnC,SAAO,SAA0BC,GAAsC;AAMrE,UAAMC,IAAeC;AAAA,MACnBJ;AAAA,MACAC;AAAA,IAAA;AAEF,WACE,gBAAAI,EAACC,KAAgB,GAAGJ,GAAO,MAAAF,GAAY,MAAK,UAAS,KAAK,GAAG,cAAAG,EAAA,CAA4B;AAAA,EAE7F;AACF;AAEA,SAASI,IAAkE;AACzE,SAAO,SAAiCL,GAAmD;AACzF,WACE,gBAAAG,EAACG,GAAA,EAAwD,GAAGN,GAAO,MAAK,iBAAgB;AAAA,EAE5F;AACF;AAEA,SAASO,EAAgBT,GAAiE;AACxF,SAAO,SAAwBE,GAA2C;AACxE,WAAO,gBAAAG,EAACC,GAAA,EAAgB,GAAGJ,GAAO,MAAAF,EAAA,CAAY;AAAA,EAChD;AACF;AAUO,SAASU,EACdT,GAC0B;AAC1B,SAAO;AAAA,IACL,aAAaQ,EAAgB,gCAAgC;AAAA,IAC7D,QAAQV,EAAkB,6BAA6BE,CAAa;AAAA,EAAA;AAExE;AA4CO,SAASU,EACdC,GACAC,GACe;AACf,SAAID,KAAkB,OAAa,OAC5B,WAAWA,CAAc,KAAK,WAAWC,KAAgB,EAAE,KAAK;AACzE;AAEA,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACAlB,GAC2C;AAC3C,QAAMmB,IAAOL,EAAc;AAAA,IACzB,CAACM,MACC,EAAQA,EAAa,WAAY,EAAQA,EAAa;AAAA,EAAI,GAGxDC,IAAU,CACdC,GACAC,GACAC,OACe;AAAA,IACf,KAAKA,IAAkB,GAAGF,EAAI,OAAO,IAAIA,EAAI,IAAI,IAAIC,CAAS,KAAK,GAAGD,EAAI,OAAO,IAAI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AAwBwB,EAAqB,IAAIe,EAAM,IAAK,GAAGA,EAAM,KAAK;AAAA,EAAA,EACrF,GAGIE,IACJrB,MAAoBsB,EAAgB,YAChCJ,EAAY,IAAI,CAAAC,OAAU;AAAA,IACxB,KAAK,eAAeA,EAAM,IAAK;AAAA,IAC/B,MAAMA,EAAM;AAAA,IACZ,OAAOnD,EAAkB,eAAemD,EAAM,IAAK,IAAIjD,CAAa;AAAA,IACpE,WAAW;AAAA,EAAA,EACX,IACF;AAEN,SAAO;AAAA,IACL,MAAA0C;AAAA,IACA,0BAAAI;AAAA,IACA,0BAAAC;AAAA,IACA,SAAAG;AAAA,IACA,aAAAC;AAAA,IACA,eAAepB,IAAwBzB,MAA6B;AAAA,EAAA;AAExE;"}
1
+ {"version":3,"file":"fields.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdatePaymentMethod } from '@gusto/embedded-api/models/components/payrollupdate'\nimport type { NormalizedWorkweek } from './payrollEditEmployeeHelpers'\nimport type { PayrollEditEmployeeErrorCode } from './payrollEditEmployeeSchema'\nimport { TextInputField } from '@/components/Common/Fields/TextInputField/TextInputField'\nimport { useFieldErrorMessage } from '@/partner-hook-utils/form/useFieldErrorMessage'\nimport { RadioGroupHookField } from '@/partner-hook-utils/form/fields'\nimport type { RadioGroupHookFieldProps } from '@/partner-hook-utils/form/fields/RadioGroupHookField'\nimport type { HookFieldProps, ValidationMessages } from '@/partner-hook-utils/types'\nimport type { TextInputProps } from '@/components/Common/UI/TextInput/TextInputTypes'\nimport { PayrollCategory } from '@/components/Payroll/payrollTypes'\nimport { COMPENSATION_NAME_DOUBLE_OVERTIME, COMPENSATION_NAME_OVERTIME } from '@/shared/constants'\nimport { stripLeadingZeros } from '@/helpers/formattedStrings'\n\n/**\n * Display copy for each validation error code a bound field can surface, so the\n * consumer supplies error text once (keyed by code) rather than reconstructing\n * form paths or hardcoding which rule each field can fail. Partial: a missing\n * code falls back to the raw error code.\n *\n * @public\n */\nexport type PayrollEditEmployeeErrorMessages = Partial<Record<PayrollEditEmployeeErrorCode, string>>\n\n/**\n * Presentation props accepted by a bound numeric field in the payroll editor.\n *\n * @remarks\n * The hook binds the react-hook-form `name`, forces `type=\"number\"`, and\n * resolves the field's own validation message internally; the UI supplies copy\n * and layout props (label, adornments, `shouldVisuallyHideLabel`, required\n * state, `description`).\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type' | 'min' | 'errorMessage'\n>\n\n/**\n * A numeric field component pre-bound by the hook to a specific form path.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldComponent = ComponentType<PayrollEditEmployeeFieldProps>\n\n/**\n * Presentation props accepted by the bound payment-method field.\n *\n * @remarks\n * The hook binds the `name` and publishes the option values on\n * `fieldsMetadata.paymentMethod`; the UI passes `getOptionLabel` to translate\n * each {@link PayrollUpdatePaymentMethod} value, rather than passing `options`.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodFieldProps = HookFieldProps<\n RadioGroupHookFieldProps<never, PayrollUpdatePaymentMethod>\n>\n\n/**\n * The payment-method radio field component pre-bound by the hook.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodField =\n ComponentType<PayrollEditEmployeePaymentMethodFieldProps>\n\n/**\n * One hours input within the hours section.\n *\n * @remarks\n * `key` is an opaque, stable React key. `jobUuid`, `name`, and (when the pay\n * period is multi-workweek) `workweekStart` are reach-in handles the UI uses to\n * group and label entries. When the section is a flat array, `workweekStart` is\n * omitted (single-workweek degenerate case); when it is a `Record` keyed by\n * workweek start, each entry carries its `workweekStart`.\n *\n * @public\n */\nexport interface HourEntry {\n /** Opaque, stable React key. */\n key: string\n /** The job this hours line belongs to. */\n jobUuid: string\n /** The compensation name (e.g. the API hours-compensation name). */\n name: string\n /** The workweek start date (`YYYY-MM-DD`) when the section is workweek-keyed. */\n workweekStart?: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * One earning input, used by the additional-earnings section.\n *\n * @remarks\n * Same shape as {@link HourEntry}. Whether an earning feeds the overtime\n * (regular rate of pay) calculation is decided by the hook, which sorts it into\n * the workweek-breakdown additional-earnings section or the flat other\n * section. The UI just renders whichever section an entry appears in.\n *\n * @public\n */\nexport type EarningEntry = HourEntry\n\n/**\n * One time-off or final-payout input.\n *\n * @remarks\n * Time off is never workweek-breakdown, so this section is always a flat array.\n *\n * @public\n */\nexport interface TimeOffEntry {\n /** Opaque, stable React key. */\n key: string\n /** The time-off policy compensation name. */\n name: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n /**\n * The policy's remaining balance after the entered hours are subtracted,\n * recomputed live as the user edits. `null` when the policy has no tracked\n * accrual balance (e.g. final-payout rows). Feed it into the field's own\n * `description` to render it as the input's help text.\n */\n remaining: number | null\n}\n\n/**\n * One entry in the flat `overtimeExcludedEarnings` section.\n *\n * @remarks\n * Intentionally opaque: `overtimeExcludedEarnings` collects earnings that are not overtime-affecting\n * and whose input type the partner does not need to reason about. Render each\n * entry's `Field` keyed by `key`; use `id` as a reach-in handle for labeling.\n *\n * @public\n */\nexport interface OtherEntry {\n /** Opaque, stable React key. */\n key: string\n /** Reach-in handle identifying the underlying earning (its compensation name). */\n id: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A single job's hours section.\n *\n * @remarks\n * An employee can hold multiple jobs, each with its own hourly lines. `hours` is\n * either a flat `Entry[]` (single-workweek, or an overtime-ineligible employee)\n * OR a `Record<workweekStart, Entry[]>` (multi-workweek and overtime-eligible).\n * The value type is the signal — array is flat, object is split by workweek; use\n * {@link isSplitByWorkweek} to discriminate. `title` is the job's display title\n * (entity data, not copy) for rendering a per-job heading. Earnings are not\n * job-scoped: they live in the employee-level `overtimeIncludedEarnings` and\n * `overtimeExcludedEarnings` sections on {@link PayrollEditEmployeeFields}.\n *\n * @public\n */\nexport interface JobFields {\n /** The job identifier. */\n jobUuid: string\n /** The job's display title, when available, for a per-job heading. */\n title?: string\n /**\n * Hours inputs for this job. Excludes Overtime/Double-overtime rows while\n * `data.withOvertime` is `false`.\n */\n hours: HourEntry[] | Record<string, HourEntry[]>\n}\n\n/**\n * Presentation props accepted by a bound reimbursement description (text) field.\n *\n * @remarks\n * The hook binds the react-hook-form `name` internally; the UI supplies copy and\n * layout props (label, placeholder, `shouldVisuallyHideLabel`).\n *\n * @public\n */\nexport type ReimbursementDescriptionFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type'\n>\n\n/**\n * The draft \"add reimbursement\" field group exposed on\n * `form.Fields.reimbursementDraft`.\n *\n * @remarks\n * A single in-progress row the UI reveals when the user starts adding a\n * reimbursement. `Description` and `Amount` bind to `reimbursementDraft.description`\n * / `reimbursementDraft.amount`. The UI shows them while `form.reimbursementDraft.isAdding`\n * is `true`, then calls `actions.saveReimbursement` (commits to the list) or\n * `actions.cancelReimbursement` (discards). Committed rows are rendered from\n * `data.reimbursements`, not from bound fields.\n *\n * @public\n */\nexport interface ReimbursementDraftFields {\n /** Description field pre-bound to the draft's form path. */\n Description: ComponentType<ReimbursementDescriptionFieldProps>\n /** Amount field pre-bound to the draft's form path. */\n Amount: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A committed reimbursement row for display in the consumer's table.\n *\n * @remarks\n * Exposed on `data.reimbursements`, seeded from the employee's existing\n * reimbursements and appended to as the user saves drafts. Display-only: the UI\n * renders `description`, `amount`, and the recurring/one-time `type`, plus a\n * remove control wired to `actions.removeReimbursement(index)`. `index` is the\n * row's position in the underlying form array (the removal handle); `uuid` is\n * present for rows that already exist server-side.\n *\n * @public\n */\nexport interface ReimbursementRow {\n /** Opaque, stable React key. */\n key: string\n /** The row's index in the reimbursements form array; pass to `removeReimbursement`. */\n index: number\n /** The reimbursement's server UUID, when it already exists. */\n uuid?: string\n /** The reimbursement description (may be blank; the UI supplies a fallback). */\n description: string\n /** The reimbursement amount as a decimal string. */\n amount: string\n /** Whether this reimbursement recurs. Recurring rows are managed outside payroll. */\n recurring: boolean\n}\n\n/**\n * The render-ready field collections exposed on `form.Fields`.\n *\n * @remarks\n * Hours are grouped under `jobs`, one entry per job, so multi-job employees\n * render correctly. All earnings and the remaining sections are employee-scoped\n * and stay top-level: `overtimeIncludedEarnings` (overtime-affecting) and\n * `overtimeExcludedEarnings` (non-overtime) each render as a single section spanning every\n * job, alongside time off, final payout, payment method, and reimbursements.\n *\n * @public\n */\nexport interface PayrollEditEmployeeFields {\n /** Per-job hours sections; one entry per job. */\n jobs: JobFields[]\n /**\n * Overtime-affecting earnings across all jobs, as a single employee-level\n * section. Flat `Entry[]` when unsplit, or `Record<workweekStart, Entry[]>`\n * when split by workweek; use {@link isSplitByWorkweek} to discriminate.\n */\n overtimeIncludedEarnings: EarningEntry[] | Record<string, EarningEntry[]>\n /** Non-overtime earnings (e.g. tips), always flat; opaque render entries. */\n overtimeExcludedEarnings: OtherEntry[]\n /** Time-off inputs (never workweek-breakdown). */\n timeOff: TimeOffEntry[]\n /** Final-payout inputs, present only for dismissal payrolls. */\n finalPayout?: TimeOffEntry[]\n /** Payment-method selector, present only when the employee has direct deposit set up. */\n paymentMethod?: PayrollEditEmployeePaymentMethodField\n /**\n * The draft \"add reimbursement\" field group, present only for itemized\n * (non-off-cycle) payrolls. Render while `form.reimbursementDraft.isAdding` is\n * `true`; committed rows come from `data.reimbursements`.\n */\n reimbursementDraft?: ReimbursementDraftFields\n}\n\n/**\n * Discriminates a workweek-breakdown section: `false` for the flat\n * (single-workweek) `Entry[]` form, `true` for the workweek-keyed\n * `Record<workweekStart, Entry[]>` form.\n *\n * @typeParam TEntry - The section's entry type.\n * @param section - A `form.Fields` section that may be flat or workweek-keyed.\n * @returns `true` when the section is keyed by workweek start date.\n * @public\n */\nexport function isSplitByWorkweek<TEntry>(\n section: TEntry[] | Record<string, TEntry[]>,\n): section is Record<string, TEntry[]> {\n return !Array.isArray(section)\n}\n\n// ── Bound field factories ──────────────────────────────────────────────\n\nfunction createNumberField(\n name: string,\n errorMessages?: PayrollEditEmployeeErrorMessages,\n): PayrollEditEmployeeFieldComponent {\n return function BoundNumberField(props: PayrollEditEmployeeFieldProps) {\n // The field resolves its own validation copy from its bound path, so the\n // consumer supplies error copy once (keyed by code) and never reconstructs\n // form paths or guesses which rule a field can fail. name, type, min,\n // transform, and errorMessage are applied after the spread so callers can't\n // override the binding or the non-negative numeric contract via custom props.\n const errorMessage = useFieldErrorMessage(\n name,\n errorMessages as ValidationMessages<PayrollEditEmployeeErrorCode> | undefined,\n )\n return (\n <TextInputField\n {...props}\n name={name}\n type=\"number\"\n min={0}\n transform={stripLeadingZeros}\n errorMessage={errorMessage}\n />\n )\n }\n}\n\nfunction createPaymentMethodField(): PayrollEditEmployeePaymentMethodField {\n return function BoundPaymentMethodField(props: PayrollEditEmployeePaymentMethodFieldProps) {\n return (\n <RadioGroupHookField<never, PayrollUpdatePaymentMethod> {...props} name=\"paymentMethod\" />\n )\n }\n}\n\nfunction createTextField(name: string): ComponentType<ReimbursementDescriptionFieldProps> {\n return function BoundTextField(props: ReimbursementDescriptionFieldProps) {\n return <TextInputField {...props} name={name} />\n }\n}\n\n/**\n * Builds the draft \"add reimbursement\" field group, binding its Description and\n * Amount fields to the `reimbursementDraft` form path.\n *\n * @param errorMessages - Copy for each validation error code, baked into the amount field so it self-resolves.\n * @returns The pre-bound draft field group for `form.Fields.reimbursementDraft`.\n * @internal\n */\nexport function createReimbursementDraftFields(\n errorMessages?: PayrollEditEmployeeErrorMessages,\n): ReimbursementDraftFields {\n return {\n Description: createTextField('reimbursementDraft.description'),\n Amount: createNumberField('reimbursementDraft.amount', errorMessages),\n }\n}\n\n// ── Builders ───────────────────────────────────────────────────────────\n\n/** @internal */\nexport interface CreatePayrollEditEmployeeFieldsOptions {\n employeeCompensation: PayrollEmployeeCompensationsType | undefined\n /**\n * Fixed compensations to render, already merged with blank placeholders for\n * every company earning type (see `resolveEditableFixedCompensations`).\n */\n fixedCompensations: NonNullable<PayrollEmployeeCompensationsType['fixedCompensations']>\n workweeks: NormalizedWorkweek[]\n payrollCategory: PayrollCategory\n hasDirectDepositSetup: boolean\n /** Names of earning types included in the regular-rate-of-pay overtime calculation. */\n overtimeEarningNames: Set<string>\n /** Whether the employee is overtime-eligible (nonexempt family). Gates per-workweek splitting. */\n isOvertimeEligible: boolean\n /**\n * Gates per-workweek splitting\n * alongside `isOvertimeEligible`, and whether Overtime/Double-overtime rows\n * are included in `hours`.\n */\n withOvertime: boolean\n /** Job title lookup by job UUID, for per-job section headings. */\n jobTitlesByUuid: Map<string, string>\n /** Accrual balance by time-off policy name, for the remaining-balance display. */\n timeOffAccrualByName: Map<string, string>\n /** Copy for each validation error code, baked into every bound field so it self-resolves. */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * A time-off policy's remaining balance: its accrual balance minus the entered\n * hours. `null` when the policy has no tracked accrual balance (final-payout\n * rows). Shared by the field builder (seeding the initial value) and the hook\n * (recomputing it live as the user edits).\n *\n * @param accrualBalance - The policy's accrual balance, or `undefined` when untracked.\n * @param enteredHours - The currently entered hours for the policy.\n * @returns The remaining balance, or `null` when untracked.\n * @internal\n */\nexport function computeTimeOffRemaining(\n accrualBalance: string | undefined,\n enteredHours: string | null | undefined,\n): number | null {\n if (accrualBalance == null) return null\n return parseFloat(accrualBalance) - (parseFloat(enteredHours ?? '') || 0)\n}\n\nfunction buildBreakdownSection(\n compensations: Array<{ jobUuid?: string; name?: string }>,\n workweeks: NormalizedWorkweek[],\n pathPrefix: 'hours' | 'overtimeIncludedEarnings',\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n errorMessages: PayrollEditEmployeeErrorMessages | undefined,\n): HourEntry[] | Record<string, HourEntry[]> {\n const rows = compensations.filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n\n const toEntry = (\n row: { jobUuid: string; name: string },\n weekStart: string,\n includeWorkweek: boolean,\n ): HourEntry => ({\n key: includeWorkweek ? `${row.jobUuid}:${row.name}:${weekStart}` : `${row.jobUuid}:${row.name}`,\n jobUuid: row.jobUuid,\n name: row.name,\n ...(includeWorkweek ? { workweekStart: weekStart } : {}),\n Field: createNumberField(\n `${pathPrefix}.${row.jobUuid}.${row.name}.${weekStart}`,\n errorMessages,\n ),\n })\n\n // Split into per-workweek columns only for overtime-eligible employees while\n // `withOvertime` is on; workweek breakdowns exist solely to compute overtime\n // premiums, so an ineligible employee renders flat even on a multi-workweek\n // payroll, and an eligible one stays flat until `withOvertime` is set.\n if (workweeks.length > 1 && isOvertimeEligible && withOvertime) {\n const byWeek: Record<string, HourEntry[]> = {}\n for (const workweek of workweeks) {\n byWeek[workweek.startDate] = rows.map(row => toEntry(row, workweek.startDate, true))\n }\n return byWeek\n }\n\n const weekStart = workweeks[0]?.startDate ?? ''\n return rows.map(row => toEntry(row, weekStart, false))\n}\n\n/**\n * Builds the render-ready {@link PayrollEditEmployeeFields} from the prepared\n * compensation.\n *\n * @remarks\n * Hours and overtime-affecting earnings are grouped per job into `jobs` (a job\n * appears if it has hourly lines or overtime-affecting earnings). Fixed\n * compensations are split by whether their earning type is included in the\n * regular-rate-of-pay overtime calculation (`overtimeEarningNames`): included\n * earnings become each job's additional earnings, the rest become the flat,\n * employee-level `overtimeExcludedEarnings` section. Time off comes from the paid-time-off list,\n * final payout is added only for dismissal payrolls, and the payment-method\n * selector appears only when direct deposit is set up.\n *\n * @param options - The prepared compensation, normalized workweeks, payroll category, direct-deposit flag, overtime earning names, eligibility, the `withOvertime` flag, job titles, time-off accrual balances and entered values, and error copy.\n * @returns The populated field collections.\n * @internal\n */\nexport function createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n}: CreatePayrollEditEmployeeFieldsOptions): PayrollEditEmployeeFields {\n const hourlyCompensations = employeeCompensation?.hourlyCompensations ?? []\n const overtimeAffecting = fixedCompensations.filter(\n compensation => compensation.name != null && overtimeEarningNames.has(compensation.name),\n )\n const nonOvertime = fixedCompensations.filter(\n compensation => compensation.name == null || !overtimeEarningNames.has(compensation.name),\n )\n\n // A job appears if it has hourly lines or overtime-affecting earnings, in first\n // appearance order across those two sources.\n const jobUuids: string[] = []\n for (const compensation of [...hourlyCompensations, ...overtimeAffecting]) {\n if (compensation.jobUuid && !jobUuids.includes(compensation.jobUuid)) {\n jobUuids.push(compensation.jobUuid)\n }\n }\n\n const isOvertimeName = (name: string | null | undefined) =>\n name === COMPENSATION_NAME_OVERTIME || name === COMPENSATION_NAME_DOUBLE_OVERTIME\n\n const jobs: JobFields[] = jobUuids.map(jobUuid => {\n const jobHourlyCompensations = hourlyCompensations.filter(\n compensation => compensation.jobUuid === jobUuid,\n )\n // Overtime/Double-overtime rows stay out of `hours` entirely while\n // `withOvertime` is off — their underlying form values are untouched\n // (still whatever the prepared compensation carried), so hiding the row\n // can't lose or corrupt data. Driven by the single, employee-level flag —\n // no per-job hidden state.\n const visibleHourlyCompensations = withOvertime\n ? jobHourlyCompensations\n : jobHourlyCompensations.filter(compensation => !isOvertimeName(compensation.name))\n\n return {\n jobUuid,\n title: jobTitlesByUuid.get(jobUuid),\n hours: buildBreakdownSection(\n visibleHourlyCompensations,\n workweeks,\n 'hours',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n ),\n }\n })\n\n // Overtime-affecting earnings render as one employee-level section spanning\n // every job. Each entry keeps its per-job form path\n // (`overtimeIncludedEarnings.<jobUuid>.<name>`), so the flat section still binds and\n // submits per job.\n const overtimeIncludedEarnings = buildBreakdownSection(\n overtimeAffecting,\n workweeks,\n 'overtimeIncludedEarnings',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n )\n\n const overtimeExcludedEarnings: OtherEntry[] = nonOvertime\n .filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n .map(compensation => ({\n key: `${compensation.jobUuid}:${compensation.name}`,\n id: compensation.name,\n Field: createNumberField(\n `overtimeExcludedEarnings.${compensation.jobUuid}.${compensation.name}`,\n errorMessages,\n ),\n }))\n\n const timeOffRows = (employeeCompensation?.paidTimeOff ?? []).filter(entry => entry.name)\n const timeOff: TimeOffEntry[] = timeOffRows.map(entry => ({\n key: `timeOff:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`timeOff.${entry.name!}`, errorMessages),\n // Seeded from the initial entered hours; the hook recomputes it live.\n remaining: computeTimeOffRemaining(timeOffAccrualByName.get(entry.name!), entry.hours),\n }))\n\n // Final-payout rows never show a remaining balance.\n const finalPayout =\n payrollCategory === PayrollCategory.Dismissal\n ? timeOffRows.map(entry => ({\n key: `finalPayout:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`finalPayout.${entry.name!}`, errorMessages),\n remaining: null,\n }))\n : undefined\n\n return {\n jobs,\n overtimeIncludedEarnings,\n overtimeExcludedEarnings,\n timeOff,\n finalPayout,\n paymentMethod: hasDirectDepositSetup ? createPaymentMethodField() : undefined,\n }\n}\n"],"names":["isSplitByWorkweek","section","createNumberField","name","errorMessages","props","errorMessage","useFieldErrorMessage","jsx","TextInputField","stripLeadingZeros","createPaymentMethodField","RadioGroupHookField","createTextField","createReimbursementDraftFields","computeTimeOffRemaining","accrualBalance","enteredHours","buildBreakdownSection","compensations","workweeks","pathPrefix","isOvertimeEligible","withOvertime","rows","compensation","toEntry","row","weekStart","includeWorkweek","byWeek","workweek","createPayrollEditEmployeeFields","employeeCompensation","fixedCompensations","payrollCategory","hasDirectDepositSetup","overtimeEarningNames","jobTitlesByUuid","timeOffAccrualByName","hourlyCompensations","overtimeAffecting","nonOvertime","jobUuids","isOvertimeName","COMPENSATION_NAME_OVERTIME","COMPENSATION_NAME_DOUBLE_OVERTIME","jobs","jobUuid","jobHourlyCompensations","visibleHourlyCompensations","overtimeIncludedEarnings","overtimeExcludedEarnings","timeOffRows","entry","timeOff","finalPayout","PayrollCategory"],"mappings":";;;;;;;AAgSO,SAASA,EACdC,GACqC;AACrC,SAAO,CAAC,MAAM,QAAQA,CAAO;AAC/B;AAIA,SAASC,EACPC,GACAC,GACmC;AACnC,SAAO,SAA0BC,GAAsC;AAMrE,UAAMC,IAAeC;AAAA,MACnBJ;AAAA,MACAC;AAAA,IAAA;AAEF,WACE,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACE,GAAGJ;AAAA,QACJ,MAAAF;AAAA,QACA,MAAK;AAAA,QACL,KAAK;AAAA,QACL,WAAWO;AAAA,QACX,cAAAJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,SAASK,IAAkE;AACzE,SAAO,SAAiCN,GAAmD;AACzF,WACE,gBAAAG,EAACI,GAAA,EAAwD,GAAGP,GAAO,MAAK,iBAAgB;AAAA,EAE5F;AACF;AAEA,SAASQ,EAAgBV,GAAiE;AACxF,SAAO,SAAwBE,GAA2C;AACxE,WAAO,gBAAAG,EAACC,GAAA,EAAgB,GAAGJ,GAAO,MAAAF,EAAA,CAAY;AAAA,EAChD;AACF;AAUO,SAASW,EACdV,GAC0B;AAC1B,SAAO;AAAA,IACL,aAAaS,EAAgB,gCAAgC;AAAA,IAC7D,QAAQX,EAAkB,6BAA6BE,CAAa;AAAA,EAAA;AAExE;AA4CO,SAASW,EACdC,GACAC,GACe;AACf,SAAID,KAAkB,OAAa,OAC5B,WAAWA,CAAc,KAAK,WAAWC,KAAgB,EAAE,KAAK;AACzE;AAEA,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACAnB,GAC2C;AAC3C,QAAMoB,IAAOL,EAAc;AAAA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,EAAM,IAAI,GAClFC,IAA0BF,EAAY,IAAI,CAAAC,OAAU;AAAA,IACxD,KAAK,WAAWA,EAAM,IAAK;AAAA,IAC3B,MAAMA,EAAM;AAAA,IACZ,OAAOpD,EAAkB,WAAWoD,EAAM,IAAK,IAAIlD,CAAa;AAAA;AAAA,IAEhE,WAAWW,EAAwBwB,EAAqB,IAAIe,EAAM,IAAK,GAAGA,EAAM,KAAK;AAAA,EAAA,EACrF,GAGIE,IACJrB,MAAoBsB,EAAgB,YAChCJ,EAAY,IAAI,CAAAC,OAAU;AAAA,IACxB,KAAK,eAAeA,EAAM,IAAK;AAAA,IAC/B,MAAMA,EAAM;AAAA,IACZ,OAAOpD,EAAkB,eAAeoD,EAAM,IAAK,IAAIlD,CAAa;AAAA,IACpE,WAAW;AAAA,EAAA,EACX,IACF;AAEN,SAAO;AAAA,IACL,MAAA2C;AAAA,IACA,0BAAAI;AAAA,IACA,0BAAAC;AAAA,IACA,SAAAG;AAAA,IACA,aAAAC;AAAA,IACA,eAAepB,IAAwBzB,MAA6B;AAAA,EAAA;AAExE;"}
@@ -1 +1 @@
1
- {"version":3,"file":"payrollEditEmployeeHelpers.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.ts"],"sourcesContent":["import type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { EarningTypeList } from '@gusto/embedded-api/models/components/earningtypelist'\nimport {\n PayrollUpdatePaymentMethod,\n type PayrollUpdateEmployeeCompensations,\n} from '@gusto/embedded-api/models/components/payrollupdate'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport type {\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFormOutputs,\n} from './payrollEditEmployeeSchema'\nimport { PayrollCategory, isOffCyclePayroll } from '@/components/Payroll/payrollTypes'\nimport { cleanupReimbursements } from '@/components/Payroll/helpers'\nimport { SDKInternalError } from '@/types/sdkError'\nimport {\n COMPENSATION_NAME_DOUBLE_OVERTIME,\n COMPENSATION_NAME_OVERTIME,\n EXCLUDED_ADDITIONAL_EARNINGS,\n FlsaStatus,\n} from '@/shared/constants'\n\n/** One fixed-compensation line off the prepared compensation. */\ntype FixedCompensationEntry = NonNullable<\n PayrollEmployeeCompensationsType['fixedCompensations']\n>[number]\n\n/**\n * Normalized form of a workweek: the API exposes\n * `{ startDate?: RFCDate; endDate?: RFCDate }`, but the hook keys week-maps by\n * `YYYY-MM-DD` strings and builds breakdowns from them, so both boundaries are\n * required strings here. Surfaced on the hook's `data.workweeks` so the UI can\n * label each per-workweek column without re-parsing the raw API workweeks.\n *\n * @internal\n */\nexport interface NormalizedWorkweek {\n startDate: string\n endDate: string\n}\n\n/**\n * Normalizes the prepared payroll's top-level `workweeks` into\n * {@link NormalizedWorkweek} boundary strings, falling back to a single\n * pay-period-spanning workweek when the API returns no workweek boundaries.\n *\n * @param workweeks - The prepared payroll's top-level `workweeks` (RFCDate boundaries), possibly `null`.\n * @param payPeriod - The prepared payroll's `payPeriod`, used as the single-workweek fallback.\n * @returns One entry per workweek; a single entry spanning the pay period when none are supplied.\n * @throws SDKInternalError when neither workweeks nor a pay period are present (a malformed prepared payroll).\n * @internal\n */\nexport function normalizeWorkweeks(\n workweeks: Array<{ startDate?: RFCDate; endDate?: RFCDate }> | null | undefined,\n payPeriod: { startDate?: string; endDate?: string } | undefined,\n): NormalizedWorkweek[] {\n const normalized = (workweeks ?? []).flatMap(week =>\n week.startDate && week.endDate\n ? [{ startDate: week.startDate.toString(), endDate: week.endDate.toString() }]\n : [],\n )\n\n if (normalized.length > 0) {\n return normalized\n }\n\n if (payPeriod?.startDate && payPeriod.endDate) {\n return [{ startDate: payPeriod.startDate, endDate: payPeriod.endDate }]\n }\n\n // A prepared payroll always carries a pay period, so reaching here means the\n // response was malformed. Fail loud rather than build an empty, mis-keyed form\n // that could submit an employee's pay against a blank workweek.\n throw new SDKInternalError('Prepared payroll has no workweeks or pay period to derive from')\n}\n\n/**\n * Collects the names of earning types included in the regular-rate-of-pay\n * overtime calculation. These earnings render in the workweek-breakdown\n * additional-earnings section; all others fall into the flat `overtimeExcludedEarnings` section.\n *\n * @param earningTypeList - The company's default and custom earning types.\n * @returns A set of earning-type names with `includedInOvertimePay` set.\n * @internal\n */\nexport function collectOvertimeEarningNames(\n earningTypeList: EarningTypeList | undefined,\n): Set<string> {\n const names = new Set<string>()\n for (const earningType of [\n ...(earningTypeList?.default ?? []),\n ...(earningTypeList?.custom ?? []),\n ]) {\n if (earningType.name && earningType.includedInOvertimePay) {\n names.add(earningType.name)\n }\n }\n return names\n}\n\n/**\n * Merges the employee's existing fixed compensations with a blank placeholder for\n * every payroll fixed-compensation type they don't yet have, mirroring the stable editor\n * (`getAdditionalEarningsCompensations`). This is what lets the editor surface an\n * empty input for Bonus, Commission, etc. even when the prepared payroll carries\n * no fixed compensations. Placeholders attach to the primary job and carry no\n * amount (blank), so an untouched earning submits as zero without altering pay.\n *\n * @remarks\n * Owners (FLSA status `Owner`) never receive placeholders. Earning types that are\n * handled elsewhere or never shown as additional earnings\n * ({@link EXCLUDED_ADDITIONAL_EARNINGS}) and inactive types are skipped. The\n * result is sorted alphabetically by name. The regular-rate-of-pay split between\n * additional earnings and `overtimeExcludedEarnings` happens downstream via `overtimeEarningNames`;\n * this helper only decides which earning lines exist.\n *\n * @param existingFixedCompensations - The prepared compensation's fixed compensations.\n * @param fixedCompensationTypes - The prepared payroll's `fixedCompensationTypes` (the same source the stable editor uses).\n * @param primaryJobUuid - The employee's primary job UUID; placeholders attach here.\n * @param flsaStatus - The employee's FLSA status; owners get no placeholders.\n * @returns The merged, filtered, alphabetically sorted fixed-compensation lines.\n * @internal\n */\nexport function resolveEditableFixedCompensations(\n existingFixedCompensations: FixedCompensationEntry[] | undefined,\n fixedCompensationTypes: Array<{ name?: string | null }> | undefined,\n primaryJobUuid: string | undefined,\n flsaStatus: string | undefined,\n): FixedCompensationEntry[] {\n const merged: FixedCompensationEntry[] = [...(existingFixedCompensations ?? [])]\n\n if (flsaStatus !== FlsaStatus.OWNER && primaryJobUuid) {\n for (const compensationType of fixedCompensationTypes ?? []) {\n const name = compensationType.name\n if (!name) continue\n if (EXCLUDED_ADDITIONAL_EARNINGS.includes(name)) continue\n const exists = merged.some(entry => entry.name?.toLowerCase() === name.toLowerCase())\n if (!exists) merged.push({ name, jobUuid: primaryJobUuid })\n }\n }\n\n return merged\n .filter(entry => entry.name && !EXCLUDED_ADDITIONAL_EARNINGS.includes(entry.name))\n .sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''))\n}\n\n/**\n * Whether the employee's prepared compensation already carries non-zero\n * Overtime or Double-overtime hours.\n *\n * @remarks\n * Used to default the single `withOvertime` flag: an employee who already\n * has real overtime hours starts with the workweek split shown rather than\n * requiring an extra click to see data that's already there.\n *\n * @param hourlyCompensations - The prepared compensation's hourly lines.\n * @returns `true` when any Overtime or Double-overtime line has hours greater than zero.\n * @internal\n */\nexport function hasExistingOvertimeHours(\n hourlyCompensations: PayrollEmployeeCompensationsType['hourlyCompensations'] | undefined,\n): boolean {\n return (hourlyCompensations ?? []).some(\n compensation =>\n (compensation.name === COMPENSATION_NAME_OVERTIME ||\n compensation.name === COMPENSATION_NAME_DOUBLE_OVERTIME) &&\n parseFloat(compensation.hours ?? '0') > 0,\n )\n}\n\n/**\n * Whether a line's `breakdowns` exactly cover every workweek in `workweeks`\n * (each workweek has a breakdown entry matching both its start and end date).\n */\nfunction lineBreakdownsMatchWorkweeks(\n breakdowns: Array<{ startDate?: RFCDate; endDate?: RFCDate }> | undefined,\n workweeks: NormalizedWorkweek[],\n): boolean {\n if (!breakdowns || breakdowns.length === 0) return false\n return workweeks.every(workweek =>\n breakdowns.some(\n breakdown =>\n breakdown.startDate?.toString() === workweek.startDate &&\n breakdown.endDate?.toString() === workweek.endDate,\n ),\n )\n}\n\n/**\n * Whether any of the employee's hourly-compensation lines already carries a\n * real, per-workweek `breakdowns` array that exactly tiles the current pay\n * period's workweeks.\n *\n * @remarks\n * Used alongside {@link hasExistingOvertimeHours} to default the single\n * `withOvertime` flag: an employee whose hours are already broken down by\n * workweek (e.g. a previous edit entered real per-week values) starts with the\n * workweek split shown, seeded from those breakdowns rather than from a blank\n * or first-cell-only guess. See {@link buildWeekMap}, which applies the same\n * per-line check to decide each line's population mode.\n *\n * @param hourlyCompensations - The prepared compensation's hourly lines.\n * @param workweeks - Normalized workweeks for the pay period.\n * @returns `true` when at least one hourly line's breakdowns cover every workweek.\n * @internal\n */\nexport function hasBreakdownsMatchingWorkweeks(\n hourlyCompensations: PayrollEmployeeCompensationsType['hourlyCompensations'] | undefined,\n workweeks: NormalizedWorkweek[],\n): boolean {\n return (hourlyCompensations ?? []).some(compensation =>\n lineBreakdownsMatchWorkweeks(compensation.breakdowns, workweeks),\n )\n}\n\n/**\n * Trims an API decimal string (e.g. `\"40.000\"`, `\"500.00\"`) to a clean editable\n * value (`\"40\"`, `\"500\"`), preserving real fractional parts (`\"40.5\"`). A blank\n * or non-numeric value returns `''` (meaning \"not provided\").\n */\nfunction formatAmountInput(value: string | null | undefined): string {\n if (value == null || value === '') return ''\n const parsed = parseFloat(value)\n return Number.isNaN(parsed) ? '' : parsed.toString()\n}\n\n/**\n * Seeds a cell from a line's total: same as {@link formatAmountInput} except a\n * zero total yields `''` rather than `\"0\"`. A line whose total is zero (e.g. an\n * Overtime line with no overtime) should render as a blank cell the user can\n * fill in, not a pre-filled `0` — and a pre-filled `0` would also count as a\n * filled cell, tripping the per-row \"fill every workweek\" check for a line the\n * user never actually touched. Only used for total-seeded cells, never for real\n * per-week breakdown values (a genuine `0` breakdown must survive to keep a\n * matched split's tiling intact).\n */\nfunction formatSeededTotal(value: string | null | undefined): string {\n const formatted = formatAmountInput(value)\n return formatted === '0' ? '' : formatted\n}\n\n/**\n * Builds one job+name line's week map in one of three shapes, gated by\n * `isSplit` (`workweeks.length > 1 && isOvertimeEligible && withOvertime`):\n *\n * - Collapsed (`isSplit` false): a single key — the first workweek's start —\n * holding the total. No key is emitted for any other workweek, which is what\n * keeps a collapsed row's per-row validation a no-op (see\n * {@link createPayrollEditEmployeeSchema}).\n * - Split, breakdowns match ({@link hasBreakdownsMatchingWorkweeks} true for\n * this line): one key per workweek, each seeded from its real breakdown value.\n * - Split, no matching breakdowns: one key per workweek, with only the first\n * seeded (from the total) and the rest left blank — never auto-distributed,\n * so the user must fill them in (enforced by the schema's per-row check).\n */\nfunction buildWeekMap(\n workweeks: NormalizedWorkweek[],\n total: string | undefined,\n breakdowns:\n Array<{ startDate?: RFCDate; endDate?: RFCDate; hours?: string; amount?: string }> | undefined,\n isSplit: boolean,\n): Record<string, string> {\n const firstWorkweekStart = workweeks[0]?.startDate ?? ''\n\n if (!isSplit) {\n return { [firstWorkweekStart]: formatSeededTotal(total) }\n }\n\n const weekMap: Record<string, string> = {}\n if (lineBreakdownsMatchWorkweeks(breakdowns, workweeks)) {\n workweeks.forEach(workweek => {\n const breakdown = breakdowns?.find(\n entry => entry.startDate?.toString() === workweek.startDate,\n )\n weekMap[workweek.startDate] = formatAmountInput(breakdown?.hours ?? breakdown?.amount)\n })\n } else {\n workweeks.forEach((workweek, index) => {\n weekMap[workweek.startDate] = index === 0 ? formatSeededTotal(total) : ''\n })\n }\n return weekMap\n}\n\n/**\n * Derives the form's default values from the employee's prepared compensation.\n *\n * @remarks\n * Hourly and additional earnings are expanded into per-workweek maps via\n * {@link buildWeekMap}: collapsed to the total when not split, seeded from real\n * breakdowns or first-cell-only otherwise. Time off, final payout,\n * reimbursements, and payment method are read straight off the compensation.\n *\n * @param employeeCompensation - The employee's prepared compensation, if loaded.\n * @param workweeks - Normalized workweeks for the pay period.\n * @param withOvertime - The single, form-wide overtime-mode flag (see {@link hasExistingOvertimeHours}, {@link hasBreakdownsMatchingWorkweeks}, `actions.addOvertime`). Gates splitting alongside `isOvertimeEligible`.\n * @returns Default {@link PayrollEditEmployeeFormData} for `useForm`.\n * @internal\n */\nexport function derivePayrollEditEmployeeDefaults(\n employeeCompensation: PayrollEmployeeCompensationsType | undefined,\n workweeks: NormalizedWorkweek[],\n hasDirectDepositSetup: boolean,\n overtimeEarningNames: Set<string>,\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n fixedCompensations: FixedCompensationEntry[] = employeeCompensation?.fixedCompensations ?? [],\n): PayrollEditEmployeeFormData {\n // Only overtime-eligible employees split hours/earnings by workweek, and only\n // while the single `withOvertime` flag is on; everyone else renders (and\n // seeds) flat, even on a multi-workweek payroll.\n const isSplit = workweeks.length > 1 && isOvertimeEligible && withOvertime\n\n const hours: PayrollEditEmployeeFormData['hours'] = {}\n for (const compensation of employeeCompensation?.hourlyCompensations ?? []) {\n if (!compensation.jobUuid || !compensation.name) continue\n const jobHours = (hours[compensation.jobUuid] ??= {})\n jobHours[compensation.name] = buildWeekMap(\n workweeks,\n compensation.hours,\n compensation.breakdowns,\n isSplit,\n )\n }\n\n // Earnings whose earning type is included in the regular-rate-of-pay overtime\n // calculation stay workweek-breakdown; the rest are flat and land in `overtimeExcludedEarnings`.\n // The hook owns this bucketing so the UI just renders each section.\n const overtimeIncludedEarnings: PayrollEditEmployeeFormData['overtimeIncludedEarnings'] = {}\n const overtimeExcludedEarnings: PayrollEditEmployeeFormData['overtimeExcludedEarnings'] = {}\n for (const compensation of fixedCompensations) {\n if (!compensation.jobUuid || !compensation.name) continue\n if (overtimeEarningNames.has(compensation.name)) {\n const jobEarnings = (overtimeIncludedEarnings[compensation.jobUuid] ??= {})\n jobEarnings[compensation.name] = buildWeekMap(\n workweeks,\n compensation.amount,\n compensation.breakdowns,\n isSplit,\n )\n } else {\n const jobOther = (overtimeExcludedEarnings[compensation.jobUuid] ??= {})\n jobOther[compensation.name] = formatAmountInput(compensation.amount)\n }\n }\n\n const timeOff: PayrollEditEmployeeFormData['timeOff'] = {}\n const finalPayout: PayrollEditEmployeeFormData['finalPayout'] = {}\n for (const entry of employeeCompensation?.paidTimeOff ?? []) {\n if (!entry.name) continue\n timeOff[entry.name] = formatAmountInput(entry.hours)\n finalPayout[entry.name] = formatAmountInput(entry.finalPayoutUnusedHoursInput)\n }\n\n const reimbursements: PayrollEditEmployeeFormData['reimbursements'] = (\n employeeCompensation?.reimbursements ?? []\n ).map(reimbursement => ({\n uuid: reimbursement.uuid ?? null,\n description: reimbursement.description ?? '',\n amount: reimbursement.amount,\n recurring: reimbursement.recurring ?? false,\n }))\n\n return {\n hours,\n overtimeIncludedEarnings,\n overtimeExcludedEarnings,\n timeOff,\n finalPayout,\n reimbursements,\n reimbursementDraft: { description: '', amount: '' },\n paymentMethod: resolvePaymentMethod(employeeCompensation?.paymentMethod, hasDirectDepositSetup),\n }\n}\n\n/**\n * Resolves the default payment method, mirroring the stable component (#2683):\n * an employee with no direct deposit set up defaults to (and is forced to)\n * `Check`, even when the prepared payroll carried `Direct Deposit` or nothing.\n * `Historical` is treated as unset. The result is always `Direct Deposit` or\n * `Check` — never `Historical` — since those are the only values the update\n * endpoint accepts.\n */\nfunction resolvePaymentMethod(\n paymentMethod: string | null | undefined,\n hasDirectDepositSetup: boolean,\n): PayrollUpdatePaymentMethod {\n if (paymentMethod === PayrollUpdatePaymentMethod.Check) return PayrollUpdatePaymentMethod.Check\n if (paymentMethod === PayrollUpdatePaymentMethod.DirectDeposit && hasDirectDepositSetup) {\n return PayrollUpdatePaymentMethod.DirectDeposit\n }\n return hasDirectDepositSetup\n ? PayrollUpdatePaymentMethod.DirectDeposit\n : PayrollUpdatePaymentMethod.Check\n}\n\nfunction originalTotals<T extends { jobUuid?: string; name?: string }>(\n compensations: T[] | undefined,\n selectTotal: (compensation: T) => string | null | undefined,\n): Map<string, string> {\n const totals = new Map<string, string>()\n for (const compensation of compensations ?? []) {\n if (!compensation.jobUuid || !compensation.name) continue\n totals.set(`${compensation.jobUuid}|${compensation.name}`, selectTotal(compensation) ?? '')\n }\n return totals\n}\n\n// Precision of the per-workweek values being summed: dollar amounts carry cents,\n// hours up to six places.\nconst AMOUNT_DECIMALS = 2\nconst HOURS_DECIMALS = 6\n\n/**\n * Sums per-workweek input values in integer minor units, then scales back.\n *\n * @remarks\n * Each value is already bounded to `decimals` places, so scaling it to an\n * integer (cents for amounts, millionths for hours) and summing those integers\n * is exact. Float-accumulating the decimals directly and rounding at the end\n * would instead leak binary error into the wire value (e.g. `0.1 + 0.2` →\n * `\"0.30000000000000004\"`), which the payroll API should never receive.\n */\nfunction sumWeekValues(\n weekMap: Record<string, string>,\n workweeks: NormalizedWorkweek[],\n decimals: number,\n): string {\n const factor = 10 ** decimals\n const totalMinorUnits = workweeks.reduce((total, workweek) => {\n const value = parseFloat(weekMap[workweek.startDate] ?? '0') || 0\n return total + Math.round(value * factor)\n }, 0)\n return String(totalMinorUnits / factor)\n}\n\n/**\n * Returns a copy of one week-mapped section (`hours` or `overtimeIncludedEarnings`)\n * with every cell that loaded with a value but is now empty coerced to `\"0\"`, so a\n * user who clears a pre-filled workweek input submits an explicit zero for it rather\n * than leaving it blank. \"Loaded with a value\" means the matching cell in `defaults`\n * is non-empty; a cell that was blank at load is left untouched (it stays subject to\n * the per-row \"fill every workweek\" validation). Returns `null` when nothing changed,\n * so the caller can skip a redundant form update.\n */\nfunction zeroFillClearedSection(\n current: Record<string, Record<string, Record<string, string>>>,\n defaults: Record<string, Record<string, Record<string, string>>>,\n): Record<string, Record<string, Record<string, string>>> | null {\n let changed = false\n const next: Record<string, Record<string, Record<string, string>>> = {}\n for (const [jobUuid, names] of Object.entries(current)) {\n const nextNames: Record<string, Record<string, string>> = {}\n for (const [name, weekMap] of Object.entries(names)) {\n const nextWeekMap: Record<string, string> = {}\n for (const [week, value] of Object.entries(weekMap)) {\n const loaded = defaults[jobUuid]?.[name]?.[week]\n if (value === '' && loaded != null && loaded !== '') {\n nextWeekMap[week] = '0'\n changed = true\n } else {\n nextWeekMap[week] = value\n }\n }\n nextNames[name] = nextWeekMap\n }\n next[jobUuid] = nextNames\n }\n return changed ? next : null\n}\n\n/**\n * Coerces cleared-from-loaded workweek cells to `\"0\"` across both week-mapped\n * sections (`hours`, `overtimeIncludedEarnings`).\n *\n * @remarks\n * Run just before submit: a workweek input that loaded with a value and was\n * cleared by the user should submit an explicit `0` for that cell (whether split\n * by workweek or collapsed to a single box), instead of falling back to the\n * original value or being blocked by the per-row completeness check. Cells that\n * were blank at load are untouched. Each returned section is present only when it\n * actually changed, so the caller can `setValue` selectively.\n *\n * @param current - The live form values.\n * @param defaults - The form's loaded defaults (the API-seeded baseline for the current split mode).\n * @returns The coerced `hours` and/or `overtimeIncludedEarnings` sections, each omitted when unchanged.\n * @internal\n */\nexport function zeroFillClearedWorkweekCells(\n current: Pick<PayrollEditEmployeeFormData, 'hours' | 'overtimeIncludedEarnings'>,\n defaults: Pick<PayrollEditEmployeeFormData, 'hours' | 'overtimeIncludedEarnings'>,\n): Partial<Pick<PayrollEditEmployeeFormData, 'hours' | 'overtimeIncludedEarnings'>> {\n const hours = zeroFillClearedSection(current.hours, defaults.hours)\n const overtimeIncludedEarnings = zeroFillClearedSection(\n current.overtimeIncludedEarnings,\n defaults.overtimeIncludedEarnings,\n )\n return {\n ...(hours ? { hours } : {}),\n ...(overtimeIncludedEarnings ? { overtimeIncludedEarnings } : {}),\n }\n}\n\n/**\n * Builds the `PayrollUpdate` employee-compensation payload from form values.\n *\n * @remarks\n * When the pay period spans a single workweek (or the employee isn't split by\n * workweek), totals are sent without `breakdowns`. When split, each hourly and\n * additional-earning line is decided independently — per line, not per job\n * (the API models breakdowns on each compensation line, not as a per-job\n * all-or-nothing unit):\n *\n * - A fully-filled line (every workweek cell has a value) sends `breakdowns`\n * tiling every workweek exactly, with the total equal to the sum of the\n * per-week values.\n * - An entirely blank line sends nothing for it — no `breakdowns`, no\n * fabricated `0`, no fabricated total — leaving it as the flat, untouched\n * value it already was.\n * - A partial line (some but not all cells filled) can never reach this\n * function: {@link createPayrollEditEmployeeSchema}'s per-row check blocks\n * submit until every cell in a touched row is filled.\n *\n * @param formData - Current parsed form values.\n * @param employeeCompensation - The prepared compensation, for identifying metadata (`version`, `employeeUuid`).\n * @param workweeks - Normalized workweeks for the pay period.\n * @param payrollCategory - The payroll category, gating itemized vs. off-cycle reimbursements.\n * @param isOvertimeEligible - Whether the employee is overtime-eligible (nonexempt family).\n * @param withOvertime - The single, form-wide overtime-mode flag. Gates splitting alongside `isOvertimeEligible` and `workweeks.length > 1`; when `false`, every line submits its flat (collapsed) value regardless of eligibility.\n * @returns The employee-compensation entry for the `PayrollUpdate` request body.\n * @internal\n */\nexport function buildPayrollUpdateEmployeeCompensation(\n formData: PayrollEditEmployeeFormOutputs,\n employeeCompensation: PayrollEmployeeCompensationsType | undefined,\n workweeks: NormalizedWorkweek[],\n payrollCategory: PayrollCategory,\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n): PayrollUpdateEmployeeCompensations {\n // Breakdowns are emitted only when the line is actually split by workweek:\n // multiple workweeks, an overtime-eligible employee, and `withOvertime` on.\n // This must match the field builder's gate so what renders and what submits\n // never drift.\n const isSplit = workweeks.length > 1 && isOvertimeEligible && withOvertime\n const hasValue = (value: string | undefined) => value != null && value !== ''\n const originalHours = originalTotals(\n employeeCompensation?.hourlyCompensations,\n comp => comp.hours,\n )\n const originalAmounts = originalTotals(\n employeeCompensation?.fixedCompensations,\n comp => comp.amount,\n )\n const isRowFilled = (weekMap: Record<string, string>) =>\n workweeks.every(workweek => hasValue(weekMap[workweek.startDate]))\n const collapsedValue = (\n jobUuid: string,\n name: string,\n weekMap: Record<string, string>,\n originals: Map<string, string>,\n ) => {\n const single = weekMap[workweeks[0]?.startDate ?? '']\n return hasValue(single) ? single! : (originals.get(`${jobUuid}|${name}`) ?? '0')\n }\n\n const hourlyCompensations = Object.entries(formData.hours).flatMap(([jobUuid, names]) =>\n Object.entries(names).flatMap(([name, weekMap]) => {\n if (!isSplit) {\n return [{ jobUuid, name, hours: collapsedValue(jobUuid, name, weekMap, originalHours) }]\n }\n if (!isRowFilled(weekMap)) return []\n return [\n {\n jobUuid,\n name,\n hours: sumWeekValues(weekMap, workweeks, HOURS_DECIMALS),\n breakdowns: workweeks.map(workweek => ({\n startDate: new RFCDate(workweek.startDate),\n endDate: new RFCDate(workweek.endDate),\n hours: weekMap[workweek.startDate]!,\n })),\n },\n ]\n }),\n )\n\n const breakdownEarnings = Object.entries(formData.overtimeIncludedEarnings).flatMap(\n ([jobUuid, names]) =>\n Object.entries(names).flatMap(([name, weekMap]) => {\n if (!isSplit) {\n return [\n { jobUuid, name, amount: collapsedValue(jobUuid, name, weekMap, originalAmounts) },\n ]\n }\n if (!isRowFilled(weekMap)) return []\n return [\n {\n jobUuid,\n name,\n amount: sumWeekValues(weekMap, workweeks, AMOUNT_DECIMALS),\n breakdowns: workweeks.map(workweek => ({\n startDate: new RFCDate(workweek.startDate),\n endDate: new RFCDate(workweek.endDate),\n amount: weekMap[workweek.startDate]!,\n })),\n },\n ]\n }),\n )\n\n // Non-overtime earnings never carry breakdowns; they are sent as flat totals.\n const flatEarnings = Object.entries(formData.overtimeExcludedEarnings).flatMap(\n ([jobUuid, names]) =>\n Object.entries(names).map(([name, amount]) => ({\n jobUuid,\n name,\n amount: hasValue(amount) ? amount : (originalAmounts.get(`${jobUuid}|${name}`) ?? '0'),\n })),\n )\n\n const fixedCompensations = [...breakdownEarnings, ...flatEarnings]\n\n const isDismissal = payrollCategory === PayrollCategory.Dismissal\n const paidTimeOff = Object.entries(formData.timeOff).map(([name, value]) => ({\n name,\n hours: value || '0',\n ...(isDismissal && formData.finalPayout[name] != null\n ? { finalPayoutUnusedHoursInput: formData.finalPayout[name] || '0' }\n : {}),\n }))\n\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n\n return {\n employeeUuid: employeeCompensation?.employeeUuid,\n version: employeeCompensation?.version as string | undefined,\n excluded: employeeCompensation?.excluded,\n memo: employeeCompensation?.memo || undefined,\n ...(formData.paymentMethod ? { paymentMethod: formData.paymentMethod } : {}),\n hourlyCompensations,\n fixedCompensations,\n paidTimeOff,\n ...(usesItemizedReimbursements\n ? { reimbursements: cleanupReimbursements(formData.reimbursements) }\n : {}),\n }\n}\n"],"names":["normalizeWorkweeks","workweeks","payPeriod","normalized","week","SDKInternalError","collectOvertimeEarningNames","earningTypeList","names","earningType","resolveEditableFixedCompensations","existingFixedCompensations","fixedCompensationTypes","primaryJobUuid","flsaStatus","merged","FlsaStatus","compensationType","name","EXCLUDED_ADDITIONAL_EARNINGS","entry","a","b","hasExistingOvertimeHours","hourlyCompensations","compensation","COMPENSATION_NAME_OVERTIME","COMPENSATION_NAME_DOUBLE_OVERTIME","lineBreakdownsMatchWorkweeks","breakdowns","breakdown","workweek","hasBreakdownsMatchingWorkweeks","formatAmountInput","value","parsed","formatSeededTotal","formatted","buildWeekMap","total","isSplit","firstWorkweekStart","weekMap","index","derivePayrollEditEmployeeDefaults","employeeCompensation","hasDirectDepositSetup","overtimeEarningNames","isOvertimeEligible","withOvertime","fixedCompensations","hours","jobHours","overtimeIncludedEarnings","overtimeExcludedEarnings","jobEarnings","jobOther","timeOff","finalPayout","reimbursements","reimbursement","resolvePaymentMethod","paymentMethod","PayrollUpdatePaymentMethod","originalTotals","compensations","selectTotal","totals","AMOUNT_DECIMALS","HOURS_DECIMALS","sumWeekValues","decimals","factor","totalMinorUnits","zeroFillClearedSection","current","defaults","changed","next","jobUuid","nextNames","nextWeekMap","loaded","zeroFillClearedWorkweekCells","buildPayrollUpdateEmployeeCompensation","formData","payrollCategory","hasValue","originalHours","comp","originalAmounts","isRowFilled","collapsedValue","originals","single","RFCDate","breakdownEarnings","flatEarnings","amount","isDismissal","PayrollCategory","paidTimeOff","usesItemizedReimbursements","isOffCyclePayroll","cleanupReimbursements"],"mappings":";;;;;;AAmDO,SAASA,EACdC,GACAC,GACsB;AACtB,QAAMC,KAAcF,KAAa,CAAA,GAAI;AAAA,IAAQ,OAC3CG,EAAK,aAAaA,EAAK,UACnB,CAAC,EAAE,WAAWA,EAAK,UAAU,SAAA,GAAY,SAASA,EAAK,QAAQ,WAAS,CAAG,IAC3E,CAAA;AAAA,E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AAA0B;AAAA,IACA,aAAAmD;AAAA,IACA,GAAIC,IACA,EAAE,gBAAgBE,EAAsBnB,EAAS,cAAc,MAC/D,CAAA;AAAA,EAAC;AAET;"}
1
+ {"version":3,"file":"payrollEditEmployeeHelpers.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/payrollEditEmployeeHelpers.ts"],"sourcesContent":["import type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { EarningTypeList } from '@gusto/embedded-api/models/components/earningtypelist'\nimport {\n PayrollUpdatePaymentMethod,\n type PayrollUpdateEmployeeCompensations,\n} from '@gusto/embedded-api/models/components/payrollupdate'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport type {\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFormOutputs,\n} from './payrollEditEmployeeSchema'\nimport { PayrollCategory, isOffCyclePayroll } from '@/components/Payroll/payrollTypes'\nimport { cleanupReimbursements } from '@/components/Payroll/helpers'\nimport { SDKInternalError } from '@/types/sdkError'\nimport {\n COMPENSATION_NAME_DOUBLE_OVERTIME,\n COMPENSATION_NAME_OVERTIME,\n EXCLUDED_ADDITIONAL_EARNINGS,\n FlsaStatus,\n} from '@/shared/constants'\n\n/** One fixed-compensation line off the prepared compensation. */\ntype FixedCompensationEntry = NonNullable<\n PayrollEmployeeCompensationsType['fixedCompensations']\n>[number]\n\n/**\n * Normalized form of a workweek: the API exposes\n * `{ startDate?: RFCDate; endDate?: RFCDate }`, but the hook keys week-maps by\n * `YYYY-MM-DD` strings and builds breakdowns from them, so both boundaries are\n * required strings here. Surfaced on the hook's `data.workweeks` so the UI can\n * label each per-workweek column without re-parsing the raw API workweeks.\n *\n * @internal\n */\nexport interface NormalizedWorkweek {\n startDate: string\n endDate: string\n}\n\n/**\n * Normalizes the prepared payroll's top-level `workweeks` into\n * {@link NormalizedWorkweek} boundary strings, falling back to a single\n * pay-period-spanning workweek when the API returns no workweek boundaries.\n *\n * @param workweeks - The prepared payroll's top-level `workweeks` (RFCDate boundaries), possibly `null`.\n * @param payPeriod - The prepared payroll's `payPeriod`, used as the single-workweek fallback.\n * @returns One entry per workweek; a single entry spanning the pay period when none are supplied.\n * @throws SDKInternalError when neither workweeks nor a pay period are present (a malformed prepared payroll).\n * @internal\n */\nexport function normalizeWorkweeks(\n workweeks: Array<{ startDate?: RFCDate; endDate?: RFCDate }> | null | undefined,\n payPeriod: { startDate?: string | null; endDate?: string | null } | undefined,\n): NormalizedWorkweek[] {\n const normalized = (workweeks ?? []).flatMap(week =>\n week.startDate && week.endDate\n ? [{ startDate: week.startDate.toString(), endDate: week.endDate.toString() }]\n : [],\n )\n\n if (normalized.length > 0) {\n return normalized\n }\n\n if (payPeriod?.startDate && payPeriod.endDate) {\n return [{ startDate: payPeriod.startDate, endDate: payPeriod.endDate }]\n }\n\n // A prepared payroll always carries a pay period, so reaching here means the\n // response was malformed. Fail loud rather than build an empty, mis-keyed form\n // that could submit an employee's pay against a blank workweek.\n throw new SDKInternalError('Prepared payroll has no workweeks or pay period to derive from')\n}\n\n/**\n * Collects the names of earning types included in the regular-rate-of-pay\n * overtime calculation. These earnings render in the workweek-breakdown\n * additional-earnings section; all others fall into the flat `overtimeExcludedEarnings` section.\n *\n * @param earningTypeList - The company's default and custom earning types.\n * @returns A set of earning-type names with `includedInOvertimePay` set.\n * @internal\n */\nexport function collectOvertimeEarningNames(\n earningTypeList: EarningTypeList | undefined,\n): Set<string> {\n const names = new Set<string>()\n for (const earningType of [\n ...(earningTypeList?.default ?? []),\n ...(earningTypeList?.custom ?? []),\n ]) {\n if (earningType.name && earningType.includedInOvertimePay) {\n names.add(earningType.name)\n }\n }\n return names\n}\n\n/**\n * Merges the employee's existing fixed compensations with a blank placeholder for\n * every payroll fixed-compensation type they don't yet have, mirroring the stable editor\n * (`getAdditionalEarningsCompensations`). This is what lets the editor surface an\n * empty input for Bonus, Commission, etc. even when the prepared payroll carries\n * no fixed compensations. Placeholders attach to the primary job and carry no\n * amount (blank), so an untouched earning submits as zero without altering pay.\n *\n * @remarks\n * Owners (FLSA status `Owner`) never receive placeholders. Earning types that are\n * handled elsewhere or never shown as additional earnings\n * ({@link EXCLUDED_ADDITIONAL_EARNINGS}) and inactive types are skipped. The\n * result is sorted alphabetically by name. The regular-rate-of-pay split between\n * additional earnings and `overtimeExcludedEarnings` happens downstream via `overtimeEarningNames`;\n * this helper only decides which earning lines exist.\n *\n * @param existingFixedCompensations - The prepared compensation's fixed compensations.\n * @param fixedCompensationTypes - The prepared payroll's `fixedCompensationTypes` (the same source the stable editor uses).\n * @param primaryJobUuid - The employee's primary job UUID; placeholders attach here.\n * @param flsaStatus - The employee's FLSA status; owners get no placeholders.\n * @returns The merged, filtered, alphabetically sorted fixed-compensation lines.\n * @internal\n */\nexport function resolveEditableFixedCompensations(\n existingFixedCompensations: FixedCompensationEntry[] | undefined,\n fixedCompensationTypes: Array<{ name?: string | null }> | undefined,\n primaryJobUuid: string | undefined,\n flsaStatus: string | undefined,\n): FixedCompensationEntry[] {\n const merged: FixedCompensationEntry[] = [...(existingFixedCompensations ?? [])]\n\n if (flsaStatus !== FlsaStatus.OWNER && primaryJobUuid) {\n for (const compensationType of fixedCompensationTypes ?? []) {\n const name = compensationType.name\n if (!name) continue\n if (EXCLUDED_ADDITIONAL_EARNINGS.includes(name)) continue\n const exists = merged.some(entry => entry.name?.toLowerCase() === name.toLowerCase())\n if (!exists) merged.push({ name, jobUuid: primaryJobUuid })\n }\n }\n\n return merged\n .filter(entry => entry.name && !EXCLUDED_ADDITIONAL_EARNINGS.includes(entry.name))\n .sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''))\n}\n\n/**\n * Whether the employee's prepared compensation already carries non-zero\n * Overtime or Double-overtime hours.\n *\n * @remarks\n * Used to default the single `withOvertime` flag: an employee who already\n * has real overtime hours starts with the workweek split shown rather than\n * requiring an extra click to see data that's already there.\n *\n * @param hourlyCompensations - The prepared compensation's hourly lines.\n * @returns `true` when any Overtime or Double-overtime line has hours greater than zero.\n * @internal\n */\nexport function hasExistingOvertimeHours(\n hourlyCompensations: PayrollEmployeeCompensationsType['hourlyCompensations'] | undefined,\n): boolean {\n return (hourlyCompensations ?? []).some(\n compensation =>\n (compensation.name === COMPENSATION_NAME_OVERTIME ||\n compensation.name === COMPENSATION_NAME_DOUBLE_OVERTIME) &&\n parseFloat(compensation.hours ?? '0') > 0,\n )\n}\n\n/**\n * Whether a line's `breakdowns` exactly cover every workweek in `workweeks`\n * (each workweek has a breakdown entry matching both its start and end date).\n */\nfunction lineBreakdownsMatchWorkweeks(\n breakdowns: Array<{ startDate?: RFCDate; endDate?: RFCDate }> | undefined,\n workweeks: NormalizedWorkweek[],\n): boolean {\n if (!breakdowns || breakdowns.length === 0) return false\n return workweeks.every(workweek =>\n breakdowns.some(\n breakdown =>\n breakdown.startDate?.toString() === workweek.startDate &&\n breakdown.endDate?.toString() === workweek.endDate,\n ),\n )\n}\n\n/**\n * Whether any of the employee's hourly-compensation lines already carries a\n * real, per-workweek `breakdowns` array that exactly tiles the current pay\n * period's workweeks.\n *\n * @remarks\n * Used alongside {@link hasExistingOvertimeHours} to default the single\n * `withOvertime` flag: an employee whose hours are already broken down by\n * workweek (e.g. a previous edit entered real per-week values) starts with the\n * workweek split shown, seeded from those breakdowns rather than from a blank\n * or first-cell-only guess. See {@link buildWeekMap}, which applies the same\n * per-line check to decide each line's population mode.\n *\n * @param hourlyCompensations - The prepared compensation's hourly lines.\n * @param workweeks - Normalized workweeks for the pay period.\n * @returns `true` when at least one hourly line's breakdowns cover every workweek.\n * @internal\n */\nexport function hasBreakdownsMatchingWorkweeks(\n hourlyCompensations: PayrollEmployeeCompensationsType['hourlyCompensations'] | undefined,\n workweeks: NormalizedWorkweek[],\n): boolean {\n return (hourlyCompensations ?? []).some(compensation =>\n lineBreakdownsMatchWorkweeks(compensation.breakdowns, workweeks),\n )\n}\n\n/**\n * Trims an API decimal string (e.g. `\"40.000\"`, `\"500.00\"`) to a clean editable\n * value (`\"40\"`, `\"500\"`), preserving real fractional parts (`\"40.5\"`). A blank\n * or non-numeric value returns `''` (meaning \"not provided\").\n */\nfunction formatAmountInput(value: string | null | undefined): string {\n if (value == null || value === '') return ''\n const parsed = parseFloat(value)\n return Number.isNaN(parsed) ? '' : parsed.toString()\n}\n\n/**\n * Seeds a cell from a line's total: same as {@link formatAmountInput} except a\n * zero total yields `''` rather than `\"0\"`. A line whose total is zero (e.g. an\n * Overtime line with no overtime) should render as a blank cell the user can\n * fill in, not a pre-filled `0` — and a pre-filled `0` would also count as a\n * filled cell, tripping the per-row \"fill every workweek\" check for a line the\n * user never actually touched. Only used for total-seeded cells, never for real\n * per-week breakdown values (a genuine `0` breakdown must survive to keep a\n * matched split's tiling intact).\n */\nfunction formatSeededTotal(value: string | null | undefined): string {\n const formatted = formatAmountInput(value)\n return formatted === '0' ? '' : formatted\n}\n\n/**\n * Builds one job+name line's week map in one of three shapes, gated by\n * `isSplit` (`workweeks.length > 1 && isOvertimeEligible && withOvertime`):\n *\n * - Collapsed (`isSplit` false): a single key — the first workweek's start —\n * holding the total. No key is emitted for any other workweek, which is what\n * keeps a collapsed row's per-row validation a no-op (see\n * {@link createPayrollEditEmployeeSchema}).\n * - Split, breakdowns match ({@link hasBreakdownsMatchingWorkweeks} true for\n * this line): one key per workweek, each seeded from its real breakdown value.\n * - Split, no matching breakdowns: one key per workweek, with only the first\n * seeded (from the total) and the rest left blank — never auto-distributed,\n * so the user must fill them in (enforced by the schema's per-row check).\n */\nfunction buildWeekMap(\n workweeks: NormalizedWorkweek[],\n total: string | undefined,\n breakdowns:\n Array<{ startDate?: RFCDate; endDate?: RFCDate; hours?: string; amount?: string }> | undefined,\n isSplit: boolean,\n): Record<string, string> {\n const firstWorkweekStart = workweeks[0]?.startDate ?? ''\n\n if (!isSplit) {\n return { [firstWorkweekStart]: formatSeededTotal(total) }\n }\n\n const weekMap: Record<string, string> = {}\n if (lineBreakdownsMatchWorkweeks(breakdowns, workweeks)) {\n workweeks.forEach(workweek => {\n const breakdown = breakdowns?.find(\n entry => entry.startDate?.toString() === workweek.startDate,\n )\n weekMap[workweek.startDate] = formatAmountInput(breakdown?.hours ?? breakdown?.amount)\n })\n } else {\n workweeks.forEach((workweek, index) => {\n weekMap[workweek.startDate] = index === 0 ? formatSeededTotal(total) : ''\n })\n }\n return weekMap\n}\n\n/**\n * Derives the form's default values from the employee's prepared compensation.\n *\n * @remarks\n * Hourly and additional earnings are expanded into per-workweek maps via\n * {@link buildWeekMap}: collapsed to the total when not split, seeded from real\n * breakdowns or first-cell-only otherwise. Time off, final payout,\n * reimbursements, and payment method are read straight off the compensation.\n *\n * @param employeeCompensation - The employee's prepared compensation, if loaded.\n * @param workweeks - Normalized workweeks for the pay period.\n * @param withOvertime - The single, form-wide overtime-mode flag (see {@link hasExistingOvertimeHours}, {@link hasBreakdownsMatchingWorkweeks}, `actions.addOvertime`). Gates splitting alongside `isOvertimeEligible`.\n * @returns Default {@link PayrollEditEmployeeFormData} for `useForm`.\n * @internal\n */\nexport function derivePayrollEditEmployeeDefaults(\n employeeCompensation: PayrollEmployeeCompensationsType | undefined,\n workweeks: NormalizedWorkweek[],\n hasDirectDepositSetup: boolean,\n overtimeEarningNames: Set<string>,\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n fixedCompensations: FixedCompensationEntry[] = employeeCompensation?.fixedCompensations ?? [],\n): PayrollEditEmployeeFormData {\n // Only overtime-eligible employees split hours/earnings by workweek, and only\n // while the single `withOvertime` flag is on; everyone else renders (and\n // seeds) flat, even on a multi-workweek payroll.\n const isSplit = workweeks.length > 1 && isOvertimeEligible && withOvertime\n\n const hours: PayrollEditEmployeeFormData['hours'] = {}\n for (const compensation of employeeCompensation?.hourlyCompensations ?? []) {\n if (!compensation.jobUuid || !compensation.name) continue\n const jobHours = (hours[compensation.jobUuid] ??= {})\n jobHours[compensation.name] = buildWeekMap(\n workweeks,\n compensation.hours,\n compensation.breakdowns,\n isSplit,\n )\n }\n\n // Earnings whose earning type is included in the regular-rate-of-pay overtime\n // calculation stay workweek-breakdown; the rest are flat and land in `overtimeExcludedEarnings`.\n // The hook owns this bucketing so the UI just renders each section.\n const overtimeIncludedEarnings: PayrollEditEmployeeFormData['overtimeIncludedEarnings'] = {}\n const overtimeExcludedEarnings: PayrollEditEmployeeFormData['overtimeExcludedEarnings'] = {}\n for (const compensation of fixedCompensations) {\n if (!compensation.jobUuid || !compensation.name) continue\n if (overtimeEarningNames.has(compensation.name)) {\n const jobEarnings = (overtimeIncludedEarnings[compensation.jobUuid] ??= {})\n jobEarnings[compensation.name] = buildWeekMap(\n workweeks,\n compensation.amount,\n compensation.breakdowns,\n isSplit,\n )\n } else {\n const jobOther = (overtimeExcludedEarnings[compensation.jobUuid] ??= {})\n jobOther[compensation.name] = formatAmountInput(compensation.amount)\n }\n }\n\n const timeOff: PayrollEditEmployeeFormData['timeOff'] = {}\n const finalPayout: PayrollEditEmployeeFormData['finalPayout'] = {}\n for (const entry of employeeCompensation?.paidTimeOff ?? []) {\n if (!entry.name) continue\n timeOff[entry.name] = formatAmountInput(entry.hours)\n finalPayout[entry.name] = formatAmountInput(entry.finalPayoutUnusedHoursInput)\n }\n\n const reimbursements: PayrollEditEmployeeFormData['reimbursements'] = (\n employeeCompensation?.reimbursements ?? []\n ).map(reimbursement => ({\n uuid: reimbursement.uuid ?? null,\n description: reimbursement.description ?? '',\n amount: reimbursement.amount,\n recurring: reimbursement.recurring ?? false,\n }))\n\n return {\n hours,\n overtimeIncludedEarnings,\n overtimeExcludedEarnings,\n timeOff,\n finalPayout,\n reimbursements,\n reimbursementDraft: { description: '', amount: '' },\n paymentMethod: resolvePaymentMethod(employeeCompensation?.paymentMethod, hasDirectDepositSetup),\n }\n}\n\n/**\n * Resolves the default payment method, mirroring the stable component (#2683):\n * an employee with no direct deposit set up defaults to (and is forced to)\n * `Check`, even when the prepared payroll carried `Direct Deposit` or nothing.\n * `Historical` is treated as unset. The result is always `Direct Deposit` or\n * `Check` — never `Historical` — since those are the only values the update\n * endpoint accepts.\n */\nfunction resolvePaymentMethod(\n paymentMethod: string | null | undefined,\n hasDirectDepositSetup: boolean,\n): PayrollUpdatePaymentMethod {\n if (paymentMethod === PayrollUpdatePaymentMethod.Check) return PayrollUpdatePaymentMethod.Check\n if (paymentMethod === PayrollUpdatePaymentMethod.DirectDeposit && hasDirectDepositSetup) {\n return PayrollUpdatePaymentMethod.DirectDeposit\n }\n return hasDirectDepositSetup\n ? PayrollUpdatePaymentMethod.DirectDeposit\n : PayrollUpdatePaymentMethod.Check\n}\n\nfunction originalTotals<T extends { jobUuid?: string; name?: string }>(\n compensations: T[] | undefined,\n selectTotal: (compensation: T) => string | null | undefined,\n): Map<string, string> {\n const totals = new Map<string, string>()\n for (const compensation of compensations ?? []) {\n if (!compensation.jobUuid || !compensation.name) continue\n totals.set(`${compensation.jobUuid}|${compensation.name}`, selectTotal(compensation) ?? '')\n }\n return totals\n}\n\n// Precision of the per-workweek values being summed: dollar amounts carry cents,\n// hours up to six places.\nconst AMOUNT_DECIMALS = 2\nconst HOURS_DECIMALS = 6\n\n/**\n * Sums per-workweek input values in integer minor units, then scales back.\n *\n * @remarks\n * Each value is already bounded to `decimals` places, so scaling it to an\n * integer (cents for amounts, millionths for hours) and summing those integers\n * is exact. Float-accumulating the decimals directly and rounding at the end\n * would instead leak binary error into the wire value (e.g. `0.1 + 0.2` →\n * `\"0.30000000000000004\"`), which the payroll API should never receive.\n */\nfunction sumWeekValues(\n weekMap: Record<string, string>,\n workweeks: NormalizedWorkweek[],\n decimals: number,\n): string {\n const factor = 10 ** decimals\n const totalMinorUnits = workweeks.reduce((total, workweek) => {\n const value = parseFloat(weekMap[workweek.startDate] ?? '0') || 0\n return total + Math.round(value * factor)\n }, 0)\n return String(totalMinorUnits / factor)\n}\n\n/**\n * Returns a copy of one week-mapped section (`hours` or `overtimeIncludedEarnings`)\n * with every cell that loaded with a value but is now empty coerced to `\"0\"`, so a\n * user who clears a pre-filled workweek input submits an explicit zero for it rather\n * than leaving it blank. \"Loaded with a value\" means the matching cell in `defaults`\n * is non-empty; a cell that was blank at load is left untouched (it stays subject to\n * the per-row \"fill every workweek\" validation). Returns `null` when nothing changed,\n * so the caller can skip a redundant form update.\n */\nfunction zeroFillClearedSection(\n current: Record<string, Record<string, Record<string, string>>>,\n defaults: Record<string, Record<string, Record<string, string>>>,\n): Record<string, Record<string, Record<string, string>>> | null {\n let changed = false\n const next: Record<string, Record<string, Record<string, string>>> = {}\n for (const [jobUuid, names] of Object.entries(current)) {\n const nextNames: Record<string, Record<string, string>> = {}\n for (const [name, weekMap] of Object.entries(names)) {\n const nextWeekMap: Record<string, string> = {}\n for (const [week, value] of Object.entries(weekMap)) {\n const loaded = defaults[jobUuid]?.[name]?.[week]\n if (value === '' && loaded != null && loaded !== '') {\n nextWeekMap[week] = '0'\n changed = true\n } else {\n nextWeekMap[week] = value\n }\n }\n nextNames[name] = nextWeekMap\n }\n next[jobUuid] = nextNames\n }\n return changed ? next : null\n}\n\n/**\n * Coerces cleared-from-loaded workweek cells to `\"0\"` across both week-mapped\n * sections (`hours`, `overtimeIncludedEarnings`).\n *\n * @remarks\n * Run just before submit: a workweek input that loaded with a value and was\n * cleared by the user should submit an explicit `0` for that cell (whether split\n * by workweek or collapsed to a single box), instead of falling back to the\n * original value or being blocked by the per-row completeness check. Cells that\n * were blank at load are untouched. Each returned section is present only when it\n * actually changed, so the caller can `setValue` selectively.\n *\n * @param current - The live form values.\n * @param defaults - The form's loaded defaults (the API-seeded baseline for the current split mode).\n * @returns The coerced `hours` and/or `overtimeIncludedEarnings` sections, each omitted when unchanged.\n * @internal\n */\nexport function zeroFillClearedWorkweekCells(\n current: Pick<PayrollEditEmployeeFormData, 'hours' | 'overtimeIncludedEarnings'>,\n defaults: Pick<PayrollEditEmployeeFormData, 'hours' | 'overtimeIncludedEarnings'>,\n): Partial<Pick<PayrollEditEmployeeFormData, 'hours' | 'overtimeIncludedEarnings'>> {\n const hours = zeroFillClearedSection(current.hours, defaults.hours)\n const overtimeIncludedEarnings = zeroFillClearedSection(\n current.overtimeIncludedEarnings,\n defaults.overtimeIncludedEarnings,\n )\n return {\n ...(hours ? { hours } : {}),\n ...(overtimeIncludedEarnings ? { overtimeIncludedEarnings } : {}),\n }\n}\n\n/**\n * Builds the `PayrollUpdate` employee-compensation payload from form values.\n *\n * @remarks\n * When the pay period spans a single workweek (or the employee isn't split by\n * workweek), totals are sent without `breakdowns`. When split, each hourly and\n * additional-earning line is decided independently — per line, not per job\n * (the API models breakdowns on each compensation line, not as a per-job\n * all-or-nothing unit):\n *\n * - A fully-filled line (every workweek cell has a value) sends `breakdowns`\n * tiling every workweek exactly, with the total equal to the sum of the\n * per-week values.\n * - An entirely blank line sends nothing for it — no `breakdowns`, no\n * fabricated `0`, no fabricated total — leaving it as the flat, untouched\n * value it already was.\n * - A partial line (some but not all cells filled) can never reach this\n * function: {@link createPayrollEditEmployeeSchema}'s per-row check blocks\n * submit until every cell in a touched row is filled.\n *\n * @param formData - Current parsed form values.\n * @param employeeCompensation - The prepared compensation, for identifying metadata (`version`, `employeeUuid`).\n * @param workweeks - Normalized workweeks for the pay period.\n * @param payrollCategory - The payroll category, gating itemized vs. off-cycle reimbursements.\n * @param isOvertimeEligible - Whether the employee is overtime-eligible (nonexempt family).\n * @param withOvertime - The single, form-wide overtime-mode flag. Gates splitting alongside `isOvertimeEligible` and `workweeks.length > 1`; when `false`, every line submits its flat (collapsed) value regardless of eligibility.\n * @returns The employee-compensation entry for the `PayrollUpdate` request body.\n * @internal\n */\nexport function buildPayrollUpdateEmployeeCompensation(\n formData: PayrollEditEmployeeFormOutputs,\n employeeCompensation: PayrollEmployeeCompensationsType | undefined,\n workweeks: NormalizedWorkweek[],\n payrollCategory: PayrollCategory,\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n): PayrollUpdateEmployeeCompensations {\n // Breakdowns are emitted only when the line is actually split by workweek:\n // multiple workweeks, an overtime-eligible employee, and `withOvertime` on.\n // This must match the field builder's gate so what renders and what submits\n // never drift.\n const isSplit = workweeks.length > 1 && isOvertimeEligible && withOvertime\n const hasValue = (value: string | undefined) => value != null && value !== ''\n const originalHours = originalTotals(\n employeeCompensation?.hourlyCompensations,\n comp => comp.hours,\n )\n const originalAmounts = originalTotals(\n employeeCompensation?.fixedCompensations,\n comp => comp.amount,\n )\n const isRowFilled = (weekMap: Record<string, string>) =>\n workweeks.every(workweek => hasValue(weekMap[workweek.startDate]))\n const collapsedValue = (\n jobUuid: string,\n name: string,\n weekMap: Record<string, string>,\n originals: Map<string, string>,\n ) => {\n const single = weekMap[workweeks[0]?.startDate ?? '']\n return hasValue(single) ? single! : (originals.get(`${jobUuid}|${name}`) ?? '0')\n }\n\n const hourlyCompensations = Object.entries(formData.hours).flatMap(([jobUuid, names]) =>\n Object.entries(names).flatMap(([name, weekMap]) => {\n if (!isSplit) {\n return [{ jobUuid, name, hours: collapsedValue(jobUuid, name, weekMap, originalHours) }]\n }\n if (!isRowFilled(weekMap)) return []\n return [\n {\n jobUuid,\n name,\n hours: sumWeekValues(weekMap, workweeks, HOURS_DECIMALS),\n breakdowns: workweeks.map(workweek => ({\n startDate: new RFCDate(workweek.startDate),\n endDate: new RFCDate(workweek.endDate),\n hours: weekMap[workweek.startDate]!,\n })),\n },\n ]\n }),\n )\n\n const breakdownEarnings = Object.entries(formData.overtimeIncludedEarnings).flatMap(\n ([jobUuid, names]) =>\n Object.entries(names).flatMap(([name, weekMap]) => {\n if (!isSplit) {\n return [\n { jobUuid, name, amount: collapsedValue(jobUuid, name, weekMap, originalAmounts) },\n ]\n }\n if (!isRowFilled(weekMap)) return []\n return [\n {\n jobUuid,\n name,\n amount: sumWeekValues(weekMap, workweeks, AMOUNT_DECIMALS),\n breakdowns: workweeks.map(workweek => ({\n startDate: new RFCDate(workweek.startDate),\n endDate: new RFCDate(workweek.endDate),\n amount: weekMap[workweek.startDate]!,\n })),\n },\n ]\n }),\n )\n\n // Non-overtime earnings never carry breakdowns; they are sent as flat totals.\n const flatEarnings = Object.entries(formData.overtimeExcludedEarnings).flatMap(\n ([jobUuid, names]) =>\n Object.entries(names).map(([name, amount]) => ({\n jobUuid,\n name,\n amount: hasValue(amount) ? amount : (originalAmounts.get(`${jobUuid}|${name}`) ?? '0'),\n })),\n )\n\n const fixedCompensations = [...breakdownEarnings, ...flatEarnings]\n\n const isDismissal = payrollCategory === PayrollCategory.Dismissal\n const paidTimeOff = Object.entries(formData.timeOff).map(([name, value]) => ({\n name,\n hours: value || '0',\n ...(isDismissal && formData.finalPayout[name] != null\n ? { finalPayoutUnusedHoursInput: formData.finalPayout[name] || '0' }\n : {}),\n }))\n\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n\n return {\n employeeUuid: employeeCompensation?.employeeUuid,\n version: employeeCompensation?.version as string | undefined,\n excluded: employeeCompensation?.excluded,\n memo: employeeCompensation?.memo || undefined,\n ...(formData.paymentMethod ? { paymentMethod: formData.paymentMethod } : {}),\n hourlyCompensations,\n fixedCompensations,\n paidTimeOff,\n ...(usesItemizedReimbursements\n ? { reimbursements: cleanupReimbursements(formData.reimbursements) }\n : {}),\n }\n}\n"],"names":["normalizeWorkweeks","workweeks","payPeriod","normalized","week","SDKInternalError","collectOvertimeEarningNames","earningTypeList","names","earningType","resolveEditableFixedCompensations","existingFixedCompensations","fixedCompensationTypes","primaryJobUuid","flsaStatus","merged","FlsaStatus","compensationType","name","EXCLUDED_ADDITIONAL_EARNINGS","entry","a","b","hasExistingOvertimeHours","hourlyCompensations","compensation","COMPENSATION_NAME_OVERTIME","COMPENSATION_NAME_DOUBLE_OVERTIME","lineBreakdownsMatchWorkweeks","breakdowns","breakdown","workweek","hasBreakdownsMatchingWorkweeks","formatAmountInput","value","parsed","formatSeededTotal","formatted","buildWeekMap","total","isSplit","firstWorkweekStart","weekMap","index","derivePayrollEditEmployeeDefaults","employeeCompensation","hasDirectDepositSetup","overtimeEarningNames","isOvertimeEligible","withOvertime","fixedCompensations","hours","jobHours","overtimeIncludedEarnings","overtimeExcludedEarnings","jobEarnings","jobOther","timeOff","finalPayout","reimbursements","reimbursement","resolvePaymentMethod","paymentMethod","PayrollUpdatePaymentMethod","originalTotals","compensations","selectTotal","totals","AMOUNT_DECIMALS","HOURS_DECIMALS","sumWeekValues","decimals","factor","totalMinorUnits","zeroFillClearedSection","current","defaults","changed","next","jobUuid","nextNames","nextWeekMap","loaded","zeroFillClearedWorkweekCells","buildPayrollUpdateEmployeeCompensation","formData","payrollCategory","hasValue","originalHours","comp","originalAmounts","isRowFilled","collapsedValue","originals","single","RFCDate","breakdownEarnings","flatEarnings","amount","isDismissal","PayrollCategory","paidTimeOff","usesItemizedReimbursements","isOffCyclePayroll","cleanupReimbursements"],"mappings":";;;;;;AAmDO,SAASA,EACdC,GACAC,GACsB;AACtB,QAAMC,KAAcF,KAAa,CAAA,GAAI;AAAA,IAAQ,OAC3CG,EAAK,aAAaA,EAAK,UACnB,CAAC,EAAE,WAAWA,EAAK,UAAU,SAAA,GAAY,SAASA,EAAK,QAAQ,WAAS,CAAG,IAC3E,CAAA;AAAA,EAAC;AAGP,MAAID,EAAW,SAAS;AACtB,WAAOA;AAGT,MAAID,GAAW,aAAaA,EAAU;AACpC,WAAO,CAAC,EAAE,WAAWA,EAAU,WAAW,SAASA,EAAU,SAAS;AAMxE,QAAM,IAAIG,EAAiB,gEAAgE;AAC7F;AAWO,SAASC,EACdC,GACa;AACb,QAAMC,wBAAY,IAAA;AAClB,aAAWC,KAAe;AAAA,IACxB,GAAIF,GAAiB,WAAW,CAAA;AAAA,IAChC,GAAIA,GAAiB,UAAU,CAAA;AAAA,EAAC;AAEhC,IAAIE,EAAY,QAAQA,EAAY,yBAClCD,EAAM,IAAIC,EAAY,IAAI;AAG9B,SAAOD;AACT;AAyBO,SAASE,EACdC,GACAC,GACAC,GACAC,GAC0B;AAC1B,QAAMC,IAAmC,CAAC,GAAIJ,KAA8B,EAAG;AAE/E,MAAIG,MAAeE,EAAW,SAASH;AACrC,eAAWI,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