Skip to content

Commit

Permalink
Stringified total sum (#3)
Browse files Browse the repository at this point in the history
* Add a grand total for order listing

* Stringify total sum

* Bump Ubuntu release to align with trunk tool

---------

Co-authored-by: Andreas Molzer <[email protected]>
  • Loading branch information
HeroicKatora and Andreas Molzer authored Nov 29, 2023
1 parent 7ec9ec7 commit eec5b7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
environment: "build"
steps:
- uses: actions/checkout@v3
Expand Down
20 changes: 20 additions & 0 deletions napoli-pain/src/components/order_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,25 @@ impl Component for OrderDetails {
})
.collect::<Vec<_>>();


let total_millicents: i64 =
order
.entries
.iter()
.map(|order| order.price_in_millicents)
.sum();

let total_str = match napoli_lib::Millicents::from_raw(total_millicents) {
Ok(price) => {
let (euros, cents) = price.to_euro_tuple();
format!("{}.{:02}\u{00a0}€", euros, cents)
}
Err(e) => format!(
"Invalid price value: {}; Error: {:?}",
total_millicents, e
),
};

let id = order.id;
let menu_url = order.menu_url.clone();
let menu_url_text = menu_url.clone();
Expand All @@ -189,6 +208,7 @@ impl Component for OrderDetails {
<AddOrderEntryForm order_id={order.id} onclick={on_add_new_order_request} />
<OrderSummary order_entries={order.entries.clone()} />
<StreamingIndicator status={self.live_streaming_status.clone()} />
<p>{"Total: "}{total_str}</p>
</div>
}
} else {
Expand Down

0 comments on commit eec5b7f

Please sign in to comment.