Skip to content

Commit d533548

Browse files
authored
Fix(Invoicing) Fix crashes when prices are 0 (#3744)(patch)
## Description AZ reported that samples with the price 0 crashes the entire invoicing flow ### Changed - Return 0 instead of None if price is 0
1 parent e9c0c2b commit d533548

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

cg/meta/invoice.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ def _discount_price(self, record: Sample or Pool, discount: int = 0) -> int | No
137137
priority = self.get_priority(record, for_discount_price=True)
138138
full_price = getattr(record.application_version, f"price_{priority}")
139139
discount_factor = 1 - discount / 100
140-
if not full_price:
141-
return None
142-
return round(full_price * discount_factor)
140+
return round(full_price * discount_factor) if full_price else 0
143141

144142
def _cost_center_split_factor(
145143
self, price: int, cost_center: str, percent_kth: int, tag: str, version: str
@@ -162,15 +160,14 @@ def _cost_center_split_factor(
162160
self.log.append(
163161
f"Could not get price for samples with application tag/version: {tag}/{version}."
164162
)
165-
return None
163+
return 0
166164
return split_price
167165

168166
def get_invoice_entity_record(
169167
self, cost_center: str, discount: int, record: Sample or Pool
170168
) -> InvoiceInfo:
171169
"""Return invoice information for a specific sample or pool."""
172170
application = self.get_application(record=record, discount=discount)
173-
174171
split_discounted_price = self._cost_center_split_factor(
175172
price=application.discounted_price,
176173
cost_center=cost_center,

0 commit comments

Comments
 (0)