Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advice Design Pattern to add multiple fees and item wise list

I need to write application in that I have calculation like this:

  1. Basic Fee
  2. Registration Fee; registration % ( basic fee) will vary based on property .
  3. Sales tax; ( basic fee + Registration Fee ) %, similar based on location it will vary;
  4. Service tax;( basic fee + Registration Fee + Sales Tax) %

In this I need to configure that tell us to include or not the Sales tax and service tax. Finally I need to Item wise amounts AS Basic Fee, Registration Fee, Sales tax and Service tax.

What design pattern I have to use to achieve this?

I have confusion on Decorator and Chain-of-Responsibility. and on each thing I have to store there respective fee. at the end. need list as

Desc     Basic  Reg  Sales  Service  Total
------------------------------------------
Item 1   100    25   22     13       160 
Item 2   80     15   12     8        115
------------------------------------------
Total    180    40   34     25       275
like image 401
Jkumar Avatar asked Nov 12 '22 05:11

Jkumar


1 Answers

I believe decorator pattern should fits your requirements.

like image 119
Wiktor Avatar answered Jan 04 '23 01:01

Wiktor