Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0056894
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Gift cards and gift vouchersmajoralways2024-10-24 18:092024-11-05 05:47
ReportersofidossantView Statuspublic 
Assigned Tosreehari 
PrioritynormalResolutionopenFixed in Version
StatusscheduledFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionpiSCM revision 
Review Assigned To
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0056894: API Consume Gift cards

DescriptionError when using the API
https://livebuilds.openbravo.com/context/retail_pos2_modules_pgsql/ws/org.openbravo.retail.api.giftcards.ImportService/ConsumeGiftCard [^]

When you consume the points partially, you can consume more than the value of the gift card, that is, if I have one that is worth 50, I can make 2 consumptions of 40 and this is an ERROR.

The response of the api is 10 (in the second time I consume it), but the transaction that is created is of 40
Steps To Reproduce1- Creation of the GIFTCARD

With this
https://livebuilds.openbravo.com/context/retail_pos2_modules_pgsql/ws/org.openbravo.api.ImportService/GiftCard [^]

  {
    "client":"The White Valley Group",
    "organization":"The White Valley Group",
    "searchKey": "TEST-SOFISSA",
    "active": true,
    "dateOrdered": "2024-10-22",
    "businessPartner": "VBS/C0001",
    "product": "GC/001",
    "amount": 50,
    "currentAmount": 50,
    "type": "BasedOnCreditNote",
    "expirationDate": "2025-09-23"
  }

I attached the image

2- And then I try to consume:
https://livebuilds.openbravo.com/context/retail_pos2_modules_pgsql/ws/org.openbravo.retail.api.giftcards.ImportService/ConsumeGiftCard [^]

{
  "client": "The White Valley Group",
  "organization": "The White Valley Group",
  "giftCardIdentifier": "TEST-SOFISSA",
  "amount": 40,
}

Response

{
    "data": {
        "id": "9BF85FA64B114A16A9C1185D0E3BF9EE",
        "amount": 40,
        "gcnvGiftcardInst": "E16782A0E46D4BB69131B7B139F3CA70"
    },
    "links": null
}

And then again
consume:
https://livebuilds.openbravo.com/context/retail_pos2_modules_pgsql/ws/org.openbravo.retail.api.giftcards.ImportService/ConsumeGiftCard [^]

{
  "client": "The White Valley Group",
  "organization": "The White Valley Group",
  "giftCardIdentifier": "TEST-SOFISSA",
  "amount": 40,
}

{
    "data": {
        "id": "40041B28F59345DCA056C315E8780077",
        "amount": 10,
        "gcnvGiftcardInst": "E16782A0E46D4BB69131B7B139F3CA70"
    },
    "links": null
}

But if you see the transaction is for 40, I attached the images
IMPORTANT when you login, use a default one organization with currency
Proposed SolutionThe error is in this JAVA
src/org/openbravo/retail/giftcards/ConsumeGiftCardAmount.java

BigDecimal realamount = amount;
      if (!isReturn && amount.compareTo(BigDecimal.ZERO) > 0) {
        if (giftcard.getCurrentamount().compareTo(amount) < 0) {
          realamount = giftcard.getCurrentamount();
        }
      }

      String newTrxId;
      try {
        newTrxId = jsonsent.getString("newTransactionId");
      } catch (Exception e) {
        newTrxId = SequenceIdData.getUUID();
      }

      final boolean isCancelled = jsonsent.optBoolean("reimburseGiftCard", false);
      String transactionId = jsonsent.has("transaction") ? jsonsent.getString("transaction") : null;
      GiftCardTrans transaction = model.consumeAmountGiftCard(newTrxId, giftcard, new Date(),
          OBDal.getInstance().get(Order.class, jsonsent.optString("order")),
          OBDal.getInstance().get(OrderLine.class, jsonsent.optString("orderline")), amount,
          isReturn, transactionId == null || "null".equals(transactionId) ? null : transactionId,
          jsonsent.has("hasPaymentMethod") ? jsonsent.getBoolean("hasPaymentMethod") : false,
          isCancelled);



When it generates the transaction, it doesn't do it with the realamount, but with the amount and that's why it can consume more.
TagsNo tags attached.
Attached Filespng file icon Captura de pantalla -2024-10-24 13-10-24.png [^] (133,010 bytes) 2024-10-24 18:10


png file icon Captura de pantalla -2024-10-23 15-25-43.png [^] (153,301 bytes) 2024-10-24 18:10

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0171356)
hgbot (developer)
2024-11-05 05:47

Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.api.giftcards/-/merge_requests/45 [^]

- Issue History
Date Modified Username Field Change
2024-10-24 18:09 sofidossant New Issue
2024-10-24 18:09 sofidossant Assigned To => Retail
2024-10-24 18:09 sofidossant Triggers an Emergency Pack => No
2024-10-24 18:10 sofidossant File Added: Captura de pantalla -2024-10-24 13-10-24.png
2024-10-24 18:10 sofidossant File Added: Captura de pantalla -2024-10-23 15-25-43.png
2024-10-24 18:20 sofidossant Steps to Reproduce Updated View Revisions
2024-10-25 06:21 guillermogil Assigned To Retail => guilleaer
2024-10-25 14:22 Practics Issue Monitored: Practics
2024-10-29 08:16 guilleaer Status new => acknowledged
2024-11-02 05:54 sreehari Assigned To guilleaer => sreehari
2024-11-02 05:54 sreehari Status acknowledged => scheduled
2024-11-05 05:47 hgbot Note Added: 0171356


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker