public async Task <IActionResult> OnPostAsync(string paymentCode) { try { if (paymentCode == null) { return(NotFound()); } Cash_PaymentsUnposted = await NodeContext.Cash_PaymentsUnposted.FindAsync(paymentCode); if (Cash_PaymentsUnposted != null) { NodeContext.Cash_PaymentsUnposted.Remove(Cash_PaymentsUnposted); await NodeContext.SaveChangesAsync(); } RouteValueDictionary route = new(); route.Add("CashAccountCode", Cash_PaymentsUnposted.CashAccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnGetAsync(string cashAccountCode) { try { var cashAccountList = NodeContext.Org_CashAccountAssets.Where(t => !t.AccountClosed).OrderBy(t => t.LiquidityLevel).Select(t => t.CashAccountCode); CashAccountCodes = new SelectList(await cashAccountList.ToListAsync()); if (string.IsNullOrEmpty(cashAccountCode)) { cashAccountCode = await cashAccountList.FirstOrDefaultAsync(); } Profile profile = new(NodeContext); CashAccounts cashAccounts = new(NodeContext); var cashAccount = await NodeContext.Org_CashAccountAssets.Where(t => t.CashAccountCode == cashAccountCode).FirstAsync(); Cash_AssetsUnposted = new Cash_vwPaymentsUnposted { CashAccountCode = cashAccount.CashAccountCode, PaymentCode = await cashAccounts.NextPaymentCode(), AccountCode = cashAccount.AccountCode, CashCode = cashAccount.CashCode, TaxCode = cashAccount.TaxCode, PaidOn = DateTime.Today, UserId = await profile.UserId(UserManager.GetUserId(User)), InsertedBy = await profile.UserName(UserManager.GetUserId(User)), IsProfitAndLoss = true }; Cash_AssetsUnposted.UpdatedBy = Cash_AssetsUnposted.InsertedBy; await SetViewData(); return(Page()); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnGetAsync(string paymentCode) { if (paymentCode == null) { return(NotFound()); } Cash_PaymentsUnposted = await NodeContext.Cash_PaymentsUnposted.FirstOrDefaultAsync(m => m.PaymentCode == paymentCode); if (Cash_PaymentsUnposted == null) { return(NotFound()); } else { await SetViewData(); return(Page()); } }
public async Task <IActionResult> OnGetAsync(string paymentCode) { try { if (string.IsNullOrEmpty(paymentCode)) { return(NotFound()); } Cash_PaymentsUnposted = await NodeContext.Cash_PaymentsUnposted.FirstOrDefaultAsync(m => m.PaymentCode == paymentCode); if (Cash_PaymentsUnposted == null) { return(NotFound()); } else { if ((User.IsInRole(Constants.ManagersRole) || User.IsInRole(Constants.AdministratorsRole)) == false) { var profile = new Profile(NodeContext); var user = await UserManager.GetUserAsync(User); if (Cash_PaymentsUnposted.UserId != await profile.UserId(user.Id)) { return(Forbid()); } } await SetViewData(); return(Page()); }; } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnGetAsync(string cashAccountCode, string mode, string accountCode, string cashCode, string taxCode) { try { var cashAccountNames = from t in NodeContext.Org_tbAccounts where !t.AccountClosed && t.AccountTypeCode < 2 && t.CoinTypeCode == 2 orderby t.CashAccountName select t.CashAccountName; CashAccountNames = new SelectList(await cashAccountNames.ToListAsync()); if (!string.IsNullOrEmpty(cashAccountCode)) { CashAccountCode = cashAccountCode; } else if (string.IsNullOrEmpty(CashAccountCode)) { CashAccounts cashAccounts = new(NodeContext); CashAccountCode = await cashAccounts.CurrentAccount(); } CashAccountName = await NodeContext.Org_tbAccounts.Where(t => t.CashAccountCode == CashAccountCode).Select(t => t.CashAccountName).FirstOrDefaultAsync(); if (!string.IsNullOrEmpty(mode)) { InputMode = Int32.Parse(mode); AccountCode = string.Empty; CashCode = string.Empty; TaxCode = string.Empty; } var organisationNames = from t in NodeContext.Org_AccountLookup orderby t.AccountName select t.AccountName; OrganisationNames = new SelectList(await organisationNames.ToListAsync()); var profile = new Profile(NodeContext); if (!string.IsNullOrEmpty(accountCode)) { AccountCode = accountCode; } else if (string.IsNullOrEmpty(AccountCode)) { AccountCode = await profile.CompanyAccountCode; } OrganisationName = await NodeContext.Org_tbOrgs.Where(o => o.AccountCode == AccountCode).Select(o => o.AccountName).FirstOrDefaultAsync(); if (InputMode == 1) { var cashDescriptions = from t in NodeContext.Cash_CodeLookup where t.CashTypeCode < (short)NodeEnum.CashType.Bank orderby t.CashDescription select t.CashDescription; CashDescriptions = new SelectList(await cashDescriptions.ToListAsync()); if (!string.IsNullOrEmpty(cashCode)) { CashCode = cashCode; } else if (string.IsNullOrEmpty(CashCode)) { CashCode = await NodeContext.Cash_CodeLookup .Where(c => c.CashTypeCode < (short)NodeEnum.CashType.Bank) .OrderBy(c => c.CashCode) .Select(c => c.CashCode) .FirstAsync(); } CashDescription = await NodeContext.Cash_tbCodes.Where(c => c.CashCode == CashCode).Select(c => c.CashDescription).FirstOrDefaultAsync(); var taxDescriptions = from t in NodeContext.App_TaxCodes orderby t.TaxDescription select t.TaxDescription; TaxDescriptions = new SelectList(await taxDescriptions.ToListAsync()); if (!string.IsNullOrEmpty(taxCode)) { TaxCode = taxCode; } else if (string.IsNullOrEmpty(TaxCode) && !string.IsNullOrEmpty(CashCode)) { CashCodes cash = new(NodeContext, CashCode); TaxCode = cash.TaxCode; } else { TaxCode = await NodeContext.App_tbTaxCodes .Where(t => t.TaxTypeCode == (short)NodeEnum.TaxType.VAT) .OrderBy(t => t.TaxCode) .Select(t => t.TaxCode) .FirstAsync(); } TaxDescription = await NodeContext.App_tbTaxCodes.Where(t => t.TaxCode == TaxCode).Select(t => t.TaxDescription).FirstOrDefaultAsync(); } Cash_PaymentsUnposted = new Cash_vwPaymentsUnposted { CashAccountCode = CashAccountCode, AccountCode = AccountCode, CashCode = CashCode, TaxCode = TaxCode, PaidOn = DateTime.Today, UserId = await profile.UserId(UserManager.GetUserId(User)), InsertedBy = await profile.UserName(UserManager.GetUserId(User)), IsProfitAndLoss = false }; Cash_PaymentsUnposted.UpdatedBy = Cash_PaymentsUnposted.InsertedBy; Orgs orgs = new(NodeContext, AccountCode); var balance = await orgs.BalanceOutstanding(); if (balance < 0) { Cash_PaymentsUnposted.PaidOutValue = Math.Abs(balance); } else { Cash_PaymentsUnposted.PaidInValue = balance; } await SetViewData(); return(Page()); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }