//private async Task<CreditorAccountUnitReceiptNotePostedViewModel> GetCreditorAccountFromUnitReceiptNote(string urnNo)
        //{
        //    var jsonSerializerSettings = new JsonSerializerSettings
        //    {
        //        MissingMemberHandling = MissingMemberHandling.Ignore
        //    };

        //    //var token = GetTokenAsync().Result;

        //    var categoryUri = APIEndpoint.Purchasing + $"unit-receipt-notes/by-user/correction-note/";
        //    var categoryResponse = _http.GetAsync(categoryUri, token).Result;

        //    var categoryResult = new BaseResponse<List<CategoryCOAResult>>()
        //    {
        //        data = new List<CategoryCOAResult>()
        //    };
        //    if (categoryResponse.IsSuccessStatusCode)
        //    {
        //        categoryResult = JsonConvert.DeserializeObject<BaseResponse<List<CategoryCOAResult>>>(categoryResponse.Content.ReadAsStringAsync().Result, jsonSerializerSettings);
        //    }

        //    _cacheManager.Set(MemoryCacheConstant.Categories, categoryResult.data);
        //}

        public async Task <int> CreateFromMemoAsync(CreditorAccountMemoPostedViewModel viewModel)
        {
            CreditorAccountModel model = await DbSet.FirstOrDefaultAsync(x => x.SupplierCode == viewModel.SupplierCode && x.InvoiceNo == viewModel.InvoiceNo);

            if (model == null)
            {
                throw new NotFoundException();
            }

            model.MemoDate     = viewModel.Date;
            model.MemoDPP      = viewModel.DPP;
            model.MemoPPN      = viewModel.PPN;
            model.MemoNo       = viewModel.Code;
            model.MemoMutation = viewModel.DPP + viewModel.PPN;
            model.FinalBalance = model.UnitReceiptMutation + model.BankExpenditureNoteMutation + model.MemoMutation;

            UpdateModel(model.Id, model);
            return(await DbContext.SaveChangesAsync());
        }
 public async Task Should_Fail_Create_From_Memo()
 {
     CreditorAccountService             service  = new CreditorAccountService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
     CreditorAccountMemoPostedViewModel memoData = new CreditorAccountMemoPostedViewModel();
     await Assert.ThrowsAnyAsync <NotFoundException>(() => service.CreateFromMemoAsync(memoData));
 }