예제 #1
0
    private DataSet Search()
    {
        try
        {
            VoucherSearch search = new VoucherSearch();
            search.ChequeNumberFrom = txtChqNoFrom.Text.Trim();
            search.ChequeNumberTo   = txtChqNoTo.Text.Trim();

            if (dtpFromDate.Text.Trim() == String.Empty)
            {
                search.ChequeDateFrom = DateTime.MinValue;
            }
            else
            {
                search.ChequeDateFrom = DateTime.Parse(dtpFromDate.Value.ToString());
            }

            if (dtpToDate.Text.Trim() == String.Empty)
            {
                search.ChequeDateTo = DateTime.MinValue;
            }
            else
            {
                search.ChequeDateTo = DateTime.Parse(dtpToDate.Value.ToString());
            }

            return(new VoucherDAO().SearchVoucher(search));
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
예제 #2
0
        public void Test_issue51_fixed() //Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/51
        {
            //Arrange
            /* Assuming several (at least 5) vouchers exists */

            //Act & Assert
            var connector      = new VoucherConnector();
            var searchSettings = new VoucherSearch();

            searchSettings.FinancialYearID = 1;

            searchSettings.Limit = 2;
            var voucherResult = connector.Find(searchSettings);

            searchSettings.Page = 2;
            var voucherResult2 = connector.Find(searchSettings);

            searchSettings.Page = 3;
            var voucherResult3 = connector.Find(searchSettings);
        }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            VoucherSearch search = new VoucherSearch();
            if (dtpFromDate.Text == string.Empty)
            {
                search.FromDate = null;
            }
            else
            {
                search.FromDate = dtpFromDate.Date;
            }

            if (dtpToDate.Text == string.Empty)
            {
                search.ToDate = null;
            }
            else
            {
                search.ToDate = dtpToDate.Date;
            }

            DataSet ds = new VoucherDAO().GetExpencesForReportingByDateRange(search);
            Session["VoucherExpencesReport"] = ds;
            dxgvExpenseReport.DataSource     = ds;
            dxgvExpenseReport.DataBind();
        }
        catch (Exception ex)
        {
            ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnSearch_Click(object sender, EventArgs e)");
            if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
            {
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
            }
            else
            {
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);
            }
        }
    }
예제 #4
0
    public async Task Test_Vouchers_Find_By_Series()
    {
        //Arrange
        Thread.Sleep(2);

        var voucher1 = new Voucher()
        {
            Description     = "TestVoucher",
            Comments        = "Some comments",
            VoucherSeries   = "TST", //predefined series
            TransactionDate = new DateTime(2020, 1, 1),
            VoucherRows     = new List <VoucherRow>()
            {
                new VoucherRow()
                {
                    Account = 1930, Debit = 1500, Credit = 0
                },
                new VoucherRow()
                {
                    Account = 1910, Debit = 0, Credit = 1500
                }
            }
        };
        var voucher2 = new Voucher()
        {
            Description     = "TestVoucher",
            Comments        = "Some comments",
            VoucherSeries   = "TST", //predefined series
            TransactionDate = new DateTime(2020, 1, 1),
            VoucherRows     = new List <VoucherRow>()
            {
                new VoucherRow()
                {
                    Account = 1930, Debit = 1500, Credit = 0
                },
                new VoucherRow()
                {
                    Account = 1910, Debit = 0, Credit = 1500
                }
            }
        };
        var voucher3 = new Voucher()
        {
            Description     = "TestVoucher",
            Comments        = "Some comments",
            VoucherSeries   = "A", //predefined series
            TransactionDate = new DateTime(2020, 1, 1),
            VoucherRows     = new List <VoucherRow>()
            {
                new VoucherRow()
                {
                    Account = 1930, Debit = 1500, Credit = 0
                },
                new VoucherRow()
                {
                    Account = 1910, Debit = 0, Credit = 1500
                }
            }
        };

        var connector = FortnoxClient.VoucherConnector;

        voucher1 = await connector.CreateAsync(voucher1);

        voucher2 = await connector.CreateAsync(voucher2);

        voucher3 = await connector.CreateAsync(voucher3);

        //Act
        var settings = new VoucherSearch()
        {
            LastModified  = TestUtils.Recently,
            VoucherSeries = "TST"
        };

        //Assert
        var vouchers = await connector.FindAsync(settings);

        Assert.AreEqual(2, vouchers.TotalResources);

        //Clean
        await connector.DeleteAsync(voucher3.VoucherNumber, voucher3.VoucherSeries, voucher3.Year);

        await connector.DeleteAsync(voucher2.VoucherNumber, voucher2.VoucherSeries, voucher2.Year);

        await connector.DeleteAsync(voucher1.VoucherNumber, voucher1.VoucherSeries, voucher1.Year);
    }
예제 #5
0
        public void Test_Vouchers_Find_By_Series()
        {
            //Arrange
            Thread.Sleep(2);

            var voucher1 = new Voucher()
            {
                Description     = "TestVoucher",
                Comments        = "Some comments",
                VoucherSeries   = "TST", //predefined series
                TransactionDate = new DateTime(2020, 1, 1),
                VoucherRows     = new List <VoucherRow>()
                {
                    new VoucherRow()
                    {
                        Account = 1930, Debit = 1500, Credit = 0
                    },
                    new VoucherRow()
                    {
                        Account = 1910, Debit = 0, Credit = 1500
                    }
                }
            };
            var voucher2 = new Voucher()
            {
                Description     = "TestVoucher",
                Comments        = "Some comments",
                VoucherSeries   = "TST", //predefined series
                TransactionDate = new DateTime(2020, 1, 1),
                VoucherRows     = new List <VoucherRow>()
                {
                    new VoucherRow()
                    {
                        Account = 1930, Debit = 1500, Credit = 0
                    },
                    new VoucherRow()
                    {
                        Account = 1910, Debit = 0, Credit = 1500
                    }
                }
            };
            var voucher3 = new Voucher()
            {
                Description     = "TestVoucher",
                Comments        = "Some comments",
                VoucherSeries   = "A", //predefined series
                TransactionDate = new DateTime(2020, 1, 1),
                VoucherRows     = new List <VoucherRow>()
                {
                    new VoucherRow()
                    {
                        Account = 1930, Debit = 1500, Credit = 0
                    },
                    new VoucherRow()
                    {
                        Account = 1910, Debit = 0, Credit = 1500
                    }
                }
            };

            IVoucherConnector connector = new VoucherConnector();

            voucher1 = connector.Create(voucher1);
            voucher2 = connector.Create(voucher2);
            voucher3 = connector.Create(voucher3);

            //Act
            var settings = new VoucherSearch()
            {
                LastModified  = DateTime.Now.AddSeconds(-2),
                VoucherSeries = "TST"
            };

            //Assert
            var vouchers = connector.Find(settings);

            Assert.AreEqual(2, vouchers.TotalResources);

            //Clean
            connector.Delete(voucher3.VoucherNumber, voucher3.VoucherSeries, voucher3.Year);
            connector.Delete(voucher2.VoucherNumber, voucher2.VoucherSeries, voucher2.Year);
            connector.Delete(voucher1.VoucherNumber, voucher1.VoucherSeries, voucher1.Year);
        }