From 1e984df3aa94522c9e3d786902e45d99a0080851 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 18 Jun 2013 01:35:12 +0200 Subject: [PATCH 01/12] more beautiful ordergroup edit form --- app/views/admin/ordergroups/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/ordergroups/_form.html.haml b/app/views/admin/ordergroups/_form.html.haml index 23cb846b..6278e47d 100644 --- a/app/views/admin/ordergroups/_form.html.haml +++ b/app/views/admin/ordergroups/_form.html.haml @@ -5,7 +5,7 @@ = f.input :contact_person = f.input :contact_phone = f.input :contact_address - = f.input :ignore_apple_restriction + = f.input :ignore_apple_restriction, :label => false, :inline_label => true .form-actions = f.button :submit = link_to t('ui.or_cancel'), :back From 931b3bef5e9a21a8a65b4f7b671ecff4063020a4 Mon Sep 17 00:00:00 2001 From: wvengen Date: Thu, 20 Jun 2013 01:20:13 +0200 Subject: [PATCH 02/12] fix touch event twice bug (complements ac62dcce9d8872caea742c78e149f4cee8a32c3e) --- app/assets/javascripts/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 5509e1f3..377d3b0a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,7 +18,7 @@ $.fn.extend({ var isTouchSupported = 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch; return function( types, selector, data, fn, one ) { if (typeof types == 'string' && isTouchSupported && !(types.match(/touch/gi))) types = types.replace(/click/gi, 'touchstart'); - return this._on( types, selector, data, fn); + return this._on( types, selector, data, fn, one ); }; }()), }); From 3cfd8b2d448793ad0bd40cb06ea14986f3bec6bb Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 21 Jun 2013 13:25:52 +0200 Subject: [PATCH 03/12] fix i18n key --- app/views/finance/balancing/confirm.html.haml | 2 +- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- config/locales/nl.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/finance/balancing/confirm.html.haml b/app/views/finance/balancing/confirm.html.haml index 2fb2f707..96f762fd 100644 --- a/app/views/finance/balancing/confirm.html.haml +++ b/app/views/finance/balancing/confirm.html.haml @@ -7,4 +7,4 @@ %td.numeric= number_to_currency(group_order.price) .form-actions = link_to t('.clear'), close_finance_order_path(@order), method: :put, class: 'btn btn-primary' - = link_to t('.or_cancle'), new_finance_order_path(order_id: @order.id) \ No newline at end of file + = link_to t('.or_cancel'), new_finance_order_path(order_id: @order.id) diff --git a/config/locales/de.yml b/config/locales/de.yml index 2e862424..6b82a2f4 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -545,7 +545,7 @@ de: confirm: clear: Abschließen first_paragraph: ! 'Wenn die Bestellung abgeschlossen wird, werden ebenfalls alle Gruppenkonten aktualisiert.
Die Konten werden wie folgt belastet:' - or_cancle: oder zurück zur Abrechnung + or_cancel: oder zurück zur Abrechnung title: Bestellung abschließen edit_results_by_articles: add_article: Artikel hinzufügen diff --git a/config/locales/en.yml b/config/locales/en.yml index e60b2a73..ede708e5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -547,7 +547,7 @@ en: confirm: clear: Close first_paragraph: ! 'When the order is closed, all group accounts will be updated.
The accounts will be charged as follows:' - or_cancle: or back to accounting + or_cancel: or back to accounting title: Close order edit_results_by_articles: add_article: Add article diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 863744dc..a39b87e6 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -523,7 +523,7 @@ nl: confirm: clear: Sluiten first_paragraph: ! 'Wanneer de bestelling gesloten wordt, worden alle tegoeden van huishoudens bijgewerkt.
De tegoeden worden als volgt belast:' - or_cancle: of terug naar afrekenen + or_cancel: of terug naar afrekenen title: Order sluiten edit_results_by_articles: add_article: Artikel toevoegen From 906093b3ce44281180406848149b6bc56e9279b1 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 21 Jun 2013 13:49:34 +0200 Subject: [PATCH 04/12] small i18n fixes and clarifications --- .../balancing/_group_order_articles.html.haml | 12 ++++++------ config/locales/en.yml | 2 +- config/locales/nl.yml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/finance/balancing/_group_order_articles.html.haml b/app/views/finance/balancing/_group_order_articles.html.haml index 2895ca13..6689cd95 100644 --- a/app/views/finance/balancing/_group_order_articles.html.haml +++ b/app/views/finance/balancing/_group_order_articles.html.haml @@ -22,20 +22,20 @@ = link_to "-", update_result_finance_group_order_article_path(group_order_article, modifier: '-'), method: :put, remote: true, class: 'btn btn-mini' %td.numeric - = number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result, :unit => "") + = number_to_currency(group_order_article.order_article.price.fc_price * group_order_article.result) %td.actions{:style=>"width:1em"} - = link_to "Bearbeiten", edit_finance_group_order_article_path(group_order_article), remote: true, + = link_to t('ui.edit'), edit_finance_group_order_article_path(group_order_article), remote: true, class: 'btn btn-mini' %td.actions{:style=>"width:1em"} - = link_to "Löschen", finance_group_order_article_path(group_order_article), method: :delete, + = link_to t('ui.delete'), finance_group_order_article_path(group_order_article), method: :delete, remote: true, class: 'btn btn-mini btn-danger' %td %tfoot %tr %td - %td{:style => "width:8em"}= t('total_fc') + %td{:style => "width:8em"}= t('.total_fc') %td{:id => "group_orders_sum_quantity_#{order_article.id}"} = order_article.group_orders_sum[:quantity] %td.numeric{:id => "group_orders_sum_price_#{order_article.id}"} - = number_to_currency(order_article.group_orders_sum[:price], :unit => "") - %td{:colspan => "3"} \ No newline at end of file + = number_to_currency(order_article.group_orders_sum[:price]) + %td{:colspan => "3"} diff --git a/config/locales/en.yml b/config/locales/en.yml index ede708e5..b74b42ad 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -562,7 +562,7 @@ en: group_order_articles: add_group: Add group group: Group - total: Total costs + total: Subtotal total_fc: Sum (FC-Price) units: Units index: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index a39b87e6..85b74578 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -538,7 +538,7 @@ nl: group_order_articles: add_group: Huishouden toevoegen group: Huishouden - total: Totale prijs + total: Subtotaal total_fc: Som (FC-prijs) units: Eenheden index: From c5c4b1f93fb706c86f6ce4026516122b765ef0b1 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 21 Jun 2013 13:54:36 +0200 Subject: [PATCH 05/12] small translation updates --- config/locales/de.yml | 2 +- config/locales/en.yml | 6 +++--- config/locales/nl.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 6b82a2f4..74f2decd 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -571,7 +571,7 @@ de: invoice_date: ! 'Rechnungsdatum:' invoice_number: ! 'Rechnungsnummer:' minus_refund_calculated: ! '- Pfand berechnet:' - new: Neue Rechnung erstellen + new: neue Rechnung erstellen new_body: ! 'Eine Rechnung für diese Bestellung anlegen:' plus_refund_credited: ! '+ Pfand gutgeschrieben:' refund_adjusted_amount: ! 'pfandbereinigter Betrag:' diff --git a/config/locales/en.yml b/config/locales/en.yml index b74b42ad..a0ddba53 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -562,8 +562,8 @@ en: group_order_articles: add_group: Add group group: Group - total: Subtotal - total_fc: Sum (FC-Price) + total: Total costs + total_fc: Sum (FC-price) units: Units index: title: Closed orders @@ -573,7 +573,7 @@ en: invoice_date: ! 'Invoice date:' invoice_number: ! 'Invoice number:' minus_refund_calculated: ! '- deposit charged:' - new: Create new invoice + new: create new invoice new_body: ! 'Create an invoice for this order:' plus_refund_credited: ! '+ deposit returned:' refund_adjusted_amount: ! 'amount adjusted for refund:' diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 85b74578..f915c4ef 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -538,7 +538,7 @@ nl: group_order_articles: add_group: Huishouden toevoegen group: Huishouden - total: Subtotaal + total: Totale prijs total_fc: Som (FC-prijs) units: Eenheden index: @@ -549,7 +549,7 @@ nl: invoice_date: ! 'Factuurdatum:' invoice_number: ! 'Factuurnummer:' minus_refund_calculated: ! '- statiegeld berekend:' - new: Factuur toevoegen + new: factuur toevoegen new_body: ! 'Een factuur aan deze rekening toevoegen:' plus_refund_credited: ! '+ statiegeld teruggekregen:' refund_adjusted_amount: ! 'bedrag gecorrigeerd voor statiegeld:' From cab6ada8b8486247e28719f01acf99f70dcb2bb4 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 21 Jun 2013 14:24:05 +0200 Subject: [PATCH 06/12] small invoice i18n cleanup/refactoring --- app/views/finance/invoices/_form.html.haml | 4 ++-- app/views/finance/invoices/show.html.haml | 10 ++++++++-- config/locales/de.yml | 9 +++------ config/locales/en.yml | 9 +++------ config/locales/nl.yml | 9 +++------ 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/views/finance/invoices/_form.html.haml b/app/views/finance/invoices/_form.html.haml index 1df288ae..8f8ce228 100644 --- a/app/views/finance/invoices/_form.html.haml +++ b/app/views/finance/invoices/_form.html.haml @@ -3,9 +3,9 @@ = f.hidden_field :order_id - if @invoice.delivery - %p= t('.linked', what_link: link_to(t('.delivery'), [@invoice.supplier,@invoice.delivery])).html_safe + %p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_delivery'), [@invoice.supplier,@invoice.delivery])).html_safe - if @invoice.order - %p= t('.linked', what_link: link_to(t('.order'), @invoice.order)).html_safe + %p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), @invoice.order)).html_safe = f.association :supplier, hint: false = f.input :number diff --git a/app/views/finance/invoices/show.html.haml b/app/views/finance/invoices/show.html.haml index c80aec9a..28bb4519 100644 --- a/app/views/finance/invoices/show.html.haml +++ b/app/views/finance/invoices/show.html.haml @@ -1,12 +1,18 @@ - title t('.title', number: @invoice.number) %p - %b= t 'simple_form.labels.invoice.supplier' + %b= t('simple_form.labels.invoice.supplier') + ':' = @invoice.supplier.name + - if @invoice.delivery %p %b= t('simple_form.labels.invoice.delivery') + ':' - = t('.linked', what_link: link_to(t('.delivery'), [@invoice.supplier,@invoice.delivery])).html_safe + = t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_delivery'), [@invoice.supplier,@invoice.delivery])).html_safe +- if @invoice.order + %p + %b= t('simple_form.labels.invoice.order') + ':' + = t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), @invoice.order)).html_safe + %p %b= t('simple_form.labels.invoice.number') + ':' = @invoice.number diff --git a/config/locales/de.yml b/config/locales/de.yml index 74f2decd..3f2ced66 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -668,23 +668,20 @@ de: invoices: edit: title: Rechnung bearbeiten - form: - delivery: Lieferung - linked: Diese Rechnung ist mit einer %{what_link} verknüpft. - order: Bestellung index: action_new: Neue Rechnung anlegen title: Rechnungen invoices: confirm_delete: Bist Du sicher? delivery: Lieferung + linked: Diese Rechnung ist mit %{what_link} verknüpft. + linked_delivery: einer Lieferung + linked_order: einer Bestellung new: back: Züruck title: Neue Rechnung anlegen show: back: Züruck - delivery: Lieferung - linked: Diese Rechnung ist mit einer %{what_link} verknüpft. title: Rechnung %{number} order_articles: edit: diff --git a/config/locales/en.yml b/config/locales/en.yml index a0ddba53..e75ab6ba 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -670,23 +670,20 @@ en: invoices: edit: title: Edit invoice - form: - delivery: delivery - linked: This invoice is linked to a %{what_link}. - order: order index: action_new: Create new invoice title: Invoices invoices: confirm_delete: Are you sure? delivery: Delivery + linked: This invoice is linked to %{what_link}. + linked_delivery: a delivery + linked_order: an order new: back: Back title: Create new invoice show: back: Back - delivery: delivery - linked: This invoice is linked to a %{what_link}. title: Invoice %{number} order_articles: edit: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index f915c4ef..f683e21a 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -646,23 +646,20 @@ nl: invoices: edit: title: Factuur bewerken - form: - delivery: levering - linked: Deze factuur is met aan %{what_link} gekoppeld. - order: bestelling index: action_new: Nieuwe factuur toevoegen title: Facturen invoices: confirm_delete: Weet je het zeker? delivery: Levering + linked: Deze factuur is aan %{what_link} gekoppeld. + linked_delivery: een levering + linked_order: een bestelling new: back: Terug title: Nieuwe factuur toevoegen show: back: Terug - delivery: levering - linked: Deze factuur is aan een %{what_link} gekoppeld. title: Factuur %{number} order_articles: edit: From 7dbe1363ed7a5faa992bbd712add5486849031ef Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 24 Jun 2013 13:32:07 +0200 Subject: [PATCH 07/12] fix adding article balancing failing with 'already taken' (closes foodcoops/foodsoft#125) --- app/controllers/finance/order_articles_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/finance/order_articles_controller.rb b/app/controllers/finance/order_articles_controller.rb index edd0fd82..eed715eb 100644 --- a/app/controllers/finance/order_articles_controller.rb +++ b/app/controllers/finance/order_articles_controller.rb @@ -11,7 +11,15 @@ class Finance::OrderArticlesController < ApplicationController def create @order = Order.find(params[:order_id]) - @order_article = @order.order_articles.build(params[:order_article]) + # The article may with zero units ordered - in that case find and set amount to nonzero. + # If order_article is ordered and a new order_article is created, an error message will be + # given mentioning that the article already exists, which is desired. + @order_article = @order.order_articles.where(:article_id => params[:order_article][:article_id]).first + if @order_article and @order_article.units_to_order == 0 + @order_article.units_to_order = 1 + else + @order_article = @order.order_articles.build(params[:order_article]) + end unless @order_article.save render action: :new end From e450cf404ead7acf4266b572064496d4649a539b Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 25 Jun 2013 00:16:30 +0200 Subject: [PATCH 08/12] harmonize order cycle translations --- config/locales/de.yml | 4 ++-- config/locales/en.yml | 30 +++++++++++++++--------------- config/locales/nl.yml | 28 ++++++++++++++-------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 3f2ced66..6e3390b1 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -546,7 +546,7 @@ de: clear: Abschließen first_paragraph: ! 'Wenn die Bestellung abgeschlossen wird, werden ebenfalls alle Gruppenkonten aktualisiert.
Die Konten werden wie folgt belastet:' or_cancel: oder zurück zur Abrechnung - title: Bestellung abschließen + title: Bestellung abrechnen edit_results_by_articles: add_article: Artikel hinzufügen amount: Menge @@ -782,7 +782,7 @@ de: account_balance: Kontostand available_funds: verfügbares Guthaben finished_orders: nicht abgerechnete Bestellungen - open_orders: laufende Bestellungen + open_orders: Laufende Bestellungen title: Guthaben title: Bestellüberblick messages: diff --git a/config/locales/en.yml b/config/locales/en.yml index e75ab6ba..12a50fae 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -543,12 +543,12 @@ en: notice: Order was accounted succesfully, the balance of the account was updated. close_direct: alert: ! 'Order can not be closed: %{message}' - notice: Order was closed + notice: Order was closed. confirm: clear: Close first_paragraph: ! 'When the order is closed, all group accounts will be updated.
The accounts will be charged as follows:' or_cancel: or back to accounting - title: Close order + title: Settle order edit_results_by_articles: add_article: Add article amount: Amount @@ -603,7 +603,7 @@ en: ended: ended last_edited_by: Last edited by name: Supplier - no_closed_orders: At the moment there are no ended orders. + no_closed_orders: At the moment there are no closed orders. state: State summary: changed: Data was changed! @@ -662,7 +662,7 @@ en: group: Group last_transactions: Last transactions note: Note - open_transactions: not yet accounted + open_transactions: not yet settled show_all: show all supplier: supplier title: Finances @@ -736,8 +736,8 @@ en: desc: View all %{link} here. open_orders: current orders title: Orders of %{group} - title_closed: Accounted - title_open: Completed/not accounted + title_closed: settled + title_open: closed/not settled create: error_general: The order couldn’t be updated due to a bug. error_stale: Someone else has ordered in the meantime, couldn't update the order. @@ -776,14 +776,14 @@ en: index: closed_orders: more: more... - title: Closed orders + title: Settled orders finished_orders: - title: Unaccounted orders + title: Unsettled orders total_sum: Total sum funds: account_balance: Account balance available_funds: Available credit - finished_orders: Unaccounted orders + finished_orders: unsettled orders open_orders: Current orders title: Credit title: Orders overview @@ -813,7 +813,7 @@ en: total_price: Total price unit_price: Unit price units: Units - closed_by: Accounted by %{user} + closed_by: Settled by %{user} comment: Comment comments: title: Comments @@ -1300,13 +1300,13 @@ en: ended_orders: Closed orders ending: End new_order: Create new order - no_open_orders: There are no current orders. + no_open_orders: There are currently no open orders. note: Note open_orders: Current orders supplier: Supplier title: Manage orders model: - error_closed: Order was already accounted for + error_closed: Order was already settled error_nosel: At least one article must be selected error_starts_before_ends: must be after the start date (or remain empty) notice_close: ! 'Order: %{name}, until %{ends}' @@ -1347,10 +1347,10 @@ en: sort_group: Sorted in groups supplier: ! 'Supplier:' title: ! 'Order: %{name}' - warn_not_closed: Warning, order is not accounted yet. + warn_not_closed: Warning, order is not yet settled. state: - closed: closed - finished: finished + closed: settled + finished: closed open: open update: notice: The order was updated. diff --git a/config/locales/nl.yml b/config/locales/nl.yml index f683e21a..8989d734 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -524,7 +524,7 @@ nl: clear: Sluiten first_paragraph: ! 'Wanneer de bestelling gesloten wordt, worden alle tegoeden van huishoudens bijgewerkt.
De tegoeden worden als volgt belast:' or_cancel: of terug naar afrekenen - title: Order sluiten + title: Order afrekenen edit_results_by_articles: add_article: Artikel toevoegen amount: Aantal @@ -579,7 +579,7 @@ nl: ended: beëindigd last_edited_by: Laatst aangepast door name: Leverancier - no_closed_orders: Momenteel zijn er geen beëindigde bestellingen. + no_closed_orders: Momenteel zijn er geen gesloten bestellingen. state: Status summary: changed: @@ -712,7 +712,7 @@ nl: desc: Bekijk hier alle %{link}. open_orders: lopende bestellingen title: Bestellingen van %{group} - title_closed: Afgerekend + title_closed: afgerekend title_open: gesloten/niet afgerekend create: error_general: De bestelling kon niet bijgewerkt worden vanwege een fout. @@ -754,12 +754,12 @@ nl: more: meer... title: Afgerekende bestellingen finished_orders: - title: + title: Niet afgerekende bestellingen total_sum: funds: account_balance: available_funds: - finished_orders: + finished_orders: niet afgerekende bestellingen open_orders: Lopende bestellingen title: Credit title: Besteloverzicht @@ -1037,7 +1037,7 @@ nl: email_is_public: name_is_public: negative_balance: - order_finished: + order_finished: Informeer me over mijn bestelresultaat (wanneer de bestelling gesloten wordt). phone_is_public: send_as_email: upcoming_tasks: @@ -1172,16 +1172,16 @@ nl: action_end: confirm_delete: confirm_end: - ended_orders: + ended_orders: Gesloten bestellingen ending: new_order: - no_open_orders: + no_open_orders: Er zijn momenteel geen lopende bestellingen. note: - open_orders: + open_orders: Lopende bestellingen supplier: title: model: - error_closed: + error_closed: Bestelling was al afgerekend error_nosel: error_starts_before_ends: notice_close: @@ -1220,11 +1220,11 @@ nl: sort_group: supplier: title: - warn_not_closed: + warn_not_closed: Opgelet, bestelling is nog niet afgerekend. state: - closed: - finished: - open: + closed: afgerekend + finished: gesloten + open: lopend update: notice: pages: From 91c8be6b6c8e344a11c213f181482f56a19f7e1d Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 25 Jun 2013 13:04:55 +0200 Subject: [PATCH 09/12] make tests work again --- test/fixtures/articles.yml | 4 ---- test/fixtures/groups.yml | 7 ++----- test/fixtures/suppliers.yml | 13 ------------- test/test_helper.rb | 12 +++++++++++- test/unit/supplier_test.rb | 6 +++--- test/unit/user_test.rb | 35 ++++++++++++++++++++--------------- 6 files changed, 36 insertions(+), 41 deletions(-) diff --git a/test/fixtures/articles.yml b/test/fixtures/articles.yml index 125bd282..0bf03e48 100644 --- a/test/fixtures/articles.yml +++ b/test/fixtures/articles.yml @@ -1,8 +1,4 @@ # == Schema Information -<<<<<<< HEAD:test/fixtures/articles.yml -======= -# Schema version: 20090325175756 ->>>>>>> wiki:test/fixtures/articles.yml # # Table name: articles # diff --git a/test/fixtures/groups.yml b/test/fixtures/groups.yml index af0e71b4..c6152192 100644 --- a/test/fixtures/groups.yml +++ b/test/fixtures/groups.yml @@ -3,6 +3,7 @@ admins: type: Workgroup name: Administrators description: System administrators. + created_on: <%= 5.weeks.ago.to_s(:db) %> role_admin: true role_suppliers: true role_article_meta: true @@ -11,12 +12,8 @@ admins: bananas: type: Ordergroup name: Banangroup + created_on: <%= 4.weeks.ago.to_s(:db) %> account_balance: 100.00 - account_updated: <%= 1.weeks.ago.to_s(:db) %> contact_person: Tim contact_phone: 030 123132456 contact_address: Waldermarstrasse 43, 10988 Berlin - - - - diff --git a/test/fixtures/suppliers.yml b/test/fixtures/suppliers.yml index dc0a4049..4a2302c3 100644 --- a/test/fixtures/suppliers.yml +++ b/test/fixtures/suppliers.yml @@ -1,8 +1,4 @@ # == Schema Information -<<<<<<< HEAD:test/fixtures/suppliers.yml -======= -# Schema version: 20090325175756 ->>>>>>> wiki:test/fixtures/suppliers.yml # # Table name: suppliers # @@ -38,12 +34,3 @@ terra: Terra possibly delivers also on other days than tuesday. Don't hesitate to ask for it. min_order_quantity: 80,-€ (gross) - - - - - - - - - diff --git a/test/test_helper.rb b/test/test_helper.rb index 8bf1192f..80fc4fc5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,5 +9,15 @@ class ActiveSupport::TestCase # -- they do not yet inherit this setting fixtures :all - # Add more helper methods to be used by all tests here... + def login(nick='admin', pass='secret') + open_session do |session| + session.post '/f/login', nick: nick, password: pass + end + end + + def logout + open_session do |session| + session.post '/f/logout' + end + end end diff --git a/test/unit/supplier_test.rb b/test/unit/supplier_test.rb index f8db2bf0..df82c6bf 100644 --- a/test/unit/supplier_test.rb +++ b/test/unit/supplier_test.rb @@ -1,18 +1,18 @@ require File.dirname(__FILE__) + '/../test_helper' -class SupplierTest < Test::Unit::TestCase +class SupplierTest < ActiveSupport::TestCase fixtures :suppliers def setup @supplier = Supplier.find_by_name("Terra") end - def test_read + test 'read' do assert_equal "Terra", @supplier.name assert_equal "www.terra-natur.de", @supplier.url end - def test_update + test 'update' do assert_equal "tuesday", @supplier.delivery_days @supplier.delivery_days = 'wednesday' assert @supplier.save, @supplier.errors.full_messages.join("; ") diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index c7223272..8f6228dc 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -1,13 +1,13 @@ require File.dirname(__FILE__) + '/../test_helper' -class UserTest < Test::Unit::TestCase +class UserTest < ActiveSupport::TestCase fixtures :users def setup @admin = users(:admin) end - def test_read_user + test 'read_user' do assert_kind_of User, @admin assert_equal "Anton", @admin.first_name assert_equal "Admininistrator", @admin.last_name @@ -15,20 +15,25 @@ class UserTest < Test::Unit::TestCase assert @admin.role_admin? end - def test_create_and_read_password - @admin.set_password({:required => true}, "secret", "secret") + test 'create_and_read_password' do + @admin.password = "some_secret" + @admin.password_confirmation = @admin.password + assert @admin.valid? + assert @admin.has_password("some_secret") + end + + test 'invalid_password' do + @admin.password = "foo" + @admin.password_confirmation = @admin.password + assert @admin.invalid? + assert_equal [I18n.t('activemodel.errors.messages.too_short', count: 5)], @admin.errors[:password] + end + + test 'password_not_match' do + @admin.password = "foobar" + @admin.password_confirmation = "foobor" @admin.save - assert @admin.has_password("secret") - end - - def test_invalid_password - @admin.set_password({:required => true}, "foo", "foo") - assert_equal 'Passwort muss zwischen 6 u. 25 Zeichen haben', @admin.errors.on_base - end - - def test_password_not_match - @admin.set_password({:required => true}, "foobar", "foobor") - assert_equal 'Passworteingaben stimmen nicht überein', @admin.errors.on_base + assert_equal [I18n.t('activemodel.errors.messages.confirmation')], @admin.errors[:password] end end From dddd11d8f0ed3ee199e2a56a3c3d3e5a63be7a41 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 26 Jun 2013 00:42:09 +0200 Subject: [PATCH 10/12] do not autocapitalize or autocorrect on login fields to avoid login errors on iPad/iPhone --- app/views/sessions/new.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/sessions/new.html.haml b/app/views/sessions/new.html.haml index c0026150..09a45c39 100644 --- a/app/views/sessions/new.html.haml +++ b/app/views/sessions/new.html.haml @@ -14,12 +14,12 @@ .control-group %label(for='nick' class='control-label')= t '.user' .controls - = text_field_tag 'nick' + = text_field_tag 'nick', nil, autocapitalize: 'off', autocorrect: 'off' .control-group %label(for='password' class='control-label')= t '.password' .controls - = password_field_tag 'password' + = password_field_tag 'password', nil, autocapitalize: 'off', autocorrect: 'off' .control-group .controls From c31e864c73549a15f3f84938e021ac39bcd78d55 Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 26 Jun 2013 01:17:04 +0200 Subject: [PATCH 11/12] internationalise currency in order screen --- app/assets/javascripts/ordering.js | 12 ++++++++---- app/views/group_orders/_form.html.haml | 11 ++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/ordering.js b/app/assets/javascripts/ordering.js index a75d0541..1a1421bd 100644 --- a/app/assets/javascripts/ordering.js +++ b/app/assets/javascripts/ordering.js @@ -7,7 +7,9 @@ var modified = false // indicates if anything has been clicked on this page var groupBalance = 0; // available group money -var decimalSeparator = "."; // default decimal separator +var currencySeparator = "."; // default decimal separator +var currencyPrecision = 2; // default digits behind comma +var currencyUnit = "€"; // default currency var toleranceIsCostly = true; // default tolerance behaviour var isStockit = false; // Wheter the order is from stock oder normal supplier @@ -20,8 +22,10 @@ var toleranceOthers = new Array(); var itemsAllocated = new Array(); // how many items the group has been allocated and should definitely get var quantityAvailable = new Array(); // stock_order. how many items are currently in stock -function setDecimalSeparator(character) { - decimalSeparator = character; +function setCurrencyFormat(separator, precision, unit) { + currencySeparator = separator; + currencyPrecision = precision; + currencyUnit = unit; } function setToleranceBehaviour(value) { @@ -129,7 +133,7 @@ function update(item, quantity, tolerance) { } function asMoney(amount) { - return String(amount.toFixed(2)).replace(/\./, ","); + return String(amount.toFixed(currencyPrecision)).replace(/\./, currencySeparator) + ' ' + currencyUnit; } function calcUnits(unitSize, quantity, tolerance) { diff --git a/app/views/group_orders/_form.html.haml b/app/views/group_orders/_form.html.haml index 0cfc0caa..2939a689 100644 --- a/app/views/group_orders/_form.html.haml +++ b/app/views/group_orders/_form.html.haml @@ -3,7 +3,7 @@ $(function() { #{data_to_js(@ordering_data)} setGroupBalance(#{@ordering_data[:available_funds]}); - setDecimalSeparator(","); + setCurrencyFormat("#{t('number.currency.format.separator')}", #{t('number.currency.format.precision')}, "#{t('number.currency.format.unit')}"); setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]}); setStockit(#{@order.stockit?}); }); @@ -97,8 +97,7 @@ %input{type: 'button', value: '-', 'data-decrease_tolerance' => order_article.id} %td{id: "td_price_#{order_article.id}", style: "text-align:right; padding-right:10px; width:4em"} - %span{id: "price_#{order_article.id}_display"}= number_to_currency(@ordering_data[:order_articles][order_article.id][:total_price], unit: "") - € + %span{id: "price_#{order_article.id}_display"}= number_to_currency(@ordering_data[:order_articles][order_article.id][:total_price]) .article-info .article-name= order_article.article.name .pull-right @@ -125,8 +124,7 @@ %tr %td= t('.total_sum_amount') + ':' %td.currency - %span#total_price= @group_order.price - € + %span#total_price= number_to_currency(@group_order.price) %tr %td= t('.available_funds') + ':' %td.currency= number_to_currency(@ordering_data[:available_funds]) @@ -134,8 +132,7 @@ %td= t('.new_funds') + ':' %td.currency %strong - %span#new_balance= @ordering_data[:available_funds] - @group_order.price - € + %span#new_balance= number_to_currency(@ordering_data[:available_funds] - @group_order.price) #order-button = submit_tag( t('.action_save'), id: 'submit_button', class: 'btn btn-primary' ) #{link_to t('ui.or_cancel'), group_orders_path} From befe89d4eff4f8f321e1e23f29f12b727b668dda Mon Sep 17 00:00:00 2001 From: wvengen Date: Wed, 26 Jun 2013 01:36:44 +0200 Subject: [PATCH 12/12] fix tolerance display in group_order form --- app/models/group_order.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/group_order.rb b/app/models/group_order.rb index 35bec437..9b5eb764 100644 --- a/app/models/group_order.rb +++ b/app/models/group_order.rb @@ -37,8 +37,8 @@ class GroupOrder < ActiveRecord::Base :quantity => (goa ? goa.quantity : 0), :others_quantity => order_article.quantity - (goa ? goa.quantity : 0), :used_quantity => (goa ? goa.result(:quantity) : 0), - :tolerance => (goa ? goa.result(:tolerance) : 0), - :others_tolerance => order_article.tolerance - (goa ? goa.result(:tolerance) : 0), + :tolerance => (goa ? goa.tolerance : 0), + :others_tolerance => order_article.tolerance - (goa ? goa.tolerance : 0), :used_tolerance => (goa ? goa.result(:tolerance) : 0), :total_price => (goa ? goa.total_price : 0), :missing_units => order_article.missing_units,