Skip to content

Commit

Permalink
Merge branch 'main' into LIMS-1257-mortar-and-paste-view-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunga001 committed Jan 9, 2025
2 parents 0ffffd2 + c65cc2c commit f725992
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/bika/cement/browser/batch/templates/mix_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<td class="label bg-light">Theoretical Volume</td>
<td>
<span tal:content="concrete/theoretical_volume|nothing"/>
<span tal:condition="concrete/theoretical_volume"> cu ft</span>
<span tal:condition="concrete/theoretical_volume|nothing"> cu ft</span>
</td>
<td class="label bg-light">Batch Volume</td>
<td>
Expand Down
27 changes: 14 additions & 13 deletions src/bika/cement/extenders/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from bika.lims import api
from bika.lims.browser.fields import UIDReferenceField
from senaite.core.catalog import SETUP_CATALOG
from bika.cement.utils import format_number


class ExtensionField(object):
Expand Down Expand Up @@ -207,22 +208,22 @@ def parse_mix_design_data(self, data):

def parse_mix_design_concrete_data(self, data):
concrete_data = {}
concrete_data["batch_volume"] = data[0][6]
concrete_data["batch_volume"] = format_number(data[0][6])
concrete_data["design_title"] = data[1][2] # design w/cm (title)
concrete_data["replacement"] = data[1][4]
concrete_data["paste_content"] = data[1][6]
concrete_data["total_cm"] = data[2][4]
concrete_data["theoretical_volume"] = data[2][6]
concrete_data["replacement"] = format_number(data[1][4])
concrete_data["paste_content"] = format_number(data[1][6])
concrete_data["total_cm"] = format_number(data[2][4])
concrete_data["theoretical_volume"] = format_number(data[2][6])
concrete_data["super_air_meter"] = data[2][8]
concrete_data["design_air"] = data[3][2]
concrete_data["design_slump"] = data[3][4]
concrete_data["theoretical_unit_weight"] = data[3][6]
concrete_data["measured_air"] = data[4][2]
concrete_data["measured_slump"] = data[4][4]
concrete_data["lab_temperature"] = data[5][4]
concrete_data["concrete_temp"] = data[6][4]
concrete_data["design_air"] = format_number(data[3][2])
concrete_data["design_slump"] = format_number(data[3][4])
concrete_data["theoretical_unit_weight"] = format_number(data[3][6])
concrete_data["measured_air"] = format_number(data[4][2])
concrete_data["measured_slump"] = format_number(data[4][4])
concrete_data["lab_temperature"] = format_number(data[5][4])
concrete_data["concrete_temp"] = format_number(data[6][4])
# Additional Table
concrete_data["trucked_volume"] = data[3][8]
concrete_data["trucked_volume"] = format_number(data[3][8])
concrete_data["trucked_number"] = data[4][8]
concrete_data["ticket_number"] = data[5][8]
concrete_data["plant_number"] = data[6][8]
Expand Down
17 changes: 17 additions & 0 deletions src/bika/cement/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-

def format_number(value, decimal_places=2):
if value in (None, ""):
return None

if isinstance(value, (int, long)):
try:
return int(value) # Return as-is if it's an integer
except OverflowError:
return value

try:
num = float(value)
return num if num.is_integer() else round(num, decimal_places)
except ValueError:
return None # Handle cases where conversion fails

0 comments on commit f725992

Please sign in to comment.