@fabriktor/fx 0.0.126 → 0.0.128
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.
|
@@ -148,6 +148,7 @@ export class MultiCreator {
|
|
|
148
148
|
signal.throwIfAborted();
|
|
149
149
|
this.opts.before_request?.();
|
|
150
150
|
const result = await this.opts.run(structuredClone(current.input), {
|
|
151
|
+
entry_id: current.id,
|
|
151
152
|
signal,
|
|
152
153
|
idempotency_key: current.idempotency_key,
|
|
153
154
|
created_id: current.created_id,
|
|
@@ -75,6 +75,7 @@ export const payrollPolicies = {
|
|
|
75
75
|
filters: [
|
|
76
76
|
"name",
|
|
77
77
|
"type",
|
|
78
|
+
"is_accrued",
|
|
78
79
|
"is_employer_contribution",
|
|
79
80
|
"folder_id",
|
|
80
81
|
"currency",
|
|
@@ -310,23 +311,28 @@ export class PayrollsWorkspace {
|
|
|
310
311
|
: command.resource;
|
|
311
312
|
if (attempt.created_id)
|
|
312
313
|
return this.owned(actor, resource, attempt.created_id, attempt.signal);
|
|
314
|
+
const requestID = attempt.entry_id ?? attempt.idempotency_key;
|
|
313
315
|
const fingerprint = JSON.stringify({ owner_id: actor.owner_id, command });
|
|
314
|
-
const previous = this.submitted.get(
|
|
315
|
-
requirePayroll(!previous || previous === fingerprint, "changed");
|
|
316
|
+
const previous = this.submitted.get(requestID);
|
|
317
|
+
requirePayroll(!previous || previous.fingerprint === fingerprint, "changed");
|
|
316
318
|
const sourceKeys = command.resource === PayrollResource.HourBanks ||
|
|
317
319
|
command.resource === PayrollResource.Payables
|
|
318
320
|
? command.input.ids.map((id) => `${actor.owner_id}:${command.resource}:${id}`)
|
|
319
321
|
: [];
|
|
320
322
|
for (const key of sourceKeys)
|
|
321
323
|
requirePayroll(!this.sourceRequests.has(key) ||
|
|
322
|
-
this.sourceRequests.get(key) ===
|
|
323
|
-
|
|
324
|
+
this.sourceRequests.get(key) === requestID, "pending_source");
|
|
325
|
+
// A fresh HTTP attempt must re-read configuration and source consumption state.
|
|
326
|
+
if (!previous || previous.idempotency_key !== attempt.idempotency_key)
|
|
324
327
|
await this.validateCommand(actor, command, attempt.signal);
|
|
325
328
|
attempt.before_request?.();
|
|
326
329
|
attempt.signal.throwIfAborted();
|
|
327
|
-
this.submitted.set(
|
|
330
|
+
this.submitted.set(requestID, {
|
|
331
|
+
fingerprint,
|
|
332
|
+
idempotency_key: attempt.idempotency_key,
|
|
333
|
+
});
|
|
328
334
|
for (const key of sourceKeys)
|
|
329
|
-
this.sourceRequests.set(key,
|
|
335
|
+
this.sourceRequests.set(key, requestID);
|
|
330
336
|
const p = this.payrolls;
|
|
331
337
|
const request = {
|
|
332
338
|
signal: attempt.signal,
|
|
@@ -364,7 +370,7 @@ export class PayrollsWorkspace {
|
|
|
364
370
|
isHTTPClientErr(error) &&
|
|
365
371
|
error.status !== undefined &&
|
|
366
372
|
payrollGenerationRejectionStatuses.includes(error.status)) {
|
|
367
|
-
this.submitted.delete(
|
|
373
|
+
this.submitted.delete(requestID);
|
|
368
374
|
for (const key of sourceKeys)
|
|
369
375
|
this.sourceRequests.delete(key);
|
|
370
376
|
attempt.on_rejected?.();
|
|
@@ -373,7 +379,7 @@ export class PayrollsWorkspace {
|
|
|
373
379
|
});
|
|
374
380
|
const id = requiredOperationID(out, "Generated payroll record response did not contain an ID.");
|
|
375
381
|
attempt.on_created?.(id);
|
|
376
|
-
this.submitted.delete(
|
|
382
|
+
this.submitted.delete(requestID);
|
|
377
383
|
for (const key of sourceKeys)
|
|
378
384
|
this.sourceRequests.delete(key);
|
|
379
385
|
return this.owned(actor, resource, id, attempt.signal);
|