Many properties of a certain Order (and associated Models) record are dynamic (and directly affect each other) and I am trying to make a robust data workflow which would yield the most stable, yet flexible results.
Consider this model schema (unimportant properties are omitted):
- Order [weight, total_charge, tax_charge, shipping_charge, country_id ...]
- OrderItem [order_id, quantity, unit_price, discount, tax_rate, subtotal, ...]
- OrderItem [order_id, quantity, unit_price, discount, tax_rate, subtotal, ...]
- Payment [order_id, amount, ...]
If you change any of these properties, all others are affected.
eg. Order.country_id affects Order.shipping_charge and OrderItem.tax_rate
eg. OrderItem.discount affects OrderItem.subtotal, Order.total_charge and Order.tax_charge.
I would also like to be able to make "faux" calculations, without stored data, by supplying only a data array and have all the data rendered.
etc.
I am wondering WHERE and HOW should I properly approach these connections in their respective models? beforeSave callback, afterFind? Both? Make a behavior?
Does anyone have experience with this kind of co-dependence in Cake? How to make it as clean and robust as possible?
Thanks!
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment