https://app.diagrams.net/#G1GuqjSLqoK1zjw2jr4DRt07uxWzGFZEK6#%7B%22pageId%22%3A%22tH9kuUiNKOi_-HY1bFgd%22%7D

TermDefinition 
CPC For NoveCare is the Combination of the ship to, material, and incoterm 
Latest closed monthThe latest month before the current month in the COPA03 query where there is volume for at least a sale order in that month  
\N8110 - Qty Sold External <> 0
Latest creation date of a line itemLatest creation date of a line item within the ''latest closed month''
Latest sales orderThe biggest sales order number with the same date as ''Latest creation date of a line item''
Latest line itemThe last line item created for the  ''latest sale order''
Last invoice priceThe unit price of the latest line item per CPC which is calculated by the total number of the sale divided by the total volume recorded for the latest line item
HL last invoice priceThe ''last invoice price'' calculated for a CPC without considering incoterm 


With the example below:

Latest closed month:  Current month being July. the latest closed month is May. The month before the current month being June is not considered because the QTY is zeroMay

Latest creation date of a line itemMay 30, 2023

Latest sales order:→  SO4

Latest line itemSO4/1

Last invoice price (See the records in yellow below)→ Last invoice price= (500+300)/(20+0)=40 euro/kg


Month 

Material 

Ship to

Incoterm 

Sales order/Line item 

Line item creation date

Amount

QTY

Apr

M1

ST 1

INC 2

SO5

Apr 1, 2023

1000

50

May

M2

ST 2

INC 2

SO2

May 20, 2023

3000

50

May

M2

ST 2

INC 2

SO3

May 21, 2023

6000

0

May

M2

ST 2

INC 2

SO3/1

May 30, 2023

4000

20

May

M2

ST 2

INC 2

SO4

May 30, 2023

300

10

May 

M2

ST 2

INC 2

SO4/1

May 30, 2023

500

20

Jun

M2

ST 2

INC 2

SO3/1

Jun 14, 2023

2000

0

Jul 

M2

ST 2

INC 2

SO3/3

15 July, 2023

100

10

Jul 

M2

ST 2

INC 2

SO4/1

15 July, 2023

300

0

Jul

M2

ST 2

INC 2

SO2/1

15 July, 2023

1500

300