コード例 #1
0
ファイル: Shop.cs プロジェクト: dovanduy/Library
        private CashDistributionEngine get_CashDistributionEngineAndCheckBalance(decimal paymentAmount, bool isNonRefundablePaymentAllowed)
        {
            UserId.IsNullOrWhiteSpaceThrowException("You must be logged in");
            decimal amountToBuyShop = MenuPathMain.Payment_To_Buy_Shop();

            Person person = PersonBiz.GetPersonForUserId(UserId);

            person.IsNullThrowException();

            CashBalanceVM cashBalance = BalanceFor_Person(person.Id, CashStateENUM.Available);

            CashDistributionEngine cde = new CashDistributionEngine(
                cashBalance,
                paymentAmount,
                0,
                isNonRefundablePaymentAllowed);


            if (cde.CanBuy())
            {
                string msg = string.Format("You have a total balance of: Rs{0:N2}. Money = {1:N2}, Non Refundable Tokens {2:N2}. You can buy the shop for this month! The expected spending will be as follows: Money = Rs{3:N2}, Tokens = Rs{4:N2}",
                                           cde.CashBalance.Total(),
                                           cde.CashBalance.Refundable,
                                           cde.CashBalance.NonRefundable,
                                           cde.Refundable_Final,
                                           cde.NonRefundable_Final);

                cde.Message = msg;
                return(cde);
            }
            else
            {
                throw new Exception("You have a total balance of: Rs" + cde.CashBalance.Total().ToString("N2") + ". You do not have sufficent money to buy the shop.");
            }
        }
コード例 #2
0
        private void set_Payment_For_Product(BuySellDoc bsd, ControllerCreateEditParameter parm)
        {
            //first check to see if product can be paid for in token, if yes, then how much?


            decimal currBalance_NonRefundable     = parm.GlobalObject.Money_User.Non_Refundable.MoneyAmount;
            decimal currBalance_Refundable        = parm.GlobalObject.Money_User.Refundable.MoneyAmount;
            decimal payment_Refundable            = bsd.Total_Product_Refundable;
            decimal payment_NonRefundable         = bsd.Total_Product_Non_Refundable;
            bool    isNonRefundablePaymentAllowed = payment_NonRefundable > 0;

            CashBalanceVM          cashBalance = new CashBalanceVM(currBalance_Refundable, currBalance_NonRefundable);
            CashDistributionEngine cde         = new CashDistributionEngine(
                cashBalance,
                payment_NonRefundable,
                payment_Refundable,
                isNonRefundablePaymentAllowed);


            if (cde.CanBuy())
            {
                string msg = string.Format("You have a total balance of: Rs{0:N2}. Money = {1:N2}, Non Refundable Tokens {2:N2}. The expected spending will be as follows: Money = Rs{3:N2}, Tokens = Rs{4:N2}",
                                           cde.CashBalance.Total(),
                                           cde.CashBalance.Refundable,
                                           cde.CashBalance.NonRefundable,
                                           cde.Refundable_Final,
                                           cde.NonRefundable_Final);

                cde.Message = msg;
            }
            else
            {
                throw new Exception("You have a total balance of: Rs" + cde.CashBalance.Total().ToString("N2") + ". You do not have sufficent money to buy.");
            }


            decimal total_Non_Refundable_Payment = cde.NonRefundable_Final;
            decimal total_Refundable_Payment     = cde.Refundable_Final;


            bsd.Total_Product_Payment_For_Invoice.SetToTodaysDate(
                total_Refundable_Payment,
                total_Non_Refundable_Payment,
                UserId,
                UserName);
        }