Ejemplo n.º 1
0
        public SaleCommission ComputeCommission(Sale sale, SalesPerson salesPerson)
        {
            // TODO: check for null values on extra commission
            decimal commissionRate;
            SaleCommissionType commissionType;
            if (sale.IsDirectSaleOf(salesPerson))
            {
                commissionRate = salesPerson.CommissionRate.Basic;
                commissionType = SaleCommissionType.Basic;
            }
            else
            {
                commissionRate = salesPerson.CommissionRate.Extra ?? 0;
                commissionType = SaleCommissionType.Extra;
            }

            decimal commissionAmount = (decimal)commissionRate * sale.Amount;
            decimal percentage = (decimal)commissionRate * 100;

            return new SaleCommission(
                sale.Id,
                salesPerson.Id,
                sale.Amount,
                commissionAmount,
                (decimal)commissionRate,
                commissionType);
        }
Ejemplo n.º 2
0
Archivo: Sale.cs Proyecto: Daskul/BIG
 public bool IsDirectSaleOf(SalesPerson salesPerson)
 {
     return salesPerson.Id == this.SalesPersonId;
 }