From 43a41062e9c7f78e2c9318dbd5a53f8c61d44c14 Mon Sep 17 00:00:00 2001 From: FGU Date: Fri, 24 Feb 2023 18:25:50 +0100 Subject: [PATCH] add base price to group order form --- app/helpers/group_orders_helper.rb | 8 ++++++++ app/views/group_orders/_form.html.haml | 2 ++ config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fr.yml | 1 + config/locales/nl.yml | 1 + 7 files changed, 15 insertions(+) diff --git a/app/helpers/group_orders_helper.rb b/app/helpers/group_orders_helper.rb index c5e27c66..4f1d352f 100644 --- a/app/helpers/group_orders_helper.rb +++ b/app/helpers/group_orders_helper.rb @@ -53,4 +53,12 @@ module GroupOrdersHelper return 'missing-many' end end + + def price_per_base_unit(article:, price:) + quantity_unit = QuantityUnit.parse(article.unit) + return nil unless quantity_unit.present? + + scaled_price, base_unit = quantity_unit.scale_price_to_base_unit(price) + "#{number_to_currency(scaled_price)}/#{base_unit}" + end end diff --git a/app/views/group_orders/_form.html.haml b/app/views/group_orders/_form.html.haml index 3ffd583e..bd3f2278 100644 --- a/app/views/group_orders/_form.html.haml +++ b/app/views/group_orders/_form.html.haml @@ -77,6 +77,7 @@ %th{style: 'width:120px'}= heading_helper StockArticle, :supplier %th{style: "width:13px;"} %th{style: "width:4.5em;"}= t '.price' + %th{style: "width:4.5em;"}= t '.price_per_base_unit' %th{style: "width:4.5em;"}= heading_helper Article, :unit - unless @order.stockit? %th{style: "width:70px;"}= heading_helper OrderArticle, :missing_units, short: true @@ -100,6 +101,7 @@ %td= truncate order_article.article.supplier.name, length: 15 %td= h order_article.article.origin %td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price]) + %td= price_per_base_unit(article: order_article.article, price: @ordering_data[:order_articles][order_article.id][:price]) %td= order_article.article.unit %td - if @order.stockit? diff --git a/config/locales/de.yml b/config/locales/de.yml index 5a1a5b35..e4134379 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1052,6 +1052,7 @@ de: action_save: Bestellung speichern new_funds: Neuer Kontostand price: Preis + price_per_base_unit: Grundpreis reset_article_search: Suche zurücksetzen search_article: Artikel suchen... sum_amount: Gesamtbestellmenge bisher diff --git a/config/locales/en.yml b/config/locales/en.yml index 59e94385..f1b43130 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1054,6 +1054,7 @@ en: action_save: Save order new_funds: New account balance price: Price + price_per_base_unit: Base price reset_article_search: Reset search search_article: Search for articles... sum_amount: Current amount diff --git a/config/locales/es.yml b/config/locales/es.yml index 620ec3bb..57525760 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -929,6 +929,7 @@ es: action_save: Guardar pedido new_funds: Nuevo balance de cuenta price: Precio + price_per_base_unit: Precio de base reset_article_search: Reinicia la búsqueda search_article: Busca artículos... sum_amount: Cantidad actual diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4dbdb864..2e1df877 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -678,6 +678,7 @@ fr: action_save: Enregistrer ta commande new_funds: Nouveau solde price: Prix + price_per_base_unit: Prix de base reset_article_search: Réinitialiser la recherche search_article: Rechercher des produits... sum_amount: Quantité déjà commandée diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 4c97dda4..da14b7bb 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1024,6 +1024,7 @@ nl: action_save: Bestelling opslaan new_funds: Nieuw tegoed price: Prijs + price_per_base_unit: Basisprjis reset_article_search: Alles tonen search_article: Artikelen zoeken... sum_amount: Huidig totaalbedrag