Why didn't the customer get the discount? Get the answer with the rule in the code.

Prices, discounts and rules often sit in a views.py or a service that only developers can read. Adea reads it and explains step by step what happened on a specific order.

Why didn't order 10432 get the volume discount?

  1. Finding order 10432
  2. Reading shop/pricing.py
  3. Matching the rule against the order lines
A question asked of a Django system

Why didn't order 10432 get the volume discount?

Adea's answer

The order had 9 items, and the volume discount starts at 10. The discount also only applies to items in the Tools category, and 2 of the items were in Accessories.

Where the number comes from

The code Adea read shop/pricing.py:112

def volume_discount(lines):
    eligible = [l for l in lines
                if l.product.category == 'tools']
    if sum(l.qty for l in eligible) >= 10:
        return Decimal('0.08')

The query it ran

SELECT l.qty, c.name FROM shop_orderline l
JOIN shop_product p ON p.id = l.product_id
JOIN shop_category c ON c.id = p.category_id
WHERE l.order_id = 10432

What you get

Explains, not just counts

Adea shows the sequence: which lines counted, which rule was hit and why the threshold was not reached. Support can answer the customer right away.

Understands your ORM

Adea follows relations and managers in the Django models and finds the right tables, even when the names do not look like what you call things.

The rule can be corrected

If Adea has understood a rule wrongly, a developer corrects it. The fix applies to all future answers.

How to connect a Django app

Give read access to the repo and to a Postgres read-only user. Adea finds the models itself.

CREATE ROLE adea_readonly LOGIN PASSWORD '…';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO adea_readonly;
Read the setup guide

Questions about Django

Does it work with Django REST framework and Celery?

Adea reads the code that decides the rules, whether it lives in views, serializers, services or tasks.

Can support see the customer's data?

Only the tables and columns you open for their role.

What about Django admin?

It is not required, but you can have Adea link to the record in admin in the answer.

What do you want to know?