public void MichiganBudgetTest()
        {
            ExcoBudget budget = ExcoBudget.Instance;

            string[] lines = File.ReadAllLines("D:\\workspace\\ERP\\ExcoUtility\\USA_Budget.txt");
            foreach (string line in lines)
            {
                int    indexComma = line.IndexOf(',');
                double amount     = Convert.ToDouble(line.Substring(0, indexComma - 1));
                string custID     = line.Substring(indexComma + 1, line.Length - indexComma - 1);
                Assert.AreEqual(amount / 12.0, budget.GetMonthlyBudget(custID, 3));
            }
        }
Exemple #2
0
        public void GetData(int plant, string id, string curr)
        {
            this.curr = curr;
            this.id   = plant;
            GetFiscal();
            // get period details
            ExcoODBC database = ExcoODBC.Instance;

            database.Open(Database.CMSDAT);
            for (int i = 0; i < 12; i++)
            {
                double value = 0.0;
                // invoice
                string         query  = "select coalesce(sum(dipric*(max(diqtso,diqtsp))), 0.0) from cmsdat.oih, cmsdat.oid where dhbcs#='" + id + "' and dhincr='I' and dhpost='Y' and dhinv#=diinv# and diglcd='SAL' and dhplnt='" + plant.ToString("D3") + "' and dharpr=" + fiscalPeriod[i].ToString() + " and dharyr=" + fiscalYear[i].ToString();
                OdbcDataReader reader = database.RunQuery(query);
                if (reader.Read())
                {
                    value = Convert.ToDouble(reader[0]);
                }
                reader.Close();
                // credit
                query  = "select coalesce(sum(dipric*(max(diqtso,diqtsp))), 0.0) from cmsdat.oih, cmsdat.oid where dhbcs#='" + id + "' and dhincr='C' and dhpost='Y' and dhinv#=diinv# and diglcd='SAL' and dhplnt='" + plant.ToString("D3") + "' and dharpr=" + fiscalPeriod[i].ToString() + " and dharyr=" + fiscalYear[i].ToString();
                reader = database.RunQuery(query);
                if (reader.Read())
                {
                    value -= Convert.ToDouble(reader[0]);
                }
                reader.Close();
                // discount and fast track
                query  = "select coalesce(sum(fldext), 0.0) from cmsdat.oih, cmsdat.ois where dhbcs#='" + id + "' and dhpost='Y' and dhinv#=flinv# and (fldisc like 'D%' or fldisc like 'M%' or fldisc like 'F%') and dhplnt='" + plant.ToString("D3") + "' and dharpr=" + fiscalPeriod[i].ToString() + " and dharyr=" + fiscalYear[i].ToString();
                reader = database.RunQuery(query);
                if (reader.Read())
                {
                    value += Convert.ToDouble(reader[0]);
                }
                reader.Close();
                // net sale
                ExcoCalendar calendar = new ExcoCalendar(year, i + 1, true, plant);
                actual[i]       = value;
                actualTotal    += actual[i];
                actualTotalCAD += actual[i] * ExcoExRate.GetToCADRate(calendar, curr);
                ExcoBudget excoBudget = ExcoBudget.Instance;
                budget[i]       = excoBudget.GetMonthlyBudget(id, plant);
                budgetTotal    += budget[i];
                budgetTotalCAD += budget[i] * ExcoExRate.GetToCADRate(calendar, curr);
            }
        }