Merge latest changes in master of http://github.com/foodcoops/foodsoft

This commit is contained in:
Julius 2013-06-26 20:23:11 +02:00
commit d0ccf07bc5
20 changed files with 139 additions and 125 deletions

View file

@ -11,6 +11,19 @@
//= require_self
//= require ordering
// allow touch devices to work on click events
// http://stackoverflow.com/a/16221066
$.fn.extend({ _on: (function(){ return $.fn.on; })() });
$.fn.extend({
on: (function(){
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, one );
};
}()),
});
// function for sorting DOM elements
$.fn.sorter = (function(){
// Thanks to James Padolsey and Avi Deitcher

View file

@ -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) {

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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"}
= number_to_currency(order_article.group_orders_sum[:price])
%td{:colspan => "3"}

View file

@ -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)
= link_to t('.or_cancel'), new_finance_order_path(order_id: @order.id)

View file

@ -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

View file

@ -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

View file

@ -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}

View file

@ -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