private Result CommitChanges(ConfirmRequired confirmRequired) { //return immediately if there is no data if (_currentItems == null) { return(new Result(false, "No record to update")); } // return if no record was changed if (!_hasModified) { return(new Result(false, "No changes made")); } // if must ask user wether to commit changes if (confirmRequired == ConfirmRequired.Yes) { if (MessageWindow.ConfirmSaveChangesFirst() == MessageBoxResult.No) { return(new Result(false, "Changes was discarded")); } } // update/insert records in the database foreach (CashVoucher currentItem in _currentItems) { if (currentItem.ID == 0) { var result = currentItem.Create(); if (result.Success == false) { return(result); } } else { var result = currentItem.Update(); if (result.Success == false) { return(result); } } } _hasModified = false; #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find("CV", _voucherNumber); voucherLog.Date = _voucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion return(new Result(true, "Record saved")); }
private Result PerformPosting() { // post time desposit end balance debit side var result = PostTimeDepositEndBalance(); if (!result.Success) { return(result); } // post interest expense debit side result = PostInterestExpense(); if (!result.Success) { return(result); } // post service fee credit side result = PostServiceFee(); if (!result.Success) { return(result); } // post cash on hand credit side result = PostCashOnHand(); if (!result.Success) { return(result); } #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find(_voucherDocument.VoucherType.ToString(), _voucherDocument.VoucherNo); voucherLog.Date = _voucherDocument.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion return(result); }
public static List <AccountDetail> Find(string memberCode, string accountCode, string certificateNo, DateTime asOf) { var sqlParams = new List <SqlParameter> { new SqlParameter("ts_member_code", memberCode), new SqlParameter("ts_account_code", accountCode), new SqlParameter("ts_certificate_no", certificateNo), new SqlParameter("td_as_of", asOf) }; DataTable dataTable; DateTime forwardedDate = ForwardedBalance.MaxDocumentDate(); if (forwardedDate != Convert.ToDateTime(string.Format("12/31/{0}", asOf.Year - 1))) { sqlParams.Add(new SqlParameter("ts_present_database", DatabaseController.GetDatabaseByYear(asOf.Year))); sqlParams.Add(new SqlParameter("ts_previous_database", DatabaseController.GetDatabaseByYear(forwardedDate.Year))); dataTable = DatabaseController.ExecuteStoredProcedure("sp_account_details_opening_year", sqlParams.ToArray()); } else { dataTable = DatabaseController.ExecuteStoredProcedure("sp_account_details_per_date", sqlParams.ToArray()); } var result = new List <AccountDetail>(); foreach (DataRow dataRow in dataTable.Rows) { var detail = new AccountDetail(); detail.SetPropertiesFromDataRow(dataRow); var voucherLog = new VoucherLog(); voucherLog.Find(detail.VoucherType, detail.VoucherNumber); detail.Initial = voucherLog.Initials; detail.Remarks = voucherLog.Remarks; result.Add(detail); } return(result); }
private void btnPost_Click(object sender, EventArgs e) { var collection = OfficialReceipt.WhereDocumentNumberIs(_officialReceipt.VoucherNo); if (collection.Count > 0) { MessageWindow.ShowAlertMessage("OR No. already in use."); return; } try { _officialReceipt.Collector = MainController.LoggedUser.CollectorName; _officialReceipt.IsPosted = true; _officialReceipt.Create(); // cash on hand var or = new OfficialReceipt { MemberCode = _officialReceipt.MemberCode, MemberName = _officialReceipt.MemberName }; var coh = Account.FindByCode(GlobalSettings.CodeOfCashOnHand); or.AccountCode = coh.AccountCode; or.AccountTitle = coh.AccountTitle; // insert denomination details or.Debit = _officialReceipt.Credit; if (_denomonation != null) { #region --- Cash CashAndCheckBreakDown --- //JEA: Since deno09 is not available (0.50), I use it as lieu to 200 or.Deno01 = _denomonation.Deno01; //1000 or.Deno02 = _denomonation.Deno02; //500 or.Deno03 = _denomonation.Deno03; //100 or.Deno04 = _denomonation.Deno04; //50 or.Deno05 = _denomonation.Deno05; //20 or.Deno06 = _denomonation.Deno06; //10 or.Deno07 = _denomonation.Deno07; //5 or.Deno08 = _denomonation.Deno08; //1 or.Deno09 = _denomonation.Deno09; //.5 -> 200 or.Deno10 = _denomonation.Deno10; //.25 #endregion --- Cash CashAndCheckBreakDown --- #region --- Check CashAndCheckBreakDown --- or.BankName1 = _denomonation.BankName1; or.BankDate1 = _denomonation.BankDate1; or.BankCheck1 = _denomonation.BankCheck1; or.BankAmount1 = _denomonation.BankAmount1; or.BankName2 = _denomonation.BankName2; or.BankDate2 = _denomonation.BankDate2; or.BankCheck2 = _denomonation.BankCheck2; or.BankAmount2 = _denomonation.BankAmount2; or.BankName3 = _denomonation.BankName3; or.BankDate3 = _denomonation.BankDate3; or.BankCheck3 = _denomonation.BankCheck3; or.BankAmount3 = _denomonation.BankAmount3; or.BankName4 = _denomonation.BankName4; or.BankDate4 = _denomonation.BankDate4; or.BankCheck4 = _denomonation.BankCheck4; or.BankAmount4 = _denomonation.BankAmount4; or.BankName5 = _denomonation.BankName5; or.BankDate5 = _denomonation.BankDate5; or.BankCheck5 = _denomonation.BankCheck5; or.BankAmount5 = _denomonation.BankAmount5; #endregion } or.AmountInWords = Converter.AmountToWords(_officialReceipt.Credit); or.Amount = _officialReceipt.Credit; or.VoucherDate = _officialReceipt.VoucherDate; or.VoucherNo = _officialReceipt.VoucherNo; or.VoucherType = VoucherTypes.OR; or.Collector = MainController.LoggedUser.CollectorName; or.IsPosted = true; or.Create(); #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find("OR", _officialReceipt.VoucherNo); voucherLog.Date = _officialReceipt.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; if (_denomonation != null && _denomonation.HasCheckDeposit) { voucherLog.Remarks = "CHK"; } voucherLog.Save(); #endregion MessageWindow.ShowNotifyMessage("Transaction posted! Printing validation..."); DialogResult = true; Close(); } catch (Exception exception) { MessageWindow.ShowAlertMessage(exception.Message); } }
private void PostButtonOnClick(object sender, RoutedEventArgs e) { var result = _withdrawal.Validate(); if (!result.Success) { MessageWindow.ShowAlertMessage(result.Message); return; } #region --- Withdrawal Credit Side --- var voucher = new Voucher { VoucherDate = _withdrawal.WithdrawalSettings.TransactionDate, VoucherNo = _withdrawal.WithdrawalSettings.WithdrawalVoucherNo, VoucherType = VoucherTypes.CV }; var totalWithdrawals = Withdrawal.TotalWithdrawals(voucher.VoucherNo) + _withdrawal.WithdrawalAmount; result = Withdrawal.ReBalanceWithdrawals(voucher, totalWithdrawals); if (!result.Success) { MessageWindow.ShowAlertMessage(result.Message); return; } #endregion #region --- Withdrawal Debit Side --- var cv = new CashVoucher(); var member = Nfmb.FindByCode(_withdrawal.AccountInfo.MemberCode); cv.MemberCode = member.MemberCode; cv.MemberName = member.MemberName; var account = Account.FindByCode(_withdrawal.AccountInfo.AccountCode); cv.AccountCode = account.AccountCode; cv.AccountTitle = account.AccountTitle; cv.Debit = _withdrawal.WithdrawalAmount; cv.VoucherDate = voucher.VoucherDate; cv.VoucherNo = voucher.VoucherNo; cv.VoucherType = voucher.VoucherType; cv.WithdrawalSlipNo = _withdrawal.WithdrawalSlipNo; cv.Create(); #endregion #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find("CV", cv.VoucherNo); voucherLog.Date = cv.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion var validationBuilder = new StringBuilder(); validationBuilder.AppendFormat("{0} {1} {2} {3} {4} {5:yyyy-MM-dd hh:mm:ss} {6}", cv.MemberCode, cv.AccountCode, cv.VoucherNo, cv.WithdrawalSlipNo, cv.Debit, DateTime.Now, MainController.LoggedUser.Initials); if (MessageWindow.ShowConfirmMessage("Print withdrawal validation?") == MessageBoxResult.Yes) { ReportController.PrintWitdrawalValidation(cv); } DialogResult = true; Close(); }
private void btnPost_Click(object sender, EventArgs e) { var collection = JournalVoucher.WhereDocumentNumberIs(_journalVoucher.VoucherNo); if (collection.Count > 0) { MessageWindow.ShowAlertMessage("JV No. already in use."); return; } try { btnPost.Content = "Posting, please wait..."; JournalVoucher jv; foreach (var item in _viewModel.Collection) { jv = new JournalVoucher(); jv.MemberCode = item.MemberCode; jv.MemberName = item.MemberName; jv.AccountCode = item.AccountCode; jv.AccountTitle = item.AccountTitle; jv.Credit = item.Credit; jv.VoucherDate = _journalVoucher.VoucherDate; jv.VoucherNo = _journalVoucher.VoucherNo; jv.VoucherType = VoucherTypes.JV; jv.IsPosted = true; jv.Create(); } // closing jv = new JournalVoucher(); var coop = Nfmb.FindByCode(GlobalSettings.CodeOfCompany); jv.MemberCode = coop.MemberCode; jv.MemberName = coop.MemberName; var intExpense = _viewModel.InterestExpenseOnSavingsDepositAccount; jv.AccountCode = intExpense.AccountCode; jv.AccountTitle = intExpense.AccountTitle; jv.Debit = _viewModel.Collection.Sum(voucher => voucher.Credit); jv.VoucherDate = _journalVoucher.VoucherDate; jv.VoucherNo = _journalVoucher.VoucherNo; jv.VoucherType = VoucherTypes.JV; jv.Explanation = "Savings Deposit interest posting"; jv.IsPosted = true; jv.Create(); #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find("JV", _journalVoucher.VoucherNo); voucherLog.Date = _journalVoucher.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion btnPost.Content = string.Format("Posting Complete"); MessageWindow.ShowNotifyMessage("Interest on Savings Deposit succesfully posted!"); DialogResult = true; Close(); } catch (Exception exception) { MessageWindow.ShowAlertMessage(exception.Message); } }
private Result PostToVoucher() { var postingDetails = new LoanPostingDetails { VoucherType = VoucherTypes.CV, VoucherDate = GlobalSettings.DateOfOpenTransaction }; postingDetails.VoucherNumber = Voucher.LastDocumentNo(postingDetails.VoucherType) + 1; postingDetails.ReleaseNumber = ModelController.Releases.MaxReleaseNumber() + 1; postingDetails.ReleaseDate = postingDetails.VoucherDate; // 1. ask user to enter voucher information var postingWindow = new LoanPostingWindow(postingDetails); if (postingWindow.ShowDialog() != true) { return(new Result(false, "Posting was cancelled by user.")); } // 1.1 Must be open transaction if (postingDetails.VoucherDate != GlobalSettings.DateOfOpenTransaction) { return(new Result(false, "Voucher date is locked!")); } if (postingDetails.VoucherDate != MainController.LoggedUser.TransactionDate) { return(new Result(false, "Transaction Date is not valid or not set!")); } // 2. inform user if voucher information already exist, ask if to overwrite if (postingDetails.VoucherType == VoucherTypes.CV) { ObservableCollection <CashVoucher> cvEntries = CashVoucher.WhereDocumentNumberIs(postingDetails.VoucherNumber); if (cvEntries.Count > 0) { return(new Result(false, string.Format("{0} #{1} already exist!", postingDetails.VoucherType, postingDetails.VoucherNumber))); } } if (postingDetails.VoucherType == VoucherTypes.JV) { ObservableCollection <JournalVoucher> jvEntries = JournalVoucher.WhereDocumentNumberIs(postingDetails.VoucherNumber); if (jvEntries.Count > 0) { return(new Result(false, string.Format("{0} #{1} already exist!", postingDetails.VoucherType, postingDetails.VoucherNumber))); } } // 3. post transaction details _loanDetails.ReleaseNo = postingDetails.ReleaseNumber; _loanDetails.DateReleased = postingDetails.ReleaseDate; //TODO: Loan Application Information //loanDetails.ThisMonth //loanDetails.DateApplied = _loanDetail.DateGranted; //loanDetails.DateApproved //loanDetails.DateCancelled; //loanDetails.DateReleased // net proceeds var netProceeds = new ComputationDetail { AccountCode = _loanComputation.NetProceedsCode, AccountTitle = _loanComputation.NetProceedsTitle, Amount = _loanComputation.NetProceedsAmount }; if (postingDetails.VoucherType == VoucherTypes.JV) { #region --- Add entry for Cash On Hand --- var net = new JournalVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = netProceeds.AccountCode, AccountTitle = netProceeds.AccountTitle, Credit = netProceeds.Amount, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber, }; net.Amount = net.Credit; net.AmountInWords = Converter.AmountToWords(net.Amount); Result postResult = net.Create(); if (!postResult.Success) { JournalVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entries for Charges --- foreach (ComputationDetail computationDetail in _loanComputation.Charges) { if (string.IsNullOrEmpty(computationDetail.AccountCode) || computationDetail.Amount == 0) { continue; } var charges = new JournalVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = computationDetail.AccountCode, AccountTitle = computationDetail.AccountTitle, Credit = computationDetail.Amount, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = charges.Create(); if (postResult.Success) { continue; } JournalVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entries for Deductions --- foreach (ComputationDetail computationDetail in _loanComputation.Deductions) { if (string.IsNullOrEmpty(computationDetail.AccountCode) || computationDetail.Amount == 0) { continue; } var deductions = new JournalVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = computationDetail.AccountCode, AccountTitle = computationDetail.AccountTitle, Credit = computationDetail.Amount, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = deductions.Create(); if (postResult.Success) { continue; } JournalVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entry for Unearned Income --- Account ui = Account.FindByCode(GlobalSettings.CodeOfUnearnedIncome); var unearnedIncome = new JournalVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = ui.AccountCode, AccountTitle = ui.AccountTitle, Credit = _loanAmortizationHeader.PaymentSchedules.Sum(sched => sched.Interest), VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = unearnedIncome.Create(); if (!postResult.Success) { JournalVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entry for Capital Build-Up --- Account cbu = Account.FindByCode(GlobalSettings.CodeOfCapitalBuildUp); var capitalBuildUp = new JournalVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = cbu.AccountCode, AccountTitle = cbu.AccountTitle, Credit = _loanAmortizationHeader.PaymentSchedules.Sum(sched => sched.CapitalBuildUp), VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = capitalBuildUp.Create(); if (!postResult.Success) { JournalVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Finally add entry for the loan applied --- var loanVoucherEntry = new JournalVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = _loanDetails.AccountCode, AccountTitle = _loanDetails.AccountTitle, Debit = _loanDetails.LoanAmount + unearnedIncome.Credit + capitalBuildUp.Credit, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber, LoanDetails = _loanDetails, Explanation = _loanDetails.GenerateExplanation() }; postResult = loanVoucherEntry.Create(); if (!postResult.Success) { JournalVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion } else { #region --- Add entry for Cash On Hand --- var net = new CashVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = netProceeds.AccountCode, AccountTitle = netProceeds.AccountTitle, Credit = netProceeds.Amount, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber, }; net.Amount = net.Credit; net.AmountInWords = Converter.AmountToWords(net.Amount); Result postResult = net.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entries for Charges --- foreach (ComputationDetail computationDetail in _loanComputation.Charges) { if (string.IsNullOrEmpty(computationDetail.AccountCode) || computationDetail.Amount == 0) { continue; } var charges = new CashVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = computationDetail.AccountCode, AccountTitle = computationDetail.AccountTitle, Credit = computationDetail.Amount, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = charges.Create(); if (postResult.Success) { continue; } CashVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entries for Deductions --- foreach (ComputationDetail computationDetail in _loanComputation.Deductions) { if (string.IsNullOrEmpty(computationDetail.AccountCode) || computationDetail.Amount == 0) { continue; } var deductions = new CashVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = computationDetail.AccountCode, AccountTitle = computationDetail.AccountTitle, Credit = computationDetail.Amount, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = deductions.Create(); if (postResult.Success) { continue; } CashVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entry for Unearned Income --- Account ui = Account.FindByCode(GlobalSettings.CodeOfUnearnedIncome); var unearnedIncome = new CashVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = ui.AccountCode, AccountTitle = ui.AccountTitle, Credit = _loanAmortizationHeader.PaymentSchedules.Sum(sched => sched.Interest), VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = unearnedIncome.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Add entry for Capital Build-Up --- Account cbu = Account.FindByCode(GlobalSettings.CodeOfCapitalBuildUp); var capitalBuildUp = new CashVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = cbu.AccountCode, AccountTitle = cbu.AccountTitle, Credit = _loanAmortizationHeader.PaymentSchedules.Sum(sched => sched.CapitalBuildUp), VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber }; postResult = capitalBuildUp.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion #region --- Finally add entry for the loan applied --- var loanVoucherEntry = new CashVoucher { MemberCode = _loanDetails.MemberCode, MemberName = _loanDetails.MemberName, AccountCode = _loanDetails.AccountCode, AccountTitle = _loanDetails.AccountTitle, Debit = _loanDetails.LoanAmount + unearnedIncome.Credit + capitalBuildUp.Credit, VoucherDate = postingDetails.VoucherDate, VoucherNo = postingDetails.VoucherNumber, LoanDetails = _loanDetails, Explanation = _loanDetails.GenerateExplanation() }; postResult = loanVoucherEntry.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(postingDetails.VoucherNumber); return(postResult); } #endregion } #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find(postingDetails.VoucherType.ToString(), postingDetails.VoucherNumber); voucherLog.Date = postingDetails.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion return(new Result(true, string.Format("A loan has been created! Please check {0} #{1}.", postingDetails.VoucherType, postingDetails.VoucherNumber))); }
private void btnPost_Click(object sender, EventArgs e) { var loanAmount = _cashVoucher.Debit; var voucherNo = _cashVoucher.VoucherNo; var voucherDate = MainController.LoggedUser.TransactionDate; var document = new VoucherDocument(VoucherTypes.CV, voucherNo, voucherDate); // is there already a loan product for salary advance? if (_loanProduct == null) { MessageWindow.ShowAlertMessage("No Loan Products found for Salary Advance."); return; } // does user enter a valid amount? if (loanAmount <= 0) { MessageWindow.ShowAlertMessage("Invalid amount!"); return; } // does the voucher number been used? var collection = CashVoucher.WhereDocumentNumberIs(voucherNo); if (collection.Count > 0) { MessageWindow.ShowAlertMessage("CV No. already in use."); return; } try { // what is the account for salary advance? var salaryAdvance = Account.FindByCode(GlobalSettings.CodeOfSalaryAdvance); var cashOnHandReceived = loanAmount; #region --- Finally add entry for the loan applied --- // what will be the loan details? var loanDetails = GenerateLoanDetails(); _cashVoucher.SetMember(_member); _cashVoucher.SetAccount(salaryAdvance); _cashVoucher.SetDocument(document); _cashVoucher.Explanation = loanDetails.GenerateExplanation(); _cashVoucher.LoanDetails = loanDetails; Result postResult = _cashVoucher.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(document.Number); MessageWindow.ShowAlertMessage(postResult.Message); return; } #endregion #region --- Interest Charge --- var interest = new CashVoucher(); interest.SetMember(_member); interest.SetAccount(Account.FindByCode(GlobalSettings.CodeOfMiscellaneousIncome)); interest.SetDocument(document); interest.Credit = loanDetails.InterestAmount; postResult = interest.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(document.Number); MessageWindow.ShowAlertMessage(postResult.Message); return; } cashOnHandReceived -= interest.Credit; #endregion #region --- Add entries for Charges --- foreach (var charge in _loanProduct.LoanCharges) { var entry = new CashVoucher(); entry.SetMember(_member); entry.SetAccount(Account.FindByCode(charge.AccountCode)); entry.SetDocument(document); entry.Credit = loanAmount * charge.Rate; postResult = entry.Create(); if (postResult.Success) { cashOnHandReceived -= entry.Credit; continue; } CashVoucher.DeleteAll(document.Number); MessageWindow.ShowAlertMessage(postResult.Message); return; } #endregion #region --- Add entry for Cash On Hand --- var net = new CashVoucher(); net.SetMember(_member); net.SetAccount(Account.FindByCode(GlobalSettings.CodeOfCashOnHand)); net.SetDocument(document); net.Credit = cashOnHandReceived; net.Amount = cashOnHandReceived; net.AmountInWords = Converter.AmountToWords(cashOnHandReceived); postResult = net.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(document.Number); MessageWindow.ShowAlertMessage(postResult.Message); return; } #endregion #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find("CV", _cashVoucher.VoucherNo); voucherLog.Date = _cashVoucher.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion MessageWindow.ShowNotifyMessage("Salary Advance created. Please check CV# " + voucherNo); DialogResult = true; Close(); } catch (Exception exception) { MessageWindow.ShowAlertMessage(exception.Message); } }
private void Post() { var loanAmount = _cashVoucher.Debit; var voucherNo = _cashVoucher.VoucherNo; var voucherDate = MainController.LoggedUser.TransactionDate; var document = new VoucherDocument(VoucherTypes.CV, voucherNo, voucherDate); // is there already a loan product for Go Negosyo? if (_loanProduct == null) { MessageWindow.ShowAlertMessage("No Loan Products found for Go Negosyo."); return; } // does user enter a valid amount? if (loanAmount <= 0) { MessageWindow.ShowAlertMessage("Invalid amount!"); return; } // does the voucher number been used? var collection = CashVoucher.WhereDocumentNumberIs(voucherNo); if (collection.Count > 0) { MessageWindow.ShowAlertMessage("CV No. already in use."); return; } try { // what is the account for Go Negosyo? var goNegosyo = Account.FindByCode(GlobalSettings.CodeOfGoNegosyo); #region --- Finally add entry for the loan applied --- // what will be the loan details? var loanDetails = GenerateLoanDetails(); _cashVoucher.SetMember(_member); _cashVoucher.SetAccount(goNegosyo); _cashVoucher.SetDocument(document); _cashVoucher.Explanation = loanDetails.GenerateExplanation(); _cashVoucher.LoanDetails = loanDetails; Result postResult = _cashVoucher.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(document.Number); MessageWindow.ShowAlertMessage(postResult.Message); return; } #endregion // NO CHARGES #region --- Add entry for Accounts Payable Merchandise --- var net = new CashVoucher(); net.SetMember(_member); net.SetAccount(Account.FindByCode(GlobalSettings.CodeOfAccountsPayableMerchandise)); net.SetDocument(document); net.Credit = loanAmount; net.Amount = loanAmount; net.AmountInWords = Converter.AmountToWords(loanAmount); postResult = net.Create(); if (!postResult.Success) { CashVoucher.DeleteAll(document.Number); MessageWindow.ShowAlertMessage(postResult.Message); return; } #endregion #region --- Voucher Log --- var voucherLog = new VoucherLog(); voucherLog.Find("CV", _cashVoucher.VoucherNo); voucherLog.Date = _cashVoucher.VoucherDate; voucherLog.Initials = MainController.LoggedUser.Initials; voucherLog.Save(); #endregion MessageWindow.ShowNotifyMessage("Go Negosyo created. Please check CV# " + voucherNo); DialogResult = true; Close(); } catch (Exception exception) { MessageWindow.ShowAlertMessage(exception.Message); } }