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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How can I split purchase order quantity and Unit cost into multiple assets in D365FO?

(2) ShareShare
ReportReport
Posted on by 18
I have a requirement in Dynamics 365 Finance and Operations where I need to split a single purchase order line into multiple fixed assets based on quantity & Unit Cost.

Scenario:

  • Purchase Order Quantity = 2
  • Total Amount             = 2000

Expected:

  • System should create 2  fixed asset Id's
  • Each asset value  (Unit cost) = 1000
In the purchase order, multiple fixed assets are created only when ‘New Fixed Asset’ is set to Yes and the ‘Split Quantity (custom button )’ is enabled

 
Once the product receipt is posted, the system creates the fixed asset in the Fixed Assets module.

After invoice posting, the created asset IDs do not have correctly distributed quantities and unit costs.
 
Current Output:
Qty   AssetId          Unit Cost
2     COMP-000051  1000
1     COMP-000052   0
 
 
 

     
I have created a Chain of Command (CoC) extension on the PurchPackingSlipJournalPost class and customized the createFixedAsset() method
 
Running Code:
 
[ExtensionOf(classStr(PurchPackingSlipJournalPost))]
final class ROJ_PurchPackingSlipJournalCreate_Extension
{
    protected AssetId createFixedAsset(
        PurchParmLine _purchParmLine,
        PurchParmLine_Asset _purchParmLine_Asset)
    {
        AssetId assetId = next createFixedAsset(_purchParmLine, _purchParmLine_Asset);
        PurchLine purchLine = _purchParmLine.purchLine();
        if (!purchLine)
        {
            return assetId;
        }
        if (!(purchLine.CreateFixedAsset == NoYes::Yes &&
              purchLine.ROJ_SplitQuantity == NoYes::Yes))
        {
            return assetId;
        }
        Qty qty = purchLine.PurchQty;
        AmountCur totalAmount = purchLine.LineAmount;
        if (qty <= 1 || totalAmount <= 0)
        {
            return assetId;
        }
        AssetTable existingAsset;
        select firstOnly forUpdate existingAsset
            where existingAsset.AssetId == assetId;
        if (existingAsset)
        {
            ttsBegin;
            existingAsset.delete();
            ttsCommit;
        }
        AmountCur perAssetAmount = totalAmount / qty;
        AmountCur runningTotal = 0;
        AmountCur assetValue;
        AssetBookId bookId = AssetParameters::find().BookIdDefault;
        for (int i = 1; i <= qty; i++)
        {
            ttsBegin;
            AssetTable newAsset;
            NumberSeq numberSeq;
            newAsset.clear();
            newAsset.initValue();
            newAsset.AssetGroup = purchLine.AssetGroup;
            newAsset.Name = purchLine.itemName()
            newAsset.PurchLineRecId = purchLine.RecId;
            newAsset.Quantity = 1;
            newAsset.UnitCost = assetValue;
            newAsset.initFromAssetGroupId(newAsset.AssetGroup);
            numberSeq = newAsset.initAssetNumberSeq();
            if (numberSeq)
            {
                newAsset.AssetId = numberSeq.num();
                numberSeq.used();
            }
            newAsset.insert();
            if (i == qty)
            {
                assetValue = totalAmount - runningTotal;
            }
            else
            {
                assetValue = perAssetAmount;
                runningTotal += perAssetAmount;
            }
            AssetBook assetBook;
            select forUpdate assetBook
                where assetBook.AssetId == newAsset.AssetId
                   && assetBook.BookId == bookId;
            if (assetBook)
            {
                assetBook.AcquisitionPrice = assetValue;
                assetBook.update();
            }
            AssetTrans assetTrans;
            assetTrans.clear();
            assetTrans.AssetId     = newAsset.AssetId;
            assetTrans.BookId      = bookId;
            assetTrans.TransType   = AssetTransType::Acquisition;
            assetTrans.AmountMST   = assetValue;
            assetTrans.TransDate   = systemDateGet();
            assetTrans.insert();
            ttsCommit;
        }
        return assetId;
    }
 
Expected OutPut:
The system should create multiple asset records with equal quantity distribution (1 per asset) and evenly distributed unit cost.
 
Qty   AssetId             Unit Cost
1     COMP-000051    1000
1     COMP-000052    1000
 
Additionally, each asset should have quantity = 1, and the corresponding unit cost should be correctly updated in the Asset Book.
 
 
Categories:
I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 531

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 257 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans