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
357eee49
Commit
357eee49
authored
Feb 12, 2019
by
Cédric Le Ninivin
Committed by
Cédric Le Ninivin
Feb 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder: Reach workable calculation
parent
f53cd9a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
3 deletions
+36
-3
bt5/erp5_base/MixinTemplateItem/portal_components/mixin.erp5.BuilderMixin.py
...TemplateItem/portal_components/mixin.erp5.BuilderMixin.py
+36
-3
No files found.
bt5/erp5_base/MixinTemplateItem/portal_components/mixin.erp5.BuilderMixin.py
View file @
357eee49
...
@@ -461,7 +461,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -461,7 +461,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
)
)
# Prepare period_list
# Prepare period_list
limit_date
=
getPreviousValidDate
(
from_date
)
limit_date
=
getPreviousValidDate
(
getPreviousValidDate
(
from_date
)
-
0.1
)
limit_date_list
=
[]
limit_date_list
=
[]
last_date
=
getPreviousValidDate
(
history_list
[
-
1
][
0
])
last_date
=
getPreviousValidDate
(
history_list
[
-
1
][
0
])
while
limit_date
<=
last_date
:
while
limit_date
<=
last_date
:
...
@@ -471,6 +471,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -471,6 +471,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Hackish and dangerous
# Hackish and dangerous
next_start_date
=
limit_date
)).
earliestTime
()
next_start_date
=
limit_date
)).
earliestTime
()
min_stock_value
=
supply
.
getMinOrderQuantity
()
/
default_quantity_unit_flow_quantity_unit_conversion_ratio
factor
=
supply
.
getMinFlow
()
next_period_history_list
=
[]
#self.log(limit_date_list)
#self.log(limit_date_list)
# Create a movement per period
# Create a movement per period
for
period_start_date
in
limit_date_list
:
for
period_start_date
in
limit_date_list
:
...
@@ -481,16 +484,46 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -481,16 +484,46 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_start_date
=
period_start_date
)).
earliestTime
()
next_start_date
=
period_start_date
)).
earliestTime
()
period_history_list
=
[]
period_history_list
=
[]
if
next_period_history_list
and
\
next_next_period_start_date
==
next_period_start_date
:
period_history_list
=
next_period_history_list
[:]
while
history_list
and
history_list
[
0
][
0
]
<
next_period_start_date
:
while
history_list
and
history_list
[
0
][
0
]
<
next_period_start_date
:
period_history_list
.
append
(
history_list
.
pop
(
0
))
period_history_list
.
append
(
history_list
.
pop
(
0
))
# Using period history list calculate min stock
# Using period history list calculate min stock
min_inventory
=
self
.
Base_evaluateMinInventoryForSupplyAtDate
(
# In this iteration we verify that the invetory is always superior
# to the min_stock_value
min_inventory_end_of_period
=
min_stock_value
# Anticipate next period need if a ratio is defined
next_period_history_list
=
[]
next_next_period_start_date
=
DateTime
(
supply
.
getNextPeriodicalDate
(
next_period_start_date
,
next_start_date
=
next_period_start_date
)).
earliestTime
()
if
factor
and
next_next_period_start_date
<=
last_date
:
# prepare new hixtory_list
while
history_list
and
history_list
[
0
][
0
]
<
next_next_period_start_date
:
next_period_history_list
.
append
(
history_list
.
pop
(
0
))
# Calculate need with ratio
# Here it is actually just a ratio of the next period consumption.
min_inventory_end_of_period
=
self
.
Base_evaluateMinInventoryForSupplyAtDate
(
supply
=
supply
,
history_list
=
next_period_history_list
,
at_date
=
next_period_start_date
,
factor
=
factor
,
min_stock_value
=
min_inventory_end_of_period
,
)
week_consumption
=
self
.
Base_evaluateMinInventoryForSupplyAtDate
(
supply
=
supply
,
supply
=
supply
,
history_list
=
period_history_list
,
history_list
=
period_history_list
,
at_date
=
period_start_date
,
at_date
=
period_start_date
,
conversion_ratio
=
default_quantity_unit_flow_quantity_unit_conversion_ratio
,
factor
=
1
,
)
)
min_inventory
=
min_inventory_end_of_period
+
week_consumption
quantity
=
0
quantity
=
0
if
future_inventory_to_date
<
min_inventory
:
# SKU
if
future_inventory_to_date
<
min_inventory
:
# SKU
...
...
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