I am currently modeling a system responsible for managing royalty payments. The fee can be as simple as:
or as complicated as:
- Pay Author B 15% of the income up to 1000 sold, then 12% of the income
- Also pay the author B $ 1.50 for each sold up to 1000 quantity sold.
or
- Pay Author C 15% of income for first income of $ 1,000, then 12% of income.
In short, a payment can be either a flat amount for each sold, or a percentage of revenue. The payment term may be based on the quantity sold or on revenue. I tried to create a class (which closely matches the database table behind the scenes) that covers all this flexibility by specifying types for a range of payments and payment values. However, I am worried that perhaps I am trying to make this class do too much, and may be in the corner if we need to consider additional scenarios in the future. I am looking for suggestions for alternative development approaches.
public class PaymentRule
{
public decimal RangeMinimum { get; set; }
public decimal? RangeMaximum { get; set; }
public decimal PaymentValue { get; set; }
public string RangeType { get; set; }
public decimal ValueType { get; set; }
public decimal CalculateRoyaltyDue(int quantitySold, decimal revenue)
{
}
}
Any suggestions would be appreciated.
UPDATE 5/9/2012:
I should mention that these rules must be stored in the SQL Server database.
source
share