Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
b98bf37c
Commit
b98bf37c
authored
Mar 08, 2019
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core: add MovingAverageSetToZeroWhenNegatif valuation method
parent
72528d3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
product/ERP5/Tool/SimulationTool.py
product/ERP5/Tool/SimulationTool.py
+2
-1
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetAssetPrice.sql
...teItem/portal_skins/erp5_core/Resource_zGetAssetPrice.sql
+20
-0
No files found.
product/ERP5/Tool/SimulationTool.py
View file @
b98bf37c
...
...
@@ -1847,6 +1847,7 @@ class SimulationTool(BaseTool):
WeightedAverage
MonthlyWeightedAverage
MovingAverage
MovingAverageSetToZeroWhenNegatif
When using a specific valuation method, a resource_uid is expected
as well as one of (section_uid or node_uid).
"""
...
...
@@ -1868,7 +1869,7 @@ class SimulationTool(BaseTool):
return
total_result
if
valuation_method
not
in
(
'Fifo'
,
'Filo'
,
'WeightedAverage'
,
'MonthlyWeightedAverage'
,
'MovingAverage'
):
'MonthlyWeightedAverage'
,
'MovingAverage'
,
'MovingAverageSetToZeroWhenNegatif'
):
raise
ValueError
(
"Invalid valuation method: %s"
%
valuation_method
)
if
unit_price
and
valuation_method
in
(
'Fifo'
,
'Filo'
):
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetAssetPrice.sql
View file @
b98bf37c
...
...
@@ -64,6 +64,26 @@ where
<
dtml
-
var
where_expression
>
order
by
date
<
dtml
-
elif
"'MovingAverageSetToZeroWhenNegatif'==valuation_method"
>
/*
Very similar to WeightedAverage except it set total_asset_price to zero
when total_quantity is negatif
*/
set
@
total_asset_price
=
0
,
@
total_quantity
=
0
<
dtml
-
var
sql_delimiter
>
select
(
@
incoming_total_price
:
=
IF
(
quantity
>
0
,
total_price
,
0
))
as
incoming_total_price
,
(
@
base_total_quantity
:
=
@
total_quantity
+
GREATEST
(
0
,
quantity
))
as
dummy
,
(
@
unit_price
:
=
IF
(
@
base_total_quantity
=
0
,
0
,
(
@
total_asset_price
+@
incoming_total_price
)
/@
base_total_quantity
))
as
unit_price
,
(
@
total_asset_price
:
=
GREATEST
(
@
total_asset_price
+
@
incoming_total_price
+
LEAST
(
0
,
quantity
)
*
@
unit_price
,
0
))
as
total_asset_price
,
(
@
total_quantity
:
=
GREATEST
(
@
total_quantity
+
quantity
,
0
))
as
dummy2
from
stock
,
catalog
where
<
dtml
-
var
where_expression
>
order
by
date
<
dtml
-
elif
"valuation_method=='Fifo'"
>
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment