import AEP_INVOICE_PDF:*; rem Formatting constants; Constant &PrintAtr_Bold20 = "FontName=Helvetica,FontSize=20,Bold"; Constant &PrintAtr_Bold16_Blue = "FontName=Helvetica,FontSize=16,Bold,color=blue"; Constant &PrintAtr_16 = "FontName=Helvetica,FontSize=16"; rem column position constants; Constant &UnitPos = 55; Constant &QtyPos = 65; Constant &AmtPos = 88; Function rpt_begin(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record); End-Function; Function rpt_page_header(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record); End-Function; Function rpt_page_footer(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record); End-Function; Function rpt_detail_section(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record); Local number &xPoint, &yPoint, &xPoint2, &yPoint2, &TotalAmt_save_X, &TotalAmt_save_Y; Local number &i, &UnitPrice, &Units, &Amt, &TotalAmt, &TotalBeginLine, &tax, &other, &lines, &invnum;; Local string &InvoiceNumber; &InvoiceNumber = &Rec.GetField(Field.AEP_KEY_DETAIL).Value; &invnum = Value(Right(&InvoiceNumber, 4)); rem force new page with new file; &AEP_RPT.NewPage(&Rec, "newfile=;"); rem override default filename; &AEP_RPT.SetPdfFileName(&InvoiceNumber); rem draw rectangle around the page; &AEP_RPT.DrawBox(&AEP_RPT.get_PageTopLeft_x(), &AEP_RPT.get_PageTopLeft_y(), &AEP_RPT.get_PageBottomRight_x(), &AEP_RPT.get_PageBottomRight_y(), "lineThickness=1,color=red"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(60, "INVOICE", "FontName=Helvetica,FontSize=40,Bold,Color=blue"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(1, "ABC Comporation - " | &InvoiceNumber, &PrintAtr_Bold20 | ",Color=magenta"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(1, "12 John Place - " | &InvoiceNumber, &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(45, "Date:", &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(&AmtPos, "12-Mar-2015", &PrintAtr_16 | ",right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(1, "Sydney", &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(45, "Invoice#:", &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(&AmtPos, &InvoiceNumber, &PrintAtr_16 | ",right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(1, "Australia", &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(45, "Customer ID:", &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(&AmtPos, "CUST" | &InvoiceNumber, &PrintAtr_16 | ",right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.NewLine(1, &Rec); &xPoint = &AEP_RPT.get_CurrLeftMargin() + 10; &yPoint = &AEP_RPT.get_CurrPointY(); &xPoint2 = &xPoint + 350; &yPoint2 = &yPoint - 30; &AEP_RPT.DrawBox(&xPoint, &yPoint, &xPoint2, &yPoint2, "lineThickness=0,fillcolor=lightGray"); &AEP_RPT.AdjustCurrPointY((&AEP_RPT.get_CharHeight() * 2.5)); &AEP_RPT.PrintStr(2, "BILL TO", &PrintAtr_Bold20); &AEP_RPT.AdjustCurrPointY((&AEP_RPT.get_CharHeight() * 2.0)); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(2, "Contact: John Smith - " | &InvoiceNumber, &PrintAtr_Bold20); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(2, "XYZ Corporation - " | &InvoiceNumber, &PrintAtr_16); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(2, "23 New Building - " | &InvoiceNumber, &PrintAtr_16); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(2, "City Circle", &PrintAtr_16); &AEP_RPT.PrintStr(45, "Due Date:", &PrintAtr_Bold16_Blue); &AEP_RPT.PrintStr(&AmtPos, "12-Apr-2015", &PrintAtr_16 | ",Color=red,bold,right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(2, "Canberra - Australia", &PrintAtr_16); &AEP_RPT.PrintStr(45, "Net Amount:", &PrintAtr_16 | ",Bold,Color=blue"); rem save current x,y to print the total later; &TotalAmt_save_X = &AEP_RPT.ColPositionToPoint_X(&AmtPos); &TotalAmt_save_Y = &AEP_RPT.get_CurrPointY(); rem print header line surrounded in the box; &AEP_RPT.NewLine(1, &Rec); &xPoint = &AEP_RPT.get_CurrLeftMargin() + 10; &yPoint = &AEP_RPT.get_CurrPointY(); &xPoint2 = &AEP_RPT.get_PageBottomRight_x() - 10; &yPoint2 = &yPoint - 30; &AEP_RPT.DrawBox(&xPoint, &yPoint, &xPoint2, &yPoint2, "lineThickness=0,fillcolor=lightGray"); &AEP_RPT.AdjustCurrPointY((&AEP_RPT.get_CharHeight() * 2.5)); &AEP_RPT.PrintStr(2, "Description", &PrintAtr_Bold20); &AEP_RPT.PrintStr(39, "Unit Price", &PrintAtr_Bold20); &AEP_RPT.PrintStr(60, "Qty", &PrintAtr_Bold20); &AEP_RPT.PrintStr(75, "Amount", &PrintAtr_Bold20); rem print items; &AEP_RPT.AdjustCurrPointY((&AEP_RPT.get_CharHeight() * 1.0)); &TotalAmt = 0; For &i = 1 To &invnum + 5 &AEP_RPT.NewLine(1, &Rec); &UnitPrice = &UnitPrice * &i + 100; &Units = &Units + 2 + &i; &Amt = &UnitPrice * &Units; &TotalAmt = &TotalAmt + &Amt; &AEP_RPT.PrintStr(2, "Item " | &InvoiceNumber | ":" | &i, &PrintAtr_16); &AEP_RPT.PrintStr(&UnitPos, NumberToString("%6.2", &UnitPrice), &PrintAtr_16 | ",right"); &AEP_RPT.PrintStr(&QtyPos, NumberToString("%6.2", &Units), &PrintAtr_16 | ",right"); &AEP_RPT.PrintStr(&AmtPos, NumberToString("%6.2", &Amt), &PrintAtr_16 | ",right"); End-For; rem position to print invoice totals; &TotalBeginLine = 37; &AEP_RPT.SetCurrPointY_AtLine(&TotalBeginLine); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(&UnitPos, "Sub Total: ", &PrintAtr_16 | ",Bold,Color=blue"); &AEP_RPT.PrintStr(&AmtPos, NumberToString("%6.2", &TotalAmt), &PrintAtr_16 | ",right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(&UnitPos, "Tax: ", &PrintAtr_16 | ",Bold,Color=blue"); &tax = &TotalAmt * 0.1; &AEP_RPT.PrintStr(&AmtPos, NumberToString("%6.2", &tax), &PrintAtr_16 | ",right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(&UnitPos, "Other: ", &PrintAtr_16 | ",Bold,Color=blue"); &other = 100; &AEP_RPT.PrintStr(&AmtPos, NumberToString("%6.2", &other), &PrintAtr_16 | ",right"); &AEP_RPT.NewLine(1, &Rec); &AEP_RPT.PrintStr(&UnitPos, "Total: ", &PrintAtr_16 | ",Bold,Color=blue"); &TotalAmt = &TotalAmt + &tax + &other; &AEP_RPT.PrintStr(&AmtPos, NumberToString("%6.2", &TotalAmt), &PrintAtr_16 | ",right,color=red,bold"); &AEP_RPT.PrintStrAbs(&TotalAmt_save_X, &TotalAmt_save_Y, NumberToString("%6.2", &TotalAmt), &PrintAtr_16 | ",Color=red,right,bold"); rem print comments; &AEP_RPT.SetCurrPointY_AtLine(&TotalBeginLine); &xPoint = &AEP_RPT.get_CurrLeftMargin() + 10; &yPoint = &AEP_RPT.get_CurrPointY(); &xPoint2 = &xPoint + 255; &yPoint2 = &yPoint - 30; &AEP_RPT.DrawBox(&xPoint, &yPoint, &xPoint2, &yPoint2, "lineThickness=0,fillcolor=lightGray"); &AEP_RPT.AdjustCurrPointY((&AEP_RPT.get_CharHeight() * 2.5)); &AEP_RPT.PrintStr(2, "Other Comments", &PrintAtr_Bold20); &AEP_RPT.NewLine(1, &Rec); &lines = &AEP_RPT.PrintStrWrap( False, &Rec, 2, 33, &InvoiceNumber | ": We have not received any purchase order and items have been delivered.", &PrintAtr_16, "-"); End-Function; Function rpt_init_variables(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record); rem init variables; End-Function; Function rpt_skip(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record) Returns boolean; rem function called before releasing input row to appear as detail line in the report; rem if row needs to be skiped based on certain conditions, true should be returned; Local boolean &RtnSts = False; Return &RtnSts; End-Function; Function rpt_end(&AEP_RPT As AEP_INVOICE_PDF:AEP_INVOICE_PDF, &Rec As Record); End-Function;