From 9e754fe63026d6f2f713b6163548a1872016b526 Mon Sep 17 00:00:00 2001 From: shibao Date: Tue, 19 Apr 2022 19:42:16 -0400 Subject: [PATCH] Show average price per round on ammo type table --- CHANGELOG.md | 1 + lib/cannery_web/live/ammo_type_live/index.ex | 8 ++++++++ priv/gettext/default.pot | 3 +++ priv/gettext/prompts.pot | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 269fe3d3..afe40a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Add German translation: Thank you [Kaia](https://shitposter.club/users/kaia)! - Fix not being able to edit ammo group when fully used up - Fix bug with average price per round calculation +- Show average price per round on ammo type table # v0.4.1 - Fix button and tag text wrapping diff --git a/lib/cannery_web/live/ammo_type_live/index.ex b/lib/cannery_web/live/ammo_type_live/index.ex index 1b6d1ed1..c02bb1df 100644 --- a/lib/cannery_web/live/ammo_type_live/index.ex +++ b/lib/cannery_web/live/ammo_type_live/index.ex @@ -84,6 +84,7 @@ defmodule CanneryWeb.AmmoTypeLive.Index do end) |> Kernel.++([ %{label: gettext("Total # of rounds"), key: "round_count", type: :round_count}, + %{label: gettext("Average Price paid"), key: "avg_price_paid", type: :avg_price_paid}, %{label: nil, key: "actions", type: :actions, sortable: false} ]) @@ -107,6 +108,13 @@ defmodule CanneryWeb.AmmoTypeLive.Index do :round_count -> ammo_type |> Ammo.get_round_count_for_ammo_type(current_user) + :avg_price_paid -> + + case ammo_type |> Ammo.get_average_cost_for_ammo_type!(current_user) do + nil -> gettext("No cost information") + count -> gettext("$%{amount}", amount: count |> :erlang.float_to_binary(decimals: 2)) + end + :actions -> ~H"""
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 8d0443b5..808a8d3a 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -44,6 +44,7 @@ msgid "Ammo type" msgstr "" #, elixir-autogen, elixir-format +#: lib/cannery_web/live/ammo_type_live/index.ex:87 #: lib/cannery_web/live/ammo_type_live/show.html.heex:94 msgid "Average Price paid" msgstr "" @@ -628,6 +629,7 @@ msgstr "" #: lib/cannery_web/live/ammo_group_live/index.ex:117 #: lib/cannery_web/live/ammo_group_live/show.html.heex:32 #: lib/cannery_web/live/ammo_group_live/show.html.heex:39 +#: lib/cannery_web/live/ammo_type_live/index.ex:117 #: lib/cannery_web/live/ammo_type_live/show.html.heex:98 msgid "$%{amount}" msgstr "" @@ -738,6 +740,7 @@ msgid "Show %{name}" msgstr "" #, elixir-autogen, elixir-format +#: lib/cannery_web/live/ammo_type_live/index.ex:114 #: lib/cannery_web/live/ammo_type_live/show.html.heex:104 msgid "No cost information" msgstr "" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index 74abb9df..e4be2383 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -94,7 +94,7 @@ msgstr "" #, elixir-autogen, elixir-format #: lib/cannery_web/live/ammo_group_live/index.ex:167 #: lib/cannery_web/live/ammo_group_live/show.html.heex:66 -#: lib/cannery_web/live/ammo_type_live/index.ex:130 +#: lib/cannery_web/live/ammo_type_live/index.ex:140 msgid "Are you sure you want to delete this ammo?" msgstr ""