gberz3
2007-May-29 14:44 UTC
HOW TO: Implementing discounts in an invoicing/billing/pos system. . .?
Hi All, I''m in the process of creating an invoicing/billing/pos-esque package with Rails. It was suggested I do something I''m excited about and potentially even need in order to motivate me; so, that''s what I''m doing. Aaaaaanywho, I''ve got a bit of an implementation question. I want this application to be as "real-world" as possible. That being the case, I''m having an issue with how to implement discounts. Personally I usually only discount on the basis of the entire order whenever billing. However, I''m sure certain ones discount on a per-line-item basis. So, I guess, I''m basically asking for implementation suggestions when it comes to discounts. For instance should I implement a discount: 1) per invoice? 2) per line item? 3) on both? 4) by some mechanism not mentioned here? . . .please provide a few details to back up your suggestion(s) if at all possible. Thanks, Michael --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jemminger
2007-May-29 15:31 UTC
Re: HOW TO: Implementing discounts in an invoicing/billing/pos system. . .?
depends on how you want to do it ;-)
very roughly and off the top of my head, i''d think you could
accomplish #3 like so:
class Order < AR::B
has_many :order_discounts
def get_total_with_discounts
... total the line_items with respective discounts if any...
... return total with order_discounts applied if any...
end
end
class LineItem < AR::B
has_many :line_item_discounts
end
this assumes multiple discounts are allowed for Order and LineItem...
otherwise use has_one
hope this helps
On May 29, 10:44 am, gberz3
<gbe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi All,
>
> I''m in the process of creating an invoicing/billing/pos-esque
package
> with Rails. It was suggested I do something I''m excited about and
> potentially even need in order to motivate me; so, that''s what
I''m
> doing.
>
> Aaaaaanywho, I''ve got a bit of an implementation question. I want
> this application to be as "real-world" as possible. That being
the
> case, I''m having an issue with how to implement discounts.
Personally
> I usually only discount on the basis of the entire order whenever
> billing. However, I''m sure certain ones discount on a
per-line-item
> basis.
>
> So, I guess, I''m basically asking for implementation suggestions
when
> it comes to discounts. For instance should I implement a discount:
>
> 1) per invoice?
>
> 2) per line item?
>
> 3) on both?
>
> 4) by some mechanism not mentioned here?
>
> . . .please provide a few details to back up your suggestion(s) if at
> all possible.
>
> Thanks,
> Michael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---