Posting 2 Document No Series in Sales Invoice

bangswitbangswit Member Posts: 265
hi all...
i have a scenario like this
i have 2 no series for posted invoices... S-INV and S-INV-C
in sales line , I add field named consignment (boolean type)
I made sales order there are several items with non consigment (without tickmark in consignment field) and consigment (with tickmark in consignment field)
so for the items that non consignment if i post, it should be goes to document with S-INV no series
and for the items that consignment if i post, it should be goes to document with S-INV-C no series

does anybody could help me?
thanks

Comments

  • vijay_gvijay_g Member Posts: 884
    Not a typical case,
    you can handal it first before invoice posting(like update posting no. series) and
    at the time of posting where you will check all items are consignment or not(in codeunit 90) based on you could be update Posting No. Series.
    i hope all items in a invoice must be same type either consignment or not.
  • BeliasBelias Member Posts: 2,998
    so, you basically have to create 2 invoices: one fore the ticked lines, and one for the not-ticked lines...
    You can:
    -before posting, check if there's a at least one sales line with consignement and one without consignment: if so, you have to create 2 posted invoices; if not, just set the posting no. series depending on the boolean value of the lines

    -if you have to create 2 invoices, create one with only consignment lines, and one with only non-consignment lines, then set the relative posting no. series and post the invoices. (be aware that because of the commits, if the second invoice fails, the first is already posted)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • vijay_gvijay_g Member Posts: 884
    bangswit wrote:
    so for the items that non consignment if i post, it should be goes to document with S-INV no series
    and for the items that consignment if i post, it should be goes to document with S-INV-C no series
    yes..i think so
    there must be two different invoice for consignment item or Non-consignment item
  • bangswitbangswit Member Posts: 265
    vijay_g wrote:
    Not a typical case,
    you can handal it first before invoice posting(like update posting no. series) and
    at the time of posting where you will check all items are consignment or not(in codeunit 90) based on you could be update Posting No. Series.
    i hope all items in a invoice must be same type either consignment or not.
    no... I mean for example,in 1 document there are 5 items
    item code consignment
    item 1 yes
    item 2 no
    item 3 no
    item 4 yes
    item 5 no
    it can be like this
  • BeliasBelias Member Posts: 2,998
    oh, yes, if you use the solution i posted before, you can (and should) change this
    IF ApprovalMgt.PrePostApprovalCheck(Rec,PurchaseHeader) THEN
      CODEUNIT.RUN(CODEUNIT::"Sales-Post (Yes/No)",Rec);
    
    to this
    IF ApprovalMgt.PrePostApprovalCheck(Rec,PurchaseHeader) THEN
      IF CODEUNIT.RUN(CODEUNIT::"Sales-Post (Yes/No)",Rec) THEN
        IF ApprovalMgt.PrePostApprovalCheck(Rec,PurchaseHeader) THEN
          CODEUNIT.RUN(CODEUNIT::"Sales-Post (Yes/No)",MyNewInvoiceDocument);
    

    Test it, you will probably get a runtime error...in that case, you can't use "IF codeunit.RUN then" construction, but you have to do a simple CODEUNIT.run without the IF clause
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bangswitbangswit Member Posts: 265
    IF ApprovalMgt.PrePostApprovalCheck(Rec,PurchaseHeader) THEN
    IF CODEUNIT.RUN(CODEUNIT::"Sales-Post (Yes/No)",Rec) THEN
    IF ApprovalMgt.PrePostApprovalCheck(Rec,PurchaseHeader) THEN
    CODEUNIT.RUN(CODEUNIT::"Sales-Post (Yes/No)",MyNewInvoiceDocument);

    PurchaseHeader?
    I Thought this is sales order ...
    so I should make new code unit?
  • BeliasBelias Member Posts: 2,998
    It's just the standard code...take a look at the posting action of the invoice page...
    that purchase header it's a dummy record in order to call the same function both for sales and purchases...it's an arguable design, but not so bad...at a first glance, i would have created 2 functions...anyway...just don't care about it :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bangswitbangswit Member Posts: 265
    I thought it should be in code unit 80 customized
    specifictly... after this code
    // Insert invoice header or credit memo header
    IF Invoice THEN
    IF "Document Type" IN ["Document Type"::Order,"Document Type"::Invoice] THEN BEGIN
    SalesInvHeader.INIT;
    SalesInvHeader.TRANSFERFIELDS(SalesHeader);

    SalesInvHeader."Date Sent" := 0D;
    SalesInvHeader."Time Sent" := 0T;

    am I right?
  • BeliasBelias Member Posts: 2,998
    I thought it should be in code unit 80 customized
    specifictly... after this code


    Quote:
    // Insert invoice header or credit memo header
    IF Invoice THEN
    IF "Document Type" IN ["Document Type"::Order,"Document Type"::Invoice] THEN BEGIN
    SalesInvHeader.INIT;
    SalesInvHeader.TRANSFERFIELDS(SalesHeader);

    SalesInvHeader."Date Sent" := 0D;
    SalesInvHeader."Time Sent" := 0T;


    am I right?
    No, don't do it...sorry but now i've not time to explain why, wait for someone else, sorry [-o<
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bangswitbangswit Member Posts: 265
    Belias wrote:
    I thought it should be in code unit 80 customized
    specifictly... after this code


    Quote:
    // Insert invoice header or credit memo header
    IF Invoice THEN
    IF "Document Type" IN ["Document Type"::Order,"Document Type"::Invoice] THEN BEGIN
    SalesInvHeader.INIT;
    SalesInvHeader.TRANSFERFIELDS(SalesHeader);

    SalesInvHeader."Date Sent" := 0D;
    SalesInvHeader."Time Sent" := 0T;


    am I right?
    No, don't do it...sorry but now i've not time to explain why, wait for someone else, sorry [-o<

    anybody can help me?
Sign In or Register to comment.