Skip to content

Commit

Permalink
Adapted foodcoops#764 according to use select instead of checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Oct 17, 2020
1 parent 1f75581 commit 5114a15
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/models/group_order_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ def calculate_result(total = nil)
# Determine quantities to be ordered...
order_quantities.each do |goaq|
q = goaq.quantity
q = [q, total - total_quantity].min unless FoodsoftConfig[:ignore_received_units_on_redistribute]
q = [q, total - total_quantity].min if FoodsoftConfig[:distribution_strategy] == :first_order_first_serve
total_quantity += q
if goaq.group_order_article_id == self.id
logger.debug "increasing quantity by #{q}"
quantity += q
end
break if total_quantity >= total && !FoodsoftConfig[:ignore_received_units_on_redistribute]
break if total_quantity >= total && FoodsoftConfig[:distribution_strategy] == :first_order_first_serve
end

# Determine tolerance to be ordered...
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/config_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ConfigSerializer < ActiveModel::Serializer

# settings
attributes :currency_unit, :currency_space, :default_locale, :price_markup,
:tolerance_is_costly, :ignore_received_units_on_redistribute, :use_apple_points, :use_tolerance
:tolerance_is_costly, :distribution_strategy, :use_apple_points, :use_tolerance

# layout
attributes :page_footer_html, :webstats_tracking_code_html
Expand Down
5 changes: 4 additions & 1 deletion app/views/admin/configs/_tab_others.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
= config_input form, :use_nick, as: :boolean
= config_input form, :tolerance_is_costly, as: :boolean
= config_input form, :ignore_received_units_on_redistribute, as: :boolean
- distribution_options = [[t('config.keys.distribution_strategy_options.first_order_first_serve'), :first_order_first_serve],
[t('config.keys.distribution_strategy_options.no_automatic_distribution'), :no_automatic_distribution]]
= config_input form, :distribution_strategy, as: :select, collection: distribution_options,
include_blank: false, input_html: {class: 'input-xxlarge'}
= config_input form, :disable_invite, as: :boolean
= config_input form, :help_url, as: :url, input_html: {class: 'input-xlarge'}
= config_input form, :webstats_tracking_code, as: :text, input_html: {class: 'input-xxlarge', rows: 3}
7 changes: 5 additions & 2 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ de:
tasks_upfront_days: Anzahl der Tage, für welche du im Voraus wiederkehrende Aufgaben definieren möchtest
tax_default: Standard Mehrwertsteuersatz für neue Artikel
tolerance_is_costly: Eine möglichst große Menge im Rahmen der Tolerenz bestellen. Wenn dies nicht aktiviert ist, wird im Rahmen der Toleranz nur so viel bestellt, dass damit komplette Einheiten (Boxen) bestellt werden können. Die Option wirkt sich auch auf die Toleranz des Gesamtpreises einer offenen Mitgliederbestellung aus.
ignore_received_units_on_redistribute: Auch, wenn insgesamt zu wenig geliefert wurde, wird den Bestellgruppen der volle Betrag verrechnet, bis die Menge manuell korrigiert wird.
distribution_strategy: Wie bei der Verteilung von Artikeln nach dem Empfangen einer Bestellung vorgegangen werden soll.
use_apple_points: Wenn das Apfel Punktesystem aktiviert ist, ist es erforderlich, dass Mitglieder Aufgaben erledigen um bestellen zu können.
use_boxfill: Wenn aktiviert, können Benutzer nahe am Ende der Bestellung diese nur mehr so verändern, dass sich die Gesamtsumme erhöht. Dies hilft beim auffüllen der verbleibenden Kisten. Es muss trotzdem noch das Kistenauffülldatum bei der Bestellung gesetzt werden.
use_iban: Zusätzlich Feld für die internationale Kontonummer bei Benutzern und Lieferanten anzeigen
Expand Down Expand Up @@ -631,7 +631,10 @@ de:
tax_default: Mehrwertsteuer
time_zone: Zeitzone
tolerance_is_costly: Bestelltoleranz maximal ausnutzen, um möglichst große Mengen zu bestellen
ignore_received_units_on_redistribute: Liefermenge beim Verrechnen der einzelnen Bestellgruppen ignorieren
distribution_strategy: Verteilungs-Strategie
distribution_strategy_options:
first_order_first_serve: Zuerst an die verteilen, die zuerst bestellt haben
no_automatic_distribution: Keine automatische Verteilung
use_apple_points: Apfelpunkte verwenden
use_boxfill: Kistenauffüllphase
use_iban: IBAN verwenden
Expand Down
7 changes: 5 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ en:
tasks_upfront_days: For how many days in advance you would like to schedule periodic tasks.
tax_default: Default VAT percentage for new articles.
tolerance_is_costly: Order as much of the member tolerance as possible (compared to only as much needed to fill the last box). Enabling this also includes the tolerance in the total price of the open member order.
ignore_received_units_on_redistribute: Even if the supplier hasn't delivered all that was ordered, the order groups will be charged for the full amounts, unless manually changed.
distribution_strategy: How articles should be distributed after an order has been received.
use_apple_points: When the apple point system is enabled, members are required to do some tasks to be able to keep ordering.
use_boxfill: When enabled, near end of an order, members are only able to change their order when increases the total amount ordered. This helps to fill any remaining boxes. You still need to set a box-fill date for the orders.
use_iban: When enabled, supplier and user provide an additonal field for storing the international bank account number.
Expand Down Expand Up @@ -651,7 +651,10 @@ en:
tax_default: Default VAT
time_zone: Time zone
tolerance_is_costly: Tolerance is costly
ignore_received_units_on_redistribute: Ignore received amounts when charging order groups
distribution_strategy: Distribution strategy
distribution_strategy_options:
first_order_first_serve: First distribute to those who ordered first
no_automatic_distribution: No automatic distribution
use_apple_points: Apple points
use_boxfill: Box-fill phase
use_iban: Use IBAN
Expand Down
17 changes: 11 additions & 6 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ es:
all_ordergroups: Todos los grupos de pedido
all_users: Todos los usuarios
all_workgroups: Todos los grupos de trabajo
created_at: creado
created_at: creado
first_paragraph: Aquí puedes administrar grupos y usuarios de Foodsoft.
groupname: nombre del grupo
members: miembros
Expand Down Expand Up @@ -455,7 +455,7 @@ es:
status: Estado (x=saltar)
file_label: Por favor elige un archivo compatible
options:
convert_units: Mantener unidades actuales, recomputar la cantidad y precio de unidades (como sincronizar).
convert_units: Mantener unidades actuales, recomputar la cantidad y precio de unidades (como sincronizar).
outlist_absent: Borrar artículos que no están en el archivo subido.
sample:
juices: Jugos
Expand Down Expand Up @@ -503,6 +503,7 @@ es:
tasks_upfront_days: Con cuántos días de antelación te gustaría programar las tareas periódicas.
tax_default: Porcentaje por defecto del IVA para artículos nuevos.
tolerance_is_costly: Pide lo que más permita la tolerancia de los miembros (en lugar de sólo lo necesario para llenar la última caja). Permitir esto también incluye la tolerancia en el precio final del pedido abierto de cada miembro.
distribution_strategy: Cómo se deben distribuir los artículos después de recibir un pedido.
use_apple_points: Cuando el sistema de puntos-manzana está habilitado los miembros deberán realizar algunas tareas para poder hacer pedidos.
use_boxfill: Cuando está activado, cerca del cierre de un pedido los miembros no podrán cambiar su pedido a menos que se incremente el valor pedido total. Esto ayudará a llenar las cajas que faltan. Igualmente deberás decidir una fecha de llenado de cajas para los pedidos.
use_iban: Cuando esta opción está habilitada, el proveedor y el usuario pueden guardan también su número de cuenta bancaria internacional (IBAN).
Expand Down Expand Up @@ -547,6 +548,10 @@ es:
tax_default: IVA por defecto
time_zone: Zona horaria
tolerance_is_costly: La tolerancia es prioritaria
distribution_strategy: Estrategia de distribución
distribution_strategy_options:
first_order_first_serve: Primero distribuya a quienes ordenaron primero
no_automatic_distribution: Sin distribución automática
use_apple_points: Puntos-manzana
use_boxfill: Fase de llenar las cajas
use_iban: Usar IBAN
Expand Down Expand Up @@ -912,7 +917,7 @@ es:
changes_saved: Guarda los cambios.
index:
my_ordergroup:
last_update: La última actualización fue hace %{when}
last_update: La última actualización fue hace %{when}
title: Mi grupo de pedido
transactions:
title: Últimas transacciones
Expand Down Expand Up @@ -1001,7 +1006,7 @@ es:
error_invite_invalid: Tu invitación no es válida.
error_token_invalid: La sesión ha expirado o no es válida. Prueba de nuevo.
reset_password:
notice: Si tu email está ya registrado aquí, recibirás un mensaje con un enlace para
notice: Si tu email está ya registrado aquí, recibirás un mensaje con un enlace para
update_password:
notice: Tu contraseña ha sido actualizada. Prueba a conectarte ahora.
forgot_password:
Expand Down Expand Up @@ -1368,7 +1373,7 @@ es:
copy:
title: Copia artículo de stock
create:
notice: Se ha creado el nuevo producto en stock "%{name}"
notice: Se ha creado el nuevo producto en stock "%{name}"
derive:
title: Añade un artículo en stock desde plantilla
destroy:
Expand Down Expand Up @@ -1476,7 +1481,7 @@ es:
accept_task: Aceptar tarea
confirm_delete_group: Estás seguro/a de que quieres borrar esta tarea y todas las tareas subsecuentes?
confirm_delete_single: Estás seguro/a de que quieres borrar esta tarea?
confirm_delete_single_from_group: Estás seguro/a de que quieres borrar esta tarea (y mantener las tareas recurrentes relacionadas)?
confirm_delete_single_from_group: Estás seguro/a de que quieres borrar esta tarea (y mantener las tareas recurrentes relacionadas)?
delete_group: Borrar esta tarea y las subsecuentes
edit_group: Edita recurrencia
mark_done: Marca tarea como hecha
Expand Down
13 changes: 9 additions & 4 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fr:
gross_price: Prix TTC
manufacturer: Product-rice-eur
name: Nom
order_number: Numéro
order_number: Numéro
order_number_short: Numéro
origin: Lieu de production
price: Prix HT
Expand Down Expand Up @@ -403,6 +403,7 @@ fr:
hints:
homepage: Site de votre coop.
name: Le nom de votre coop.
distribution_strategy: Comment procéder à la distribution des articles après réception d'une commande.
keys:
contact:
city: Ville
Expand All @@ -413,6 +414,10 @@ fr:
zip_code: Code postal
currency_unit: Monnaie
name: Nom
distribution_strategy: Stratégie de distribution
distribution_strategy_options:
first_order_first_serve: Distribuez d'abord à ceux qui ont commandé en premier
no_automatic_distribution: Pas de distribution automatique
tabs:
language: Langue
list: Liste
Expand Down Expand Up @@ -851,7 +856,7 @@ fr:
error_invite_invalid: Ton invitation n'est pas ou plus valide.
error_token_invalid: Ton jeton de connexion n'est pas ou plus valide, essaie de cliquer à nouveau sur le lien.
reset_password:
notice: Tu vas maintenant recevoir un message contenant un lien qui te permettra de réinitialiser ton mot de passe.
notice: Tu vas maintenant recevoir un message contenant un lien qui te permettra de réinitialiser ton mot de passe.
update_password:
notice: Ton mot de passe a été mis à jour. Tu peux maintenant de connecter.
forgot_password:
Expand Down Expand Up @@ -1334,7 +1339,7 @@ fr:
notice: La description du boulot a été mise à jour.
notice_converted: Le boulot a été converti en boulot ordinaire (sans répétition).
user:
more: Tu t'ennuies en ce moment? Il y aura sûrement du boulot pour toi %{tasks_link}.
more: Tu t'ennuies en ce moment? Il y aura sûrement du boulot pour toi %{tasks_link}.
tasks_link: par là-bas
title: Ton boulot
title_accepted: Boulots acceptés
Expand All @@ -1359,7 +1364,7 @@ fr:
edit:
title: Modifier l'équipe
error_last_admin_group: Impossible de supprimer la dernière cellule avec privilèges administratrices.
error_last_admin_role: Les privilèges administratrices ne peuvent pas être retirés à la dernière cellule qui les possède.
error_last_admin_role: Les privilèges administratrices ne peuvent pas être retirés à la dernière cellule qui les possède.
index:
title: Équipes
update:
Expand Down
5 changes: 5 additions & 0 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ nl:
tasks_upfront_days: Hoeveel dagen vantevoren je periodieke taken wil aanmaken.
tax_default: Standaard BTW percentage voor nieuwe artikelen.
tolerance_is_costly: Bestel zoveel artikelen als mogelijk in de tolerantie (in plaats van net genoeg om de laatste doos te vullen). Dit zorgt er ook voor dat de tolerantie in de prijs van open ledenbestellingen wordt meegenomen.
distribution_strategy: Hoe verder te gaan met de distributie van artikelen na ontvangst van een bestelling.
use_apple_points: Wanneer het appelpunten systeem is geactiveerd, kunnen leden slechts bestellen wanneer ze meewerken aan taken.
use_boxfill: Wanneer dit aan staat, kunnen gebruikers aan het einde van de bestelfase hun bestelling alleen wijzigen als het de totale bestelling vergroot. Dit helpt om dozen te vullen. Bij de bestelling moet nog wel de dozen-vul-datum ingevuld worden.
use_iban: Om leverancier en gebruiker een extra veld te geven voor het internationale bankrekeningnummer (IBAN).
Expand Down Expand Up @@ -639,6 +640,10 @@ nl:
tax_default: Standaard BTW
time_zone: Tijdzone
tolerance_is_costly: Tolerantie is duur
distribution_strategy: Distributie strategie
distribution_strategy_options:
first_order_first_serve: Verdeel eerst onder degenen die het eerst hebben besteld
no_automatic_distribution: Geen automatische distributie
use_apple_points: Appelpunten
use_boxfill: Dozen vullen fase
use_iban: IBAN gebruiken
Expand Down
1 change: 1 addition & 0 deletions lib/foodsoft_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def get_default_config
tasks_period_days: 7,
tasks_upfront_days: 49,
shared_supplier_article_sync_limit: 200,
distribution_strategy: :first_order_first_serve,
# The following keys cannot, by default, be set by foodcoops themselves.
protected: {
multi_coop_install: true,
Expand Down

0 comments on commit 5114a15

Please sign in to comment.