@fabriktor/fx 0.0.95 → 0.0.97

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.
@@ -26,7 +26,7 @@ type VendorInvoiceInsertOptions = Parameters<BillableOperator["insertOneVendorIn
26
26
  type VendorInvoiceReplaceOptions = Parameters<BillableOperator["replaceOneVendorInvoice"]>[0];
27
27
  type WarehouseInsertOptions = Parameters<BillableOperator["insertOneWarehouse"]>[0];
28
28
  type WarehouseReplaceOptions = Parameters<BillableOperator["replaceOneWarehouse"]>[0];
29
- export type SearchBillsOptions = OwnerSearchOptions;
29
+ export type SearchBillsOptions = OwnerSearchOptions & Partial<Pick<Bill, "is_estimate" | "is_canceled" | "type">>;
30
30
  export type SearchBillsPage = SearchPage<Bill>;
31
31
  export type CreateBillableFolderOptions = BillableFolderInsertOptions;
32
32
  export type ReplaceBillableFolderOptions = BillableFolderReplaceOptions;
@@ -280,4 +280,6 @@ export declare function billableCatalogOwnerIDs(context: BillableReadContext): s
280
280
  export declare function newBillableFX(opts: BillableFXOptions): BillableFX;
281
281
  export declare function billableCanCompleteBill(bill: Bill): boolean;
282
282
  export declare function billableCanCancelBill(bill: Bill): boolean;
283
+ export declare function billReportAfter(bill: Bill): string;
284
+ export declare function billReportName(bill: Bill): string | undefined;
283
285
  export {};
@@ -5,6 +5,7 @@
5
5
  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
6
  import { queryParams } from "@fabriktor/client";
7
7
  import { BillTypeDynamic, BillTypeFixed, UserTypeEmployee, UserTypeEmployer, } from "@fabriktor/schema";
8
+ import { isZeroDateTime } from "../core/date.js";
8
9
  import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
9
10
  import { requiredOperationID, resolvedID } from "../core/id.js";
10
11
  import { runPreActionCheck } from "../core/pre-action.js";
@@ -109,6 +110,11 @@ export class BillableFX {
109
110
  async searchBills(opts) {
110
111
  return await runOwnerSearch({
111
112
  ...opts,
113
+ query: queryParams({
114
+ is_estimate: opts.is_estimate,
115
+ is_canceled: opts.is_canceled,
116
+ type: opts.type,
117
+ }),
112
118
  search: (searchOpts) => this.billable.searchManyBills(searchOpts),
113
119
  });
114
120
  }
@@ -756,6 +762,16 @@ export function billableCanCompleteBill(bill) {
756
762
  export function billableCanCancelBill(bill) {
757
763
  return !bill.is_canceled && (!bill.is_estimate || resolvedID(bill.accepted_bill_id) === undefined);
758
764
  }
765
+ export function billReportAfter(bill) {
766
+ return [bill.canceled_at, bill.completed_at, bill.created_at].find((value) => !isZeroDateTime(value)) ?? bill.created_at;
767
+ }
768
+ export function billReportName(bill) {
769
+ if (bill.report_generated_revision == null && !bill.report_pending)
770
+ return undefined;
771
+ return bill.report_generated_revision === bill.report_revision
772
+ ? (bill.report_file_name ?? "")
773
+ : "";
774
+ }
759
775
  function fixedEstimateID(opts) {
760
776
  const estimate = opts.estimate;
761
777
  const id = resolvedID(estimate.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/fx",
3
- "version": "0.0.95",
3
+ "version": "0.0.97",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,8 +17,8 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/client": "0.0.76",
20
+ "@fabriktor/client": "0.0.77",
21
21
  "@fabriktor/fx": "0.0.94",
22
- "@fabriktor/schema": "0.0.59"
22
+ "@fabriktor/schema": "0.0.60"
23
23
  }
24
24
  }