public async Task <int> AutoJournalFromOthersExpenditureProof(OthersExpenditureProofDocumentCreateUpdateViewModel viewModel, string documentNo) { var model = new JournalTransactionModel() { Date = viewModel.Date.GetValueOrDefault(), Description = "Auto Journal Bukti Pengeluaran Bank Lain - Lain", ReferenceNo = documentNo, Status = "POSTED", Items = new List <JournalTransactionItemModel>() }; model.Items = viewModel.Items.Select(item => new JournalTransactionItemModel() { COA = new COAModel() { Id = item.COAId.GetValueOrDefault(), }, Debit = item.Debit.GetValueOrDefault() }).ToList(); var accountBankCOA = await GetAccountBankCOA(viewModel.AccountBankId.GetValueOrDefault()); var creditItem = new JournalTransactionItemModel() { COA = new COAModel() { Code = accountBankCOA }, Credit = viewModel.Items.Sum(item => item.Debit.GetValueOrDefault()) }; model.Items.Add(creditItem); return(await _journalTransactionService.CreateAsync(model)); }
public async Task <int> AutoJournalFromOthersExpenditureProof(OthersExpenditureProofDocumentModel model, List <OthersExpenditureProofDocumentItemModel> items) { var journalTransactionModel = new JournalTransactionModel() { Date = model.Date, Description = "Auto Journal Bukti Pengeluaran Bank Lain - Lain", ReferenceNo = model.DocumentNo, Status = "POSTED", Items = new List <JournalTransactionItemModel>() }; journalTransactionModel.Items = items.Select(item => new JournalTransactionItemModel() { COA = new COAModel() { Id = item.COAId, }, Debit = item.Debit }).ToList(); var accountBankCOA = await GetAccountBankCOA(model.AccountBankId); var creditItem = new JournalTransactionItemModel() { COA = new COAModel() { Code = accountBankCOA }, Credit = items.Sum(item => item.Debit) }; journalTransactionModel.Items.Add(creditItem); return(await _journalTransactionService.CreateAsync(journalTransactionModel)); }
public async Task Should_Success_Update_Data_NewItem() { var service = new JournalTransactionService(GetServiceProvider().Object, _dbContext(GetCurrentMethod())); var model = await _dataUtil(service).GetTestData(); model.Description = "NewDescription"; var newItemDebit = new JournalTransactionItemModel() { COA = new COAModel() { Id = 1, Code = "" }, Debit = 100 }; model.Items.Add(newItemDebit); var newItemCredit = new JournalTransactionItemModel() { COA = new COAModel() { Id = 1, Code = "" }, Credit = 100 }; model.Items.Add(newItemCredit); var Response = await service.UpdateAsync(model.Id, model); Assert.NotEqual(0, Response); }