Example #1
0
        public InvoiceInfotViewModel GetLimitStartAndEndInvoiceDSelf(int invoiceMonth, int invoiceYear)
        {
            DateTime?startDate = null;
            DateTime?endDate   = null;
            var      result    = new InvoiceInfotViewModel();

            var basic = _basicRepository.GetAllQueryable().FirstOrDefault();

            if (basic != null)
            {
                // set startDate
                if (basic.SettlementDay == 31)
                {
                    startDate = new DateTime(invoiceYear, invoiceMonth, 1);
                }
                else
                {
                    startDate = new DateTime(invoiceYear, invoiceMonth, basic.SettlementDay + 1);
                }

                // set end date
                if (basic.SettlementDay == 31)
                {
                    endDate = new DateTime(invoiceYear, invoiceMonth, DateTime.DaysInMonth(invoiceYear, invoiceMonth));
                }
                else
                {
                    if (invoiceMonth == 12)
                    {
                        endDate = new DateTime(invoiceYear + 1, 1, basic.SettlementDay);
                    }
                    else
                    {
                        endDate = new DateTime(invoiceYear, invoiceMonth + 1, basic.SettlementDay);
                    }
                }
            }

            if (startDate == null)
            {
                startDate = new DateTime(invoiceYear, invoiceMonth, 1);
                endDate   = new DateTime(invoiceYear, invoiceMonth, DateTime.DaysInMonth(invoiceYear, invoiceMonth));
            }

            result.StartDate        = (DateTime)startDate;
            result.EndDate          = (DateTime)endDate;
            result.SettlementD      = 31;
            result.TaxMethodI       = "0";
            result.TaxRate          = 0;
            result.TaxRoundingI     = "0";
            result.RevenueRoundingI = "0";
            if (basic != null)
            {
                result.SettlementD  = basic.SettlementDay;
                result.TaxMethodI   = basic.TaxMethodI;
                result.TaxRate      = (decimal)basic.TaxRate;
                result.TaxRoundingI = basic.TaxRoundingI;
            }

            return(result);
        }