Giter Site home page Giter Site logo

checkout.py's People

Contributors

davidslv avatar

Watchers

 avatar  avatar

checkout.py's Issues

Small tips/questions

  1. In python it can be problematic to have an object as default argument like a list [] or dict [] as you have in pricing_rules=[]. Because that part of the code only runs once and so that list will always be the same.
    https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L6

  2. I would try to load the list of products in the checkout init dynamically from a CSV file.
    https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L12

  3. For the list of products in memory, I suggest using a dictionary instead of a list, so that you can quickly access a product using their code.
    https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L12

  4. To calculate the sum of discounts you could use something similar to what you did in the total.
    total -= sum(rule.discount(self) for rule in self.pricing_rules)
    https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L24

    4.1. Also I would only pass the basket instead of the checkout instance.

  5. In the Bulk Discount, why are you saving storing the t_item?
    https://github.com/Davidslv/checkout.py/blob/master/bulk_discount.py#L12

  6. In the Bogof Discount, was it for a specific product? I thought all items could have this discount.
    https://github.com/Davidslv/checkout.py/blob/master/bogof_rule.py#L6

So, no big tips on the code man. Everything looks pythonic ;)

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.