Beispiel #1
0
        public decimal GetTax(decimal?totalTobePaid = null, decimal?companyRecommendedTipPercentage = null, decimal?companyTax = null, CheckinSub sub = null)
        {
            if (sub == null)
            {
                if (totalTobePaid == null)
                {
                    totalTobePaid = TotalToBePaid;
                }
                if (companyRecommendedTipPercentage == null)
                {
                    companyRecommendedTipPercentage = Company.RecommendedTipPercentage;

                    if (companyRecommendedTipPercentage != TipPercentage)
                    {
                        companyRecommendedTipPercentage = TipPercentage;
                    }
                }
                if (companyTax == null)
                {
                    companyTax = Company.TaxPercentage;
                }

                decimal percentage = (companyRecommendedTipPercentage.Value + companyTax.Value) / 100;

                var a         = (totalTobePaid.Value * percentage);
                var b         = (1 + percentage);
                var tipAndTax = a / b;//4,5

                var subTotal = totalTobePaid.Value - tipAndTax;
                var tax      = (subTotal * companyTax.Value) / 100;

                return(tax);
            }
            else
            {
                var tax = sub.SubTotal * Company.TaxPercentage / 100;

                return(tax);
            }
        }
Beispiel #2
0
        public decimal GetTip(decimal?totalTobePaid = null, decimal?companyRecommendedTipPercentage = null, decimal?companyTax = null, CheckinSub sub = null)
        {
            if (sub == null)
            {
                if (totalTobePaid == null)
                {
                    totalTobePaid = TotalToBePaid;
                }
                if (companyRecommendedTipPercentage == null)
                {
                    companyRecommendedTipPercentage = Company.RecommendedTipPercentage;

                    if (companyRecommendedTipPercentage != TipPercentage)
                    {
                        companyRecommendedTipPercentage = TipPercentage;
                    }
                }
                if (companyTax == null)
                {
                    companyTax = Company.TaxPercentage;
                }

                decimal percentage = (companyRecommendedTipPercentage.Value + companyTax.Value) / 100;

                var a         = (totalTobePaid.Value * percentage);
                var b         = (1 + percentage);
                var tipAndTax = a / b;

                var subTotal = totalTobePaid.Value - tipAndTax;
                var tip      = (subTotal * companyRecommendedTipPercentage.Value) / 100;

                return(tip);
            }
            else
            {
                if (sub.CheckinSubStatus == CheckinSubStatus.RequestedCheckout)
                {
                    return(sub.PriceTipPaid);
                }
                else
                {
                    var tip = sub.SubTotal * Company.RecommendedTipPercentage / 100;
                    return(tip);
                }
            }
        }
Beispiel #3
0
        public decimal CalcTotalToBePaidByTip(decimal totalTobePaid, decimal companyRecommendedTipPercentage, decimal companyTax, decimal newTip, CheckinSub sub = null)
        {
            if (sub == null)
            {
                decimal percentage = (companyRecommendedTipPercentage + companyTax) / 100;

                var a         = (totalTobePaid * percentage);
                var b         = (1 + percentage);
                var tipAndTax = a / b;

                var subTotal = totalTobePaid - tipAndTax;
                var tip      = (subTotal * companyRecommendedTipPercentage) / 100;

                tipAndTax = tipAndTax - tip;

                return(subTotal + tipAndTax + newTip);
            }
            else
            {
                var tip = sub.SubTotal * companyRecommendedTipPercentage / 100;
                var tax = sub.SubTotal * companyTax / 100;

                decimal toSum = totalTobePaid - sub.SubTotal - tip - tax;
                if (toSum < 0)
                {
                    toSum = 0;
                }

                var total = sub.SubTotal + tax + newTip + toSum;
                return(total);
            }
        }