protected void dueAmountPayButton_Click(object sender, EventArgs e) { BillManager billManager = new BillManager(); string amount = amountTextBox.Value.ToString().Trim(); if (amount != "") { string billNo = ViewState["BillNo"].ToString(); bool isPaid = billManager.IsBillPaid(billNo); if (isPaid == true) { testTypeSuccessfullAlartLabel.Text = "Bill already Paid."; testTypeSuccessfullDiv.Visible = true; } else { int rowAffected = billManager.UpdateBillStatus(billNo); if (rowAffected > 0) { testTypeSuccessfullAlartLabel.Text = "Bill Successfully paid."; testTypeSuccessfullDiv.Visible = true; } } } }
public void DatabaseCreate() { GetConnection(); _mDbConnection.Open(); List <string> createTableQueries = new List <string>(); UserDataManager.CreateTableQueries(createTableQueries); BillManager.CreateTableQueries(createTableQueries); using (SQLiteTransaction mytransaction = _mDbConnection.BeginTransaction()) { using (SQLiteCommand command = _mDbConnection.CreateCommand()) { command.Transaction = mytransaction; foreach (string query in createTableQueries) { command.CommandText = query; try { command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine($@"Error in {query}"); Console.WriteLine($@"Message {ex.Message}"); } } } mytransaction.Commit(); } _mDbConnection.Close(); }
public MainWindow() { DataContext = new SetListBoxHomepage(); InitializeComponent(); BillManager billManager = new BillManager(); //MessageBox.Show(billManager.GetBills().ToString()); }
public companyWindow(CompanyRepository companyRepository, BillRepository billRepository, BillManager billManager) { this.companyRepository = companyRepository; this.billRepository = billRepository; this.billManager = billManager; CompanyWindowViewModel = new InformationWindowViewModel<Company>(); CompanyWindowViewModel.Items = new ObservableCollection<Company>(companyRepository.All.ToList()); InitializeComponent(); DataContext = this; controller = new InformationWindowController<Company>(CompanyWindowViewModel, companies_ComboBox, new TextBox[] { companyName_TextBox, companyStreet_TextBox, companyCity_TextBox, companyPostalCode_TextBox, companyID_TextBox, companyAccountNumber_TextBox, companyBankName_TextBox, companyBankBIC_TextBox, companyBillerName_TextBox, companyPhoneNumber_TextBox, companyEmailAddress_TextBox }); }
public void TestInitialize() { _fixture = new Fixture(); _composition = new CompositionHelper(Settings.Default.MainConnectionString, Settings.Default.FilesConnectionString); _manager = _composition.Kernel.Get <BillManager>(); _billRepository = _composition.Kernel.Get <IBillRepository>(); }
public void InsertBill() { BillManager billManage = new BillManager(); SetBillData(); billManage.SaveBill(myBillItem); passBillID = billManage.myReturnedID; }
protected void saveButton_Click(object sender, EventArgs e) { string name = nameTextBox.Value; DateTime dateBirth = DateTime.Parse(dateOfBirthTextBox.Value); double fee = double.Parse(feeTextBox.Value); string mobileNo = mobileTextBox.Value.ToString(); DateTime currentDateTime = DateTime.Now; List <Test> testList = (List <Test>)ViewState["TestList"]; if (testList.Count > 0) { if (name != "" && mobileNo != "") { PatientManager patientManager = new PatientManager(); BillManager billManager = new BillManager(); OrderManager orderManager = new OrderManager(); Patient patient = new Patient(name, mobileNo, dateBirth); int patientRowAffected = patientManager.Save(patient); int patientId = patientManager.GetLastPatientId(); double totalAmount = Convert.ToDouble(ViewState["TotalAmount"]); string billNo = currentDateTime.ToString("yyyyMMddHHmmss") + patientId.ToString(); Bill bill = new Bill(billNo, currentDateTime, totalAmount, "unpaid"); int billRowAffected = billManager.Save(bill); foreach (Test test in testList) { Order order = new Order(patientId, test.Id, billNo); int orderRowAffected = orderManager.Save(order); } //if (patientRowAffected > 0 && billRowAffected > 0 && orderRowAffected > 0) //{ testTypeSuccessfullAlartLabel.Text = "All Test are successfully saved!!"; testTypeSuccessfullDiv.Visible = true; testTypeDangerDiv.Visible = false; GetReportInPdf(name, mobileNo, billNo, dateBirth); //} } else { testTypeDangerAlartLabel.Text = "Patient name and mobile number must required!!"; testTypeDangerDiv.Visible = true; testTypeSuccessfullDiv.Visible = false; } } else { testTypeDangerAlartLabel.Text = "No Test is added!!"; testTypeDangerDiv.Visible = true; testTypeSuccessfullDiv.Visible = false; } }
private void UpdateBill() { using (EditBill editBill = new EditBill()) { editBill.txtDiscount.text = txtDiscount.Text; editBill.txtTotal.text = txtAmount.Text; editBill.txtFinal.text = txtFinal.Text; editBill.txtPayMade.text = txtPayMade.Text; editBill.txtBalance.text = txtBalance.Text; editBill.txtSem.text = txtSemester.Text; editBill.txtSchoolYear.text = txtSchoolYear.Text; editBill.calDueDate.Value = DateTime.Parse(billDueDate); string comp = billStatus; if (comp == "false") { editBill.cmbStatus.selectedIndex = 1; editBill.calDatePaid.Enabled = false; } else { editBill.calDatePaid.Value = DateTime.Parse(billDatePaid); editBill.cmbStatus.selectedIndex = 0; editBill.calDatePaid.Enabled = true; } editBill.isEdit = true; editBill.ShowDialog(); if (editBill.isConfirmed == true) { var billManage = new BillManager(); var item = new BillItem(); item.Bill_Discount = Double.Parse(editBill.txtDiscount.text); item.Bill_TotalAmount = Decimal.Parse(editBill.txtTotal.text); item.Bill_FinalAmount = Decimal.Parse(editBill.txtFinal.text); item.Bill_PaymentMade = Decimal.Parse(editBill.txtPayMade.text); item.Bill_Balance = Decimal.Parse(editBill.txtBalance.text); item.Bill_Semester = editBill.txtSem.text; item.Bill_SchoolYear = editBill.txtSchoolYear.text; item.Bill_DueDate = editBill.calDueDate.Value.ToString("MM/dd/yyyy"); item.Bill_Id = billId; if (editBill.cmbStatus.selectedIndex == 0) { item.Bill_Status = "true"; item.Bill_DatePaid = editBill.calDatePaid.Value.ToString("MM/dd/yyyy"); } else { item.Bill_Status = "false"; item.Bill_DatePaid = "N/A"; } billManage.UpdateBill(item); } } StdClick(); }
private bool tryPut(ref Model.Bill model, out string errMsg) { errMsg = ""; bool re = false; model.Modifier = this.auth.UserId; model.ModifiedDate = DateTime.Now; if (BillManager.ModifyBillById(ref model, out errMsg)) { re = true; } return(re); }
public MainWindow() { InitializeComponent(); model = new EzBillingModel(); clientRepository = new ClientRepository(model); companyRepository = new CompanyRepository(model); billRepository = new BillRepository(model); excelConnection = new ExcelConnection(); billManager = new BillManager(); clientWindow = new clientWindow(clientRepository, billRepository, billManager); companyWindow = new companyWindow(companyRepository, billRepository, billManager); clientWindow.Closing += new CancelEventHandler(window_Closing); companyWindow.Closing += new CancelEventHandler(window_Closing); ClientViewModel = new InformationWindowViewModel<Client>(); ClientViewModel.Items = new ObservableCollection<Client>(clientRepository.All.ToList()); CompanyViewModel = new InformationWindowViewModel<Company>(); CompanyViewModel.Items = new ObservableCollection<Company>(companyRepository.All.ToList()); CompanyViewModel.PropertyChanged += CompanyViewModel_PropertyChanged; ProductViewModel = new InformationWindowViewModel<Product>(); ProductViewModel.Items = new ObservableCollection<Product>(); ProductViewModel.PropertyChanged += ProductViewModel_PropertyChanged; BillViewModel = new InformationWindowViewModel<Bill>(); BillViewModel.Items = new ObservableCollection<Bill>(); BillViewModel.PropertyChanged += BillViewModel_PropertyChanged; this.Closing += MainWindow_Closing; productSectionInputFields = new TextBox[] { productName_TextBox, productQuantity_TextBox, productUnit_TextBox, productUnitPrice_TextBox, productVATPercent_TextBox }; DataContext = this; excelConnection.Open(); }
public decimal FutureValue(DateTime futureDate, decimal?netPay) { try { Logger.Instance.Calculation($"FutureValue"); var payperiods = PayPeriodsTilDue(futureDate); var date = DateTime.Today; var billManager = new BillManager(); var billsFromDb = billManager.GetAllBills(); var bills = new Dictionary <string, string> { { "currentDate", DateTime.Today.ToShortDateString() }, { "endDate", DateTime.Today.Day <= 14 ? new DateTime(date.Year, date.Month, 15).ToShortDateString() : new DateTime(date.Year, date.Month, LastDayOfMonth(date).Day).ToShortDateString() }, { "periodCosts", "0" }, { "totalCosts", "0" }, { "totalSavings", "0" } }; foreach (var bill in billsFromDb) { bills.Add(bill.Name, bill.DueDate.ToShortDateString()); } for (var i = 0; i < payperiods; i++) { bills = UpdateBillDueDates(bills); bills = UpdateTotalCosts(bills); SetCurrentAndEndDate(bills); decimal?savings = Convert.ToDecimal(bills["totalSavings"]); var periodCosts = Convert.ToDecimal(bills["periodCosts"]); savings += netPay - periodCosts; bills["totalSavings"] = savings.ToString(); } //var cost = Convert.ToDecimal(bills["periodCosts"]); var save = Convert.ToDecimal(bills["totalSavings"]); Logger.Instance.Calculation($"FutureValue({futureDate:d}, {netPay}) returned {save}"); return(save); } catch (Exception e) { throw e; } }
private bool tryPost(ref Bill model, out string errMsg) { errMsg = ""; bool re = false; model.Oiler = this.auth.UserId; model.Time = System.DateTime.Now; model.Creater = this.auth.UserId; model.CreatedDate = System.DateTime.Now; model.Modifier = this.auth.UserId; model.ModifiedDate = System.DateTime.Now; if (BillManager.AddBill(ref model, out errMsg)) { re = true; } return(re); }
public decimal DiscretionarySpendingByDateRange(DateTime begin, DateTime end) { try { Logger.Instance.Calculation($"DiscretionarySpendingByDateRange"); var transactionManager = new TransactionManager(); var transactions = transactionManager.GetTransactionsBetweenDates(begin, end); var billManager = new BillManager(); var bills = billManager.GetAllBills(); var isBill = false; var ret = 0m; foreach (var transaction in transactions) { foreach (var bill in bills) { // If the bill name matches the transaction payee, count the transaction as a bill (mandatory expense) if (bill.Name.Equals(transaction.Payee)) { isBill = true; Logger.Instance.Calculation($"{transaction.Amount}: {transaction.Payee} transaction is a bill"); } else { Logger.Instance.Calculation($"{transaction.Amount}: {transaction.Payee} transaction is not a bill"); } } // If transaction is not a bill, add to discretionary spending total if (isBill) { continue; } ret += transaction.Amount; Logger.Instance.Calculation($"{transaction.Amount} added to discretionary spending total"); } Logger.Instance.Calculation($"{ret} total discretionary spending from {begin:d} to {end:d}"); return(ret); } catch (Exception e) { Logger.Instance.Error(e); return(0.0m); } }
public TransactionDTO() { Transaction = new Transaction(); Transactions = new List <Transaction>(); Metrics = new TransactionMetrics(); try { Accounts = new AccountManager().GetAllAccounts(); CreditCards = new CreditCardManager().Get(new CreditCardDTO()).CreditCards; BillsOutstanding = new BillManager().GetOutstandingBills(); FilterOptions = GetFilterOptions(); } catch (Exception) { Accounts = new List <Account>(); CreditCards = new List <CreditCard>(); } }
private void OnBillClick(int position) { var bill = _bills[position]; if (bill == null) { _logger.Error("Cannot process Bill click event. Unable to fidn bills at position " + position); return; } var title = bill.GetDisplayTitle(); var billSummary = BillManager.GetBillDetailedSummary(bill); var link = bill.Urls.Count > 0 ? bill.Urls[0] : string.Empty; AppHelper.ShowDetailsDialog(_fragment, title, billSummary, link); }
private Dictionary <string, string> UpdateTotalCosts(Dictionary <string, string> billsDictionary) { try { Logger.Instance.Calculation($"UpdateTotalCosts"); var billManager = new BillManager(); var bills = billManager.GetAllBills(); var currentDate = Convert.ToDateTime(billsDictionary["currentDate"]); var endDate = Convert.ToDateTime(billsDictionary["endDate"]); var expenses = 0.0m; billsDictionary["periodCosts"] = "0"; foreach (var bill in billsDictionary) { if (bill.Key == "currentDate" || bill.Key == "endDate" || bill.Key == "periodCosts" || bill.Key == "totalSavings" || bill.Key == "totalCosts") { continue; } var dueDate = Convert.ToDateTime(bill.Value); if (!(dueDate >= currentDate && dueDate <= endDate)) { continue; } expenses += bills.Where(b => b.Name == bill.Key).Select(b => b.AmountDue).FirstOrDefault(); Logger.Instance.Calculation($"{expenses} added to {bill.Key}"); } var billCosts = Convert.ToDecimal(billsDictionary["totalCosts"]); billsDictionary["totalCosts"] = (expenses + billCosts).ToString(CultureInfo.InvariantCulture); Logger.Instance.Calculation($"{expenses + billCosts} added to total costs (expenses: {expenses} + bill costs: {billCosts})"); billsDictionary["periodCosts"] = expenses.ToString(CultureInfo.InvariantCulture); Logger.Instance.Calculation($"expenses: {expenses} added to period costs"); return(billsDictionary); } catch (Exception e) { Logger.Instance.Error(e); return(null); } }
private Task <Tuple <List <Bill>, bool, int, string> > GetAllBillsTasks() { var getBillsTask = new Task <Tuple <List <Bill>, bool, int, string> >((prms) => { var passedParams = (prms as Tuple <string, BillManager, int, int>); var legislatorId = passedParams.Item1; var bm = new BillManager(new Logger(Class.SimpleName)); var localCurrentPage = passedParams.Item3; var mode = (BillViewerKind)((int)passedParams.Item4); var results = bm.GetBillsIntroduced(localCurrentPage); var isThereMoreVotes = results.IsThereMoreResults; return(new Tuple <List <Bill>, bool, int, string>(results.Results, isThereMoreVotes, localCurrentPage, string.Empty)); }, new Tuple <string, BillManager, int, int>("search term goes here", _billManager, currentPage, (int)_viewerMode)); return(getBillsTask); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RetainInstance = true; var serialziedLegislator = Arguments.GetString(BundleType.Legislator); if (!string.IsNullOrWhiteSpace(serialziedLegislator)) { _legislator = new Legislator().DeserializeFromJson(serialziedLegislator); } if (Arguments.ContainsKey(BundleType.BillsIsThereMoreContent)) { _isThereMoreVotes = Arguments.GetBoolean(BundleType.BillsIsThereMoreContent); } _billManager = new BillManager(MyLogger); _viewerMode = (BillViewerKind)Arguments.GetInt(BundleType.BillViewerFragmentType); }
public TransactionViewModel() { Transaction = new Transaction(); Transactions = new List <Transaction>(); Metrics = new TransactionMetrics(); AutoTransferPaycheckContributions = false; Date = DateTime.Today.ToString("d", CultureInfo.CurrentCulture); try { Accounts = new AccountManager().GetAllAccounts(); BillsOutstanding = new BillManager().GetOutstandingBills(); FilterOptions = GetFilterOptions(); } catch (Exception e) { Accounts = new AccountManager().GetAllAccounts(); BillsOutstanding = new BillManager().GetOutstandingBills(); Logger.Instance.Error(e); } }
protected void reportShowButton_Click(object sender, EventArgs e) { DateTime lowerDate = DateTime.Parse(lowerDateTextBox.Value.ToString()); DateTime upperDate = DateTime.Parse(upperDateTextBox.Value.ToString()); BillManager billManager = new BillManager(); List <ViewUnpaidBill> viewUnpaidBillList = billManager.GetUnpaidBillsByDate(lowerDate, upperDate); billShowGridView.DataSource = viewUnpaidBillList; billShowGridView.DataBind(); double totalAmount = 0; foreach (ViewUnpaidBill viewUnpaidBill in viewUnpaidBillList) { totalAmount += viewUnpaidBill.BillAmount; } totalAmountTextBox.Value = totalAmount.ToString(); }
public MainWindow(Employee employee) { InitializeComponent(); //Declare variables _employee = employee; _employeeManager = new EmployeeManager(); _carManager = new CarManager(); _customerManager = new CustomerManager(); _billingManager = new BillManager(); _saleManager = new SaleManager(); _partsManager = new PartsManager(); _repairManager = new RepairManager(); lblUser.Content = employee.getEmployeeName(); //Reset labels and group boxes refreshListView(); hideAllGroupBoxes(); blankLabels(); disableButtons(); }
private Task <Tuple <List <Bill>, bool, int, string> > GetLegislatorsBillsTask() { var getBillsTask = new Task <Tuple <List <Bill>, bool, int, string> >((prms) => { var passedParams = (prms as Tuple <string, BillManager, int, int>); var legislatorId = passedParams.Item1; var bm = new BillManager(new Logger(Class.SimpleName)); var localCurrentPage = passedParams.Item3; var mode = (BillViewerKind)((int)passedParams.Item4); var results = mode == BillViewerKind.CosponsoredBills ? bm.GetBillsCosponsoredbyLegislator2(legislatorId, localCurrentPage) : bm.GetBillsSponsoredbyLegislator2(legislatorId, localCurrentPage); var isThereMoreVotes = results.IsThereMoreResults; return(new Tuple <List <Bill>, bool, int, string>(results.Results, isThereMoreVotes, localCurrentPage, string.Empty)); }, new Tuple <string, BillManager, int, int>(_legislator.IdBioguide, _billManager, currentPage, (int)_viewerMode)); return(getBillsTask); }
protected void amountSearchButton_Click(object sender, EventArgs e) { string billNo = billNoTextBox.Value.Trim(); string mobileNo = mobileNoTextBox.Value.Trim(); if (billNo != "" || mobileNo != "") { BillManager billManager = new BillManager(); Bill bill; if (billNo != String.Empty) { bill = billManager.GetBillByBillNo(billNo); } else { bill = billManager.GetBillByMobileNo(mobileNo); } if (bill == null) { testTypeDangerAlartLabel.Text = "Not Found!!"; testTypeDangerDiv.Visible = true; } else { amountTextBox.Value = bill.Amount.ToString(); dueDateTextBox.Value = bill.Date.Date.ToString("dd/MM/yyyy"); ViewState["BillNo"] = bill.BillNo; } } else { testTypeDangerAlartLabel.Text = "Please enter either Bill No or Mobile No!!"; testTypeDangerDiv.Visible = true; } }
private void LoadStdBill() { loadBillData = new BillCollection(); loadBillData.LoadBillWithStdIdFromDb(Int32.Parse(LoginUser.stdLogStudentId)); foreach (var popBill in loadBillData.pubBillCollect) { if (DateTime.Parse(popBill.Bill_DueDate) < DateTime.Today) { var setOldManage = new BillManager(); setOldManage.SetTuitionToOld(popBill.Bill_Id); SetOldPart(); stop = true; return; } lblTotalTuitionContainer.Text = popBill.Bill_FinalAmount.ToString(); lblDiscountContainer.Text = $"{popBill.Bill_Discount.ToString()}%"; lblTotalBalanceContainer.Text = popBill.Bill_Balance.ToString(); lblTotalPaymentMadeContainer.Text = popBill.Bill_PaymentMade.ToString(); lblFullPaidDateContainer.Text = popBill.Bill_DatePaid.ToString(); lblTuitionDueDateContainer.Text = popBill.Bill_DueDate.ToString(); billId = popBill.Bill_Id; } }
public Dictionary <string, decimal> GetRequiredSavingsDict() { try { var savingsAccountBalances = new Dictionary <string, decimal>(); ExpenseManager expenseManager = new ExpenseManager(); AccountManager accountManager = new AccountManager(); BillManager billManager = new BillManager(); List <Expense> unpaidExpenses = expenseManager.GetAllUnpaidExpenses(); //foreach (var bill in _db.Bills.ToList()) foreach (var expense in unpaidExpenses) { try { var bill = billManager.GetBill(expense.BillId); if (bill == null) { Logger.Instance.Debug($"No Bill found WHERE expense.BillId = {expense.BillId}"); Logger.Instance.DataFlow($"No Bill found WHERE expense.BillId = {expense.BillId}"); continue; } bill.Account = accountManager.GetAccount(bill.AccountId); if (bill.Account == null) { continue; } var billTotal = expense.Amount; // Use info from Expense and not Bill to account for when the current Bill.Amount differs from past amounts var dueDate = expense.Due; var payPeriodsLeft = PayPeriodsTilDue(dueDate); var savePerPaycheck = 0.0m; var save = 0.0m; // Calculate how much to save each pay period if (dueDate > DateTime.Today) { switch (bill.PaymentFrequency) { case FrequencyEnum.Annually: savePerPaycheck = billTotal / 24; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; case FrequencyEnum.SemiAnnually: savePerPaycheck = billTotal / 12; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; case FrequencyEnum.Quarterly: savePerPaycheck = billTotal / 6; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; case FrequencyEnum.SemiMonthly: savePerPaycheck = billTotal / 4; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; case FrequencyEnum.Monthly: savePerPaycheck = billTotal / 2; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; case FrequencyEnum.BiWeekly: savePerPaycheck = billTotal; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; case FrequencyEnum.Weekly: savePerPaycheck = billTotal * 2; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; default: savePerPaycheck = billTotal / 2; Logger.Instance.Calculation($"{expense.Name} save/paycheck = {Math.Round(savePerPaycheck, 2)} to {bill.Account.Name} account"); break; } save = payPeriodsLeft > 1 ? Math.Round(billTotal - payPeriodsLeft * savePerPaycheck, 2) : savePerPaycheck; } else { save = expense.Amount; } // required savings = bill amount due - (how many pay periods before due date * how much to save per pay period) Logger.Instance.Calculation($"{bill.Account.Name} - [{Math.Round(billTotal, 2)}] [{bill.DueDate:d}] [{payPeriodsLeft}(ppl)] [{Math.Round(savePerPaycheck, 2)}(spp)] [{Math.Round(save, 2)}(req save)]"); if (savingsAccountBalances.ContainsKey(bill.Account.Name)) { savingsAccountBalances[bill.Account.Name] += save; } else { savingsAccountBalances.Add(bill.Account.Name, save); } } catch (Exception e) { Logger.Instance.Error(e); throw; } } return(savingsAccountBalances); } catch (Exception e) { Logger.Instance.Error(e); throw; } }
public Dictionary <string, decimal> GetPaycheckContributionsDict() { try { var accountManager = new AccountManager(); var accounts = accountManager.GetAllAccounts(); var billManager = new BillManager(); var bills = billManager.GetAllBills(); var accountContribution = new Dictionary <string, decimal>(); //Zeros out all accounts req paycheck contributions foreach (var account in accounts) { account.PaycheckContribution = 0.0m;; } // update suggested paycheck contributions for bills foreach (var bill in bills) { var billTotal = bill.AmountDue; Logger.Instance.Calculation($"{billTotal} due on {bill.DueDate} for {bill.Name}"); // get the account assigned to the bill bill.Account = accounts.FirstOrDefault(a => a.Id == bill.AccountId); if (bill.Account != null && bill.Account.ExcludeFromSurplus) { continue; } //TODO: Needs to account for all pay frequencies //TODO: Suggested contribution assumes payday twice a month. need to update to include other options if (bill.Account == null) { continue; } var contribution = 0.0m; switch (bill.PaymentFrequency) { case FrequencyEnum.Annually: contribution = billTotal / 24; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.SemiAnnually: contribution = billTotal / 12; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.Quarterly: contribution = billTotal / 6; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.SemiMonthly: // every 2 months contribution = billTotal / 4; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.Monthly: contribution = billTotal / 2; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.Weekly: contribution = billTotal * 2; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.BiWeekly: contribution = billTotal; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; case FrequencyEnum.Daily: break; default: contribution = billTotal / 2; if (accountContribution.ContainsKey(bill.Account.Name)) { accountContribution[bill.Account.Name] += contribution; } else { accountContribution.Add(bill.Account.Name, contribution); } Logger.Instance.Calculation($"{Math.Round(contribution, 2)} added to {bill.Account.Name}.SuggestedContribution"); break; } } return(accountContribution); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Updates database Bills.DueDate if the previous due date has passed /// </summary> public void UpdateBillDueDates() { try { Logger.Instance.Calculation($"UpdateBillDueDates"); var billManager = new BillManager(); var bills = billManager.GetAllBills(); var beginDate = DateTime.Today; foreach (var bill in bills) { if (bill.DueDate.Date > beginDate) { continue; } var frequency = bill.PaymentFrequency; var dueDate = bill.DueDate; var newDueDate = dueDate; /* Updates bill due date to the current due date * while loop handles due date updates, regardless of how out of date they are */ while (newDueDate < beginDate) { switch (frequency) { case FrequencyEnum.Daily: newDueDate = newDueDate.AddDays(1); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.Weekly: newDueDate = newDueDate.AddDays(7); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.BiWeekly: newDueDate = newDueDate.AddDays(14); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.Monthly: newDueDate = newDueDate.AddMonths(1); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.SemiMonthly: newDueDate = newDueDate.AddDays(15); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.Quarterly: newDueDate = newDueDate.AddMonths(3); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.SemiAnnually: newDueDate = newDueDate.AddMonths(6); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; case FrequencyEnum.Annually: newDueDate = newDueDate.AddYears(1); Logger.Instance.Calculation($"New due date {newDueDate:d}"); break; default: throw new ArgumentOutOfRangeException(); } } bill.DueDate = newDueDate; _db.Entry(bill).State = EntityState.Modified; Logger.Instance.Calculation($"{bill.Name} due date of {dueDate:d} updated to {newDueDate:d}"); if (!AddNewExpenseToDb(bill)) { return; } } _db.SaveChanges(); } catch (Exception e) { Logger.Instance.Error(e); } }
public bool updateCheck(CheckQueueRecord Check, string tran_type) { bool return_val = false; Check.replaceQuote(); BillManager bMgr = new BillManager(elt_account_number); ArrayList AAJEntryList = Check.All_accounts_journal_entry_list; int printID = Check.print_id; BillRecord bRec = (BillRecord)Check.BillList[0]; if (bMgr.updateBillRecord(ref bRec, "CHK")) { for (int i = 0; i < AAJEntryList.Count; i++) { if (((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != -1 && ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != 0) { this.aajMgr.checkInitial_Acct_Record((AllAccountsJournalRecord)AAJEntryList[i]); } } int tran_seq_id = this.aajMgr.getNextTranSeqNumber(); Cmd = new SqlCommand(); Cmd.Connection = Con; Con.Open(); SqlTransaction trans = Con.BeginTransaction(); Cmd.Transaction = trans; try { //DELETE PREVIOUS CHECK_DETAIL LIST SQL = "DELETE FROM check_detail where elt_account_number =" + elt_account_number + " and print_id=" + printID; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); //DELETE ALL_ACCOUNTS_JOURNAL ENTRY SQL = "DELETE FROM all_accounts_journal where elt_account_number =" + elt_account_number + " and tran_num=" + printID + " and tran_type='" + tran_type + "'"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); //INSERT CHECK_DETAL LIST ArrayList chkList = Check.CheckDetailList; for (int i = 0; i < chkList.Count; i++) { CheckDetailRecord cdRec = (CheckDetailRecord)chkList[i]; cdRec.replaceQuote(); cdRec.print_id = printID; SQL = "INSERT INTO [check_detail] "; SQL += "( elt_account_number, "; SQL += "amt_due,"; SQL += "amt_paid,"; SQL += "bill_amt,"; SQL += "bill_number,"; SQL += "due_date,"; SQL += "invoice_no,"; SQL += "memo,"; SQL += "pmt_method,"; SQL += "print_id,"; SQL += "tran_id)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + cdRec.amt_due; SQL += "','" + cdRec.amt_paid; SQL += "','" + cdRec.bill_amt; SQL += "','" + cdRec.bill_number; SQL += "','" + cdRec.due_date; SQL += "','" + cdRec.invoice_no; SQL += "','" + cdRec.memo; SQL += "','" + cdRec.pmt_method; SQL += "','" + printID; SQL += "','" + cdRec.tran_id; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } //INSERT AAJ ENTRIES for (int i = 0; i < AAJEntryList.Count; i++) { if (((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != -1 && ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != 0) { ((AllAccountsJournalRecord)AAJEntryList[i]).replaceQuote(); ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num = printID; SQL = "INSERT INTO [all_accounts_journal] "; SQL += "( elt_account_number, "; SQL += "tran_num,"; SQL += "gl_account_number,"; SQL += "gl_account_name,"; SQL += "tran_seq_num,"; SQL += "tran_type,"; SQL += "tran_date,"; SQL += "Customer_Number,"; SQL += "Customer_Name,"; SQL += "debit_amount,"; SQL += "credit_amount,"; SQL += "balance,"; SQL += "previous_balance,"; SQL += "gl_balance,"; SQL += "gl_previous_balance)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_name; SQL += "','" + tran_seq_id++; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_type; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_date; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_name; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).debit_amount; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).credit_amount; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).previous_balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_previous_balance; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } } //UPDATE THE CHECK string check_type = ""; if (tran_type == "CHK" || tran_type == "CSH" || tran_type == "CRC" || tran_type == "BTB") { check_type = "C"; } else { check_type = "BP"; } SQL = "UPDATE [check_queue] "; SQL += "Set elt_account_number='" + elt_account_number + "',"; SQL += "ap='" + Check.ap + "',"; SQL += "bank='" + Check.bank + "',"; SQL += "bill_date='" + Check.bill_date + "',"; SQL += "bill_due_date='" + Check.bill_due_date + "',"; SQL += "check_amt='" + Check.check_amt + "',"; SQL += "check_type='" + check_type + "',"; SQL += "memo='" + Check.memo + "',"; SQL += "pmt_method='" + Check.pmt_method + "',"; SQL += "print_check_as='" + Check.print_check_as + "',"; SQL += "print_date='" + Check.print_date + "',"; SQL += "print_id='" + Check.print_id + "',"; SQL += "print_status='" + Check.print_status + "',"; SQL += "vendor_info='" + Check.vendor_info + "',"; SQL += "vendor_name='" + Check.vendor_name + "',"; SQL += "vendor_number='" + Check.vendor_number + "'"; SQL += "where elt_account_number =" + elt_account_number + " and print_id=" + printID; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); trans.Commit(); return_val = true; } catch (Exception ex) { trans.Rollback(); throw ex; } finally { Con.Close(); } } return(return_val); }
public CheckQueueManager(string elt_acct) : base(elt_acct) { aajMgr = new AllAccountsJournalManager(elt_account_number); cdMgr = new CheckDetailManager(elt_account_number); bMgr = new BillManager(elt_account_number); }
public bool enqueueCheck(CheckQueueRecord Check, string tran_type) { bool return_val = false; Check.replaceQuote(); BillManager bMgr = new BillManager(elt_account_number); ArrayList AAJEntryList = Check.All_accounts_journal_entry_list; int printID = getNextPrintID(); Check.print_id = printID; BillRecord bRec = (BillRecord)Check.BillList[0]; bRec.Print_id = printID; if (bMgr.insertBillRecord(ref bRec, "CHK")) { for (int i = 0; i < AAJEntryList.Count; i++) { if (((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != -1 && ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != 0) { this.aajMgr.checkInitial_Acct_Record((AllAccountsJournalRecord)AAJEntryList[i]); } } int tran_seq_id = this.aajMgr.getNextTranSeqNumber(); //INSERT CHECK_DETAL LIST Cmd = new SqlCommand(); Cmd.Connection = Con; Con.Open(); SqlTransaction trans = Con.BeginTransaction(); Cmd.Transaction = trans; try { ArrayList chkList = Check.CheckDetailList; for (int i = 0; i < chkList.Count; i++) { CheckDetailRecord cdRec = (CheckDetailRecord)chkList[i]; cdRec.replaceQuote(); cdRec.print_id = printID; SQL = "INSERT INTO [check_detail] "; SQL += "( elt_account_number, "; SQL += "amt_due,"; SQL += "amt_paid,"; SQL += "bill_amt,"; SQL += "bill_number,"; SQL += "due_date,"; SQL += "invoice_no,"; SQL += "memo,"; SQL += "pmt_method,"; SQL += "print_id,"; SQL += "tran_id)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + cdRec.amt_due; SQL += "','" + cdRec.amt_paid; SQL += "','" + cdRec.bill_amt; SQL += "','" + cdRec.bill_number; SQL += "','" + cdRec.due_date; SQL += "','" + cdRec.invoice_no; SQL += "','" + cdRec.memo; SQL += "','" + cdRec.pmt_method; SQL += "','" + printID; SQL += "','" + cdRec.tran_id; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } //INSERT AAJ ENTRIES for (int i = 0; i < AAJEntryList.Count; i++) { if (((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != -1 && ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number != 0) { ((AllAccountsJournalRecord)AAJEntryList[i]).replaceQuote(); ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num = printID; SQL = "INSERT INTO [all_accounts_journal] "; SQL += "( elt_account_number, "; SQL += "tran_num,"; SQL += "gl_account_number,"; SQL += "gl_account_name,"; SQL += "tran_seq_num,"; SQL += "tran_type,"; SQL += "tran_date,"; SQL += "Customer_Number,"; SQL += "Customer_Name,"; SQL += "debit_amount,"; SQL += "credit_amount,"; SQL += "balance,"; SQL += "previous_balance,"; SQL += "gl_balance,"; SQL += "gl_previous_balance)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_num; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_account_name; SQL += "','" + tran_seq_id++; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_type; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).tran_date; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_number; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).customer_name; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).debit_amount; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).credit_amount; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).previous_balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_balance; SQL += "','" + ((AllAccountsJournalRecord)AAJEntryList[i]).gl_previous_balance; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); } } //INSERT A CHECK string check_type = ""; if (tran_type == "CHK" || tran_type == "CSH" || tran_type == "CRC" || tran_type == "BTB") { check_type = "C"; } else { check_type = "BP"; } SQL = "INSERT INTO [check_queue] "; SQL += "(elt_account_number,"; SQL += "ap,"; SQL += "bank,"; SQL += "bill_date,"; SQL += "bill_due_date,"; SQL += "check_amt,"; SQL += "check_type,"; SQL += "memo,"; SQL += "pmt_method,"; SQL += "print_check_as,"; SQL += "print_date,"; SQL += "print_id,"; SQL += "print_status,"; SQL += "vendor_info,"; SQL += "vendor_name,"; if (Check.check_no != 0) { SQL += "check_no,"; } SQL += "vendor_number)"; SQL += "VALUES"; SQL += "('" + elt_account_number; SQL += "','" + Check.ap; SQL += "','" + Check.bank; SQL += "','" + Check.bill_date; SQL += "','" + Check.bill_due_date; SQL += "','" + Check.check_amt; SQL += "','" + check_type; SQL += "','" + Check.memo; SQL += "','" + Check.pmt_method; SQL += "','" + Check.print_check_as; SQL += "','" + Check.print_date; SQL += "','" + Check.print_id; SQL += "','" + Check.print_status; SQL += "','" + Check.vendor_info; SQL += "','" + Check.vendor_name; if (Check.check_no != 0) { SQL += "','" + Check.check_no; } SQL += "','" + Check.vendor_number; SQL += "')"; Cmd.CommandText = SQL; Cmd.ExecuteNonQuery(); trans.Commit(); return_val = true; } catch (Exception ex) { trans.Rollback(); throw ex; } finally { Con.Close(); } } if (Check.check_no != 0) { GLManager glmgr = new GLManager(elt_account_number); try { glmgr.updateNextCheckNumber(Check.bank, Check.check_no); } catch (Exception ex2) { throw ex2; } } return(return_val); }
public BillController(BillManager repo) { _repo = repo; }
public SchedulePayManagerController() { billmanager = new BillManager(); }