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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
f7c814f1
Commit
f7c814f1
authored
Jun 09, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more and more interpolation API
parent
89c5db3e
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
306 additions
and
90 deletions
+306
-90
bt5/tmp_work/TestTemplateItem/portal_components/test.erp5.testInventoryAPI.py
...plateItem/portal_components/test.erp5.testInventoryAPI.py
+207
-68
product/ERP5/Tool/SimulationTool.py
product/ERP5/Tool/SimulationTool.py
+2
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
...tem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
+17
-22
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SimulationTool_zGetInterpolationMethod.sql
...kins/erp5_core/SimulationTool_zGetInterpolationMethod.sql
+48
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SimulationTool_zGetInterpolationMethod.xml
...kins/erp5_core/SimulationTool_zGetInterpolationMethod.xml
+32
-0
No files found.
bt5/tmp_work/TestTemplateItem/portal_components/test.erp5.testInventoryAPI.py
View file @
f7c814f1
This diff is collapsed.
Click to expand it.
product/ERP5/Tool/SimulationTool.py
View file @
f7c814f1
...
...
@@ -652,6 +652,8 @@ class SimulationTool(BaseTool):
# if we consider flow, we also select movement whose mirror date is
# in the from_date/to_date range and movement whose
# start_date/stop_date contains the report range.
# The selected range is wider, but the selected movements will have an
# "interpolation_ratio" applied to their quantity and prices.
if
to_date
:
column_value_dict
[
'date'
]
=
ComplexQuery
(
Query
(
date
=
(
from_date
,
to_date
),
range
=
'minmax'
),
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Resource_zGetInventoryList.sql
View file @
f7c814f1
SELECT
<
dtml
-
if
expr
=
"interpolation_method == 'linear'"
>
@
interpolation_ratio
:
=
CASE
WHEN
<
dtml
-
var
stock_table_id
>
.
mirror_date
=
<
dtml
-
var
stock_table_id
>
.
date
THEN
1
ELSE
(
UNIX_TIMESTAMP
(
LEAST
(
<
dtml
-
sqlvar
flow_valuation_method_to_date
type
=
"datetime"
>
,
GREATEST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
)
))
-
UNIX_TIMESTAMP
(
GREATEST
(
<
dtml
-
sqlvar
flow_valuation_method_from_date
type
=
"datetime"
>
,
LEAST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
))))
/
(
UNIX_TIMESTAMP
(
GREATEST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
))
-
UNIX_TIMESTAMP
(
LEAST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
))
)
END
<
dtml
-
else
>
@
interpolation_ratio
:
=
1
</
dtml
-
if
>
flow_ratio
,
<
dtml
-
let
interpolation_ratio
=
"SimulationTool_zGetInterpolationMethod(
stock_table_id=stock_table_id,
interpolation_method=interpolation_method,
interpolation_method_from_date=interpolation_method_from_date,
interpolation_method_to_date=interpolation_method_to_date,
interpolation_method_at_date=interpolation_method_at_date,
src__=1)"
>
SELECT
<
dtml
-
if
expr
=
"precision is not None"
>
SUM
(
ROUND
(
<
dtml
-
var
stock_table_id
>
.
quantity
<
dtml
-
if
transformed_uid
>
*
transformation
.
quantity
</
dtml
-
if
>
*
@
interpolation_ratio
,
<
dtml
-
var
precision
>
))
AS
inventory
,
*
<
dtml
-
var
interpolation_ratio
>
,
<
dtml
-
var
precision
>
))
AS
inventory
,
SUM
(
ROUND
(
<
dtml
-
var
stock_table_id
>
.
quantity
<
dtml
-
if
transformed_uid
>
*
transformation
.
quantity
</
dtml
-
if
>
*
@
interpolation_ratio
,
<
dtml
-
var
precision
>
))
AS
total_quantity
,
*
<
dtml
-
var
interpolation_ratio
>
,
<
dtml
-
var
precision
>
))
AS
total_quantity
,
<
dtml
-
if
convert_quantity_result
>
SUM
(
ROUND
(
<
dtml
-
var
stock_table_id
>
.
quantity
*
measure
.
quantity
<
dtml
-
if
quantity_unit_uid
>
/
quantity_unit_conversion
.
quantity
</
dtml
-
if
>
*
@
interpolation_ratio
,
<
dtml
-
var
precision
>
))
*
<
dtml
-
var
interpolation_ratio
>
,
<
dtml
-
var
precision
>
))
AS
converted_quantity
,
</
dtml
-
if
>
IFNULL
(
SUM
(
ROUND
(
<
dtml
-
var
stock_table_id
>
.
total_price
*
@
interpolation_ratio
,
<
dtml
-
var
precision
>
)),
0
)
AS
total_price
<
dtml
-
var
stock_table_id
>
.
total_price
*
<
dtml
-
var
interpolation_ratio
>
,
<
dtml
-
var
precision
>
)),
0
)
AS
total_price
<
dtml
-
else
>
SUM
(
<
dtml
-
var
stock_table_id
>
.
quantity
<
dtml
-
if
transformed_uid
>
*
transformation
.
quantity
</
dtml
-
if
>
*
@
interpolation_ratio
*
<
dtml
-
var
interpolation_ratio
>
)
AS
inventory
,
SUM
(
<
dtml
-
var
stock_table_id
>
.
quantity
<
dtml
-
if
transformed_uid
>
*
transformation
.
quantity
</
dtml
-
if
>
*
@
interpolation_ratio
*
<
dtml
-
var
interpolation_ratio
>
)
AS
total_quantity
,
<
dtml
-
if
convert_quantity_result
>
ROUND
(
SUM
(
<
dtml
-
var
stock_table_id
>
.
quantity
*
measure
.
quantity
<
dtml
-
if
quantity_unit_uid
>
/
quantity_unit_conversion
.
quantity
</
dtml
-
if
>
<
dtml
-
if
transformed_uid
>
*
transformation
.
quantity
</
dtml
-
if
>
*
@
flow_ratio
),
12
)
<
dtml
-
if
transformed_uid
>
*
transformation
.
quantity
</
dtml
-
if
>
*
<
dtml
-
var
interpolation_ratio
>
),
12
)
AS
converted_quantity
,
</
dtml
-
if
>
IFNULL
(
SUM
(
<
dtml
-
var
stock_table_id
>
.
total_price
)
*
@
flow_ratio
,
0
)
AS
total_price
IFNULL
(
SUM
(
<
dtml
-
var
stock_table_id
>
.
total_price
*
<
dtml
-
var
interpolation_ratio
>
)
,
0
)
AS
total_price
</
dtml
-
if
>
<
dtml
-
if
inventory_list
>
,
...
...
@@ -147,3 +141,4 @@ GROUP BY
ORDER
BY
<
dtml
-
var
order_by_expression
>
</
dtml
-
if
>
</
dtml
-
let
>
\ No newline at end of file
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SimulationTool_zGetInterpolationMethod.sql
0 → 100644
View file @
f7c814f1
<
dtml
-
if
expr
=
"interpolation_method == 'linear'"
>
CASE
WHEN
<
dtml
-
var
stock_table_id
>
.
mirror_date
=
<
dtml
-
var
stock_table_id
>
.
date
THEN
1
ELSE
(
UNIX_TIMESTAMP
(
LEAST
(
<
dtml
-
if
interpolation_method_at_date
>
<
dtml
-
sqlvar
interpolation_method_at_date
type
=
"datetime"
>
<
dtml
-
else
>
<
dtml
-
sqlvar
interpolation_method_to_date
type
=
"datetime"
>
</
dtml
-
if
>
,
GREATEST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
)
))
-
UNIX_TIMESTAMP
(
GREATEST
(
<
dtml
-
sqlvar
interpolation_method_from_date
type
=
"datetime"
>
,
LEAST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
))))
/
(
UNIX_TIMESTAMP
(
GREATEST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
))
-
UNIX_TIMESTAMP
(
LEAST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
))
)
END
<
dtml
-
elif
expr
=
"interpolation_method == 'all_or_nothing'"
>
CASE
WHEN
(
-- movement contained in time frame
LEAST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
)
>=
<
dtml
-
sqlvar
interpolation_method_from_date
type
=
"datetime"
>
AND
GREATEST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
)
<
dtml
-
if
interpolation_method_at_date
>
<=
<
dtml
-
sqlvar
interpolation_method_at_date
type
=
"datetime"
>
<
dtml
-
else
>
<
<
dtml
-
sqlvar
interpolation_method_to_date
type
=
"datetime"
>
</
dtml
-
if
>
)
THEN
1
ELSE
0
END
<
dtml
-
elif
expr
=
"interpolation_method == 'one_for_all'"
>
CASE
WHEN
(
-- movement overlaps with time frame
GREATEST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
)
<=
<
dtml
-
sqlvar
interpolation_method_from_date
type
=
"datetime"
>
OR
LEAST
(
<
dtml
-
var
stock_table_id
>
.
date
,
<
dtml
-
var
stock_table_id
>
.
mirror_date
)
<
dtml
-
if
interpolation_method_at_date
>
>=
<
dtml
-
sqlvar
interpolation_method_at_date
type
=
"datetime"
>
<
dtml
-
else
>
>
<
dtml
-
sqlvar
interpolation_method_to_date
type
=
"datetime"
>
</
dtml
-
if
>
)
THEN
0
ELSE
1
END
<
dtml
-
else
>
1
</
dtml
-
if
>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SimulationTool_zGetInterpolationMethod.xml
0 → 100644
View file @
f7c814f1
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"SQL"
module=
"Products.ZSQLMethods.SQL"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
arguments_src
</string>
</key>
<value>
<string>
stock_table_id\r\n
interpolation_method\r\n
interpolation_method_from_date\r\n
interpolation_method_to_date\r\n
interpolation_method_at_date
</string>
</value>
</item>
<item>
<key>
<string>
connection_id
</string>
</key>
<value>
<string>
cmf_activity_sql_connection
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SimulationTool_zGetInterpolationMethod
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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