@fabriktor/fx 0.0.88 → 0.0.90

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.
@@ -3,6 +3,7 @@ import { type Bill, BillableFolder, Charge, Equipment, Item, LaborRate, MeterRea
3
3
  import type { ContactsFXOperator, EmploymentOwnerScope } from "../contacts/contacts.js";
4
4
  import { type OwnerSearchOptions, type SearchOptions, type SearchPage, type SearchQuery } from "../core/search.js";
5
5
  type GenerateBillPayload = Parameters<BillableOperator["generateBill"]>[0];
6
+ export type SalaryEstimateInput = GenerateBillPayload["salary_estimate"];
6
7
  type BillInsertOptions = Parameters<BillableOperator["insertOneBill"]>[0];
7
8
  type BillReplaceOptions = Parameters<BillableOperator["replaceOneBill"]>[0];
8
9
  type BillableFolderInsertOptions = Parameters<BillableOperator["insertOneBillableFolder"]>[0];
@@ -134,6 +135,7 @@ export type GenerateDynamicBillOptions = {
134
135
  in: GenerateBillPayload;
135
136
  exclude_billed?: boolean;
136
137
  };
138
+ export declare function zeroSalaryEstimate(): SalaryEstimateInput;
137
139
  export type MarkLocationAchievedOptions = {
138
140
  in: GenerateBillPayload;
139
141
  };
@@ -253,6 +255,7 @@ export declare class BillableFX implements BillableFXOperator {
253
255
  vendorInvoiceFromBill(opts: VendorInvoiceFromBillOptions): Promise<VendorInvoice>;
254
256
  private generateBill;
255
257
  private checkVendorInvoiceNumber;
258
+ private searchReadableActivity;
256
259
  private searchReadable;
257
260
  private findBill;
258
261
  private findBillableFolder;
@@ -65,6 +65,14 @@ export const BillableReadResource = {
65
65
  VendorInvoice: "vendor_invoice",
66
66
  Warehouse: "warehouse",
67
67
  };
68
+ export function zeroSalaryEstimate() {
69
+ return {
70
+ employee_ids: [],
71
+ daily_work_hours: 0,
72
+ daily_transport_hours: 0,
73
+ days_per_week: 0,
74
+ };
75
+ }
68
76
  export const BillablePreActionReason = {
69
77
  VendorInvoiceNumberExists: "vendor_invoice_number_exists",
70
78
  };
@@ -140,13 +148,8 @@ export class BillableFX {
140
148
  });
141
149
  }
142
150
  async searchReadableCharges(opts) {
143
- const employer_scope_ids = activityEmployerScopeIDs(opts);
144
- return await this.searchReadable({
151
+ return await this.searchReadableActivity({
145
152
  ...opts,
146
- allowed_owner_ids: activityOwnerIDs(opts.context),
147
- filter: employer_scope_ids === undefined
148
- ? undefined
149
- : (charge) => employer_scope_ids.has(charge.employer_id),
150
153
  search: (searchOpts) => this.billable.searchManyCharges(searchOpts),
151
154
  });
152
155
  }
@@ -236,21 +239,8 @@ export class BillableFX {
236
239
  });
237
240
  }
238
241
  async searchReadableMeterReadings(opts) {
239
- const employer_scope_ids = activityEmployerScopeIDs(opts);
240
- const equipment_owners = new Map();
241
- return await this.searchReadable({
242
+ return await this.searchReadableActivity({
242
243
  ...opts,
243
- allowed_owner_ids: activityOwnerIDs(opts.context),
244
- filter: employer_scope_ids === undefined
245
- ? undefined
246
- : async (reading) => {
247
- let owner = equipment_owners.get(reading.equipment_id);
248
- if (owner === undefined) {
249
- owner = this.findEquipment(reading.equipment_id).then((equipment) => equipment.owner_id);
250
- equipment_owners.set(reading.equipment_id, owner);
251
- }
252
- return employer_scope_ids.has(await owner);
253
- },
254
244
  search: (searchOpts) => this.billable.searchManyMeterReadings(searchOpts),
255
245
  });
256
246
  }
@@ -382,6 +372,7 @@ export class BillableFX {
382
372
  is_estimate: false,
383
373
  upfront_rate: 0,
384
374
  exclude_billed: opts.exclude_billed,
375
+ salary_estimate: zeroSalaryEstimate(),
385
376
  }));
386
377
  }
387
378
  async markLocationAchieved(opts) {
@@ -415,6 +406,16 @@ export class BillableFX {
415
406
  },
416
407
  });
417
408
  }
409
+ async searchReadableActivity(opts) {
410
+ const employer_scope_ids = activityEmployerScopeIDs(opts);
411
+ return await this.searchReadable({
412
+ ...opts,
413
+ allowed_owner_ids: activityOwnerIDs(opts.context),
414
+ filter: employer_scope_ids === undefined
415
+ ? undefined
416
+ : (value) => employer_scope_ids.has(value.employer_id),
417
+ });
418
+ }
418
419
  async searchReadable(opts) {
419
420
  const { context: _context, owner_ids: requested_owner_ids, employer_scope_ids: _employer_scope_ids, allowed_owner_ids, search, filter, query, ...searchOpts } = opts;
420
421
  const owner_ids = restrictOwnerIDs(allowed_owner_ids, requested_owner_ids);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/client": "0.0.73",
21
- "@fabriktor/schema": "0.0.56"
20
+ "@fabriktor/client": "0.0.74",
21
+ "@fabriktor/schema": "0.0.57"
22
22
  }
23
23
  }