Example #1
0
        public PickingSlipReportContext GetPickingSlipReportContext(List <CustomerProductDataVO> productObjects, List <string> customerNames, bool bGetProKnowDetails)
        {
            var context = new PickingSlipReportContext();

            context.RunDate = ShopDateTime.Instance.FullShopDateTime;

            if (bGetProKnowDetails)
            {
                // Have extra enumeration to go ProKnow with only ONE call
                var lstGroupOfInputValues = new List <groupOfValuesInputType>();
                _ResponseValues = new List <groupOfValuesOutputType>();
                foreach (var productObject in productObjects)
                {
                    // Last step is to thread out individual Picking Slips
                    foreach (var pawnItem in productObject.Items)
                    {
                        if (pawnItem.CategoryCode > 0 &&
                            !string.IsNullOrEmpty(pawnItem.QuickInformation.Manufacturer) &&
                            !string.IsNullOrEmpty(pawnItem.QuickInformation.Model) &&
                            !string.IsNullOrEmpty(pawnItem.Icn))
                        {
                            var valueInputType = new groupOfValuesInputType()
                            {
                                categoryCode = pawnItem.CategoryCode,
                                Manufacturer = pawnItem.QuickInformation.Manufacturer,
                                Model        = pawnItem.QuickInformation.Model,
                                responseKey  = pawnItem.Icn
                            };
                            lstGroupOfInputValues.Add(valueInputType);
                        }
                    }
                }
                // Make call to ProKnow Service with batch of input values
                if (lstGroupOfInputValues.Count > 0)
                {
                    var proKnowService        = new WebServiceProKnow(GlobalDataAccessor.Instance.DesktopSession);
                    var groupOfValuesResponse = proKnowService.GetGroupOfValues(lstGroupOfInputValues);
                    if (groupOfValuesResponse.serviceData != null)
                    {
                        if (groupOfValuesResponse.serviceData.Items[0].GetType() == typeof(groupOfValuesOutputType))
                        {
                            foreach (var o in groupOfValuesResponse.serviceData.Items)
                            {
                                _ResponseValues.Add((groupOfValuesOutputType)o);
                            }
                        }
                    }
                }
            }
            //foreach (CustomerProductDataVO productObject in productObjects)
            for (int i = 0; i < productObjects.Count; i++)
            {
                PickingSlipReportService service = null;

                var productObject = productObjects[i];
                var sCustomerName = customerNames[i];

                if (productObject.GetType() == typeof(PawnLoan))
                {
                    var pLoan = (PawnLoan)productObject;
                    service = new PickingSlipReportService()
                    {
                        OrgNumber          = pLoan.OrigTicketNumber,
                        Customer           = sCustomerName,
                        DateDue            = pLoan.DueDate,
                        PreviousLoanNumber = Utilities.GetIntegerValue(pLoan.PrevTicketNumber, 0),
                        PfiEligible        = Utilities.GetDateTimeValue(pLoan.PfiEligible, DateTime.MinValue),
                        PartialPayments    = new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).IsPartialPaymentAllowed(GlobalDataAccessor.Instance.CurrentSiteId),
                        CurrentLoanNumber  = Utilities.GetIntegerValue(pLoan.TicketNumber, 0),
                        CurrentLoanAmount  = pLoan.PartialPaymentPaid ? pLoan.CurrentPrincipalAmount : Utilities.GetDecimalValue(pLoan.Amount, 0M),
                        LoanAmount         = Utilities.GetDecimalValue(pLoan.Amount, 0M),
                        Finance            = pLoan.InterestAmount,
                        Service            = pLoan.ServiceCharge,
                        IsPurchase         = false
                    };
                }
                else if (productObject.GetType() == typeof(PurchaseVO))
                {
                    var purchaseObj = (PurchaseVO)productObject;

                    service = new PickingSlipReportService()
                    {
                        OrgNumber          = purchaseObj.RefNumber,
                        Customer           = sCustomerName,
                        DateDue            = purchaseObj.DateMade,
                        PreviousLoanNumber = 0,
                        PfiEligible        = Utilities.GetDateTimeValue(purchaseObj.PfiEligible, DateTime.MinValue),
                        PartialPayments    = false,
                        CurrentLoanNumber  = Utilities.GetIntegerValue(purchaseObj.TicketNumber, 0),
                        CurrentLoanAmount  = 0,
                        LoanAmount         = Utilities.GetDecimalValue(purchaseObj.Amount, 0M),
                        Finance            = 0,
                        Service            = 0,
                        IsPurchase         = true
                    };
                }
                // Last step is to thread out individual Picking Slips
                int pawnItemNumber = 1;
                foreach (var pawnItem in productObject.Items)
                {
                    var sAnswerIdx = string.Empty;
                    foreach (var ia in pawnItem.Attributes)
                    {
                        var a           = ia.Answer;
                        var sAnswerText = a.AnswerText.ToLower();

                        if (sAnswerText.IndexOf("cond ", System.StringComparison.Ordinal) >= 0 && a.AnswerCode != 999)
                        {
                            sAnswerIdx = a.AnswerText.Substring(5, 1);
                            break;
                        }
                    }

                    if (service != null)
                    {
                        PickingSlipReportItem item = new PickingSlipReportItem()
                        {
                            ItemLocation      = pawnItem.Location,
                            ItemLocationAisle = pawnItem.Location_Aisle,
                            ItemLocationShelf = pawnItem.Location_Shelf,
                            Amount            = pawnItem.ItemAmount,
                            ItemDescription   = pawnItem.TicketDescription,
                            ItemNumber        = pawnItemNumber
                        };

                        service.Items.Add(item);
                    }
                    pawnItemNumber++;
                }

                context.Service.Add(service);
            }

            return(context);
        }
        private void PrintPickingSlip(PickingSlipReportService service, Document document, PdfWriter writer)
        {
            PdfPTable table = new PdfPTable(COLUMNS);

            table.HeaderRows = 7;

            PdfPCell cell;

            string reportTitle = "** LOAN PFI PICKING SLIP **";

            if (service.IsPurchase)
            {
                reportTitle = "** PURCHASE PFI PICKING SLIP **";
            }
            cell        = new PdfPCell(new Phrase(reportTitle, ReportFontBold));
            cell.Border = Rectangle.NO_BORDER;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = COLUMNS;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase(ReportContext.RunDate.ToString("d"), ReportFont));
            cell.Border              = Rectangle.BOTTOM_BORDER;
            cell.BorderWidth         = 2f;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = 4;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("Org. #:", ReportFont));
            cell.Border              = Rectangle.BOTTOM_BORDER;
            cell.BorderWidth         = 2f;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = 1;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase(service.OrgNumber.ToString(), ReportFont));
            cell.Border              = Rectangle.BOTTOM_BORDER;
            cell.BorderWidth         = 2f;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = 1;
            table.AddCell(cell);

            if (service.IsPurchase)
            {
                PrintSummaryRow("Customer:", service.Customer, string.Empty, string.Empty, "Purchase Amt:", service.LoanAmount.ToString("c"), table);
                PrintSummaryRow(string.Empty, string.Empty, "PFI Elig:", service.PfiEligible.ToShortDateString(), string.Empty, string.Empty, table);
                PrintSummaryRow(string.Empty, string.Empty, "Purchase #:", service.CurrentLoanNumber.ToString(), string.Empty, string.Empty, table);
            }
            else
            {
                if (service.PartialPayments)
                {
                    PrintSummaryRow("Customer:", service.Customer, "Loan Amt:", service.LoanAmount.ToString("c"), "Current Principal:", service.CurrentLoanAmount.ToString("c"), table);
                }
                else
                {
                    PrintSummaryRow("Customer:", service.Customer, string.Empty, string.Empty, "Loan Amt:", service.LoanAmount.ToString("c"), table);
                }

                PrintSummaryRow("Date Due:", service.DateDue.ToShortDateString(), "PFI Elig:", service.PfiEligible.ToShortDateString(), "Finance:", service.Finance.ToString("c"), table);
                PrintSummaryRow("Previous Loan #:", service.PreviousLoanNumber.ToString(), "Current Loan #:", service.CurrentLoanNumber.ToString(), "Service:", service.Service.ToString("c"), table);
            }
            PrintSummaryRow(string.Empty, string.Empty, string.Empty, string.Empty, "Total:", service.Total.ToString("c"), table);

            cell                     = new PdfPCell(new Phrase("Description", ReportFontBold));
            cell.Border              = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER;
            cell.BorderWidth         = 2f;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = 4;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("Location", ReportFontBold));
            cell.Border              = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER;
            cell.BorderWidth         = 2f;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = 1;
            table.AddCell(cell);

            cell                     = new PdfPCell(new Phrase("Item Amount", ReportFontBold));
            cell.Border              = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER;
            cell.BorderWidth         = 2f;
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            cell.PaddingTop          = 10f;
            cell.PaddingBottom       = 10f;
            cell.Colspan             = 1;
            table.AddCell(cell);

            foreach (PickingSlipReportItem item in service.Items)
            {
                cell        = new PdfPCell(new Phrase(item.GetItemDescription(), ReportFont));
                cell.Border = Rectangle.NO_BORDER;
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                cell.Colspan             = 4;
                table.AddCell(cell);

                cell        = new PdfPCell(new Phrase(item.GetLocation(), ReportFont));
                cell.Border = Rectangle.NO_BORDER;
                cell.HorizontalAlignment = Element.ALIGN_LEFT;
                cell.Colspan             = 1;
                table.AddCell(cell);

                cell        = new PdfPCell(new Phrase(item.Amount.ToString("c"), ReportFont));
                cell.Border = Rectangle.NO_BORDER;
                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                cell.Colspan             = 1;
                table.AddCell(cell);
            }

            document.Add(table);

            string text = "EMP#: ___________________      Date#:___________________";

            float len = footerBaseFont.GetWidthPoint(text, 8);

            Rectangle pageSize = document.PageSize;

            contentByte = writer.DirectContent;
            template    = contentByte.CreateTemplate(50, 50);

            contentByte.BeginText();
            contentByte.SetFontAndSize(footerBaseFont, 8);
            contentByte.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetBottom(30));
            contentByte.ShowText(text);
            contentByte.EndText();

            contentByte.AddTemplate(template, pageSize.GetLeft(40) + len, pageSize.GetBottom(30));
            document.NewPage();
        }