public void UpdateUnit(Unit unit) { if (unit is RentedUnit) { var rentedUnit = unit as RentedUnit; if (rentedUnit.OldAmount != rentedUnit.Amount) { var proRata = CalcualteProRata((DateTime)rentedUnit.ChangedDate, (DateTime)rentedUnit.PaidUntil, rentedUnit.Amount - rentedUnit.OldAmount); _accountTransactionService.AddAccountTransaction(rentedUnit.CustomerAccountId, AccountTransactionType.Rental, proRata, AccountTransactionInputType.Adjustment, rentedUnit.StockId, rentedUnit.Stock.ManufacturerModel + " Pro-rata"); } } _customerAccountRepository.UpdateUnit(unit); }