@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.cjs.js CHANGED
@@ -2560,9 +2560,9 @@ var productSchema = {
2560
2560
  };
2561
2561
 
2562
2562
  // src/services/file/file.service.ts
2563
- var createFileService = (client) => ({
2564
- async uploadFile(formData) {
2565
- const url = client["url"].replace("/graphql", "") + "/api/upload";
2563
+ var createFileService = (client) => {
2564
+ async function uploadFile(path, formData) {
2565
+ const url = client["url"].replace("/graphql", "") + path;
2566
2566
  const token = await client["tokenProvider"]();
2567
2567
  const headers = {
2568
2568
  ...token ? { Authorization: `Bearer ${token}` } : {}
@@ -2581,13 +2581,40 @@ var createFileService = (client) => ({
2581
2581
  return text;
2582
2582
  }
2583
2583
  }
2584
- });
2584
+ return {
2585
+ /**
2586
+ *
2587
+ * @param form { storeId: string; productId: string; file: File;}
2588
+ * @returns Transaction
2589
+ */
2590
+ uploadFileProductImage(form) {
2591
+ return uploadFile("/api/upload/product", form);
2592
+ },
2593
+ /**
2594
+ * Uploads a transaction receipt
2595
+ * @param form {
2596
+ * file: File;
2597
+ * transactionId: string;
2598
+ * storeId: string;
2599
+ * }
2600
+ * @returns Transaction with updated receipt URL
2601
+ */
2602
+ uploadTxReceipt(form) {
2603
+ return uploadFile("/api/upload/transaction-receipt", form);
2604
+ }
2605
+ };
2606
+ };
2585
2607
 
2586
2608
  // src/services/inventory/product.service.ts
2587
2609
  var createProductService = (client) => ({
2610
+ /**
2611
+ *
2612
+ * @param form { storeId: string; productId: string; file: File;}
2613
+ * @returns Transaction
2614
+ */
2588
2615
  async uploadProductImage(form) {
2589
2616
  const fileClient = createFileService(client);
2590
- return (await fileClient.uploadFile(form)).product;
2617
+ return (await fileClient.uploadFileProductImage(form)).product;
2591
2618
  },
2592
2619
  async getCustomerProductCountsByIds(input, fetchFields, option) {
2593
2620
  var _a, _b, _c, _d;
@@ -3206,12 +3233,19 @@ var orderSchema = {
3206
3233
 
3207
3234
  // src/services/sales/sale.entity.ts
3208
3235
  var expenseQuery = [
3209
- "id",
3236
+ "amount",
3210
3237
  "createdAt",
3238
+ "createdById",
3211
3239
  "description",
3212
- "title",
3240
+ "dispenseStaffIds",
3241
+ "expenseCategoryId",
3242
+ "expenseType",
3243
+ "id",
3244
+ "narration",
3245
+ "paymentType",
3213
3246
  "repeatedEvery",
3214
- "expenseCategoryId"
3247
+ "title",
3248
+ "storeId"
3215
3249
  ];
3216
3250
  var expenseCategoryQuery = [
3217
3251
  "id",
@@ -3435,6 +3469,19 @@ var updateTransactionResponseNestedFields = getTransactionResponseNestedFields;
3435
3469
 
3436
3470
  // src/services/sales/transaction.service.ts
3437
3471
  var createTransactionService = (client) => ({
3472
+ /**
3473
+ * Uploads a transaction receipt
3474
+ * @param form {
3475
+ * file: File;
3476
+ * transactionId: string;
3477
+ * storeId: string;
3478
+ * }
3479
+ * @returns Transaction with updated receipt URL
3480
+ */
3481
+ async uploadExpenseReceipt(form) {
3482
+ const fileClient = createFileService(client);
3483
+ return (await fileClient.uploadTxReceipt(form)).transaction;
3484
+ },
3438
3485
  async updateTransaction(input, fetchFields, option) {
3439
3486
  var _a, _b, _c, _d;
3440
3487
  const res = await client.request(
@@ -3767,7 +3814,7 @@ var createExpenseDispenseService = (client) => {
3767
3814
  });
3768
3815
  },
3769
3816
  dispenseExpense: async (req) => {
3770
- const { amountPaid, narration, createdById, expenseId } = req.expenseDispense;
3817
+ const { amountPaid, narration, createdById, expenseId, paymentType } = req.expenseDispense;
3771
3818
  const expenseRes = await expenseService.getExpense({
3772
3819
  expense: {
3773
3820
  id: expenseId
@@ -3786,7 +3833,8 @@ var createExpenseDispenseService = (client) => {
3786
3833
  amountPaid,
3787
3834
  narration,
3788
3835
  createdById,
3789
- expenseId
3836
+ expenseId,
3837
+ paymentType
3790
3838
  }
3791
3839
  });
3792
3840
  return transaction || void 0;
@@ -3810,18 +3858,39 @@ var createExpenseDispenseService = (client) => {
3810
3858
  expenseId,
3811
3859
  amountPaid: expense.amount,
3812
3860
  narration: expense.narration || "Approved expense dispense",
3813
- createdById: expense.createdById
3861
+ createdById: expense.createdById,
3862
+ paymentType: expense.paymentType
3863
+ }
3864
+ });
3865
+ await expenseService.updateExpense({
3866
+ expenseId,
3867
+ expense: {
3868
+ expenseType: addToExpenseList ? "operation" : "staffRequestFulfilled"
3814
3869
  }
3815
3870
  });
3816
- if (addToExpenseList) {
3817
- await expenseService.updateExpense({
3818
- expenseId,
3819
- expense: {
3820
- expenseType: "operation"
3821
- }
3822
- });
3823
- }
3824
3871
  return transaction || null;
3872
+ },
3873
+ declineExpenseDispense: async (req) => {
3874
+ const { expenseId } = req;
3875
+ const expenseRes = await expenseService.getExpense({
3876
+ expense: {
3877
+ id: expenseId
3878
+ }
3879
+ });
3880
+ if (!expenseRes || !expenseRes.expense) {
3881
+ throw new Error("Expense not found");
3882
+ }
3883
+ const expense = expenseRes.expense;
3884
+ if (expense.expenseType !== "staffRequest") {
3885
+ throw new Error("Only staff requested expenses can be declined for dispense");
3886
+ }
3887
+ await expenseService.updateExpense({
3888
+ expenseId,
3889
+ expense: {
3890
+ expenseType: "staffRequestDeclined"
3891
+ }
3892
+ });
3893
+ return null;
3825
3894
  }
3826
3895
  };
3827
3896
  };