Exemplo n.º 1
0
        private void ProcessHtmlAllJU(JournalUnitTypes juType)
        {
            double total;
            List <JournalUnitReportItem> allItems;

            var factory = GetReportFactory();

            switch (juType)
            {
            case JournalUnitTypes.A:
            case JournalUnitTypes.B:
            case JournalUnitTypes.C:
                RoomJU roomJU = factory.GetReportRoomJU(StartPeriod, EndPeriod, juType, GetClientID());
                ToolJU toolJU = factory.GetReportToolJU(StartPeriod, EndPeriod, juType, GetClientID());
                allItems = ReportFactory.GetAllJU(roomJU, toolJU, out total);
                break;

            case JournalUnitTypes.All:
                RoomJU roomJUA = factory.GetReportRoomJU(StartPeriod, EndPeriod, JournalUnitTypes.A, GetClientID());
                ToolJU toolJUA = factory.GetReportToolJU(StartPeriod, EndPeriod, JournalUnitTypes.A, GetClientID());
                RoomJU roomJUB = factory.GetReportRoomJU(StartPeriod, EndPeriod, JournalUnitTypes.B, GetClientID());
                ToolJU toolJUB = factory.GetReportToolJU(StartPeriod, EndPeriod, JournalUnitTypes.B, GetClientID());
                RoomJU roomJUC = factory.GetReportRoomJU(StartPeriod, EndPeriod, JournalUnitTypes.C, GetClientID());
                ToolJU toolJUC = factory.GetReportToolJU(StartPeriod, EndPeriod, JournalUnitTypes.C, GetClientID());

                double temp;
                total = 0;

                allItems = new List <JournalUnitReportItem>();

                allItems.AddRange(ReportFactory.GetAllJU(roomJUA, toolJUA, out temp));
                total += temp;

                allItems.AddRange(ReportFactory.GetAllJU(roomJUB, toolJUB, out temp));
                total += temp;

                allItems.AddRange(ReportFactory.GetAllJU(roomJUC, toolJUC, out temp));
                total += temp;
                break;

            default:
                throw new ArgumentException(string.Format("Invalid JournalUnitTypes value: {0}", juType));
            }

            gvJU.Columns[1].Visible = true;
            gvJU.Columns[2].Visible = juType == JournalUnitTypes.All;
            gvJU.Columns[3].Visible = EndPeriod != StartPeriod.AddMonths(1);
            gvJU.DataSource         = allItems;
            gvJU.DataBind();
            SetTotalText(total);

            SetLinkText("ju-" + Enum.GetName(typeof(JournalUnitTypes), juType).ToLower(), "all");
        }
Exemplo n.º 2
0
        protected void BtnToolJU_Command(object sender, CommandEventArgs e)
        {
            JournalUnitTypes juType = (JournalUnitTypes)Enum.Parse(typeof(JournalUnitTypes), e.CommandArgument.ToString());

            ToolJU report = GetReportFactory().GetReportToolJU(StartPeriod, EndPeriod, juType, GetClientID());

            if (chkHTML.Checked)
            {
                ProcessHtmlToolJU(report);
            }
            else
            {
                ProcessExcelToolJU(report);
            }
        }
Exemplo n.º 3
0
 public ToolJU GetReportToolJU(DateTime sd, DateTime ed, JournalUnitTypes type, int id)
 {
     return(ReportRepository.GetToolJU(sd, ed, type.ToString(), id));
 }
Exemplo n.º 4
0
        public static int GetJournalUnitNumber(DateTime period, BillingCategory billingCategory, JournalUnitTypes juType)
        {
            int yearOff  = period.Year - July2010.Year;
            int monthOff = period.Month - July2010.Month;

            int increment = (yearOff * 12 + monthOff) * 6;

            //263 is the starting number for room sub in July 2010
            if (billingCategory == BillingCategory.Room && juType == JournalUnitTypes.A)
            {
                return(100 + increment);
            }
            else if (billingCategory == BillingCategory.Room && juType == JournalUnitTypes.B)
            {
                return(100 + increment + 1);
            }
            else if (billingCategory == BillingCategory.Room && juType == JournalUnitTypes.C)
            {
                return(100 + increment + 2);
            }
            else if (billingCategory == BillingCategory.Tool && juType == JournalUnitTypes.A)
            {
                return(100 + increment + 3);
            }
            else if (billingCategory == BillingCategory.Tool && juType == JournalUnitTypes.B)
            {
                return(100 + increment + 4);
            }
            else if (billingCategory == BillingCategory.Tool && juType == JournalUnitTypes.C)
            {
                return(100 + increment + 5);
            }
            else
            {
                throw new ArgumentException("Invalid arguments passed to LNF.Billing.Reports.ServiceUnitBilling.ReportSettings.GetJournalUnitNumber");
            }
        }
Exemplo n.º 5
0
        private string GenerateExcelJU(JournalUnitReportItem[] items, CreditEntry creditEntry, BillingCategory billingCategory, JournalUnitTypes juType)
        {
            //Contruct the excel object
            string fileName     = Utility.GetRequiredAppSetting("JU_Template");
            string templatePath = ExcelUtility.GetTemplatePath(fileName);

            using (var mgr = ExcelUtility.NewExcelManager())
            {
                mgr.OpenWorkbook(templatePath);
                mgr.SetActiveWorksheet("Sheet1");

                DateTime period = EndPeriod.AddMonths(-1);
                string   billingCategoryName = Utility.EnumToString(billingCategory);

                //We start at first row, because for ExcelLite control, the header row is not included

                // [2021-09-27 jg]
                //      source was previoulsy JU, now it is ENG (set in web.config)
                //      journalDescription was previously "JU {0} {1:MM/yy} {2} {3}{4}" now set in web.config
                string source            = Utility.GetRequiredAppSetting("JournalSource"); //ENG
                int    journalUnitNumber = ReportSettings.GetJournalUnitNumber(period, billingCategory, juType);
                // JournalDescription example: [email protected]; JU {0} {1:MM/yy} {2} {3}{4}
                string journalDescription = string.Format(
                    Utility.GetRequiredAppSetting("JournalDescription"),
                    /*0*/ journalUnitNumber,
                    /*1*/ period,
                    /*2*/ ReportSettings.CompanyName,
                    /*3*/ billingCategoryName,
                    /*4*/ Utility.EnumToString(juType)
                    );

                //column A
                mgr.SetCellTextValue(2, 0, "H");
                //column B
                mgr.SetCellTextValue(2, 1, "NEXT");
                //column C
                mgr.SetCellTextValue(2, 2, DateTime.Now.ToString("MM/dd/yyyy"));
                //column D
                mgr.SetCellTextValue(2, 3, source);
                //column E
                mgr.SetCellTextValue(2, 4, period.ToString("yyyy/MM"));
                //column F
                mgr.SetCellTextValue(2, 5, journalDescription);
                //column G
                mgr.SetCellTextValue(2, 6, ReportSettings.FinancialManagerUserName);

                int iRow = 3;
                int iCol = 7;

                //DataView dv = dt.DefaultView;
                //dv.Sort = "ItemDescription ASC, ProjectGrant ASC";
                foreach (JournalUnitReportItem item in items.Where(i => i.ItemDescription != $"zz{ReportSettings.FinancialManagerUserName}"))
                {
                    //column A
                    mgr.SetCellTextValue(iRow, 0, "L");
                    //column H
                    mgr.SetCellTextValue(iRow, iCol, item.Account);
                    //column I
                    mgr.SetCellTextValue(iRow, iCol + 1, item.FundCode);
                    //column J
                    mgr.SetCellTextValue(iRow, iCol + 2, item.DeptID);
                    //column K
                    mgr.SetCellTextValue(iRow, iCol + 3, item.ProgramCode);
                    //column L
                    mgr.SetCellTextValue(iRow, iCol + 4, item.Class);
                    //column M
                    mgr.SetCellTextValue(iRow, iCol + 5, item.ProjectGrant);
                    //column N
                    mgr.SetCellNumberValue(iRow, iCol + 6, string.IsNullOrEmpty(item.MerchandiseAmount) ? 0 : Convert.ToDouble(item.MerchandiseAmount));
                    //column O
                    mgr.SetCellTextValue(iRow, iCol + 7, item.DepartmentalReferenceNumber);
                    //column P
                    mgr.SetCellTextValue(iRow, iCol + 8, item.ItemDescription);
                    iRow += 1;
                }

                //Add the last row - which is the summary unit
                mgr.SetCellTextValue(iRow, 0, "L");
                mgr.SetCellTextValue(iRow, iCol, creditEntry.Account);
                mgr.SetCellTextValue(iRow, iCol + 1, creditEntry.FundCode);
                mgr.SetCellTextValue(iRow, iCol + 2, creditEntry.DeptID);
                mgr.SetCellTextValue(iRow, iCol + 3, creditEntry.ProgramCode);
                mgr.SetCellTextValue(iRow, iCol + 4, creditEntry.ClassName);
                mgr.SetCellTextValue(iRow, iCol + 5, creditEntry.ProjectGrant);
                mgr.SetCellNumberValue(iRow, iCol + 6, creditEntry.MerchandiseAmount);
                mgr.SetCellTextValue(iRow, iCol + 7, creditEntry.DepartmentalReferenceNumber); //should be davejd
                mgr.SetCellTextValue(iRow, iCol + 8, creditEntry.ItemDescription);             // should be MM/YY LNF UsageCase Subsidy;SUB#

                string workPathDir = ExcelUtility.GetWorkPath(CurrentUser.ClientID);

                if (!Directory.Exists(workPathDir))
                {
                    Directory.CreateDirectory(workPathDir);
                }

                string workFilePath = Path.Combine(workPathDir, "JU" + Enum.GetName(typeof(JournalUnitTypes), juType) + "_" + billingCategoryName + "_" + period.ToString("yyyy-MM") + Path.GetExtension(fileName));
                mgr.SaveAs(workFilePath);

                return(workFilePath);
            }
        }
Exemplo n.º 6
0
        protected void BtnAllJU_Command(object sender, CommandEventArgs e)
        {
            JournalUnitTypes juType = (JournalUnitTypes)Enum.Parse(typeof(JournalUnitTypes), e.CommandArgument.ToString(), true);

            ProcessHtmlAllJU(juType);
        }
Exemplo n.º 7
0
        private XDocument GetJuReport(JournalUnitTypes juType, string charge, DateTime sd, DateTime ed, int clientId)
        {
            RoomJU roomJU;
            RoomJU roomJUA;
            RoomJU roomJUB;
            RoomJU roomJUC;
            ToolJU toolJU;
            ToolJU toolJUA;
            ToolJU toolJUB;
            ToolJU toolJUC;
            double temp, total;
            List <JournalUnitReportItem> allItems;
            //string itemDesciption;

            var factory = GetReportFactory();

            switch (charge)
            {
            case "all":
                switch (juType)
                {
                case JournalUnitTypes.A:
                case JournalUnitTypes.B:
                case JournalUnitTypes.C:
                    roomJU   = factory.GetReportRoomJU(sd, ed, juType, clientId);
                    toolJU   = factory.GetReportToolJU(sd, ed, juType, clientId);
                    allItems = ReportFactory.GetAllJU(roomJU, toolJU, out total);
                    break;

                case JournalUnitTypes.All:
                    roomJUA = factory.GetReportRoomJU(sd, ed, JournalUnitTypes.A, clientId);
                    toolJUA = factory.GetReportToolJU(sd, ed, JournalUnitTypes.A, clientId);
                    roomJUB = factory.GetReportRoomJU(sd, ed, JournalUnitTypes.B, clientId);
                    toolJUB = factory.GetReportToolJU(sd, ed, JournalUnitTypes.B, clientId);
                    roomJUC = factory.GetReportRoomJU(sd, ed, JournalUnitTypes.C, clientId);
                    toolJUC = factory.GetReportToolJU(sd, ed, JournalUnitTypes.C, clientId);
                    total   = 0;

                    allItems = new List <JournalUnitReportItem>();

                    allItems.AddRange(ReportFactory.GetAllJU(roomJUA, toolJUA, out temp));
                    total += temp;

                    allItems.AddRange(ReportFactory.GetAllJU(roomJUB, toolJUB, out temp));
                    total += temp;

                    allItems.AddRange(ReportFactory.GetAllJU(roomJUC, toolJUC, out temp));
                    total += temp;
                    break;

                default:
                    throw new ArgumentException(string.Format("Invalid JournalUnitTypes value: {0}", juType));
                }
                break;

            case "room":
                switch (juType)
                {
                case JournalUnitTypes.A:
                case JournalUnitTypes.B:
                case JournalUnitTypes.C:
                    roomJU   = factory.GetReportRoomJU(sd, ed, juType, clientId);
                    allItems = ReportFactory.GetAllJU(roomJU, null, out total);
                    break;

                case JournalUnitTypes.All:
                    roomJUA = factory.GetReportRoomJU(sd, ed, JournalUnitTypes.A, clientId);
                    roomJUB = factory.GetReportRoomJU(sd, ed, JournalUnitTypes.B, clientId);
                    roomJUC = factory.GetReportRoomJU(sd, ed, JournalUnitTypes.C, clientId);

                    total = 0;

                    allItems = new List <JournalUnitReportItem>();

                    allItems.AddRange(ReportFactory.GetAllJU(roomJUA, null, out temp));
                    total += temp;

                    allItems.AddRange(ReportFactory.GetAllJU(roomJUB, null, out temp));
                    total += temp;

                    allItems.AddRange(ReportFactory.GetAllJU(roomJUC, null, out temp));
                    total += temp;
                    break;

                default:
                    throw new ArgumentException(string.Format("Invalid JournalUnitTypes value: {0}", juType));
                }
                break;

            case "tool":
                switch (juType)
                {
                case JournalUnitTypes.A:
                case JournalUnitTypes.B:
                case JournalUnitTypes.C:
                    toolJU   = factory.GetReportToolJU(sd, ed, juType, clientId);
                    allItems = ReportFactory.GetAllJU(null, toolJU, out total);
                    break;

                case JournalUnitTypes.All:
                    toolJUA = factory.GetReportToolJU(sd, ed, JournalUnitTypes.A, clientId);
                    toolJUB = factory.GetReportToolJU(sd, ed, JournalUnitTypes.B, clientId);
                    toolJUC = factory.GetReportToolJU(sd, ed, JournalUnitTypes.C, clientId);

                    total = 0;

                    allItems = new List <JournalUnitReportItem>();

                    allItems.AddRange(ReportFactory.GetAllJU(null, toolJUA, out temp));
                    total += temp;

                    allItems.AddRange(ReportFactory.GetAllJU(null, toolJUB, out temp));
                    total += temp;

                    allItems.AddRange(ReportFactory.GetAllJU(null, toolJUC, out temp));
                    total += temp;
                    break;

                default:
                    throw new ArgumentException(string.Format("Invalid JournalUnitTypes value: {0}", juType));
                }
                break;

            default:
                throw new ArgumentException($"Invalid charge: {charge}", "charge");
            }

            var items = allItems
                        .Where(i => !i.ItemDescription.StartsWith("zz"))
                        .OrderBy(x => x.ReportType)
                        .ThenBy(x => x.ChargeType);

            var result = new XDocument(new XElement("table",
                                                    items.Select(x => new XElement("row",
                                                                                   new XElement("Period", x.Period),
                                                                                   new XElement("ReportType", x.ReportType),
                                                                                   new XElement("ChargeType", x.ChargeType),
                                                                                   new XElement("Account", x.Account),
                                                                                   new XElement("Fund", x.FundCode),
                                                                                   new XElement("Department", x.DeptID),
                                                                                   new XElement("Program", x.ProgramCode),
                                                                                   new XElement("Class", x.Class),
                                                                                   new XElement("PojectGrant", x.ProjectGrant),
                                                                                   new XElement("MonetaryAmount", GetMonetaryAmount(x)),
                                                                                   new XElement("JournalLineReference", x.DepartmentalReferenceNumber),
                                                                                   new XElement("LineDescription", x.ItemDescription),
                                                                                   new XElement("StatAmount", string.Empty)
                                                                                   ))
                                                    ));

            return(result);
        }