public override void SerializeTo(IDictionary <string, string> serializableInfo) { base.SerializeTo(serializableInfo); serializableInfo.Add("Amount", Amount.ToString()); serializableInfo.Add("CurrentBalance", CurrentBalance.ToString()); serializableInfo.Add("CurrentAvailableBalance", CurrentAvailableBalance.ToString()); }
static internal CurrentBalanceDto Map(TrialBalanceCommand command, CurrentBalance currentBalance) { return(new CurrentBalanceDto { Command = command, Entries = Map(currentBalance.Entries) }); }
public override string ToString() { string desc = ""; if (ForcedEntity != null) { desc += ForcedEntity.Description; } else if (AutoEntity != null) { desc += AutoEntity.Description; } else { desc = Description; } if (ForcedType != null) { desc += string.Format(" ({0})", ForcedType.Description); } else if (ForcedEntity != null) { desc += string.Format(" ({0})", ForcedEntity.Type.Description); } else if (AutoEntity != null) { desc += string.Format(" ({0})", AutoEntity.Type.Description); } return(string.Format("{0} ({1}) - {2}", OperationMove.ToString(), CurrentBalance.ToString(), desc)); }
public virtual string CloseAndReport() { CurrentBalance -= monServCharge; CalculateInterest(); StringBuilder report = new StringBuilder(); report.Append("This month's starting balance: "); report.Append(string.Format("{0}", StartingBalance.toNAMoney(true)) + "\n"); report.Append("This month's final balance: "); report.Append(string.Format("{0}", CurrentBalance.toNAMoney(true)) + "\n"); report.Append("This month's total withdrawls: "); report.Append(string.Format("{0}", totalWithdraw.toNAMoney(true)) + "\n"); report.Append("This month's total deposits: "); report.Append(string.Format("{0}", totalDeposits.toNAMoney(true)) + "\n"); report.Append("This month's total number of withdrawls: "); report.Append(string.Format("{0}", numWithdraw) + "\n"); report.Append("This month's total number of deposits: "); report.Append(string.Format("{0}", numDeposits) + "\n"); report.Append("The monthly interest that was calculated this month was:"); report.Append(string.Format("{0}", (CurrentBalance * (InterestRate / 12)).toNAMoney(true))); numWithdraw = 0; numDeposits = 0; monServCharge = 0.0; return(report.ToString()); }
public void CalculateInterest() { double montlyInterestRate = Interest / 12; double montlyInterest = CurrentBalance * montlyInterestRate; CurrentBalance += montlyInterest; Console.WriteLine("The new balance is: {0}", CurrentBalance.ToNAMoney(true)); }
public void CalculateInterest() { double monInterestRate = InterestRate / 12; double monInterest = CurrentBalance * monInterestRate; CurrentBalance += monInterest; Console.WriteLine("The balance is now {0}", CurrentBalance.toNAMoney(true)); }
public Schema() : base() { InstanceType = typeof(__PersonJs__); Properties.ClearExposed(); Html = Add <__TString__>("Html"); Html.DefaultValue = "/HelloWorld/PersonJson.html"; Html.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__Html__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__Html__ = (System.String)_v_; }, false); FirstName = Add <__TString__>("FirstName$"); FirstName.DefaultValue = ""; FirstName.Editable = true; FirstName.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__FirstName__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__FirstName__ = (System.String)_v_; }, false); LastName = Add <__TString__>("LastName$"); LastName.DefaultValue = ""; LastName.Editable = true; LastName.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__LastName__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__LastName__ = (System.String)_v_; }, false); SaveTrigger = Add <__TLong__>("SaveTrigger$"); SaveTrigger.DefaultValue = 0L; SaveTrigger.Editable = true; SaveTrigger.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__SaveTrigger__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__SaveTrigger__ = (System.Int64)_v_; }, false); SaveTrigger.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.SaveTrigger() { App = (PersonJson)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonJson)pup).Handle((Input.SaveTrigger)input); }); FullName = Add <__TString__>("FullName", bind: "FullName"); FullName.DefaultValue = ""; FullName.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__FullName__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__FullName__ = (System.String)_v_; }, false); Expenses = Add <__TArray__>("Expenses"); Expenses.SetCustomGetElementType((arr) => { return(__ExpenseJ__.DefaultTemplate); }); Expenses.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__Expenses__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__Expenses__ = (__Arr__)_v_; }, false); NewExpenseTrigger = Add <__TLong__>("NewExpenseTrigger$"); NewExpenseTrigger.DefaultValue = 0L; NewExpenseTrigger.Editable = true; NewExpenseTrigger.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__NewExpenseTrigger__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__NewExpenseTrigger__ = (System.Int64)_v_; }, false); NewExpenseTrigger.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.NewExpenseTrigger() { App = (PersonJson)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonJson)pup).Handle((Input.NewExpenseTrigger)input); }); CurrentBalance = Add <__TLong__>("CurrentBalance"); CurrentBalance.DefaultValue = 0L; CurrentBalance.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__CurrentBalance__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__CurrentBalance__ = (System.Int64)_v_; }, false); CancelTrigger = Add <__TLong__>("CancelTrigger$"); CancelTrigger.DefaultValue = 0L; CancelTrigger.Editable = true; CancelTrigger.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__CancelTrigger__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__CancelTrigger__ = (System.Int64)_v_; }, false); CancelTrigger.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.CancelTrigger() { App = (PersonJson)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonJson)pup).Handle((Input.CancelTrigger)input); }); DeleteAllTrigger = Add <__TLong__>("DeleteAllTrigger$"); DeleteAllTrigger.DefaultValue = 0L; DeleteAllTrigger.Editable = true; DeleteAllTrigger.SetCustomAccessors((_p_) => { return(((__PersonJs__)_p_).__bf__DeleteAllTrigger__); }, (_p_, _v_) => { ((__PersonJs__)_p_).__bf__DeleteAllTrigger__ = (System.Int64)_v_; }, false); DeleteAllTrigger.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.DeleteAllTrigger() { App = (PersonJson)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((PersonJson)pup).Handle((Input.DeleteAllTrigger)input); }); }
public override void SerializeTo(IDictionary <string, string> serializableInfo) { serializableInfo.Add("AccountId", AccountId); serializableInfo.Add("TransactionId", TransactionId); serializableInfo.Add("TransactionType", ((int)TransactionType).ToString()); serializableInfo.Add("Amount", Amount.ToString()); serializableInfo.Add("CurrentBalance", CurrentBalance.ToString()); serializableInfo.Add("CurrentAvailableBalance", CurrentAvailableBalance.ToString()); }
/// <summary> /// Returns true if AccountDetailsViewModel instances are equal /// </summary> /// <param name="other">Instance of AccountDetailsViewModel to be compared</param> /// <returns>Boolean</returns> public bool Equals(AccountDetailsViewModel other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AccountId == other.AccountId || AccountId != null && AccountId.Equals(other.AccountId) ) && ( BankId == other.BankId || BankId != null && BankId.Equals(other.BankId) ) && ( AccountNumber == other.AccountNumber || AccountNumber != null && AccountNumber.Equals(other.AccountNumber) ) && ( SortCode == other.SortCode || SortCode != null && SortCode.Equals(other.SortCode) ) && ( AccountName == other.AccountName || AccountName != null && AccountName.Equals(other.AccountName) ) && ( CurrentBalance == other.CurrentBalance || CurrentBalance != null && CurrentBalance.Equals(other.CurrentBalance) ) && ( OverdraftLimit == other.OverdraftLimit || OverdraftLimit != null && OverdraftLimit.Equals(other.OverdraftLimit) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (CurrentBalance != null) { hashCode = hashCode * 59 + CurrentBalance.GetHashCode(); } if (AvailableBalance != null) { hashCode = hashCode * 59 + AvailableBalance.GetHashCode(); } return(hashCode); } }
public float MakeWithdrawal(float amount, string madeBy) { AccountTransaction t = new AccountTransaction(); if (amount > CurrentBalance) { throw new Exception("This exceeds the current account balance of " + CurrentBalance.ToString("C") + ". The transaction has been cancelled."); } t.Amount = amount; t.TransactionDate = DateTime.Now; t.transactionType = TransactionType.Withdrawal; t.NewAccountBalance = CurrentBalance - amount; CurrentBalance = t.NewAccountBalance; TransactionHistory.Add(t); return(CurrentBalance); }
// This prints our current balance (set from UserInterface), and various // other bits persistent UI information. private void PrintBalance() { Clear(); SetCursorPosition(1, WindowHeight - 1); SetColor(Gray); Write("Action: "); SetColor(White); Write(LastAction); string balance = " Available: "; string balanceAmount = CurrentBalance.ToString("C"); string selection = ""; string selectionName = ""; SetCursorPosition(WindowWidth - (balance.Length + 1 + balanceAmount.Length + selection.Length + selectionName.Length), WindowHeight - 1); SetColor(Gray); Write(selection); SetColor(White); Write(selectionName); SetColor(Gray); Write(balance); SetColor(White); Write(balanceAmount); SetColor(DarkGreen); SetCursorPosition(WindowWidth - 74, WindowHeight - 6); Write(Logo[0]); SetCursorPosition(WindowWidth - 74, WindowHeight - 5); Write(Logo[1]); SetCursorPosition(WindowWidth - 74, WindowHeight - 4); Write(Logo[2]); SetCursorPosition(WindowWidth - 74, WindowHeight - 3); Write(Logo[3]); SetColor(); SetCursorPosition(0, 0); }
public virtual string CloseAndReport() { CurrentBalance -= serviceCharge; CalculateInterest(); StringBuilder str = new StringBuilder(); str.Append("This month's starting balance: " + string.Format("{0}", StartingBalance.ToNAMoney(true)) + "\n"); str.Append("this month' final balance: " + string.Format("{0}", CurrentBalance.ToNAMoney(true)) + "\n"); str.Append("This month's total deposits: " + string.Format("{0}", totalDeposit.ToNAMoney(true)) + "\n"); str.Append("This month's total withdrawls: " + string.Format("{0}", totalWithdrawl.ToNAMoney(true)) + "\n"); str.Append("This month's number of deposits: " + string.Format("{0}", counterDeposit) + "\n"); str.Append("This month's number of withdrawls" + string.Format("{0}", counterWithdrawl) + "\n"); str.Append("The interest for this month was: " + string.Format("{0}", (CurrentBalance * (Interest / 12)).ToNAMoney(true)) + "\n"); counterWithdrawl = 0; counterDeposit = 0; serviceCharge = 0; return(str.ToString()); }
/// <summary> /// Returns true if BankingDepositBalance instances are equal /// </summary> /// <param name="other">Instance of BankingDepositBalance to be compared</param> /// <returns>Boolean</returns> public bool Equals(BankingDepositBalance other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( CurrentBalance == other.CurrentBalance || CurrentBalance != null && CurrentBalance.Equals(other.CurrentBalance) ) && ( AvailableBalance == other.AvailableBalance || AvailableBalance != null && AvailableBalance.Equals(other.AvailableBalance) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AccountId != null) { hashCode = hashCode * 59 + AccountId.GetHashCode(); } if (BankId != null) { hashCode = hashCode * 59 + BankId.GetHashCode(); } if (AccountNumber != null) { hashCode = hashCode * 59 + AccountNumber.GetHashCode(); } if (SortCode != null) { hashCode = hashCode * 59 + SortCode.GetHashCode(); } if (AccountName != null) { hashCode = hashCode * 59 + AccountName.GetHashCode(); } if (CurrentBalance != null) { hashCode = hashCode * 59 + CurrentBalance.GetHashCode(); } if (OverdraftLimit != null) { hashCode = hashCode * 59 + OverdraftLimit.GetHashCode(); } return(hashCode); } }
public override string ToString() { return(String.Format("{0,-10}{1,20}{2,25}{3,30}", TransactionDate.ToString("MM/dd/yyyy hh:mm:ss tt"), Action, ChangeInBalance.ToString("C"), CurrentBalance.ToString("C"))); //return $"{TransactionDate.ToString("MM/dd/yyyy hh:mm:ss tt")} {Action} {ChangeInBalance.ToString("C")} {CurrentBalance.ToString("C")}"; }
private bool IsWalletEnabled() { return(!String.IsNullOrWhiteSpace(Name) && !String.IsNullOrWhiteSpace(InitialBalance.ToString()) && !String.IsNullOrWhiteSpace(CurrentBalance.ToString()) && (Name.Length >= 2)); }
public override string ToString() => $"{TransactionType} transaction of {TransactionAmount.ToString("C2", System.Globalization.CultureInfo.CurrentCulture)}." + $"{Environment.NewLine}Previous Balance: {PreviousBalance.ToString("C2", System.Globalization.CultureInfo.CurrentCulture)}" + $"{Environment.NewLine}Current Balance: {CurrentBalance.ToString("C2", System.Globalization.CultureInfo.CurrentCulture)}";
public override void MakeWithdrawl(double amount) { base.AS = AccountStatus.Inactive; if (base.CurrentBalance >= 25) { base.AS = AccountStatus.Active; } if (base.AS == AccountStatus.Inactive) { Console.WriteLine("Apologies, the account is inactive, therefore the withdrawl may not be done"); } else { base.MakeWithdrawl(amount); if (base.CurrentBalance < 25) { Console.WriteLine("The current balance is now {0} and has now become inactive.", CurrentBalance.toNAMoney(true)); Console.WriteLine("No more withdrawls may be done until the balance exceeds 25$."); } } }
public override void MakeDeposit(double ammount) { base.accountStatus = AccountStatus.Inactive; if (base.CurrentBalance >= 25) { base.accountStatus = AccountStatus.Active; } if (base.accountStatus == AccountStatus.Inactive) { Console.WriteLine("Your account balance is below 25$, therefore you must make a big enough deposit to make it active again. \nCurrent balance is: " + CurrentBalance.ToNAMoney(true)); base.MakeDeposit(ammount); if (base.CurrentBalance >= 25) { Console.WriteLine("With the new deposit you made, your account is now active with a balance of: " + CurrentBalance.ToNAMoney(true)); } else { Console.WriteLine("Even with the new deposit, your account is still below 25$ and this results in your account still being inactive \nCurrent balance: " + CurrentBalance.ToNAMoney(true)); } } else { base.MakeDeposit(ammount); } }
public override void MakeWithdrawl(double ammount) { base.accountStatus = AccountStatus.Inactive; if (base.CurrentBalance >= 25) { base.accountStatus = AccountStatus.Active; } if (base.accountStatus == AccountStatus.Inactive) { Console.WriteLine("Your account balance is below 25$, therefore the withdrawl cannot be done. \nCurrent balance is :" + CurrentBalance.ToNAMoney(true)); } else { base.MakeWithdrawl(ammount); if (base.CurrentBalance < 25) { Console.WriteLine("The current balance is {0}$ and is now inactive. \nTo make any other withdrawls, your account balance needs to be higher than 25$", CurrentBalance.ToNAMoney(true)); } } }
public override void MakeDeposit(double amount) { base.AS = AccountStatus.Inactive; if (base.CurrentBalance >= 25) { base.AS = AccountStatus.Active; } if (base.AS == AccountStatus.Inactive) { Console.WriteLine("This account is inactive right now and must have a balance greater than or equal to 25$ to become active again."); base.MakeDeposit(amount); if (base.CurrentBalance >= 25) { Console.WriteLine("The new balance is {0} and is now active again!", CurrentBalance.toNAMoney(true)); } } else { base.MakeDeposit(amount); } }
public void CancelPurchase(Item selectedItem) { decimal beginningBalance = CurrentBalance; selectedItem.Qty++; selectedItem.Sold--; CurrentBalance += selectedItem.Price; MoneyPaid -= selectedItem.Price; string dir = Environment.CurrentDirectory; string fileName = "Log.txt"; string fullPath = Path.Combine(dir, fileName); using (StreamWriter sw = new StreamWriter(fullPath, true)) { sw.WriteLine("{0,-50}{1,-10}{2,-10}", $"{DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")} CANCEL {selectedItem.Name} {selectedItem.SlotID} ", beginningBalance.ToString("$0.00"), CurrentBalance.ToString("$0.00")); } }
public void GetAccountBalanceTest() { CurrentBalance.GetAccountBalance(); Assert.IsTrue(true); }
public void SetUp() { _moqer = new AutoMoqer(); _commitments = new EmployerCommitmentsModel { LevyFundedCommitments = new List <CommitmentModel> { new CommitmentModel { StartDate = DateTime.Now.AddMonths(-1), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Alan Wake", EmployerAccountId = ExpectedAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10.6m, NumberOfInstallments = 10, CompletionAmount = 100.8m, CourseName = "My Course", CourseLevel = 1, LearnerId = 90, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Levy, HasHadPayment = true }, new CommitmentModel { StartDate = DateTime.Now.AddMonths(2), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Jane Doe", EmployerAccountId = ReceivingEmployerAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10, NumberOfInstallments = 10, CompletionAmount = 100, CourseName = "My Course", CourseLevel = 1, LearnerId = 997, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Transfer, HasHadPayment = true }, new CommitmentModel { StartDate = DateTime.Now.AddMonths(2), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Jane Doe", EmployerAccountId = ReceivingEmployerAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10, NumberOfInstallments = 10, CompletionAmount = 100, CourseName = "My Course", CourseLevel = 1, LearnerId = 998, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Levy, HasHadPayment = false }, new CommitmentModel { StartDate = DateTime.Now.AddMonths(-2), PlannedEndDate = DateTime.Now.AddMonths(12), ApprenticeName = "Jane Doe", EmployerAccountId = ReceivingEmployerAccountId, SendingEmployerAccountId = ExpectedAccountId, MonthlyInstallment = 10, NumberOfInstallments = 10, CompletionAmount = 100, CourseName = "My Course", CourseLevel = 1, LearnerId = 999, ProviderName = "Test Provider", ProviderId = 99876, FundingSource = FundingSource.Levy, HasHadPayment = false } } }; _moqer.GetMock <ICommitmentsDataService>() .Setup(x => x.GetCurrentCommitments(It.IsAny <long>(), It.IsAny <DateTime?>())) .ReturnsAsync(_commitments); var hashingService = _moqer.GetMock <IHashingService>(); hashingService .Setup(m => m.DecodeValue("ABBA12")) .Returns(ExpectedAccountId); hashingService .Setup(m => m.DecodeValue("CDDC12")) .Returns(ReceivingEmployerAccountId); _balance = new BalanceModel { EmployerAccountId = 12345, Amount = 50000, TransferAllowance = 5000, RemainingTransferBalance = 5000, UnallocatedCompletionPayments = 2000 }; _moqer.GetMock <IAccountBalanceService>() .Setup(m => m.GetAccountBalance(It.IsAny <long>())) .ReturnsAsync(_balance); var balanceService = _moqer.GetMock <IAccountBalanceService>(); var currentBalance = new CurrentBalance(_balance, balanceService.Object, new Domain.Commitments.EmployerCommitments(12345, new EmployerCommitmentsModel())); _moqer.GetMock <ICurrentBalanceRepository>() .Setup(x => x.Get(It.IsAny <long>())) .ReturnsAsync(currentBalance); _moqer.SetInstance <IForecastingMapper>(new ForecastingMapper(Mock.Of <IApplicationConfiguration>())); }
public void GiveChange() { decimal beginningBalance = CurrentBalance; while (CurrentBalance >= .25M) { CurrentBalance -= .25M; Coins["quarters"]++; } while (CurrentBalance >= .1M) { CurrentBalance -= .1M; Coins["dimes"]++; } while (CurrentBalance > 0) { CurrentBalance -= .05M; Coins["nickels"]++; } string dir = Environment.CurrentDirectory; string fileName = "Log.txt"; string fullPath = Path.Combine(dir, fileName); using (StreamWriter sw = new StreamWriter(fullPath, true)) { sw.WriteLine("{0,-50}{1,-10}{2,-10}", $"{DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")} GIVE CHANGE", beginningBalance.ToString("$0.00"), CurrentBalance.ToString("$0.00")); } }