Exemplo n.º 1
0
 public static decimal GetValue(CoinCompartmentsType coinCompartmentsType)
 {
     return(Defination[coinCompartmentsType]);
 }
Exemplo n.º 2
0
 public void PickCash(CoinCompartmentsType coinCompartment, decimal amount)
 {
     this.CashDrawerValues[coinCompartment] -= amount;
 }
Exemplo n.º 3
0
        private KeyValuePair <CoinCompartmentsType, decimal> Payout(decimal changeAmount, CoinCompartmentsType compartmentType, CashRegister cashRegister, out decimal remainingChange)
        {
            remainingChange = changeAmount;

            bool IsDueByThisCoinCompartment = CashDrawerDefination.GetValue(compartmentType) > changeAmount;

            if (IsDueByThisCoinCompartment)
            {
                return(new KeyValuePair <CoinCompartmentsType, decimal>(compartmentType, 0));
            }

            var quantity  = Math.Floor(changeAmount / CashDrawerDefination.GetValue(compartmentType));
            var cashValue = Math.Min(quantity * CashDrawerDefination.GetValue(compartmentType), cashRegister.CashDrawerValues[compartmentType]);

            cashRegister.PickCash(compartmentType, cashValue);
            remainingChange = changeAmount - cashValue;

            return(new KeyValuePair <CoinCompartmentsType, decimal>(compartmentType, cashValue));
        }