just print DO in Sales Post Print

julkifli33julkifli33 Member Posts: 1,087
i have several customer that i dont want to print the invoice
i want my system to just print out D/O if I had a tick on the customer to tell the system not to print the invoices, instead of printing an invoice that has no value.

so if i Customer."Do Not Print Amount" = false
it only print do
is that something wrong with my code ?
code unit sales post print
GetReport(VAR SalesHeader : Record "Sales Header")
WITH SalesHeader DO BEGIN
  CASE "Document Type" OF
    "Document Type"::Order:
      BEGIN
       IF Ship THEN BEGIN
          SalesShptHeader."No." := "Last Shipping No.";
          SalesShptHeader.SETRECFILTER;
          PrintReport(ReportSelection.Usage::"S.Shipment");
       END;
       IF Invoice THEN BEGIN
          SalesInvHeader."No." := "Last Posting No.";
          SalesInvHeader.SETRECFILTER;
        //  PrintReport(ReportSelection.Usage::"S.Invoice");
       END;

        Customer.RESET;
        Customer.SETRANGE(Customer."No.","Sell-to Customer No.");
        Customer.SETRANGE(Customer."Do Not Print Amount",FALSE);
        IF Customer.FIND('-') THEN
          BEGIN
               PrintReport(ReportSelection.Usage::"S.Invoice");
          END;
      END;

Comments

  • AndwianAndwian Member Posts: 627
    Nothing wrong. :)

    I love the Smilies! Merry Christmas to all of you!
    Regards,
    Andwian
  • kinekine Member Posts: 12,562
    I did some small changes to your code:
    GetReport(VAR SalesHeader : Record "Sales Header")
    WITH SalesHeader DO BEGIN
      CASE "Document Type" OF
        "Document Type"::Order:
          BEGIN
           IF Ship THEN BEGIN
              SalesShptHeader."No." := "Last Shipping No.";
              SalesShptHeader.SETRECFILTER;
              PrintReport(ReportSelection.Usage::"S.Shipment");
           END;
           IF Invoice THEN BEGIN
              SalesInvHeader."No." := "Last Posting No.";
              SalesInvHeader.SETRECFILTER;
            //  PrintReport(ReportSelection.Usage::"S.Invoice");
              Customer.GET("Sell-to Customer No.");
              IF not Customer."Do Not Print Amount" THEN
                     PrintReport(ReportSelection.Usage::"S.Invoice");
           END;
    
          END;
    

    Your code is in wrong block. It will be called regardless you are trying to print shipment or invoice...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • AndwianAndwian Member Posts: 627
    kine wrote:
    Your code is in wrong block. It will be called regardless you are trying to print shipment or invoice...
    Careless me :oops:
    Regards,
    Andwian
Sign In or Register to comment.