web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Split invoice based on quantity in packing Slip

(1) ShareShare
ReportReport
Posted on by 9
Hello,
 
I want to split an invoice based on qty in packing Slip using x++.
For Example if I have Qty= 2 in packing slip I should obtain 2 invoices instead of 1.
How to develop this fonctionality .
thanks in advance.
 
ps: the quantity of packing slip is the deliverNow qty in salesParmLine 
I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    306,873 Super User 2026 Season 2 on at
    Hi,
     
    Can you tell us more about this requirement? What is the exact business process behind this? Were the goods also delivered on by one? In case you will have a quantity of 10, do you then need 10 invoices as well? 
  • YB-04071507-0 Profile Picture
    9 on at
    Yes, I need to create separate invoice for each unit.

     
    While posting Invoice with quantity equal to packing Slip with update = 10 (for exemple)
    I should create 10 invoices.
     
  • André Arnaud de Calavon Profile Picture
    306,873 Super User 2026 Season 2 on at
    I wonder about the business reason for the split. It feels too cumbersome to send an invoice per unit. As a customer receiving these invoices, I would not be happy.
    Anyway, if you follow the logic to have tables SalesParmTable, SalesParmUpdate, and SalesParmLine filled like the user will create these invoices via the user experience, you can set the update quantity to one. You can create a loop based on the line quantity of the packing slip details. 
  • YB-04071507-0 Profile Picture
    9 on at
    Hello,
    I try to create records in salesParmTable and SalesParLine with deliverNow=1 . 
    invoices are created but cant't be posted, only the first invoice is posted .
    this is my code:
     
     
     
     protected void createAndPostJournal()
     {
            FormletterJournalPost     formletterJournalPost1;
            SalesParmLine                  salesParmLine,salesParmLine1;
            SalesQty                           salesQty ;
            SalesParmTable                salesParmTable =                         SalesParmTable::find(formletterParmTable.parmId,formletterParmTable.tableRefId);
            salesParmUpdate              salesParmUpdate;
            salesParmTable                  salesParmTable1;
            salesFormletterParmData   salesFormLetterParmData;
            TransDate                           PackingSlipDate ;
      
            
            
            ttsbegin;
            select  firstOnly Forupdate salesParmLine where salesParmLine.parmId == salesParmTable.ParmId;
       
            salesQty = salesParmLine.DeliverNow ;
            salesParmLine.deliverNow=UnitOfMeasureConverter::convert(1,
                                      UnitOfMeasure::unitOfMeasureIdBySymbol(salesParmLine.inventTable().inventUnitId()),
                                      UnitOfMeasure::unitOfMeasureIdBySymbol(salesParmLine.salesUnit()),
                                      NoYes::Yes,
                                      InventTable::itemProduct(salesParmLine.ItemId));
            salesParmLine.setInventDeliverNow();
            salesParmLine.setLineAmount();
            salesParmLine.update();
            ttscommit;
         
            next createAndPostJournal();
     
            if (salesParmTable.documentId(salesParmTable))
            {
                salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice,             VersioningUpdateType::Initial);
                salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
                salesFormLetterParmData.createData(false);
                salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
                salesParmTable1.clear();
                salesParmTable1.TransDate                = salesParmTable.transdate;
                salesParmTable1.Ordering                 = DocumentStatus::Invoice;
                salesParmTable1.ParmJobStatus        = ParmJobStatus::Waiting;
                salesParmTable1.salesId                      = salesParmTable.salesId;
                salesParmTable1.salesName                = salesParmTable.salesName;
                salesParmTable1.DeliveryName             = salesParmTable.DeliveryName;
                salesParmTable1.DeliveryPostalAddress    = salesParmTable.DeliveryPostalAddress;
                salesParmTable1.CustAccount              = salesParmTable.CustAccount;
                salesParmTable1.CurrencyCode             = salesParmTable.CurrencyCode;
                salesParmTable1.InvoiceAccount           = salesParmTable.InvoiceAccount;
                salesParmTable1.ParmId                   = SalesParmTable.ParmId;
                salesParmTable1.insert();

                salesParmLine1.DeliverNow    = salesParmLINE.delivernow;
                salesParmLine1.setInventDeliverNow();
                salesParmLine1.setLineAmount();
                salesParmLine1.ParmId        = salesParmTable1.ParmId;
                salesParmLine1.TableRefId    = salesParmTable1.TableRefId;
                salesParmLine1.setQty(DocumentStatus::INVOICE, TRUE, true);
                //salesParmLine1.setLineAmount(salesParmLine.salesLine());
                salesParmLine1.InventDimId   = salesParmLine.InventDIMID;
                salesParmLine1.ItemId        = salesParmLine.ItemId;
                salesParmLine1.initFromSalesLine(salesParmLine.salesLine());
                salesParmLine1.calcPackingUnitQty();
                salesParmLine1.InventNow = salesParmLine.salesLine().ExpectedRetQty;
                salesParmLine1.insert();
     

                salesParmSubLine salesParmSubLine;
                salesParmSubLine.clear();
                salesParmSubLine.initValue();
                salesParmSubLine.initFromSalesParmLine(salesParmLine1);
                salesParmSubLine.InventNow              = salesParmLine.salesLine().SalesQty;
                salesParmSubLine.DeliverNow             = salesParmLine.salesLine().SalesQty;
                salesParmSubLine.insert();
                SalesLine salesline1 = salesParmLine.salesLine();
           
                this.createJournal(salesParmTable1); // CREATE Invoice
                if (journal.RecId)
                {
                    formletterJournalPost1 = this.postJournal(salesParmTable1); //Post Invoice : where the system throws multiple errors
                    this.addJournalToLists();
                }
                this.updateParmTableJobStatusExecuted(salesParmTable1);
                if ( journal.RecId && formletterJournalPost1)
                {
                    formletterJournalPost1.postJournalPost();
                    this.prepareProforma(formletterJournalPost1);
                }
              
            }
     
  • André Arnaud de Calavon Profile Picture
    306,873 Super User 2026 Season 2 on at
    Hi,
     
    What is the exact behavior for the invoices after invoice number 1? Do you get an error message or are they just not posted?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 341 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 312

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 262 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans