private Deposit getDeposit(DepositConfiguration depositConfig, QuickbooksPaytype qbPayType) { // Lets see if we already have that deposit. if (Deposits.ContainsKey(depositConfig)) { // We already have that one, lets see if it is full or not. Stack <Deposit> stack = Deposits[depositConfig]; Deposit topDeposit = stack.Peek(); if (topDeposit.isFull(qbPayType)) { Deposit deposit = new Deposit(depositConfig); stack.Push(deposit); return(deposit); } else { return(topDeposit); } } else { // Don't have this type of deposit. Lets create it. Deposit newDeposit = new Deposit(depositConfig); Stack <Deposit> newStack = new Stack <Deposit>(); newStack.Push(newDeposit); Deposits[depositConfig] = newStack; return(newDeposit); } }
/** * Return true if we cannot accept any more of the specified deposit pay type. */ public Boolean isFull(QuickbooksPaytype qbPayType) { if (_payTypeCounts.ContainsKey(qbPayType) && _payTypeCounts[qbPayType] == _depositConfig.getMaximum(qbPayType)) { return(true); } else { return(false); } }
public override bool Equals(object obj) { QuickbooksPaytype that = obj as QuickbooksPaytype; if (that == null) { return(false); } return(this.Name.Equals(that.Name)); }
public Int32 getMaximum(QuickbooksPaytype qbPaymentType) { foreach (DepositConfigPayType payType in QuickBooksPaymentTypes) { if (payType.QuickbooksPaytype.Equals(qbPaymentType)) { return(payType.Maximum); } } throw new Exception(String.Format("{0} is not contained in this deposit configuration", qbPaymentType)); }
public DepositConfiguration getDepositConfig(QuickbooksPaytype qbPayType) { foreach (DepositConfiguration config in Deposits) { foreach (DepositConfigPayType payType in config.QuickBooksPaymentTypes) { if (payType.QuickbooksPaytype.Equals(qbPayType)) return config; } } return null; }