Exemple #1
0
        //public float getCash()
        //{
        //    return cash.get();
        //}

        /// <summary>
        /// Checks inside. Wouldn't pay if can't. Takes back deposits from bank, if needed
        /// Doesn't pay tax
        /// </summary>
        public bool PayWithoutRecord(Agent whom, MoneyView howMuch, Register.Account account, bool showMessageAboutNegativeValue = true)
        {
            if (CanPay(howMuch))// It does has enough cash or deposit
            {
                if (!CanPayCashOnly(howMuch))
                {
                    Bank.ReturnDeposit(this, HowMuchLacksMoneyCashOnly(howMuch));
                }
                Register.RecordPayment(whom, account, howMuch);
                whom.cash.Add(howMuch);
                cash.Subtract(howMuch);
                return(true);
            }
            else
            {
                FailedPayments.RecordIncomeFromNowhere(account, howMuch);
                if (showMessageAboutNegativeValue)
                {
                    Debug.Log(this + " doesn't have " + howMuch + " to pay in Agent.payWithoutRecord2 " + whom
                              + " has " + getMoneyAvailable());
                }
                //PayAllAvailableMoneyWithoutRecord(whom);
                return(false);
            }
        }
Exemple #2
0
 public void PayAllAvailableMoneyWithoutRecord(Agent whom, Register.Account account)
 {
     if (Bank != null)
     {
         Bank.ReturnAllDeposits(this);
     }
     PayWithoutRecord(whom, cash, account);
 }
Exemple #3
0
        /// <summary>
        /// Checks inside. Wouldn't pay if can't. Takes back deposit from bank if needed
        /// Registers moneyIncomeThisTurn, pays tax. Returns true if was able to pay
        /// </summary>
        public bool Pay(Agent incomeReceiver, MoneyView howMuch, Register.Account account, bool showMessageAboutNegativeValue = true)
        {
            if (howMuch.isNotZero())
            {
                if (PayWithoutRecord(incomeReceiver, howMuch, account, showMessageAboutNegativeValue)) // pays here
                {
                    Money howMuchPayReally = howMuch.Copy();

                    if (incomeReceiver is Market) // Market wouldn't pay taxes cause it's abstract entity
                    {
                        return(true);
                    }

                    Agent payer = this;

                    // foreigners income tax calculation
                    if (payer is Market == false && //&& incomeReceiver is Market == false
                        payer.Country != incomeReceiver.Country &&
                        payer is Factory)    // pay taxes in enterprise jurisdiction only if it's factory
                    {
                        var payed = payer.Country.TakeIncomeTaxFrom(incomeReceiver, howMuchPayReally, false);
                        howMuchPayReally.Subtract(payed);//and reduce taxable base
                    }

                    // in rest cases only pops pay taxes
                    var popReceiver = incomeReceiver as PopUnit;
                    if (popReceiver != null)
                    {
                        incomeReceiver.Country.TakeIncomeTaxFrom(popReceiver, howMuchPayReally, popReceiver.Type.isPoorStrata());
                    }
                    //else // if it's not Pop than it should by dividends from enterprise..
                    //{
                    //    //var countryPayer = incomeReceiver as Country;
                    //    //if (countryPayer != null)
                    //        incomeReceiver.Country.TakeIncomeTaxFrom(incomeReceiver, howMuchPayReally, false);
                    //}
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }