Giter VIP home page Giter VIP logo

Comments (7)

maerteijn avatar maerteijn commented on June 14, 2024

Hi @ckepper. Discounts are calculated by applying offers on the complete basket, not just per line. So this is a bit of an edge-case as we follow the way oscar caclulates the discounts on a basket.

Do you mean btw that price_excl_tax and price_excl_tax_excl_discounts are not automatic recalculated on your client when not retrieving the basket again? These fields are only available in the basket right?

from django-oscar-api.

ckepper avatar ckepper commented on June 14, 2024

I am aware that this might be an edge case and I know that Oscar calculates discounts on the basket and not on a single line item.

What I found confusing was that I received a response to the PUT request that included price_excl_tax_excl_discounts but the value was incorrect. I would have expected that the response shows either the correct value (with discount applied) or no discount field at all. Hope that makes sense.

Here is the output of the PUT request. As you can see, price_excl_tax == price_incl_tax_excl_discounts:

{
  "url": "https://localhost/shop/api/v1/baskets/37/lines/31/",
  "product": "https://localhost/shop/api/v1/products/8/",
  "quantity": 100,
  "attributes": [],
  "price_currency": "USD",
  "price_excl_tax": 299,
  "price_incl_tax": 299,
  "price_incl_tax_excl_discounts": 299,
  "price_excl_tax_excl_discounts": 299,
  "is_tax_known": false,
  "warning": null,
  "basket": "https://localhost/shop/api/v1/baskets/37/",
  "stockrecord": "https://localhost/shop/api/v1/stockrecords/8/",
  "date_created": "2016-11-13T00:17:06.447193Z"
}

The call to the basket lines however reveals that there is a discount on the product (price_excl_tax != price_incl_tax_excl_discounts):

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "url": "https://localhost/shop/api/v1/baskets/37/lines/31/",
      "product": "https://localhost/shop/api/v1/products/8/",
      "quantity": 100,
      "attributes": [],
      "price_currency": "USD",
      "price_excl_tax": 269.1,
      "price_incl_tax": 269.1,
      "price_incl_tax_excl_discounts": 299,
      "price_excl_tax_excl_discounts": 299,
      "is_tax_known": false,
      "warning": null,
      "basket": "https://localhost/shop/api/v1/baskets/37/",
      "stockrecord": "https://localhost/shop/api/v1/stockrecords/8/",
      "date_created": "2016-11-13T00:17:06.447193Z"
    }
  ]
}

from django-oscar-api.

maerteijn avatar maerteijn commented on June 14, 2024

@ckepper Ah ok, I see now that the price_excl_tax_excl_discounts is also serialized in the line response (which means that we don't apply the offers to the basket before the response). This should be fixed (or we should leave out the price_incl_tax_excl_discounts and price_excl_tax_excl_discounts fields). I'll investigate this further and will come up with a proper solution. Thanks for reporting!

from django-oscar-api.

maerteijn avatar maerteijn commented on June 14, 2024

I will try to fix this (when I have more time) in a proper way. In the meanwhile I have this branch which hopefully fixes this : https://github.com/django-oscar/django-oscar-api/tree/fix/update-line-quantity Can I ask you try this (just to see if I'm lucky :) )

from django-oscar-api.

ckepper avatar ckepper commented on June 14, 2024

Thank you for supplying this patch so quickly. I tried it out but unfortunately it didn't fix it. I stepped through the code with a debugger and found that the correct value was in the result cache (basket._lines._result_cache[0]) but this was not used for the output.

from django-oscar-api.

maerteijn avatar maerteijn commented on June 14, 2024

Hi @ckepper, I think I fixed this in https://github.com/django-oscar/django-oscar-api/tree/fix/update-line-quantity now (and I added a test for it). Can you confirm this works for you? Then I'll review it next week and make a new release of oscarapi. Thnx.

from django-oscar-api.

maerteijn avatar maerteijn commented on June 14, 2024

@ckepper, We already made a proper solution for this and merged this to master. Maybe you can check this so we are sure we have the correct solution?

from django-oscar-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.