transports
Margin documentation
BILLED MARGIN
Basic version of algorithm is
billed margin = sum(all incomes) - sum(all expenses)
Example:
- transport document from client (1000EUR) and income invoice (1000EUR)
- transport document to contractor (800EUR) and expense invoice (800EUR)
- billed margin = income invoice 1000EUR - expense invoice 800EUR = 200EUR margin
Full version of algorithm is (when it is needed to split costs)
billed margin = sum(all assigned amount from incomes) - sum(all assigned amount from expenses)
Example:
- transport document from client (1000EUR) and income invoice (1000EUR): assigned net 800EUR
- transport document to contractor (800EUR) and expense invoice (800EUR): assigned net 400EUR
- billed margin = assigned net of income invoice 800EUR - assigned net of expense income 400EUR = 400EUR margin
Details
Definitions
- TD_I - transport document from client (income)
- TD_E - transport document to contractor (expense)
- BD - billing document (with status other than draft)
- BD_I - income BD (billing document where our company is seller)
- BD_E - expense BD (billing document where our company is buyer)
- BD_E_S - expense BD in settlement currency
- BM - billed margin of transport document
- settlement currency - defined for whole system using exchange rate as min(execution date, issue date) - 1 day
- AN_S - assigned net in settlement currency (if no assigned net in document then we use total net in settlement currency of TD_I, TD_E, BD_I, BD_E)
- BD_I_AN_S - assigned net in settlement currency of income BD
- BD_E_AN_S - assigned net in settlement currency of expense BD
- sum([item1, item2]) - sum of elements example sum([2, 4]) equals 6
Algorithm of billed margin
BM = sum([BD_I_AN_S, ...]) - sum([BD_E_AN_S, ...])
Examples
Example no.1 (minimal version)
1 client (order + income), 1 subcontractor(expense)
One transport document from client, one invoice to client and one invoice from subcontractor.
- TD_I{1} net:900 EUR (transport document from client)
- BD_I{1.1} net:900 EUR (billing document to client)
- BD_E{2} net:800 EUR (billings document from subcontractor)
BM = 100 EUR (billed margin)
BM = sum([BD_I{1.1}]) - sum([BD_E{2}]) = 900 EUR - 800 EUR = 100 EUR
Example no.2 (order 1:1)
1 client (order + income), 1 subcontractor(order + expense)
One transport document from client, one invoice to client and one transport document to subcontractor, one invoice from subcontractor.
- TD_I{1} net:900 EUR (transport document from client)
- BD_I{1.1} net:900 EUR (billing document to client{1})
- TD_E{2} net:800 EUR (transport document from subcontractor)
- BD_E{2.1} net:800 EUR (billings document from subcontractor{2})
BM = 100 EUR (billed margin)
BM = sum([BD_I{1.1}]) - sum([BD_E{2.1}]) = 900 EUR - 800 EUR = 100 EUR
Example no.3 (order 1:1 with additional fee to client)
1 client (order + income with additional fee), 1 subcontractor(order + expense)
One transport document from client, one invoice to client and one transport document to subcontractor, one invoice from subcontractor.
To billing document to client we add additional 50 EUR (example delay in loading).
- TD_I{1} net:900 EUR (transport document from client)
- BD_I{1.1} net:950 EUR (billing document to client{1})
- TD_E{2} net:800 EUR (transport document from subcontractor)
- BD_E{2.1} net:800 EUR (billings document from subcontractor{2})
BM = 150 EUR
BM = sum([BD_I{1.1}]) - sum([BD_E{2.1}]) = 950 EUR - 800 EUR = 150 EUR
Example no.4 (one client but two subcontractors)
1 client (order + income), 2 subcontractors(2 orders + 2 expenses)
One transport document from client, one invoice to client and two transport documents to subcontractor, two invoices from subcontractor.
- TD_I{1} net:1450 EUR (transport document from client)
- BD_I{1.1} net:1450 EUR (billing document to client{1})
- TD_E{2} net:800 EUR (transport document from subcontractor)
- BD_E{2.1} net:800 EUR (billings document from subcontractor{2})
- TD_E{3} net:500 EUR (transport document from subcontractor)
- BD_E{3.1} net:500 EUR (billings document from subcontractor{3})
BM = 150 EUR
BM = sum([BD_I{1.1}]) - sum([BD_E{2.1}, BD_E{3.1}]) = 1450 EUR - (800 EUR + 500 EUR) = 150 EUR
Example no.5 (order 1:1 with different currencies)
1 client (order + income), 1 subcontractor(order + expense in USD)
One transport document from client, one invoice to client and one transport document to subcontractor, one invoice from subcontractor.
- TD_I{1} net:900 EUR (transport document from client)
- BD_I{1.1} net:900 EUR (billing document to client)
- TD_E{2} net:700 USD (transport document to subcontractor)
- BD_E{2.1} net:700 USD (billings document from subcontractor)
- BD_E_S{2.1.1} net:620.68 EUR (billings document from subcontractor in settlement currency)
RATE {2.1.1} 1 USD = 0.886682 EUR (European Central Bank 2021-11-22)
- BD_E_S{2.1.1} net:620.68 EUR (billings document from subcontractor in settlement currency)
- BD_E{2.1} net:700 USD (billings document from subcontractor)
BM = 279.32 EUR
BM = sum([BD_I{1.1}]) - sum([BD_E_S{2.1.1}]) = 900 EUR - 620.68 EUR = 279.32 EUR