@fabriktor/fx 0.0.123 → 0.0.124

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.
@@ -1,6 +1,6 @@
1
1
  import { isHTTPClientErr } from "@fabriktor/client";
2
2
  import { ColPayrollsPayrolls, ColPayrollsHourBanks, ColPayrollsPayables, ColPayrollsAdjustments, ColPayrollsAdjustmentFolders, ColPayrollsPayConfigs, ColPayrollsEmployeePayConfigs, ColPayrollsAdjustmentRecords, ColPayrollsAdjustmentAggregates, ColPayrollsPayrollPrograms, UserTypeEmployer, UserTypeEmployee, AdjustmentTypeRate, AdjustmentTypePerHour, AdjustmentTypePerPeriod, PayTypeFixed, PayTypePerHour, RecurrenceTypeDaily, RecurrenceTypeWeekly, RecurrenceTypeMonthly, RecurrenceTypeYearly, } from "@fabriktor/schema";
3
- import { employmentCanRead, employmentCatalogOwnerIDs, } from "../contacts/scope.js";
3
+ import { employmentCanRead, employmentCatalogOwnerIDs, employmentOwnsRecord, } from "../contacts/scope.js";
4
4
  import { normalizeIDs, requiredOperationID } from "../core/id.js";
5
5
  import { runOwnerScopeQuery } from "../core/query.js";
6
6
  import { runOwnerScopeSearch, emptySearchPage, } from "../core/search.js";
@@ -137,6 +137,9 @@ export const payrollRecurrenceTypes = [
137
137
  ];
138
138
  // record/config.go pctMoney uses basis.X100000. A displayed percentage is 100 times the fraction.
139
139
  export const payrollPercentageScale = 1000;
140
+ // Validation and access denials reject these transactional generation requests.
141
+ // A 409 can also come from idempotency middleware, so it cannot release a request.
142
+ const payrollGenerationRejectionStatuses = [400, 403];
140
143
  export class PayrollWorkflowError extends Error {
141
144
  reason;
142
145
  constructor(reason) {
@@ -152,7 +155,7 @@ function requirePayroll(value, reason) {
152
155
  export function payrollCanManage(actor, record) {
153
156
  return (employmentCanRead(actor) &&
154
157
  actor.active_mode === UserTypeEmployer &&
155
- (!record || record.owner_id === actor.owner_id));
158
+ (!record || employmentOwnsRecord(actor, record)));
156
159
  }
157
160
  export function payrollCanRead(actor, resource) {
158
161
  return (employmentCanRead(actor) &&
@@ -341,12 +344,13 @@ export class PayrollsWorkspace {
341
344
  return p.insertOnePayrollProgram({ in: command.input, ...request });
342
345
  }
343
346
  })().catch((error) => {
344
- // These three handlers roll back their transaction on validation failure.
345
- // Other responses remain uncertain and retain request/source checkpoints.
346
- const transactional = command.resource === PayrollResource.Payrolls ||
347
- command.resource === PayrollResource.HourBanks ||
348
- command.resource === PayrollResource.Payables;
349
- if (transactional && isHTTPClientErr(error) && error.status === 400) {
347
+ // Generation from configurations, hour banks and payables returns a payroll.
348
+ // A rejection on retry does not settle an earlier ambiguous submission.
349
+ if (!previous &&
350
+ resource === PayrollResource.Payrolls &&
351
+ isHTTPClientErr(error) &&
352
+ error.status !== undefined &&
353
+ payrollGenerationRejectionStatuses.includes(error.status)) {
350
354
  this.submitted.delete(attempt.idempotency_key);
351
355
  for (const key of sourceKeys)
352
356
  this.sourceRequests.delete(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.123",
3
+ "version": "0.0.124",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {