public void Should_Success_Validate_With_Invalid_Input_Data_Out_Supplier_NotNull_NonOperasional()
        {
            DailyBankTransactionViewModel vm = new DailyBankTransactionViewModel
            {
                Bank = new AccountBankViewModel()
                {
                    Id = 0
                },
                Date       = DateTime.Now.AddYears(1),
                Status     = "OUT",
                SourceType = "Investasi",
                Supplier   = new NewSupplierViewModel()
                {
                    _id = 0
                }
            };


            Assert.True(vm.Validate(null).Count() > 0);
        }
        public void CreateDailyBankTransaction(BankExpenditureNoteModel model, IdentityService identityService)
        {
            DailyBankTransactionViewModel modelToPost = new DailyBankTransactionViewModel()
            {
                Bank = new ViewModels.NewIntegrationViewModel.AccountBankViewModel()
                {
                    Id            = model.BankId,
                    Code          = model.BankCode,
                    AccountName   = model.BankAccountName,
                    AccountNumber = model.BankAccountNumber,
                    BankCode      = model.BankCode,
                    BankName      = model.BankName,
                    Currency      = new ViewModels.NewIntegrationViewModel.CurrencyViewModel()
                    {
                        Code = model.BankCurrencyCode,
                        Id   = model.BankCurrencyId,
                    }
                },
                Date          = model.Date,
                Nominal       = model.GrandTotal,
                ReferenceNo   = model.DocumentNo,
                ReferenceType = "Bayar Hutang",
                Remark        = model.CurrencyCode != "IDR" ? $"Pembayaran atas {model.BankCurrencyCode} dengan nominal {string.Format("{0:n}", model.GrandTotal)} dan kurs {model.CurrencyCode}" : "",
                SourceType    = "Operasional",
                Status        = "OUT",
                Supplier      = new NewSupplierViewModel()
                {
                    _id  = model.SupplierId,
                    code = model.SupplierCode,
                    name = model.SupplierName
                },
                IsPosted = true
            };

            string dailyBankTransactionUri = "daily-bank-transactions";
            //var httpClient = new HttpClientService(identityService);
            var httpClient = (IHttpClientService)this.serviceProvider.GetService(typeof(IHttpClientService));
            var response   = httpClient.PostAsync($"{APIEndpoint.Finance}{dailyBankTransactionUri}", new StringContent(JsonConvert.SerializeObject(modelToPost).ToString(), Encoding.UTF8, General.JsonMediaType)).Result;

            response.EnsureSuccessStatusCode();
        }
Exemplo n.º 3
0
        public void CreateDailyBankTransaction(BankExpenditureNoteModel model, IdentityService identityService)
        {
            DailyBankTransactionViewModel modelToPost = new DailyBankTransactionViewModel()
            {
                Bank = new AccountBankViewModel()
                {
                    _id           = model.BankId,
                    code          = model.BankCode,
                    accountName   = model.BankAccountName,
                    accountNumber = model.BankAccountNumber,
                    bankCode      = model.BankCode,
                    bankName      = model.BankName,
                    currency      = new CurrencyViewModel()
                    {
                        code = model.BankCurrencyCode,
                        _id  = model.BankCurrencyId,
                    }
                },
                Date          = model.Date,
                Nominal       = model.GrandTotal,
                ReferenceNo   = model.DocumentNo,
                ReferenceType = "Bayar Hutang",
                SourceType    = "Operasional",
                Status        = "OUT",
                Supplier      = new SupplierViewModel()
                {
                    _id  = model.SupplierId,
                    code = model.SupplierCode,
                    name = model.SupplierName
                }
            };

            string dailyBankTransactionUri = "daily-bank-transactions";
            //var httpClient = new HttpClientService(identityService);
            var httpClient = (IHttpClientService)this.serviceProvider.GetService(typeof(IHttpClientService));
            var response   = httpClient.PostAsync($"{APIEndpoint.Finance}{dailyBankTransactionUri}", new StringContent(JsonConvert.SerializeObject(modelToPost).ToString(), Encoding.UTF8, General.JsonMediaType)).Result;

            response.EnsureSuccessStatusCode();
        }
Exemplo n.º 4
0
        public DailyBankTransactionViewModel GetDataToValidate()
        {
            DailyBankTransactionViewModel TestData = new DailyBankTransactionViewModel()
            {
                Bank = new AccountBankViewModel()
                {
                    Id            = 1,
                    AccountName   = "AccountName",
                    AccountNumber = "AccountNumber",
                    BankCode      = "BankCode",
                    BankName      = "Name",
                    Code          = "Code",
                    Currency      = new CurrencyViewModel()
                    {
                        Id          = 1,
                        Code        = "Code",
                        Description = "Description",
                        Rate        = 1,
                        Symbol      = "Symbol"
                    }
                },
                AfterNominal  = 0,
                BeforeNominal = 0,
                Buyer         = new NewBuyerViewModel()
                {
                    Id   = 1,
                    Code = "BuyerCode",
                    Name = "BuyerName"
                },
                Code              = "Code",
                Date              = DateTimeOffset.UtcNow,
                Nominal           = 1000,
                ReferenceNo       = "ReferenceNo",
                ReferenceType     = "ReferenceType",
                Remark            = "Remark",
                SourceType        = "Operasional",
                SourceFundingType = "Internal",
                Status            = "IN",
                Supplier          = new NewSupplierViewModel()
                {
                    _id  = 1,
                    code = "SupplierCode",
                    name = "SupplierName"
                },
                OutputBank = new AccountBankViewModel()
                {
                    Id            = 1,
                    AccountName   = "AccountName",
                    AccountNumber = "AccountNumber",
                    BankCode      = "BankCode",
                    BankName      = "Name",
                    Code          = "Code",
                    Currency      = new CurrencyViewModel()
                    {
                        Id          = 1,
                        Code        = "Code",
                        Description = "Description",
                        Rate        = 1,
                        Symbol      = "Symbol"
                    }
                }
            };

            return(TestData);
        }
Exemplo n.º 5
0
        public void Should_Success_Validate_All_Null_Data()
        {
            DailyBankTransactionViewModel vm = new DailyBankTransactionViewModel();

            Assert.True(vm.Validate(null).Count() > 0);
        }
        private async Task CreateDailyBankTransaction(PPHBankExpenditureNote model)
        {
            var item = model.Items.FirstOrDefault();
            var spb  = dbContext.UnitPaymentOrders.FirstOrDefault(entity => entity.UPONo == item.UnitPaymentOrderNo);

            if (spb == null)
            {
                spb = new UnitPaymentOrder()
                {
                    SupplierId = "1"
                }
            }
            ;

            var nominal      = model.TotalIncomeTax;
            var nominalValas = 0.0;

            if (model.Currency != "IDR")
            {
                nominalValas = model.TotalIncomeTax;
                nominal      = model.TotalIncomeTax * model.CurrencyRate.GetValueOrDefault();
            }

            int.TryParse(model.BankId, out var bankId);
            long.TryParse(spb.SupplierId, out var supplierId);
            var modelToPost = new DailyBankTransactionViewModel()
            {
                Bank = new ViewModels.NewIntegrationViewModel.AccountBankViewModel()
                {
                    Id            = bankId,
                    Code          = model.BankCode,
                    AccountName   = model.BankAccountName,
                    AccountNumber = model.BankAccountNumber,
                    BankCode      = model.BankCode,
                    BankName      = model.BankName,
                    Currency      = new ViewModels.NewIntegrationViewModel.CurrencyViewModel()
                    {
                        Code = model.Currency,
                    }
                },
                Date          = model.Date,
                Nominal       = nominal,
                CurrencyRate  = model.CurrencyRate.GetValueOrDefault(),
                ReferenceNo   = model.No,
                ReferenceType = "Bayar PPh",
                //Remark = model.Currency != "IDR" ? $"Pembayaran atas {model.BankCurrencyCode} dengan nominal {string.Format("{0:n}", model.GrandTotal)} dan kurs {model.CurrencyCode}" : "",
                SourceType = "Operasional",
                Status     = "OUT",
                Supplier   = new NewSupplierViewModel()
                {
                    _id  = supplierId,
                    code = spb.SupplierCode,
                    name = spb.SupplierName
                },
                IsPosted     = true,
                NominalValas = nominalValas
            };

            //if (model.Currency != "IDR")
            //    modelToPost.NominalValas = model.TotalIncomeTax * model.CurrencyRate;

            string dailyBankTransactionUri = "daily-bank-transactions";
            //var httpClient = new HttpClientService(identityService);
            var httpClient = (IHttpClientService)this._serviceProvider.GetService(typeof(IHttpClientService));
            var response   = await httpClient.PostAsync($"{APIEndpoint.Finance}{dailyBankTransactionUri}", new StringContent(JsonConvert.SerializeObject(modelToPost).ToString(), Encoding.UTF8, General.JsonMediaType));

            response.EnsureSuccessStatusCode();
        }