public async Task Should_Success_AutoJournalInklaring_With_ViewModel() { //Setup var dbContext = GetDbContext(GetCurrentMethod()); var serviceProviderMock = GetServiceProvider(); serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext); serviceProviderMock .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(new JournalHttpClientTestService()); Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>(); serviceProviderMock .Setup(x => x.GetService(typeof(IJournalTransactionService))) .Returns(journalTransactionServiceMock.Object); var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object); serviceProviderMock .Setup(x => x.GetService(typeof(IMasterCOAService))) .Returns(masterCOAServiceMock); var vBRequestDocumentService = new VBRequestDocumentService(dbContext, GetServiceProvider().Object); var data = await GetdataUtil(vBRequestDocumentService).GetTestData_VBRequestDocumentNonPO(); var vBRealizationWithPOService = new VBRealizationWithPOService(dbContext, serviceProviderMock.Object); var vBRealizationDocumenData = GetDataUtil(vBRealizationWithPOService).GetTestData_DenganNomorVB(); var service = new AutoJournalService(dbContext, serviceProviderMock.Object); AccountBankViewModel viewModel = new AccountBankViewModel() { AccountCOA = "AccountCOA", AccountName = "AccountName", AccountNumber = "AccountNumber", BankCode = "BankCode", BankName = "BankName", Code = "Code", Currency = new CurrencyViewModel() { Code = "Rp", Description = "Description", Rate = 1, Symbol = "IDR" }, }; List <int> vbRealizationIds = new List <int>() { 1 }; //Act var result = await service.AutoJournalInklaring(vbRealizationIds, viewModel); //Assert Assert.NotEqual(0, result); }
public void Should_Success_Instantiate() { int id = 1; string code = "code test"; string BankCode = "BankCode test"; string AccountName = "AccountName test"; string AccountNumber = "AccountNumber test"; string BankName = "BankName test"; CurrencyViewModel cvm = new CurrencyViewModel(); AccountBankViewModel abvm = new AccountBankViewModel(); abvm.Id = id; abvm.Code = code; abvm.BankCode = BankCode; abvm.AccountName = AccountName; abvm.AccountNumber = AccountNumber; abvm.BankName = BankName; abvm.Currency = cvm; Assert.Equal(id, abvm.Id); Assert.Equal(code, abvm.Code); Assert.Equal(BankCode, abvm.BankCode); Assert.Equal(AccountName, abvm.AccountName); Assert.Equal(AccountNumber, abvm.AccountNumber); Assert.Equal(cvm, abvm.Currency); }
public void Should_Success_Instantiate() { int id = 1; string code = "code test"; string BankCode = "BankCode test"; string AccountName = "AccountName test"; string AccountNumber = "AccountNumber test"; string BankName = "BankName test"; CurrencyViewModel cvm = new CurrencyViewModel(); AccountBankViewModel viewmodel = new AccountBankViewModel() { Id = id, Code = code, BankCode = BankCode, AccountName = AccountName, AccountNumber = AccountNumber, BankName = BankName, Currency = cvm }; Assert.Equal(id, viewmodel.Id); Assert.Equal(code, viewmodel.Code); Assert.Equal(BankCode, viewmodel.BankCode); Assert.Equal(AccountName, viewmodel.AccountName); Assert.Equal(AccountNumber, viewmodel.AccountNumber); Assert.Equal(cvm, viewmodel.Currency); }
private string DocumentNoGenerator(AccountBankViewModel bank) { var latestDocumentNo = _dbContext.OthersExpenditureProofDocuments.IgnoreQueryFilters().Where(document => document.DocumentNo.Contains(bank.BankCode)).OrderByDescending(document => document.Id).Select(document => new { document.DocumentNo, document.CreatedUtc }).FirstOrDefault(); var now = DateTimeOffset.Now; var result = ""; if (latestDocumentNo == null) { result = $"{now:yy}{now:MM}{bank.BankCode}K0001"; } else { if (latestDocumentNo.CreatedUtc.Month != now.Month) { result = $"{now:yy}{now:MM}{bank.BankCode}K0001"; } else { var numberString = latestDocumentNo.DocumentNo.Split("K").ToList()[1]; var number = int.Parse(numberString) + 1; result = $"{now:yy}{now:MM}{bank.BankCode}K{number.ToString().PadLeft(4, '0')}"; } } var model = new OthersExpenditureProofDocumentModel(); model.DocumentNo = result; EntityExtension.FlagForCreate(model, _identityService.Username, "finance-accounting-service"); EntityExtension.FlagForDelete(model, _identityService.Username, "finance-accounting-service"); _dbContext.OthersExpenditureProofDocuments.Add(model); _dbContext.SaveChanges(); return(result); }
public async Task Post() { AccountBankViewModel bankVM = GenerateTestModel(); var response = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(bankVM).ToString(), Encoding.UTF8, "application/json")); Assert.Equal(HttpStatusCode.Created, response.StatusCode); }
public void Should_Success_MapToModel() { AccountBankViewModel viewModel = DataUtil.GetEmptyData(); var Response = Services.MapToModel(viewModel); Assert.NotNull(Response); }
public async Task GetByDivisionName() { AccountBankViewModel bankVM = GenerateTestModel(); //var post = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(bankVM).ToString(), Encoding.UTF8, "application/json")); var response = await this.Client.GetAsync(URI + "/division/" + bankVM.Division.Name); Assert.Equal(HttpStatusCode.OK, response.StatusCode); }
public void Should_Succes_Instantiate_validateService() { var serviceProviderMock = new Mock <IServiceProvider>(); var service = new Lib.Helpers.ValidateService.ValidateService(serviceProviderMock.Object); AccountBankViewModel viewModel = new AccountBankViewModel(); service.Validate(viewModel); Assert.NotNull(service); }
public OthersExpenditureProofDocumentPDFViewModel(OthersExpenditureProofDocumentModel model, List <OthersExpenditureProofDocumentItemModel> items, AccountBankViewModel accountBank, List <COAModel> coas) { Id = model.Id; AccountBankId = model.AccountBankId; Date = model.Date; Type = model.Type; Remark = model.Remark; Items = items.Select(item => new OthersExpenditureProofDocumentItemPDFViewModel(item, coas)).ToList(); Bank = accountBank; DocumentNo = model.DocumentNo; CekBgNo = model.CekBgNo; }
public AccountBankViewModel MapToViewModel(AccountBank accountBank) { AccountBankViewModel accountBankVM = new AccountBankViewModel(); PropertyCopier <AccountBank, AccountBankViewModel> .Copy(accountBank, accountBankVM); accountBankVM.Currency = new CurrencyViewModel { Id = (int)accountBank.CurrencyId, Code = accountBank.CurrencyCode, Rate = accountBank.CurrencyId, Symbol = accountBank.CurrencySymbol }; return(accountBankVM); }
public AccountBankViewModel GetEmptyData() { AccountBankViewModel Data = new AccountBankViewModel(); Data.AccountName = ""; Data.BankAddress = ""; Data.Code = ""; Data.Currency = null; Data.Division = null; Data.AccountNumber = ""; Data.BankName = ""; Data.SwiftCode = ""; Data.Phone = ""; Data.Fax = ""; return(Data); }
public void Should_Success_Instantiate() { List <long> epoids = new List <long>(); epoids.Add(1); List <UPOAndAmountDto> uPOAndAmounts = new List <UPOAndAmountDto>(); UPOAndAmountDto uPOAndAmount = new UPOAndAmountDto(); uPOAndAmount.Amount = 1; uPOAndAmount.UPOId = 1; uPOAndAmounts.Add(uPOAndAmount); CurrencyViewModel currency = new CurrencyViewModel(); currency.Id = 1; currency.Code = ""; currency.Symbol = ""; currency.Rate = 1; currency.Description = ""; AccountBankViewModel accountBank = new AccountBankViewModel(); accountBank.Id = 1; accountBank.Code = ""; accountBank.BankCode = ""; accountBank.AccountName = ""; accountBank.AccountNumber = ""; accountBank.BankName = ""; accountBank.AccountCOA = ""; accountBank.Currency = currency; VBFormDto viewModel = new VBFormDto(); viewModel.Date = DateTimeOffset.Now; viewModel.DocumentNo = ""; viewModel.EPOIds = epoids; viewModel.Amount = 1; viewModel.UPOIds = uPOAndAmounts; viewModel.Bank = accountBank; Assert.NotNull(viewModel); }
public void Should_Success_Instantiate_First() { CurrencyViewModel currency = new CurrencyViewModel(); currency.Code = ""; currency.Description = ""; currency.Id = 1; currency.Rate = 1; currency.Symbol = ""; AccountBankViewModel accountBank = new AccountBankViewModel(); accountBank.AccountCOA = ""; accountBank.AccountName = ""; accountBank.AccountNumber = ""; accountBank.BankCode = ""; accountBank.BankName = ""; accountBank.Code = ""; accountBank.Currency = currency; accountBank.Id = 1; List <long> number = new List <long>(); number.Add(1); List <UPOAndAmountDto> amountDtos = new List <UPOAndAmountDto>(); UPOAndAmountDto amountDto = new UPOAndAmountDto(); amountDto.Amount = 1; amountDto.UPOId = 1; amountDtos.Add(amountDto); VBFormDto vBForm = new VBFormDto(); vBForm.Amount = 1; vBForm.Bank = accountBank; vBForm.Date = DateTimeOffset.Now; vBForm.DocumentNo = ""; vBForm.EPOIds = number; vBForm.UPOIds = amountDtos; Assert.NotNull(vBForm); }
public void SetBank(AccountBankViewModel bankViewModel, string username, string userAgent) { if (bankViewModel != null) { BankId = bankViewModel.Id; BankCode = bankViewModel.Code; BankBankCode = bankViewModel.BankCode; BankAccountName = bankViewModel.AccountName; BankAccountNumber = bankViewModel.AccountNumber; BankBankName = bankViewModel.BankName; BankAccountCOA = bankViewModel.AccountCOA; if (bankViewModel.Currency != null) { BankCurrencyId = bankViewModel.Currency.Id; BankCurrencyCode = bankViewModel.Currency.Code; BankCurrencySymbol = bankViewModel.Currency.Symbol; BankCurrencyRate = bankViewModel.Currency.Rate; BankCurrencyDescription = bankViewModel.Currency.Description; } } }
public AccountBank MapToModel(AccountBankViewModel accountBankVM) { AccountBank accountBank = new AccountBank(); PropertyCopier <AccountBankViewModel, AccountBank> .Copy(accountBankVM, accountBank); if (!Equals(accountBankVM.Currency, null)) { accountBank.CurrencyId = accountBankVM.Currency.Id; accountBank.CurrencyCode = accountBankVM.Currency.Code; accountBank.CurrencyRate = accountBankVM.Currency.Rate; accountBank.CurrencySymbol = accountBankVM.Currency.Symbol; } else { accountBank.CurrencyId = null; accountBank.CurrencyCode = null; accountBank.CurrencyRate = 0; accountBank.CurrencySymbol = null; } return(accountBank); }
public AccountBankViewModel MapToViewModel(AccountBank accountBank) { AccountBankViewModel accountBankVM = new AccountBankViewModel(); PropertyCopier <AccountBank, AccountBankViewModel> .Copy(accountBank, accountBankVM); accountBankVM.Currency = new CurrencyViewModel { Id = accountBank.CurrencyId.GetValueOrDefault(), Code = accountBank.CurrencyCode, Rate = accountBank.CurrencyRate, Symbol = accountBank.CurrencySymbol, Description = accountBank.CurrencyDescription }; accountBankVM.Division = new DivisionViewModel { Id = accountBank.DivisionId.GetValueOrDefault(), Code = accountBank.DivisionCode, Name = accountBank.DivisionName }; return(accountBankVM); }
public async Task <int> AutoJournalVBNonPOClearence(List <int> vbRealizationIds, AccountBankViewModel bank) { var dbContext = _serviceProvider.GetService <FinanceDbContext>(); var vbRealizations = dbContext.VBRealizationDocuments.Where(entity => vbRealizationIds.Contains(entity.Id)).ToList(); var vbRequestIds = vbRealizations.Select(element => element.VBRequestDocumentId).ToList(); var vbRequests = dbContext.VBRequestDocuments.Where(entity => vbRequestIds.Contains(entity.Id)).ToList(); var vbRealizationItems = dbContext.VBRealizationDocumentExpenditureItems.Where(entity => vbRealizationIds.Contains(entity.VBRealizationDocumentId)).ToList(); var vbRealizationUnitCosts = dbContext.VBRealizationDocumentUnitCostsItems.Where(entity => vbRealizationIds.Contains(entity.VBRealizationDocumentId) && entity.IsSelected).ToList(); var units = await _masterCOAService.GetCOAUnits(); var divisions = await _masterCOAService.GetCOADivisions(); foreach (var vbRealization in vbRealizations) { var bankDocumentNo = DocumentNoGenerator(bank); var coaUnit = "00"; var unit = units.FirstOrDefault(element => vbRealization.SuppliantUnitId == element.Id); if (unit != null) { coaUnit = unit.COACode; } var coaDivision = "0"; var division = divisions.FirstOrDefault(element => vbRealization.SuppliantDivisionId == element.Id); if (division != null) { coaDivision = division.COACode; } //var vbRequest = vbRequests.FirstOrDefault(element => element.Id == vbRealization.VBRequestDocumentId); var selectedVbRealizationItems = vbRealizationItems.Where(entity => entity.VBRealizationDocumentId == vbRealization.Id).ToList(); var selectedVbRealizationUnitCosts = vbRealizationUnitCosts.Where(entity => entity.VBRealizationDocumentId == vbRealization.Id).ToList(); if (vbRealization.IsInklaring) { var vbRequest = vbRequests.FirstOrDefault(element => element.Id == vbRealization.VBRequestDocumentId); if (vbRealization.CurrencyCode == "IDR") { var modelInklaring = new JournalTransactionModel() { Date = vbRealization.Date, Description = "Clearance VB Inklaring", ReferenceNo = bankDocumentNo, Status = "DRAFT", Items = new List <JournalTransactionItemModel>() }; foreach (var vbRealizationUnitCost in selectedVbRealizationUnitCosts) { var costCOADivision = "0"; var costDivision = divisions.FirstOrDefault(element => element.Id == vbRealizationUnitCost.DivisionId); if (costDivision != null && !string.IsNullOrWhiteSpace(costDivision.COACode)) { costCOADivision = costDivision.COACode; } var costCOAUnit = "00"; var costUnit = units.FirstOrDefault(element => element.Id == vbRealizationUnitCost.UnitId); if (costUnit != null && !string.IsNullOrWhiteSpace(costUnit.COACode)) { costCOAUnit = costUnit.COACode; } modelInklaring.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1804.00.{costCOADivision}.{costCOAUnit}" }, Debit = vbRealizationUnitCost.Amount }); modelInklaring.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1503.00.{costCOADivision}.{costCOAUnit}" }, Credit = vbRealizationUnitCost.Amount }); } var sumPPn = selectedVbRealizationItems.Sum(element => element.PPnAmount); var sumPPh = selectedVbRealizationItems.Sum(element => element.PPhAmount); if (sumPPn > 0) { modelInklaring.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1509.00.{coaDivision}.{coaUnit}" }, Debit = sumPPn }); } if (sumPPh > 0) { modelInklaring.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"3330.00.{coaDivision}.{coaUnit}" }, Credit = sumPPh }); } await _journalTransactionService.CreateAsync(modelInklaring); if (vbRequest != null) { var difference = vbRequest.Amount - vbRealization.Amount; if (difference > 0) { var modelDifference = new JournalTransactionModel() { Date = vbRequest.Date, Description = "Clearence VB Inklaring", ReferenceNo = bankDocumentNo, Status = "POSTED", Items = new List <JournalTransactionItemModel>() }; modelDifference.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = bank.AccountCOA }, Debit = difference }); modelDifference.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1503.00.{coaDivision}.{coaUnit}" }, Credit = difference }); await _journalTransactionService.CreateAsync(modelDifference); } } } } else { var model = new JournalTransactionModel() { Date = vbRealization.Date, Description = "Clearance VB", ReferenceNo = bankDocumentNo, Status = "DRAFT", Items = new List <JournalTransactionItemModel>() }; //model.Items.Add(new JournalTransactionItemModel() //{ // COA = new COAModel() // { // Code = $"9999.00.0.00" // }, // Debit = vbRealization.Amount //}); if (vbRealization.CurrencyCode == "IDR") { foreach (var vbRealizationUnitCost in selectedVbRealizationUnitCosts) { var costCOADivision = "0"; var costDivision = divisions.FirstOrDefault(element => element.Id == vbRealizationUnitCost.DivisionId); if (costDivision != null && !string.IsNullOrWhiteSpace(costDivision.COACode)) { costCOADivision = costDivision.COACode; } var costCOAUnit = "00"; var costUnit = units.FirstOrDefault(element => element.Id == vbRealizationUnitCost.UnitId); if (costUnit != null && !string.IsNullOrWhiteSpace(costUnit.COACode)) { costCOAUnit = costUnit.COACode; } model.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1011.00.{costCOADivision}.{costCOAUnit}" }, Credit = vbRealizationUnitCost.Amount }); } var sumPPn = selectedVbRealizationUnitCosts.Sum(element => { var result = (decimal)0; if (element.UseVat) { result = element.Amount * (decimal)0.1; } return(result); }); var sumPPh = selectedVbRealizationUnitCosts.Sum(element => { var result = (decimal)0; if (element.UseIncomeTax) { result = element.Amount * ((decimal)element.IncomeTaxRate / 100); } return(result); }); if (sumPPn > 0) { model.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1509.00.{coaDivision}.{coaUnit}" }, Debit = sumPPn }); } if (sumPPh > 0) { model.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"3330.00.{coaDivision}.{coaUnit}" }, Credit = sumPPh }); } } else { model.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1012.00.{coaDivision}.{coaUnit}" }, Credit = vbRealization.Amount }); } //if (model.Items.Any(element => element.COA.Code.Contains("9999"))) // model.Status = "DRAFT"; await _journalTransactionService.CreateAsync(model); } #region old auto journal //else //{ // var model = new JournalTransactionModel() // { // Date = vbRealization.Date, // Description = "Clearance VB", // ReferenceNo = vbRealization.DocumentNo, // Status = "DRAFT", // Items = new List<JournalTransactionItemModel>() // }; // //model.Items.Add(new JournalTransactionItemModel() // //{ // // COA = new COAModel() // // { // // Code = $"9999.00.0.00" // // }, // // Debit = vbRealization.Amount // //}); // if (vbRealization.CurrencyCode == "IDR") // { // model.Items.Add(new JournalTransactionItemModel() // { // COA = new COAModel() // { // Code = $"1011.00.{coaDivision}.{coaUnit}" // }, // Credit = vbRealization.Amount // }); // } // else // { // model.Items.Add(new JournalTransactionItemModel() // { // COA = new COAModel() // { // Code = $"1012.00.{coaDivision}.{coaUnit}" // }, // Credit = vbRealization.Amount // }); // } // //if (model.Items.Any(element => element.COA.Code.Contains("9999"))) // // model.Status = "DRAFT"; // await _journalTransactionService.CreateAsync(model); //} #endregion } return(vbRealizations.Count); }
public async Task <int> AutoCreateFromClearenceVB(List <int> vbRealizationIds, AccountBankViewModel accountBank) { var realizations = _dbContext.VBRealizationDocuments.Where(entity => vbRealizationIds.Contains(entity.Id) && entity.Type == VBRequestDocument.VBType.WithPO).ToList(); var result = 0; foreach (var realization in realizations) { var realizationItems = _dbContext.VBRealizationDocumentUnitCostsItems.Where(entity => entity.VBRealizationDocumentId == realization.Id).ToList(); var dailyBankTransactionModel = new DailyBankTransactionModel() { AccountBankAccountName = accountBank.AccountName, AccountBankAccountNumber = accountBank.AccountNumber, AccountBankCode = accountBank.BankCode, AccountBankCurrencyCode = accountBank.Currency.Code, AccountBankCurrencyId = (int)accountBank.Currency.Id, AccountBankCurrencySymbol = accountBank.Currency.Symbol, AccountBankId = accountBank.Id, AccountBankName = accountBank.BankName, Date = realization.Date, Nominal = realizationItems.Sum(item => item.Amount), CurrencyRate = (decimal)realization.CurrencyRate, ReferenceNo = realization.DocumentNo, ReferenceType = "Clearence VB", Remark = $"{realization.Remark}\n\nPembayaran atas {accountBank.Currency.Code} dengan nominal {string.Format("{0:n}", realizationItems.Sum(item => item.Amount))}", SourceType = "OPERASIONAL", Status = "OUT", IsPosted = true }; if (accountBank.Currency.Code != "IDR") { dailyBankTransactionModel.NominalValas = realizationItems.Sum(item => item.Amount) * (decimal)realization.CurrencyRate; } result += await _dailyBankTransactionService.CreateAsync(dailyBankTransactionModel); } return(result); }
public async Task <int> AutoJournalInklaring(List <int> vbRequestIds, AccountBankViewModel bank) { var dbContext = _serviceProvider.GetService <FinanceDbContext>(); var vbRequests = dbContext.VBRequestDocuments.Where(entity => vbRequestIds.Contains(entity.Id)).ToList(); var units = await _masterCOAService.GetCOAUnits(); var divisions = await _masterCOAService.GetCOAUnits(); foreach (var vbRequest in vbRequests) { var bankDocumentNo = DocumentNoGenerator(bank); var coaUnit = "00"; var unit = units.FirstOrDefault(element => vbRequest.SuppliantUnitId == element.Id); if (unit != null) { coaUnit = unit.COACode; } var coaDivision = "0"; var division = divisions.FirstOrDefault(element => vbRequest.SuppliantDivisionId == element.Id); if (division != null) { coaDivision = division.COACode; } if (vbRequest.IsInklaring && vbRequest.CurrencyCode == "IDR") { var modelInklaring = new JournalTransactionModel() { Date = vbRequest.Date, Description = "Approval VB Inklaring", ReferenceNo = bankDocumentNo, Status = "DRAFT", Items = new List <JournalTransactionItemModel>() }; modelInklaring.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = $"1503.00.{coaDivision}.{coaUnit}" }, Debit = vbRequest.Amount }); modelInklaring.Items.Add(new JournalTransactionItemModel() { COA = new COAModel() { Code = bank.AccountCOA }, Credit = vbRequest.Amount }); //modelInklaring.Items.Add(new JournalTransactionItemModel() //{ // COA = new COAModel() // { // Code = $"9999.00.0.00" // }, // Credit = vbRequest.Amount //}); //if (modelInklaring.Items.Any(element => element.COA.Code.Contains("9999"))) //modelInklaring.Status = "DRAFT"; await _journalTransactionService.CreateAsync(modelInklaring); } } return(vbRequests.Count); }
public string DocumentNoGenerator(AccountBankViewModel bank) { return(string.Empty); }
public async Task <int> AutoJournalVBNonPOClearence(List <int> vbRealizationIds, AccountBankViewModel bank, string referenceNo) { await Task.Delay(1000); return(await Task.FromResult(1)); }
public async Task <int> AutoJournalInklaring(List <int> vbRequestIds, AccountBankViewModel bank) { await Task.Delay(1000); return(await Task.FromResult(1)); }
public async Task <int> AutoCreateFromClearenceVB(List <int> vbRealizationIds, AccountBankViewModel bank) { await Task.Delay(1000); return(await Task.FromResult(1)); }
public async Task Should_Success_AutoJournalVBNonPOClearence_With_ViewModel() { //Setup var dbContext = GetDbContext(GetCurrentMethod()); var serviceProviderMock = GetServiceProvider(); serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext); serviceProviderMock .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(new JournalHttpClientTestService()); Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>(); serviceProviderMock .Setup(x => x.GetService(typeof(IJournalTransactionService))) .Returns(journalTransactionServiceMock.Object); var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object); serviceProviderMock .Setup(x => x.GetService(typeof(IMasterCOAService))) .Returns(masterCOAServiceMock); var vBRequestDocumentService = new VBRequestDocumentService(dbContext, GetServiceProvider().Object); var data = await GetdataUtil(vBRequestDocumentService).GetTestData_VBRequestDocumentNonPO(); var vBRealizationWithPOService = new VBRealizationWithPOService(dbContext, serviceProviderMock.Object); var vBRealizationDocumenData = GetDataUtil(vBRealizationWithPOService).GetTestData_DenganNomorVB(); var expeditionService = new VBRealizationDocumentExpeditionService(dbContext, GetServiceProvider().Object); var model = _dataUtil(expeditionService, dbContext).GetTestData_VBRealizationDocumentExpedition(); var realization = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOViewModel() { IsInklaring = true, Currency = new Lib.ViewModels.VBRealizationDocumentNonPO.CurrencyViewModel() { Code = "IDR" } }; var expenditureitem = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOExpenditureItemViewModel() { PPhAmount = 1, PPnAmount = 1, }; var unitcostitem = new Lib.ViewModels.VBRealizationDocumentNonPO.VBRealizationDocumentNonPOUnitCostViewModel() { IsSelected = true }; var vbRealizations = new VBRealizationDocumentModel(realization); var vbRealizationItems = new VBRealizationDocumentExpenditureItemModel(2, expenditureitem); var vbRealizationsUnitItems = new VBRealizationDocumentUnitCostsItemModel(2, unitcostitem); dbContext.VBRealizationDocuments.Add(vbRealizations); dbContext.VBRealizationDocumentExpenditureItems.Add(vbRealizationItems); dbContext.VBRealizationDocumentUnitCostsItems.Add(vbRealizationsUnitItems); dbContext.SaveChanges(); var service = new AutoJournalService(dbContext, serviceProviderMock.Object); AccountBankViewModel viewModel = new AccountBankViewModel() { AccountCOA = "AccountCOA", AccountName = "AccountName", AccountNumber = "AccountNumber", BankCode = "BankCode", BankName = "BankName", Code = "Code", Currency = new CurrencyViewModel() { Code = "Rp", Description = "Description", Rate = 1, Symbol = "IDR" }, }; List <int> vbRealizationIds = new List <int>() { 1, 2 }; //Act var result = await service.AutoJournalVBNonPOClearence(vbRealizationIds, viewModel, null); //Assert Assert.NotEqual(0, result); }
public async Task Should_Success_AutoJournalFromOthersExpenditureProof_With_ViewModel() { //Setup var dbContext = GetDbContext(GetCurrentMethod()); var serviceProviderMock = GetServiceProvider(); serviceProviderMock.Setup(s => s.GetService(typeof(FinanceDbContext))).Returns(dbContext); serviceProviderMock .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(new JournalHttpClientTestService()); Mock <IJournalTransactionService> journalTransactionServiceMock = new Mock <IJournalTransactionService>(); journalTransactionServiceMock.Setup(s => s.CreateAsync(It.IsAny <JournalTransactionModel>())).ReturnsAsync(1); serviceProviderMock .Setup(x => x.GetService(typeof(IJournalTransactionService))) .Returns(journalTransactionServiceMock.Object); var masterCOAServiceMock = new MasterCOAService(serviceProviderMock.Object); serviceProviderMock .Setup(x => x.GetService(typeof(IMasterCOAService))) .Returns(masterCOAServiceMock); var service = new AutoJournalService(dbContext, serviceProviderMock.Object); AccountBankViewModel viewModel = new AccountBankViewModel() { AccountCOA = "AccountCOA", AccountName = "AccountName", AccountNumber = "AccountNumber", BankCode = "BankCode", BankName = "BankName", Code = "Code", Currency = new CurrencyViewModel() { Code = "Rp", Description = "Description", Rate = 1, Symbol = "IDR" }, }; List <int> vbRealizationIds = new List <int>() { 1 }; var viewModelOtherProof = new OthersExpenditureProofDocumentModel() { Date = DateTime.Now, DocumentNo = "test", AccountBankId = 1 }; var viewModelOtherProofItems = new List <OthersExpenditureProofDocumentItemModel>() { new OthersExpenditureProofDocumentItemModel { COAId = 1, Debit = 10 } }; //Act var result = await service.AutoJournalFromOthersExpenditureProof(viewModelOtherProof, viewModelOtherProofItems); //Assert Assert.NotEqual(0, result); }
public async Task <int> AutoCreateFromClearenceVB(List <int> vbRealizationIds, AccountBankViewModel accountBank, string referenceNo) { var realizations = _dbContext.VBRealizationDocuments.Where(entity => vbRealizationIds.Contains(entity.Id) /*&& entity.Type == VBRequestDocument.VBType.WithPO*/).ToList(); var result = 0; foreach (var realization in realizations) { var realizationItems = _dbContext.VBRealizationDocumentUnitCostsItems.Where(entity => entity.VBRealizationDocumentId == realization.Id).ToList(); var BICurrency = await GetBICurrency(realization.CurrencyCode, realization.Date); var dailyBankTransactionModel = new DailyBankTransactionModel() { AccountBankAccountName = accountBank.AccountName, AccountBankAccountNumber = accountBank.AccountNumber, AccountBankCode = accountBank.BankCode, AccountBankCurrencyCode = accountBank.Currency.Code, AccountBankCurrencyId = (int)accountBank.Currency.Id, AccountBankCurrencySymbol = accountBank.Currency.Symbol, AccountBankId = accountBank.Id, AccountBankName = accountBank.BankName, Date = realization.CompletedDate == null ? realization.Date : realization.CompletedDate.GetValueOrDefault(), Nominal = realizationItems.Sum(item => item.Amount), CurrencyRate = (decimal)BICurrency.Rate, ReferenceNo = realization.ReferenceNo, //ReferenceType = "Clearence VB", Remark = $"Pembayaran atas {accountBank.Currency.Code} untuk:\nPermohonan VB {realization.VBRequestDocumentNo}\nRealisasi VB {realization.DocumentNo}", //Remark = $"{realization.Remark}\n\nPembayaran atas {accountBank.Currency.Code} dengan nominal {string.Format("{0:n}", realizationItems.Sum(item => item.Amount))}",k SourceType = "OPERASIONAL", Status = "OUT", IsPosted = true }; if (realization.IsInklaring) { dailyBankTransactionModel.ReferenceType = "Clearence VB Inklaring"; } else if (realization.Type == VBType.NonPO) { dailyBankTransactionModel.ReferenceType = "Clearence VB Non PO"; } else { dailyBankTransactionModel.ReferenceType = "Clearence VB With PO"; } if (realization.CurrencyCode != "IDR") { dailyBankTransactionModel.Nominal = realizationItems.Sum(item => item.Amount) * (decimal)BICurrency.Rate; dailyBankTransactionModel.NominalValas = realizationItems.Sum(item => item.Amount); } //if (accountBank.Currency.Code != "IDR") // dailyBankTransactionModel.NominalValas = realizationItems.Sum(item => item.Amount) * (decimal)realization.CurrencyRate; result += await _dailyBankTransactionService.CreateAsync(dailyBankTransactionModel); } return(result); }