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...
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.
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...
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 )
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?
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...
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...
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;
Comments
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: 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...
Arhontis
https://forum.mibuso.com/search
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
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...
Arhontis
https://forum.mibuso.com/search
Arhontis
https://forum.mibuso.com/search
with a Posting Date newer the one you want to post?
Arhontis
https://forum.mibuso.com/search
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
Right after the Code; in the OnRun of those two codeunits...
The cu80 is called within the "Code" function...
Arhontis
https://forum.mibuso.com/search
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...
And I thought that Greece had crazy laws...
Good luck!!!!
Arhontis
https://forum.mibuso.com/search
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;