private void ProcessOrdinalCommission(SqlConnection con, SqlTransaction tran, string companyCode)
        {
            var    countByDesignation = _salesman.CountAssociates(companyCode);
            double companiesSales     = _member.GetSalesAmount(companyCode, UserType.AlphaMember) + _member.GetSalesAmount(companyCode, UserType.BetaMember);

            foreach (var dict in countByDesignation)
            {
                double commissionPercent = _policy.OrdinalCommissionPercentage(dict.Key);
                double commission        = companiesSales * commissionPercent / 100;

                var salesmanList = _salesman.Get(companyCode, dict.Key);
                int eligible     = 0;
                foreach (var salesman in salesmanList)
                {
                    if (_policy.IsEligibleForOrdinalCommission(salesman))
                    {
                        _salary.AddOrdinalCommission(con, tran, companyCode, salesman.Code, commission / dict.Value);
                        eligible++;
                    }
                }
                if (eligible == 0)
                {
                    //Unpaid commisiion added to company account.
                    _salary.AddOrdinalCommission(con, tran, null, companyCode, commission);
                }
            }
        }
Esempio n. 2
0
        public Designation NextDesignation(string companyCode, string code)
        {
            Dictionary <Designation, int> associates = _salesman.CountAssociates(companyCode, code);

            if (associates[Designation.J] >= 2)
            {
                return(Designation.K);
            }
            else if (associates[Designation.I] >= 3)
            {
                return(Designation.J);
            }
            else if (associates[Designation.H] >= 6)
            {
                return(Designation.I);
            }
            else if (associates[Designation.E] >= 6)
            {
                return(Designation.H);
            }
            else if (associates[Designation.E] >= 4)
            {
                return(Designation.G);
            }
            else if (associates[Designation.E] >= 2 &&
                     associates[Designation.C] >= 1 &&
                     associates[Designation.B] >= 2)
            {
                return(Designation.F);
            }
            else if (associates[Designation.C] >= 3 &&
                     associates[Designation.B] >= 3)
            {
                return(Designation.E);
            }
            else if (associates[Designation.C] >= 1 &&
                     associates[Designation.B] >= 2)
            {
                return(Designation.D);
            }
            else if (associates[Designation.B] >= 3)
            {
                return(Designation.C);
            }
            else if (associates[Designation.A] >= 2)
            {
                return(Designation.B);
            }
            else
            {
                return(Designation.A);
            }
        }