public async Task <List <COA_Account_Dto> > GetListOfAccountsAsync() { List <COA_Account_Dto> accounts = new List <COA_Account_Dto>(); var result = await _coaAppService.GetListAsync(new Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto() { MaxResultCount = 10 }); for (int i = 0; i < result.TotalCount; i++) { COA_Account_Dto curDto = result.Items[i]; Console.WriteLine(curDto.AccountName); } accounts = result.Items.ToList(); //int code = 10000; //for (int i = 1; i < 10; i++) //{ // accounts.Add(new AccountsDetails(code, $"1-101001.000", "Banks", 1 + "", "Assets", "Current Assets", "", true, true, true, "Test", "IT", "Kirchgasse 6", "", "", "")); // accounts.Add(new AccountsDetails(code, $"1-101001.001", "Local Banks", 1 + "", "Assets", "Current Assets", "", false, true, false, "Test 2", "RD", "Avda.", "", "", "")); // accounts.Add(new AccountsDetails(code, $"1-101001.002", "International Banks", 1 + "", "Assets", "Current Assets", "", true, true, true, "Test 3", "Salesforce", "Carrera", "", "", "")); // accounts.Add(new AccountsDetails(code, $"1-101001.003", "Regional Banks", 1 + "", "Assets", "Current Assets", "", true, true, false, "Test 6", "IT", "Magazinweg 7", "", "", "")); // accounts.Add(new AccountsDetails(code, $"1-101001.000", "Cash", 1 + "", "Assets", "Current Assets", "", false, true, true, "Tesst 8", "RUD", "1029 - 12th Ave. S.", "", "", "")); // code += 5; //} return(accounts); }
public async Task <IActionResult> OnPostUpdate(COA_Account_UV_Dto dto) { try { var _COAsList = (await _coaAppService.GetListAsync(new Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto() { MaxResultCount = 1000 })).Items.ToList(); SubLedgerRequirements = (await _subLedgerRequirementsAppService.GetListAsync(new Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto() { MaxResultCount = 1000 })).Items.ToList(); var form = Request.Form; dto.SubLedgerRequirementAccounts = new List <COA_SubLedgerRequirement_Account_Dto>(); for (int i = 0; i < SubLedgerRequirements.Count; i++) { if (form.TryGetValue("requirement:" + i, out StringValues isChecked)) { if (isChecked == "on") { dto.SubLedgerRequirementAccounts.Add(new COA_SubLedgerRequirement_Account_Dto(_guidGenerator.Create()) { SubLedgerRequirementId = SubLedgerRequirements[i].Id, AccountId = dto.Id }); } } } if (form.TryGetValue("allowPosting", out StringValues isAPostingChecked)) { if (isAPostingChecked == "on") { dto.AllowPosting = true; } else { dto.AllowPosting = false; } } if (dto.AllowPosting && form.TryGetValue("allowPayment", out StringValues isAPChecked)) { if (isAPChecked == "on") { dto.AllowPayment = true; } else { dto.AllowPayment = false; } } else { dto.AllowReceipt = false; } if (dto.AllowPosting && form.TryGetValue("allowReceipt", out StringValues isARChecked)) { if (isARChecked == "on") { dto.AllowReceipt = true; } else { dto.AllowReceipt = false; } } else { dto.AllowReceipt = false; } form.TryGetValue("companyCode", out StringValues companyCode); companyCode = string.IsNullOrEmpty(companyCode) ? (StringValues)"00" : companyCode; form.TryGetValue("headAccCode", out StringValues headAccCode); headAccCode = string.IsNullOrEmpty(headAccCode) ? (StringValues)"00" : headAccCode; form.TryGetValue("subCat1Code", out StringValues subCat1Code); subCat1Code = string.IsNullOrEmpty(subCat1Code) ? (StringValues)"00" : subCat1Code; form.TryGetValue("subCat2Code", out StringValues subCat2Code); subCat2Code = string.IsNullOrEmpty(subCat2Code) ? (StringValues)"00" : subCat2Code; form.TryGetValue("subCat3Code", out StringValues subCat3Code); subCat3Code = string.IsNullOrEmpty(subCat3Code) ? (StringValues)"00" : subCat3Code; form.TryGetValue("subCat4Code", out StringValues subCat4Code); subCat4Code = string.IsNullOrEmpty(subCat4Code) ? (StringValues)"00" : subCat4Code; StringValues subLedgerAccountCode = ""; form.TryGetValue("subLedgerAccountCode", out subLedgerAccountCode); subLedgerAccountCode = !string.IsNullOrEmpty(subLedgerAccountCode) ? "." + subLedgerAccountCode : ""; dto.AccountCode = $"{companyCode}-{headAccCode}{subCat1Code}{subCat2Code}{subCat3Code}{subCat4Code}{subLedgerAccountCode}"; int maxCode = 0; try { Convert.ToInt32(_COAsList.Count > 0 ? _COAsList.Where(c => c.HeadAccountId == dto.HeadAccountId && c.AccountSubCatId == dto.AccountSubCatId).Max(c => c.AccountId) : 0); } catch { } dto.AccountId = maxCode + 1; //dto.HeadAccount = await _headAccountsAppService.GetAsync(dto.HeadAccountId); //dto.AccountSubCategory_1 = await _subCategoryAppService.GetAsync(dto.AccountSubCat1Id); //dto.Company = await _companyAppService.GetAsync(dto.CompanyId); //if(dto.BranchId.HasValue) // dto.Branch = await _branchAppService.GetAsync(dto.BranchId.Value); COA_Account_Dto result = null; try { result = await _coaAppService.CreateAccount(dto); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (result != null) { return(RedirectToPage("./COA")); } else { return(Page()); } } catch (Exception ex) { return(Page()); } }