Ejemplo n.º 1
0
        public ActionResult ReviewByTimePartialView(string start, string end, int? type)
        {
            try
            {
                if (Session["User"] == null)
                {
                    return null;
                }
                if ((int)Session["UserRole"] != 1)
                {
                    return null;
                }
                ReportBusiness business = new ReportBusiness();
                if (type == null)
                {
                    type = 1;
                }
                if (type == 1)
                {
                    DateTime startDate;
                    DateTime endDate;
                    if (start == null || end == null)
                    {
                        startDate = DateTime.Now.FirstDayOfWeek().AddDays(-21);
                        endDate = DateTime.Now.LastDayOfWeek();
                    }
                    else
                    {
                        startDate = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                        endDate = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }

                    List<sp_GetIncomeWeekly_Result> result = business.GetIncomeWeeklyStore(startDate, endDate);
                    return PartialView("ReviewIncomeWeeklyPartialView", result);
                }
                if (type == 2)
                {
                    DateTime startMonth = DateTime.ParseExact(start, "MM/yyyy", CultureInfo.InvariantCulture);
                    DateTime endMonth = DateTime.ParseExact(end, "MM/yyyy", CultureInfo.InvariantCulture);

                    List<sp_GetIncomeMonthly_Result> result = business.GetIncomeMonthlyStore(startMonth.Month,
                        startMonth.Year, endMonth.Month, endMonth.Year);
                    return PartialView("ReviewIncomeMonthlyPartialView", result);

                }
                if (type == 3)
                {
                    int startYear = DateTime.ParseExact(start, "yyyy", CultureInfo.InvariantCulture).Year;
                    int endYear = DateTime.ParseExact(end, "yyyy", CultureInfo.InvariantCulture).Year;
                    List<sp_GetIncomeYearly_Result> result = business.GetIncomeYearlyStore(startYear, endYear);
                    return PartialView("ReviewIncomeYearlyPartialView", result);
                }

                return null;
            }
            catch (Exception)
            {
                return null;
            }
        }
Ejemplo n.º 2
0
        public TndnTaxDeclaration GeTndnTaxDeclaration(int year)
        {
            TndnTaxDeclaration result = db.TndnTaxDeclarations.FirstOrDefault(m => m.Year == year);
            {
                if (result == null)
                {
                    result = new TndnTaxDeclaration();
                    StoreInfo storeInfo = db.StoreInfoes.FirstOrDefault();
                    if (storeInfo != null)
                    {
                        result.StoreOwnerName = storeInfo.OwnerName;
                        result.StoreTaxCode = storeInfo.TaxCode;
                        result.StoreAddress = storeInfo.Address;
                        result.StoreDistrict = storeInfo.District;
                        result.StoreProvince = storeInfo.Province;
                        result.StorePhone = storeInfo.Phonenumber;
                        result.StoreFax = storeInfo.Fax;
                        result.StoreEmail = storeInfo.Email;

                        result.SignName = storeInfo.OwnerName;
                        result.Year = year;
                    }

                    ReportBusiness business = new ReportBusiness();
                    List<sp_GetIncomeYearly_Result> incomeYearly = business.GetIncomeYearlyStore(year, year);

                    var revenue = incomeYearly.ElementAt(0).Revenue;
                    result.Value1 = revenue ?? 0;
                    result.Value2 = 0;
                    result.Value4 = 0;
                    result.Value5 = 0;
                    result.Value6 = 0;
                    result.Value7 = 0;
                    result.Value3 = result.Value4 + result.Value5 + result.Value6 + result.Value7;
                    result.Value8 = 0;

                    var materialExpense = incomeYearly.ElementAt(0).MaterialExpense;
                    result.Value10 = materialExpense ?? 0;

                    List<OtherExpense> value11List =
                        db.OtherExpenses.Where(m => m.Type == 11 && m.OtherExpenseYearTime == year).ToList();
                    result.Value11 = 0;
                    foreach (OtherExpense otherExpense in value11List)
                    {
                        result.Value11 += otherExpense.OtherExpenseAmount;
                    }

                    List<OtherExpense> value12List = db.OtherExpenses.Where(m => m.Type == 12 && m.OtherExpenseYearTime == year).ToList();
                    result.Value12 = 0;
                    foreach (OtherExpense otherExpense in value12List)
                    {
                        result.Value12 += otherExpense.OtherExpenseAmount;
                    }

                    result.Value9 = result.Value10 + result.Value11 + result.Value12;

                    result.Value13 = 0;
                    result.Value14 = 0;
                    result.Value15 = result.Value1 - result.Value3 + result.Value8 - result.Value9 - result.Value13;
                    result.Value16 = 0;
                    result.Value17 = 0;
                    result.Value18 = result.Value16 - result.Value17;
                    result.Value19 = result.Value15 + result.Value18;

                    result.ValueA1 = result.Value19;
                    result.ValueB1 = 0;
                    result.ValueB2 = 0;
                    result.ValueB3 = 0;
                    result.ValueB4 = 0;
                    result.ValueB5 = 0;
                    result.ValueB6 = 0;
                    result.ValueB7 = 0;
                    result.ValueB8 = 0;
                    result.ValueB9 = 0;
                    result.ValueB10 = 0;
                    result.ValueB11 = 0;
                    result.ValueB12 = result.ValueA1;
                    result.ValueB14 = 0;
                    result.ValueB13 = result.ValueB12 - result.ValueB14;

                    result.ValueC1 = result.ValueB13;
                    result.ValueC2 = 0;
                    result.ValueC3 = 0;
                    result.ValueC3a = 0;
                    result.ValueC3b = 0;
                    result.ValueC4 = result.ValueC1;
                    result.ValueC5 = 0;
                    result.ValueC6 = result.ValueC4 - result.ValueC5;

                    // Bug Hard code
                    int tndnTaxRate = 0;
                    TaxRate taxRate = db.TaxRates.FirstOrDefault(m => m.TaxRateId == 2);
                    if (taxRate != null)
                    {
                        tndnTaxRate = taxRate.TaxRateValue;
                    }

                    if (tndnTaxRate == 22)
                    {
                        result.ValueC7 = result.ValueC4;
                    }
                    else
                    {
                        result.ValueC7 = 0;
                    }

                    if (tndnTaxRate == 20)
                    {
                        result.ValueC8 = result.ValueC4;
                    }
                    else
                    {
                        result.ValueC8 = 0;
                    }

                    if (tndnTaxRate != 22 && tndnTaxRate != 20)
                    {
                        result.ValueC9 = result.ValueC4;
                        result.ValueC9a = tndnTaxRate;
                    }
                    else
                    {
                        result.ValueC9 = 0;
                        result.ValueC9a = 0;
                    }

                    result.ValueC10 = (int)(result.ValueC7 / 5 + result.ValueC8 * 0.22 + result.ValueC9 * result.ValueC9a / 100);
                    result.ValueC11 = 0;
                    result.ValueC12 = 0;
                    result.ValueC13 = 0;
                    result.ValueC14 = 0;
                    result.ValueC15 = 0;
                    result.ValueC16 = result.ValueC10 - result.ValueC11 - result.ValueC12 - result.ValueC15;

                    result.ValueD1 = result.ValueC16;
                    result.ValueD2 = 0;
                    result.ValueD3 = 0;
                    result.ValueD = result.ValueD1 + result.ValueD2 + result.ValueD3;

                    result.ValueE = 0;
                    result.ValueE2 = 0;
                    result.ValueE3 = 0;
                    result.ValueE1 = 0;

                    result.ValueG1 = result.ValueD1 - result.ValueE1;
                    result.ValueG2 = result.ValueD2 - result.ValueE2;
                    result.ValueG3 = result.ValueD3 - result.ValueE3;
                    result.ValueG = result.ValueG1 + result.ValueG2 + result.ValueG3;

                    result.ValueH = result.ValueD / 5;

                    result.ValueI = result.ValueG - result.ValueH;
                    result.ValueL1 = false;
                }
            }

            return result;
        }