Cost Engine/Case II

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
Note.gif Note:

This Landed Cost Use Case is based on Libero's Cost Engine/Testing User Guide (sold by e-Evolution), maintained by Redhuan D. Oon.

Testing Goals

  1. Test Purchase Order added with Landed Cost of Freight distributed according to Quantity.
  2. Test adding to the Purchase Order with Landed Cost from Invoice of Custom Taxes distributed by Quantity.
  3. Test earlier Forgotten Transaction by entering new PO, Receipt and Invoice documents.
  4. Test generated Inventory Valuation and Transaction Valuation reports to be exact.

User Setup Data

  • Client:GardenWorld
  • Calendar:Default
  • Currency:USD
  • Product: New (created manually)
  • Vendor: Standard
  • CostType: Average Costing
  • Starting Date: Jan 1, 2010

Transaction Input

  • Days from Today: Added to Starting Date
  • Qty: Quantity in transaction
  • Price: Purchase or Sales Price
  • Transaction Type: (Under Costing Transaction For table unless specified)
    • Purchase/Receipt - Purchase Order and Material Receipt of the same order
    • Credit Sales - Sales Order which results in immediate Shipment
    • Invoice Receipt - Invoice Vendor of a previous Material Receipt
    • Charge - Landed Cost element i.e. Freight, Custom Tax (Under Landed Cost table)
    • Dist Type - Landed Cost distribution type, i.e. Quantity (Under Landed Cost table)
    • Movement - creation of an Inventory Movement
    • Physical Inventory - creation of a Physical Inventory with Book Qty (using Price column)
    • Internal Use - taking from inventory for internal use, minus qty is the qty taken
  • Ref: Reference count of previous transactions passed to present transaction
  • Initiate Transaction - Assert of Transaction success.

Fitnesse Story Test

Fitnesse Story Test text specifies the output columns that interacts with the testing code. They also include the above Transaction Input.

From MCost table

The result by accessing the MCost table after the transaction. Exact detail is filtered by transactional properties i.e. ProductID, InOutLine_ID.

  • Current Cost Price
  • Cumulative Qty
  • Cumulative Amt

From CostDetail table

The result by accessing the MCostDetail table after the transaction.

  • Cost Detail Amt
  • CD Adjust
  • CD Qty
  • CD Current Cost
  • CD Cumulative Qty
  • CD Cumulative Amt

From Landed Cost Table

The coded steps to handle the table are as follows:

  • Days From Today - To set the Document Date during processing
  • Ref - To refer to the sequence of Purchase Order for processing
  • Charge - Type of Charge i.e. Freight, Customs Tax.
  • Dist Type - i.e. by Quantity, Amt.
  • Charge Amt - Cost amount of the Charge item.
  • Invoice From Receipt? - Create a new Invoice (draft status) from the Receipt referred.
  • Create Charge? - Create InvoiceLine that is set to the defined Charge.
  • Create Landed Cost? - Create Landed Cost record from the InvoiceLine.
  • Distribute Costs? - Process the Landed Cost to distribute to the assigned ReceiptLine.
  • Is It Allocated? - Check if LandedCostAllocation is created correctly.
  • Complete Invoice? - Process the Invoice and post the accounts.
  • Get Account? - Store the accounting facts to stack for later output.

Testing Steps

  1. Start with a new Product in GardenWorld.
  2. Buy 15 units for $23.50 on 01/01/2010 at Store Central Organization.
  3. Internal Use Inventory by 2 units. For a new Offce at West Zone on 20/01/2010.
  4. Buy another 50 units for $20.20 on 22/1/2010.
  5. On Previous Purchase We have to pay $ 50 by Freight Concept on 23/01/2010, distribute by Quantity.
  6. Sell 32 units for $30 each one, on 30/01/2010.
  7. On 15/02/2010 we received an Invoice for $25 of Custom Taxes whose correspond to Purchase from 22/01/2010, prorated by Quantity. This Invoice is dated 28/02/2010
  8. At this juncture a Transaction Generation of CostDetail of Freight base is done. This populate the Landed Cost Elements to reflect in COGS accounts.
  9. On 01/03/2010, Physical Inventory counted 30 units.
  10. On 15/03/2010, sold 10 units for $30 each.
  11. Forgot to record a Purchase Order, Material Receipt and Invoice (Vendor) of 15 units at $22 on 05/03/2010.

Expected Results

  • 35 Units of New Product at Current Cost of $22.84.
  • Accounting Facts balance of $799.4448:
    • Product Asset-14120 with Product CoGs-51100 adjustments.


  • Invoice completion of Landed Cost charge item hangs. SF tracker. SOLVED there.
  • Questions as to Test output. Resolved.
  • As seen in Output below, Landed Cost is not resolved during transaction as Adjust CoGS activity which Material element does. A history cost update is often necessary after each Landed Cost creation.

Reported Test Cases

The following are test cases submitted in SourceForge forums as referenced in Cost Engine/Testing. If you have more test cases you think are significant and needed please post in SourceForge and add to the wiki reference. - Redhuan D. Oon

Azzam Ahmad's First Case

  • This refers to Azzam Ahmad's example here.
  • Part 1: I created a new item. (Will reuse the same new item 'Apple' as above.)
  • I purchased the item Quantity 10 & Cost 100
  • I paid freight charge (price ) 10 and I distributed the landed cost.
  • Now, the total cost is 1010 and the average cost is 101.
  • I shipped to the customer 2 items @ cost 101 (Here Adempiere is getting the average cost correctly)
Dr Product CoGs 202 & Cr Product asset 202 
  • Let's see in next text what happened with average cost
  • Part 2: At this moment I have the Item's Quantity on hand - 8.
  • I purchased the item Quantity 10 & Cost 120
  • I paid freight charge (price ) 20 and I distributed the landed cost.
  • Total Cost paid is 1220.
  • What will be the average cost ?
Average Cost = ( 8 * 101 + 1220 ) / ( 8 + 10 ) = 112.67
  • I shipped to the customer 10 pcs form the same item
  • I posted the shipment . I found the posted amount is 1,116.67
  • Adempiere is considering the average cost 111.67 My question is : How the average cost became 111.67 while it should be 112.67 ?



From the above-defined Case II from e-Evolution Costing Engine Guide, the following output took 20 seconds to produce on a single web page:

Test Result of first 6 steps
Test Result of remaining 4 steps
  • Accounting consequence of the above is corelated here according to the number of days of document date from Jan 1 2010. The high number of days here signify present day ie, Feb 13, 2011.
Full Accounting Consequence of Landed Cost exercise
  • Transaction Valuation Report was also produced:
Transaction Value Report for both Material and Freight(Landed Cost) elements saved in PDF format
  • Inventory Valuation Effective Date for Material and Landed Cost (Freight) are also produced:
For Material Cost Element of the Apple product format
For Freight Cost Element which is the base for both landed cost charges - Freight and Customs Tax
  • This Freight report only indicated cost amount when a Cost Detail Generation of Freight Cost Element is done.
  • Expected result of $22.84 is not met by this test final score of about $22.20.

Azzam's Case

  • From Azzam Ahmad's query above, below are the output.
Costing Transaction Steps with Landed Cost activity and its history update
The rest of the exercise
  • Accounts Postings from the transactions and landed cost valuation
Accounting Consequence
Transaction Valuation Report for both Material and Freight(Landed Cost) elements
Inventory Valuation Report for Material and Freight(Landed Cost) elements
  • It seems the above case is according to what is expected - $112.667. So this test result is correct, and the output will be permanently stored as asserts.

Azzam Ahmad's Second Case

I have one more testing case here . It is called : Total Cost of Goods Sold = Total Purchased .

I will limit the test for one item : Purchase many times and sold completely. For this item I assume that Total Cost will be equal to total purchase amount. Here are the details :

Costing Method : Average PO.

To have a clean test result we need to create new item and open new period in GardenAdmin.This is a sample scenario from real live data environment of life cycle of this item :

  1. First Purchase : we purchase qty = 100 , price = 10 ( First Purchase = 1,000 )
  2. Second Purchase : we purchase qty = 200 , price = 15 , Landed Cost = 300 ( distributed by costs ) . Second Purchase = 200 * 15 + 300 = 3,300.
  3. First Shipment to Customer is : qty = 50
  4. Third Purchase : we purchase qty = 100 , price = 20 ( Third Purchase = 2,000 )
  5. Second Shipment to Customer : Qty = 50.
  6. Third Shipment to Customer  : Qty = 300.

Total Purchase = 1,000 + 3,300 + 2,000 = 6,300

We shipped full qty for this item. Total Purchase amount = 6,300. We need to check if total Cost of Goods for this item is 6,300 ?

Azzam, Shouldn't line 2 about Total Purchase = 100*10 + 200*15 + 300 = 4,300? Please check again. - Redhuan D. Oon 01:46, 17 February 2011 (UTC)

SF Tracker Link