[solved] Clear Posting Date in Sales Header after Posting

geri79geri79 Member Posts: 105
Hello,

I d like to clear the field posting date in Order documents after posting partial invoices of this order.

Maybe s.th. like Validate("Posting Date",0D) in CU80?
But where?

Thx

geri79
geri

Comments

  • ArhontisArhontis Member Posts: 667
    Hmmm... :-k

    I guess your users forget to change the date before re-posting remaining quantity, right? :)
    Only when posting partial invoices? Or always?
    In case you want to do it always, you could add some code (like that you mention) in the OnRun code of the codeunits 81 and 82:
    SalesHeader.COPY(Rec);
    Code;
    //new code start
    IF  SalesHeader."Document Type" = SalesHeader."Document Type"::Order THEN BEGIN
      SalesHeader.Validate("Posting Date",0D);
      SalesHeader.MODIFY(TRUE);
    END;
    //new code end
    Rec := SalesHeader;
    
    If you want to do it when you have remaining quantity to invoice then you should find and search all the "sales line" of that document to see if there are any remaining items to invoice... and then modify the posting date...

    Haven't tested it but I think it will work...
  • geri79geri79 Member Posts: 105
    Thx. Are you shure, that I can clear the posting date in CU81 and CU82?
    I don't think so. Without testing, I am quite sure that the original date is still needed for CU80 to write the date in diverse posted or archived dales headers. What do you think?

    Background:
    My Problem is, that in Italy you cannot post any Invoice, Order, if there is another one with a Posting Date older the one you want to post.

    geri
    geri
  • ArhontisArhontis Member Posts: 667
    The whole sales posting procedure ends up to the cu80 (does the whole work). But to post a sales order you try Post (which calls the Codeunit 81 Sales-Post (Yes/No)) or the Post and Print (which calls the Codeunit 82 Sales-Post + Print).

    Both those codeunits call afterwards the codeunit 80 Sales Post... :)

    You can see it for your self by designing the form 42 sales order and see the menu item Posting... And also by designing the cus 81 and 82 to see that they both call the SalesPost.RUN(SalesHeader) after some checks...

    That way you will not have to touch such a critical codeunit as the cu80 but the very small and trivial cu81 and 82...

    Hey, it is only a suggestion... you could always do it in the cu80 or on the form by modifying the buttons... But I think it is a simple and safe method...
  • ArhontisArhontis Member Posts: 667
    In addition, you could skip the Posting Date reseting thing and make some code to see if a sales order has been posted before and compare the posting dates to raise an error before posting... (maybe at the start of cu81 and 82 too :P )
  • ArhontisArhontis Member Posts: 667
    geri79 wrote:
    Background:
    My Problem is, that in Italy you cannot post any Invoice, Order, if there is another one with a Posting Date older the one you want to post.
    Maybe you mean:
    with a Posting Date newer the one you want to post?
  • geri79geri79 Member Posts: 105
    Thanks again.

    But if CU81 and CU82 both call CU80 (as they do) and in CU80 "Sales Header"."´Posting Date" is used (and needed), I don't think that it is a good solution to clear the "Posting Date" before CU80 is run.

    Sorry... by typing this, I got it...
    If CU80 is run by CU81 or 82, the end of the procedure must then be 81 or 82, so I clear the field after running CU80...

    ty
    geri
  • ArhontisArhontis Member Posts: 667
    Yep...

    Right after the Code; in the OnRun of those two codeunits... :D
    The cu80 is called within the "Code" function...
  • geri79geri79 Member Posts: 105
    Thx a lot.
    Older or Newer might be a language problem:

    If I want to post a Order with Posting Date 24th May but there exsist a Order or Invoice (not invoiced) with a posting date 23rd May, it want let you post it in Italy...
    geri
  • ArhontisArhontis Member Posts: 667
    :shock: lol... I think that's a bit crazy...
    And I thought that Greece had crazy laws...

    Good luck!!!!
  • geri79geri79 Member Posts: 105
    It's not too bad to check if the Salesheader still exsists after the posting...

    IF SalesHeader.GET(SalesHeader."Document Type",SalesHeader."No.") THEN BEGIN
    IF (SalesHeader."Document Type" = SalesHeader."Document Type"::Order) THEN BEGIN
    SalesHeader.VALIDATE("Posting Date",0D);
    SalesHeader.MODIFY(TRUE);
    END;
    END;
    geri
Sign In or Register to comment.