File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -263,19 +263,22 @@ fun book_recommendations_by_author($user: user) -> { book }:
263263 ($new-book, $shared-author) isa authoring;
264264 return { $new-book };
265265
266- fun order_line_best_price($line: order-line) -> { double }:
266+ fun order_line_best_price($line: order-line) -> { double? }:
267267 match
268268 ($order) isa action-execution, has timestamp $order-time;
269269 $line isa order-line, links ($order, $item);
270270 $item has price $retail-price;
271271 let $time_value = $order-time;
272- let $best-discount = best_discount_for_item($item, $time_value);
273- let $discounted-price = round(100 * $retail-price * (1 - $best-discount)) / 100;
272+ try { let $best-discount? = best_discount_for_item($item, $time_value); };
274273 $line has quantity $quantity;
275- let $line-total = $quantity * $discounted-price;
274+ match
275+ try {
276+ let $discounted-price = round(100 * $retail-price * (1 - $best-discount)) / 100;
277+ let $line-total = $quantity * $discounted-price;
278+ };
276279 return { $line-total };
277280
278- fun best_discount_for_item($item: book, $order-time: datetime) -> double:
281+ fun best_discount_for_item($item: book, $order-time: datetime) -> double? :
279282 match
280283 {
281284 $inclusion isa promotion-inclusion,
You can’t perform that action at this time.
0 commit comments