Posted Sales Invoice->Print all with specific Resource li

emulsifiedemulsified Member Posts: 139
What is the easiest way to print all Posted Sales Invoices that contain type RESOURCE with certain conditions?

For example, in our system we have:

Resource DISC1
Resource DISC2

On any given Posted Sales Invoice there will be a sales line that looks like this:

Resource DISC1 -1 5.00 -5.00

I know I can run the Posted Sales Invoice report without giving it a RecordNo and it will give me the dialog to Print, Preview, and all the other criteria where I can also add a filter for Type ->Resource, Salesperson, etc...

My goal is to print all Posted Sales Invoices within a date range that contains specific resource discounts, not just all of them.

Here is some code that I used in another report section Sales Invoice Line, Body - OnPreSection() that modified the OUTPUT that was shown to show only Resources I was interested in seeing and gathering the totals as you can see from the code below:

IF "Sales Invoice Line".Type = 3 THEN
  IF "Sales Invoice Line"."No." = '' THEN BEGIN
    CurrReport.SHOWOUTPUT(FALSE);
  END ELSE
    IF "Sales Invoice Line"."No." = 'TRACKINGNUMBER' THEN BEGIN
      CurrReport.SHOWOUTPUT(FALSE);
    END ELSE
      IF "Sales Invoice Line"."No." = 'CODISC' THEN BEGIN
        TotalCODISC := TotalCODISC + "Sales Invoice Line".Amount;
      END ELSE
        IF "Sales Invoice Line"."No." = 'DSC' THEN BEGIN
          TotalDSC := TotalDSC + "Sales Invoice Line".Amount;
        END ELSE
          IF "Sales Invoice Line"."No." = 'FDISC' THEN BEGIN
            TotalFDISC := TotalFDISC + "Sales Invoice Line".Amount;
          END ELSE
            IF "Sales Invoice Line"."No." = 'FREIGHT CHARGE' THEN BEGIN
              TotalFREIGHTCHARGE := TotalFREIGHTCHARGE + "Sales Invoice Line".Amount;
            END ELSE
              IF "Sales Invoice Line"."No." = 'LIDISC' THEN BEGIN
                TotalLIDISC := TotalLIDISC + "Sales Invoice Line".Amount;
              END ELSE
                IF "Sales Invoice Line"."No." = 'LTDISC' THEN BEGIN
                  TotalLTDISC := TotalLTDISC + "Sales Invoice Line".Amount;
                END ELSE
                  IF "Sales Invoice Line"."No." = 'NDISC' THEN BEGIN
                    TotalNDISC := TotalNDISC + "Sales Invoice Line".Amount;
                  END ELSE
                    IF "Sales Invoice Line"."No." = 'PKDISC' THEN BEGIN
                      TotalPKDISC := TotalPKDISC + "Sales Invoice Line".Amount;
                    END ELSE
                      IF "Sales Invoice Line"."No." = 'WIRE TRANSFER' THEN BEGIN
                        TotalWIRETRANSFER := TotalWIRETRANSFER + "Sales Invoice Line".Amount;
                      END ELSE
  CurrReport.SHOWOUTPUT(TRUE)
ELSE
  CurrReport.SHOWOUTPUT(FALSE);

Should I just use the above with modification? I know that there is probably a shorter method using CASE or something else.

Any suggestions would be greatly appreciated. Thanks.
Half-empy or half-full how do you view your database?

Thanks.

Comments

  • diptish.naskardiptish.naskar Member Posts: 360
    I think, you can modify this same type of code but ofcoursely with a sitch case will make this code look better.
    Diptish Naskar
    For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
  • SavatageSavatage Member Posts: 7,142
    emulsified wrote:
    My goal is to print all Posted Sales Invoices within a date range that contains specific resource discounts, not just all of them.

    do you just really need to list them in a report or do you really need the invoice?
  • emulsifiedemulsified Member Posts: 139
    All I really need is to be able to PRINT or PREVIEW any Posted Sales Invoices that contain those RESOURCE codes.

    Here is the logic I am going for:

    :arrow: Use the Sales Invoice form.

    :arrow: Only show for PREVIEW or PRINT those Posted Sales Invoices that contain those RESOURCE codes in the Sales Lines.

    That's it.
    Half-empy or half-full how do you view your database?

    Thanks.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    emulsified wrote:
    All I really need is to be able to PRINT or PREVIEW any Posted Sales Invoices that contain those RESOURCE codes.

    Here is the logic I am going for:

    :arrow: Use the Sales Invoice form.

    :arrow: Only show for PREVIEW or PRINT those Posted Sales Invoices that contain those RESOURCE codes in the Sales Lines.

    That's it.

    OK, the simple way....

    Create a Batch (non printing report) based on Sales Line.
    You will run this filters by Doc Typ Order, Typ Res, No. (your resources).
    Create a Temp record of Sales Header.
    In the onaftergetrec section in the report add code like:
    TempSalesHeader."Document Type := "document type";
    TempSalesHeader."no." := "Document no.";
    If tempsalesheader.insert then
      ;
    


    Teh in the onpostrecord section, run through the temp records, and send them as paramaters to your report to print.

    It probably took me longer to write this post that it will to write the code.
    :mrgreen:
    David Singleton
  • emulsifiedemulsified Member Posts: 139
    I am relatively new to Navision (C/AL) and that looks like the best solution to me, but I am a bit confused.

    :DI know the following:
    *Create a report using TABLE 'Sales Line'.
    *The DataItem should be 'Sales Line'.
    *I should set ProcessingOnly to 'Yes'.
    *The user should see a Request Form where they can choose a
    Date Filter and Salesperson Code.
    *I should somehow write code to loop through the filtered Sales Lines
    (the code I already wrote for a previous report) and if I get a TRUE I
    should then call the REPORT.RUNMODAL function for each instance of
    TRUE using the SalesInvoiceHeader."No."

    :? What I am not sure of:
    *How I get there? ](*,)
    *Will the user have a Request Form to input a Salesperson Code and
    Date Filter?
    *If I use REPORT.RUNMODAL function will the user get to select a
    printer?

    :-k Can't I use or modify, create a copy of the Navision report 'Sales Invoice' to do the same thing that the ProcessingOnly report does? I feel this is the best option (users like to preview and print) because my understanding is that I can run this report using the Request Form and just hard code in one of the sections (OnPre?) to do a CurrReport.SHOWOUTPUT(TRUE) when I get a Sales Line that is one of the RESOURCES I am looking for?

    Thanks.
    Half-empy or half-full how do you view your database?

    Thanks.
Sign In or Register to comment.