@connect-plus-online/ogabai-integrations 0.0.88 → 0.0.93

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.
package/dist/index.d.mts CHANGED
@@ -349,10 +349,12 @@ interface Expense {
349
349
  repeatedEvery: "day" | "week" | "month" | "year";
350
350
  dispenseStaffIds: string[];
351
351
  createdAt: string;
352
- expenseType: "none" | "operation" | "staffRequest";
352
+ expenseType: "none" | "operation" | "staffRequest" | "staffRequestFulfilled" | "staffRequestDeclined";
353
353
  amount: number;
354
354
  narration: string;
355
355
  createdById: string;
356
+ storeId: string;
357
+ paymentType: Transaction["paymentType"];
356
358
  }
357
359
  type DateFilter = {
358
360
  startDate: string;
@@ -396,6 +398,7 @@ type Transaction = {
396
398
  createdById: string;
397
399
  expenseId: string;
398
400
  narration: string;
401
+ expenseReceiptUrl: string;
399
402
  };
400
403
  type OrderStatus = "pending" | "processing" | "routing" | "delivered";
401
404
  type Order = {
@@ -1644,6 +1647,11 @@ declare const createPriceService: (client: GraphQLClient) => {
1644
1647
  };
1645
1648
 
1646
1649
  declare const createProductService: (client: GraphQLClient) => {
1650
+ /**
1651
+ *
1652
+ * @param form { storeId: string; productId: string; file: File;}
1653
+ * @returns Transaction
1654
+ */
1647
1655
  uploadProductImage(form: FormData): Promise<Product>;
1648
1656
  getCustomerProductCountsByIds(input: GetCustomerProductCountsByIdsRequest, fetchFields?: {
1649
1657
  root?: (keyof GetCustomerProductCountsByIdsResponse)[];
@@ -1929,6 +1937,16 @@ type UpdateTransactionResponseNestedFields = GetTransactionResponseNestedFields;
1929
1937
  declare const updateTransactionResponseNestedFields: GetTransactionResponseNestedFields;
1930
1938
 
1931
1939
  declare const createTransactionService: (client: GraphQLClient) => {
1940
+ /**
1941
+ * Uploads a transaction receipt
1942
+ * @param form {
1943
+ * file: File;
1944
+ * transactionId: string;
1945
+ * storeId: string;
1946
+ * }
1947
+ * @returns Transaction with updated receipt URL
1948
+ */
1949
+ uploadExpenseReceipt(form: FormData): Promise<Transaction>;
1932
1950
  updateTransaction(input: UpdateTransactionRequest, fetchFields?: {
1933
1951
  root?: (keyof UpdateTransactionResponse)[];
1934
1952
  nestedFields?: UpdateTransactionResponseNestedFields;
@@ -2105,12 +2123,15 @@ declare const createExpenseDispenseService: (client: GraphQLClient) => {
2105
2123
  skip?: number;
2106
2124
  }) => Promise<EntityResponse<Transaction[], "transactions"> | null>;
2107
2125
  dispenseExpense: (req: {
2108
- expenseDispense: Pick<Transaction, "expenseId" | "amountPaid" | "narration" | "createdById">;
2126
+ expenseDispense: Pick<Transaction, "expenseId" | "amountPaid" | "narration" | "createdById" | "paymentType">;
2109
2127
  }) => Promise<EntityResponse<Transaction, "transaction"> | undefined>;
2110
2128
  approveExpenseDispense(req: {
2111
2129
  expenseId: string;
2112
2130
  addToExpenseList?: boolean;
2113
2131
  }): Promise<EntityResponse<Transaction, "transaction"> | null>;
2132
+ declineExpenseDispense: (req: {
2133
+ expenseId: string;
2134
+ }) => Promise<EntityResponse<Transaction, "transaction"> | null>;
2114
2135
  };
2115
2136
  type ExpenseDispenseService = ReturnType<typeof createExpenseDispenseService>;
2116
2137
 
package/dist/index.d.ts CHANGED
@@ -349,10 +349,12 @@ interface Expense {
349
349
  repeatedEvery: "day" | "week" | "month" | "year";
350
350
  dispenseStaffIds: string[];
351
351
  createdAt: string;
352
- expenseType: "none" | "operation" | "staffRequest";
352
+ expenseType: "none" | "operation" | "staffRequest" | "staffRequestFulfilled" | "staffRequestDeclined";
353
353
  amount: number;
354
354
  narration: string;
355
355
  createdById: string;
356
+ storeId: string;
357
+ paymentType: Transaction["paymentType"];
356
358
  }
357
359
  type DateFilter = {
358
360
  startDate: string;
@@ -396,6 +398,7 @@ type Transaction = {
396
398
  createdById: string;
397
399
  expenseId: string;
398
400
  narration: string;
401
+ expenseReceiptUrl: string;
399
402
  };
400
403
  type OrderStatus = "pending" | "processing" | "routing" | "delivered";
401
404
  type Order = {
@@ -1644,6 +1647,11 @@ declare const createPriceService: (client: GraphQLClient) => {
1644
1647
  };
1645
1648
 
1646
1649
  declare const createProductService: (client: GraphQLClient) => {
1650
+ /**
1651
+ *
1652
+ * @param form { storeId: string; productId: string; file: File;}
1653
+ * @returns Transaction
1654
+ */
1647
1655
  uploadProductImage(form: FormData): Promise<Product>;
1648
1656
  getCustomerProductCountsByIds(input: GetCustomerProductCountsByIdsRequest, fetchFields?: {
1649
1657
  root?: (keyof GetCustomerProductCountsByIdsResponse)[];
@@ -1929,6 +1937,16 @@ type UpdateTransactionResponseNestedFields = GetTransactionResponseNestedFields;
1929
1937
  declare const updateTransactionResponseNestedFields: GetTransactionResponseNestedFields;
1930
1938
 
1931
1939
  declare const createTransactionService: (client: GraphQLClient) => {
1940
+ /**
1941
+ * Uploads a transaction receipt
1942
+ * @param form {
1943
+ * file: File;
1944
+ * transactionId: string;
1945
+ * storeId: string;
1946
+ * }
1947
+ * @returns Transaction with updated receipt URL
1948
+ */
1949
+ uploadExpenseReceipt(form: FormData): Promise<Transaction>;
1932
1950
  updateTransaction(input: UpdateTransactionRequest, fetchFields?: {
1933
1951
  root?: (keyof UpdateTransactionResponse)[];
1934
1952
  nestedFields?: UpdateTransactionResponseNestedFields;
@@ -2105,12 +2123,15 @@ declare const createExpenseDispenseService: (client: GraphQLClient) => {
2105
2123
  skip?: number;
2106
2124
  }) => Promise<EntityResponse<Transaction[], "transactions"> | null>;
2107
2125
  dispenseExpense: (req: {
2108
- expenseDispense: Pick<Transaction, "expenseId" | "amountPaid" | "narration" | "createdById">;
2126
+ expenseDispense: Pick<Transaction, "expenseId" | "amountPaid" | "narration" | "createdById" | "paymentType">;
2109
2127
  }) => Promise<EntityResponse<Transaction, "transaction"> | undefined>;
2110
2128
  approveExpenseDispense(req: {
2111
2129
  expenseId: string;
2112
2130
  addToExpenseList?: boolean;
2113
2131
  }): Promise<EntityResponse<Transaction, "transaction"> | null>;
2132
+ declineExpenseDispense: (req: {
2133
+ expenseId: string;
2134
+ }) => Promise<EntityResponse<Transaction, "transaction"> | null>;
2114
2135
  };
2115
2136
  type ExpenseDispenseService = ReturnType<typeof createExpenseDispenseService>;
2116
2137
 
package/dist/index.esm.js CHANGED
@@ -2558,9 +2558,9 @@ var productSchema = {
2558
2558
  };
2559
2559
 
2560
2560
  // src/services/file/file.service.ts
2561
- var createFileService = (client) => ({
2562
- async uploadFile(formData) {
2563
- const url = client["url"].replace("/graphql", "") + "/api/upload";
2561
+ var createFileService = (client) => {
2562
+ async function uploadFile(path, formData) {
2563
+ const url = client["url"].replace("/graphql", "") + path;
2564
2564
  const token = await client["tokenProvider"]();
2565
2565
  const headers = {
2566
2566
  ...token ? { Authorization: `Bearer ${token}` } : {}
@@ -2579,13 +2579,40 @@ var createFileService = (client) => ({
2579
2579
  return text;
2580
2580
  }
2581
2581
  }
2582
- });
2582
+ return {
2583
+ /**
2584
+ *
2585
+ * @param form { storeId: string; productId: string; file: File;}
2586
+ * @returns Transaction
2587
+ */
2588
+ uploadFileProductImage(form) {
2589
+ return uploadFile("/api/upload/product", form);
2590
+ },
2591
+ /**
2592
+ * Uploads a transaction receipt
2593
+ * @param form {
2594
+ * file: File;
2595
+ * transactionId: string;
2596
+ * storeId: string;
2597
+ * }
2598
+ * @returns Transaction with updated receipt URL
2599
+ */
2600
+ uploadTxReceipt(form) {
2601
+ return uploadFile("/api/upload/transaction-receipt", form);
2602
+ }
2603
+ };
2604
+ };
2583
2605
 
2584
2606
  // src/services/inventory/product.service.ts
2585
2607
  var createProductService = (client) => ({
2608
+ /**
2609
+ *
2610
+ * @param form { storeId: string; productId: string; file: File;}
2611
+ * @returns Transaction
2612
+ */
2586
2613
  async uploadProductImage(form) {
2587
2614
  const fileClient = createFileService(client);
2588
- return (await fileClient.uploadFile(form)).product;
2615
+ return (await fileClient.uploadFileProductImage(form)).product;
2589
2616
  },
2590
2617
  async getCustomerProductCountsByIds(input, fetchFields, option) {
2591
2618
  var _a, _b, _c, _d;
@@ -3204,12 +3231,19 @@ var orderSchema = {
3204
3231
 
3205
3232
  // src/services/sales/sale.entity.ts
3206
3233
  var expenseQuery = [
3207
- "id",
3234
+ "amount",
3208
3235
  "createdAt",
3236
+ "createdById",
3209
3237
  "description",
3210
- "title",
3238
+ "dispenseStaffIds",
3239
+ "expenseCategoryId",
3240
+ "expenseType",
3241
+ "id",
3242
+ "narration",
3243
+ "paymentType",
3211
3244
  "repeatedEvery",
3212
- "expenseCategoryId"
3245
+ "title",
3246
+ "storeId"
3213
3247
  ];
3214
3248
  var expenseCategoryQuery = [
3215
3249
  "id",
@@ -3433,6 +3467,19 @@ var updateTransactionResponseNestedFields = getTransactionResponseNestedFields;
3433
3467
 
3434
3468
  // src/services/sales/transaction.service.ts
3435
3469
  var createTransactionService = (client) => ({
3470
+ /**
3471
+ * Uploads a transaction receipt
3472
+ * @param form {
3473
+ * file: File;
3474
+ * transactionId: string;
3475
+ * storeId: string;
3476
+ * }
3477
+ * @returns Transaction with updated receipt URL
3478
+ */
3479
+ async uploadExpenseReceipt(form) {
3480
+ const fileClient = createFileService(client);
3481
+ return (await fileClient.uploadTxReceipt(form)).transaction;
3482
+ },
3436
3483
  async updateTransaction(input, fetchFields, option) {
3437
3484
  var _a, _b, _c, _d;
3438
3485
  const res = await client.request(
@@ -3765,7 +3812,7 @@ var createExpenseDispenseService = (client) => {
3765
3812
  });
3766
3813
  },
3767
3814
  dispenseExpense: async (req) => {
3768
- const { amountPaid, narration, createdById, expenseId } = req.expenseDispense;
3815
+ const { amountPaid, narration, createdById, expenseId, paymentType } = req.expenseDispense;
3769
3816
  const expenseRes = await expenseService.getExpense({
3770
3817
  expense: {
3771
3818
  id: expenseId
@@ -3784,7 +3831,8 @@ var createExpenseDispenseService = (client) => {
3784
3831
  amountPaid,
3785
3832
  narration,
3786
3833
  createdById,
3787
- expenseId
3834
+ expenseId,
3835
+ paymentType
3788
3836
  }
3789
3837
  });
3790
3838
  return transaction || void 0;
@@ -3808,18 +3856,39 @@ var createExpenseDispenseService = (client) => {
3808
3856
  expenseId,
3809
3857
  amountPaid: expense.amount,
3810
3858
  narration: expense.narration || "Approved expense dispense",
3811
- createdById: expense.createdById
3859
+ createdById: expense.createdById,
3860
+ paymentType: expense.paymentType
3861
+ }
3862
+ });
3863
+ await expenseService.updateExpense({
3864
+ expenseId,
3865
+ expense: {
3866
+ expenseType: addToExpenseList ? "operation" : "staffRequestFulfilled"
3812
3867
  }
3813
3868
  });
3814
- if (addToExpenseList) {
3815
- await expenseService.updateExpense({
3816
- expenseId,
3817
- expense: {
3818
- expenseType: "operation"
3819
- }
3820
- });
3821
- }
3822
3869
  return transaction || null;
3870
+ },
3871
+ declineExpenseDispense: async (req) => {
3872
+ const { expenseId } = req;
3873
+ const expenseRes = await expenseService.getExpense({
3874
+ expense: {
3875
+ id: expenseId
3876
+ }
3877
+ });
3878
+ if (!expenseRes || !expenseRes.expense) {
3879
+ throw new Error("Expense not found");
3880
+ }
3881
+ const expense = expenseRes.expense;
3882
+ if (expense.expenseType !== "staffRequest") {
3883
+ throw new Error("Only staff requested expenses can be declined for dispense");
3884
+ }
3885
+ await expenseService.updateExpense({
3886
+ expenseId,
3887
+ expense: {
3888
+ expenseType: "staffRequestDeclined"
3889
+ }
3890
+ });
3891
+ return null;
3823
3892
  }
3824
3893
  };
3825
3894
  };