Added a BoM option to disable the ceil() "rounding"
This commit is contained in:
parent
0402a65c8b
commit
c88dceb6dc
|
|
@ -183,14 +183,20 @@ class ComponentGroup(object):
|
||||||
self.components.append(c)
|
self.components.append(c)
|
||||||
self.refs[c.ref+c.project] = c
|
self.refs[c.ref+c.project] = c
|
||||||
|
|
||||||
|
def round_qty(self, qty):
|
||||||
|
if self.cfg.int_qtys:
|
||||||
|
return int(ceil(qty))
|
||||||
|
int_qty = int(qty)
|
||||||
|
return int_qty if int_qty == qty else qty
|
||||||
|
|
||||||
def get_count(self, project=None):
|
def get_count(self, project=None):
|
||||||
if project is None:
|
if project is None:
|
||||||
# Total components
|
# Total components
|
||||||
c = sum(map(lambda c: c.qty, self.components))
|
qty = sum(map(lambda c: c.qty, self.components))
|
||||||
else:
|
else:
|
||||||
# Only for the specified project
|
# Only for the specified project
|
||||||
c = sum(map(lambda c: c.qty if c.project == project else 0, self.components))
|
qty = sum(map(lambda c: c.qty if c.project == project else 0, self.components))
|
||||||
return int(ceil(c))
|
return self.round_qty(qty)
|
||||||
|
|
||||||
def get_build_count(self):
|
def get_build_count(self):
|
||||||
if not self.is_fitted():
|
if not self.is_fitted():
|
||||||
|
|
@ -198,11 +204,11 @@ class ComponentGroup(object):
|
||||||
return 0
|
return 0
|
||||||
if len(self.cfg.aggregate) == 1:
|
if len(self.cfg.aggregate) == 1:
|
||||||
# Just one project
|
# Just one project
|
||||||
c = sum(map(lambda c: c.qty, self.components))*self.cfg.number
|
qty = sum(map(lambda c: c.qty, self.components))*self.cfg.number
|
||||||
else:
|
else:
|
||||||
# Multiple projects, count them using the number of board for each project
|
# Multiple projects, count them using the number of board for each project
|
||||||
c = sum(map(lambda c: self.cfg.qtys[c.project]*c.qty, self.components))
|
qty = sum(map(lambda c: self.cfg.qtys[c.project]*c.qty, self.components))
|
||||||
return int(ceil(c))
|
return self.round_qty(qty)
|
||||||
|
|
||||||
def get_sources(self):
|
def get_sources(self):
|
||||||
sources = {}
|
sources = {}
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,8 @@ class BoMOptions(BaseOptions):
|
||||||
""" A prefix to add to all the references from this project. Used for multiple projects """
|
""" A prefix to add to all the references from this project. Used for multiple projects """
|
||||||
self.source_by_id = False
|
self.source_by_id = False
|
||||||
""" Generate the `Source BoM` column using the reference ID instead of the project name """
|
""" Generate the `Source BoM` column using the reference ID instead of the project name """
|
||||||
|
self.int_qtys = True
|
||||||
|
""" Component quantities are always expressed as integers. Using the ceil() function """
|
||||||
self._format_example = 'CSV'
|
self._format_example = 'CSV'
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue