@connect-plus-online/ogabai-integrations 0.0.105 → 0.0.107

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
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var graphqlClient = require('@chijioke/graphql-client');
4
+
3
5
  // src/types/user.ts
4
6
  var AppNewFeatures = /* @__PURE__ */ ((AppNewFeatures2) => {
5
7
  AppNewFeatures2["ExpenseTracker"] = "expenseTracker";
@@ -438,7 +440,7 @@ var userSettingQuery = [
438
440
  "userId"
439
441
  ];
440
442
 
441
- // src/services/inventory/entities.ts
443
+ // src/services/inventory/inventory.entities.ts
442
444
  var customersProductCountQuery = [
443
445
  "count",
444
446
  "storeId",
@@ -479,7 +481,8 @@ var stockQuery = [
479
481
  "deduction",
480
482
  "storeId",
481
483
  "createdAt",
482
- "expirationDate"
484
+ "expirationDate",
485
+ "stockType"
483
486
  ];
484
487
  var storeQuery = [
485
488
  "_id",
@@ -3334,7 +3337,8 @@ var transactionQuery = [
3334
3337
  "transactionType",
3335
3338
  "expenseId",
3336
3339
  "expenseReceiptUrl",
3337
- "narration"
3340
+ "narration",
3341
+ "parentTransactionId"
3338
3342
  ];
3339
3343
  var orderQuery = [
3340
3344
  "_id",
@@ -3528,35 +3532,8 @@ var updateTransactionResponse = getTransactionResponse;
3528
3532
  var updateTransactionResponseNestedFields = getTransactionResponseNestedFields;
3529
3533
 
3530
3534
  // src/services/sales/transaction.service.ts
3531
- var createTransactionService = (client) => ({
3532
- /**
3533
- * Uploads a transaction receipt
3534
- * @param form {
3535
- * file: File;
3536
- * transactionId: string;
3537
- * storeId: string;
3538
- * }
3539
- * @returns Transaction with updated receipt URL
3540
- */
3541
- async uploadExpenseReceipt(form) {
3542
- const fileClient = createFileService(client);
3543
- return (await fileClient.uploadTxReceipt(form)).transaction;
3544
- },
3545
- async updateTransaction(input, fetchFields, option) {
3546
- var _a, _b, _c, _d;
3547
- const res = await client.request(
3548
- transactionSchema.updateTransaction(
3549
- gqlQueryStringBuilder(
3550
- (_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateTransactionResponse,
3551
- (_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateTransactionResponseNestedFields
3552
- )
3553
- ),
3554
- input,
3555
- option
3556
- );
3557
- return (_d = (_c = res.data) == null ? void 0 : _c.updateTransaction) != null ? _d : null;
3558
- },
3559
- async addTransaction(input, fetchFields, option) {
3535
+ var createTransactionService = (client) => {
3536
+ async function addTransaction(input, fetchFields, option) {
3560
3537
  var _a, _b, _c, _d;
3561
3538
  const res = await client.request(
3562
3539
  transactionSchema.addTransaction(
@@ -3569,98 +3546,139 @@ var createTransactionService = (client) => ({
3569
3546
  option
3570
3547
  );
3571
3548
  return (_d = (_c = res.data) == null ? void 0 : _c.addTransaction) != null ? _d : null;
3572
- },
3573
- async addCustomerDeposit(input, fetchFields, option) {
3574
- return this.addTransaction(
3575
- {
3576
- transaction: {
3577
- ...input,
3578
- transactionType: "customerDeposit",
3579
- platform: "pos"
3580
- }
3581
- },
3582
- fetchFields,
3583
- option
3584
- );
3585
- },
3586
- async addCustomerRefund(input, fetchFields, option) {
3587
- return this.addTransaction(
3588
- {
3549
+ }
3550
+ return {
3551
+ /**
3552
+ *
3553
+ * @param input transactionRequest
3554
+ * @param fetchFields filter what is returned (fields)
3555
+ * @param option call options - cache
3556
+ * @returns TransactionResponse
3557
+ */
3558
+ async returnSales(input, fetchFields, option) {
3559
+ return addTransaction({
3589
3560
  transaction: {
3590
- ...input,
3591
- transactionType: "customerRefund",
3592
- platform: "pos"
3561
+ ...input.transaction,
3562
+ transactionType: "saleReturn"
3593
3563
  }
3594
- },
3595
- fetchFields,
3596
- option
3597
- );
3598
- },
3599
- async getTransaction(input, fetchFields, option) {
3600
- var _a, _b, _c, _d;
3601
- const res = await client.request(
3602
- transactionSchema.getTransaction(
3603
- gqlQueryStringBuilder(
3604
- (_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getTransactionResponse,
3605
- (_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getTransactionResponseNestedFields
3606
- )
3607
- ),
3608
- input,
3609
- option
3610
- );
3611
- return (_d = (_c = res.data) == null ? void 0 : _c.getTransaction) != null ? _d : null;
3612
- },
3613
- async getTransactions(input, fetchFields, option) {
3614
- var _a, _b, _c, _d;
3615
- const res = await client.request(
3616
- transactionSchema.getTransactions(
3617
- gqlQueryStringBuilder(
3618
- (_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getTransactionsResponse,
3619
- (_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getTransactionsResponseNestedFields
3620
- )
3621
- ),
3622
- input,
3623
- option
3624
- );
3625
- return (_d = (_c = res.data) == null ? void 0 : _c.getTransactions) != null ? _d : null;
3626
- }
3627
- });
3628
-
3629
- // src/services/sales/types/expense-category.type.ts
3564
+ }, fetchFields, option);
3565
+ },
3566
+ /**
3567
+ * Uploads a transaction receipt
3568
+ * @param form {
3569
+ * file: File;
3570
+ * transactionId: string;
3571
+ * storeId: string;
3572
+ * }
3573
+ * @returns Transaction with updated receipt URL
3574
+ */
3575
+ async uploadExpenseReceipt(form) {
3576
+ const fileClient = createFileService(client);
3577
+ return (await fileClient.uploadTxReceipt(form)).transaction;
3578
+ },
3579
+ async updateTransaction(input, fetchFields, option) {
3580
+ var _a, _b, _c, _d;
3581
+ const res = await client.request(
3582
+ transactionSchema.updateTransaction(
3583
+ gqlQueryStringBuilder(
3584
+ (_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : updateTransactionResponse,
3585
+ (_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : updateTransactionResponseNestedFields
3586
+ )
3587
+ ),
3588
+ input,
3589
+ option
3590
+ );
3591
+ return (_d = (_c = res.data) == null ? void 0 : _c.updateTransaction) != null ? _d : null;
3592
+ },
3593
+ addTransaction,
3594
+ async addCustomerDeposit(input, fetchFields, option) {
3595
+ return this.addTransaction(
3596
+ {
3597
+ transaction: {
3598
+ ...input,
3599
+ transactionType: "customerDeposit",
3600
+ platform: "pos"
3601
+ }
3602
+ },
3603
+ fetchFields,
3604
+ option
3605
+ );
3606
+ },
3607
+ async addCustomerRefund(input, fetchFields, option) {
3608
+ return this.addTransaction(
3609
+ {
3610
+ transaction: {
3611
+ ...input,
3612
+ transactionType: "customerRefund",
3613
+ platform: "pos"
3614
+ }
3615
+ },
3616
+ fetchFields,
3617
+ option
3618
+ );
3619
+ },
3620
+ async getTransaction(input, fetchFields, option) {
3621
+ var _a, _b, _c, _d;
3622
+ const res = await client.request(
3623
+ transactionSchema.getTransaction(
3624
+ gqlQueryStringBuilder(
3625
+ (_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getTransactionResponse,
3626
+ (_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getTransactionResponseNestedFields
3627
+ )
3628
+ ),
3629
+ input,
3630
+ option
3631
+ );
3632
+ return (_d = (_c = res.data) == null ? void 0 : _c.getTransaction) != null ? _d : null;
3633
+ },
3634
+ async getTransactions(input, fetchFields, option) {
3635
+ var _a, _b, _c, _d;
3636
+ const res = await client.request(
3637
+ transactionSchema.getTransactions(
3638
+ gqlQueryStringBuilder(
3639
+ (_a = fetchFields == null ? void 0 : fetchFields.root) != null ? _a : getTransactionsResponse,
3640
+ (_b = fetchFields == null ? void 0 : fetchFields.nestedFields) != null ? _b : getTransactionsResponseNestedFields
3641
+ )
3642
+ ),
3643
+ input,
3644
+ option
3645
+ );
3646
+ return (_d = (_c = res.data) == null ? void 0 : _c.getTransactions) != null ? _d : null;
3647
+ }
3648
+ };
3649
+ };
3630
3650
  var ENTITY8 = "expenseCategory";
3631
- var expenseCategoryIntegration = createStandardEntityIntegration({
3651
+ var expenseCategoryIntegration = graphqlClient.createStandardEntityIntegration({
3632
3652
  key: ENTITY8,
3633
3653
  fields: expenseCategoryQuery,
3634
3654
  nested: {
3635
3655
  features: expenseCategoryQuery
3636
3656
  }
3637
3657
  });
3638
- var expenseCategoryListIntegration = createListIntegration({
3658
+ var expenseCategoryListIntegration = graphqlClient.createListIntegration({
3639
3659
  key: ENTITY8,
3640
3660
  fields: expenseCategoryQuery,
3641
3661
  nested: {
3642
3662
  features: expenseCategoryQuery
3643
3663
  }
3644
3664
  });
3645
- var expenseCategoryDeleteIntegration = createDeleteIntegration(ENTITY8);
3646
-
3647
- // src/services/sales/types/expense.type.ts
3665
+ var expenseCategoryDeleteIntegration = graphqlClient.createDeleteIntegration(ENTITY8);
3648
3666
  var ENTITY9 = "expense";
3649
- var expenseIntegration = createStandardEntityIntegration({
3667
+ var expenseIntegration = graphqlClient.createStandardEntityIntegration({
3650
3668
  key: ENTITY9,
3651
3669
  fields: expenseQuery,
3652
3670
  nested: {
3653
3671
  features: expenseQuery
3654
3672
  }
3655
3673
  });
3656
- var expenseListIntegration = createListIntegration({
3674
+ var expenseListIntegration = graphqlClient.createListIntegration({
3657
3675
  key: ENTITY9,
3658
3676
  fields: expenseQuery,
3659
3677
  nested: {
3660
3678
  features: expenseQuery
3661
3679
  }
3662
3680
  });
3663
- var expenseDeleteIntegration = createDeleteIntegration(ENTITY9);
3681
+ var expenseDeleteIntegration = graphqlClient.createDeleteIntegration(ENTITY9);
3664
3682
 
3665
3683
  // src/services/sales/schemas/expense-category.schema.ts
3666
3684
  var expenseCategorySchema = {