Skip to content

Instantly share code, notes, and snippets.

@pjvds
Created September 12, 2012 14:40
Show Gist options
  • Save pjvds/3707076 to your computer and use it in GitHub Desktop.
Save pjvds/3707076 to your computer and use it in GitHub Desktop.
Category
{
   String Name
}

Product
{
   String Name
   Decimal SinglePrice
   Integer Amount
   Category Category
}

Order
{
   String CustomerName
   List Products
}

Model Goal

  • Calculate total order price

Retail

  • Is used when CustomerName is Ivo
  • Result must be sorted on CustomerName ASC
  • Add $5 to each product price.
  • The first three products sorted by product price get a 10% discount!
  • All original prices must be stored as well as the results.
  • Total price per product.
  • The categories should have the total price for all the product they have in the order.

Corp.

  • Is used when CustomerName is Twan
  • Result must be sorted on CustomerName DESC
  • If product is in Beer category, single product price must be multiplied by Pi.
  • All original prices must be stored as well as the results.
  • To calculate the order total: first use all products where the name starts with A, then B, then C, continue. Within a group (A, B, C...) start with the first group and set the group price to TemporaryTotal = sum(p.SinglePrice) * sum(p.Amount))+TemporaryTotal. The sum of the group prices is the order price.
  • The categories should have the total price for all the product they have in the order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment