[TYPO3-mvc] Best practice for a domain model for scaled prices

Franz Koch typo3.RemoveForMessage at elements-net.de
Mon Dec 28 14:34:26 CET 2009


Hi list,

today I've got a question about your opinions for a correct domain model 
for scaled prices. Let's use a regular shop as example. A article has a 
price with scaled pricing (german: Staffelpreis), that means that 1 
article costs 10,-€ per piece, but if you have a quantity of let's say 
10 or 100 of the same article, you only pay 9,-€ a piece.

My thinking was, that in this case, articles only can have a price and 
doesn't have to know about any scaling. So I assign a price object to 
the articles.

tx_myExt_domain_model_price
- value (basic price)
- type (net / gross)
- currency
- tax
- country (excludeField => price only applies in a certain country)
- userGroup (excludeField => only applies to a certain fe_group)
- customer (excludeField => only applies to a certain customer)
- scaledValues -> tx_myExt_domain_model_scaledPriceValues

tx_myExt_domain_model_scaledPriceValues
- quantity
- value (the price)
- type (net / gross)


This seems to be good domain model with a clean OO structure in my eyes, 
but my problem is now how to sort the articles by price in my 
articleRepository by also taking the scaled prices into account, which 
are btw. optionally. If they would apply to every article it wouldn't be 
a big issue, but sorting by two different columns from different tables 
that should be treated as one result set for sorting? I don't want to 
see this query monster with temporary result tables or alike.

So I was thinking about dropping the "basic price" from 
tx_myExt_domain_model_price and create it as record with the quantity 1 
in tx_myExt_domain_model_scaledPriceValues. Does this still sound good 
to you? Maybe I should rename the scaledPriceValue then to 
tx_myExt_domain_model_priceValue or something, but I fear the resulting 
queries with joins over several mm-tables will become a performance 
killer, too.

-- 
kind regards,
Franz Koch

---------------------------------------------------
PayPal-Account: 'paypal _at_ elements-net _dot_ de'
---------------------------------------------------


More information about the TYPO3-project-typo3v4mvc mailing list