Merge branch 'master' into 2-0-stable-Mar6

This commit is contained in:
luisramos0
2019-03-06 09:19:53 +00:00
79 changed files with 7134 additions and 3387 deletions

View File

@@ -7,12 +7,12 @@ assignees: ''
---
**## Description**
## Description
<!-- Describe the story in detail:
**- As a:** (enterprise user, super admin, user...)
**- On page:** (provide url of the page you want to modify. If not provide where will be created the new url and the name we want to give it)
**- I want to be able to do:** (specify the desired behavior)
(Link to others issues or resources to provide context > only if really necessary). -->
**## Acceptance Criteria**
## Acceptance Criteria
<!-- Document the outcomes that need to be achieved before this component can be considered complete. -->

View File

@@ -27,7 +27,8 @@ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
# - Pass customer email and phone number to PayPal (merged to upstream master)
# - Change type of password from string to password to hide it in the form
gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "2-0-stable"
gem 'stripe', '~> 4.5.0'
gem 'stripe', '~> 4.9.0'
# We need at least this version to have Digicert's root certificate
# which is needed for Pin Payments (and possibly others).
gem 'activemerchant', '~> 1.78'

View File

@@ -227,7 +227,7 @@ GEM
execjs
coffee-script-source (1.10.0)
colorize (0.8.1)
combine_pdf (1.0.15)
combine_pdf (1.0.16)
ruby-rc4 (>= 0.1.5)
compass (1.0.3)
chunky_png (~> 1.2)
@@ -551,7 +551,7 @@ GEM
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.7.8)
oj (3.7.9)
orm_adapter (0.5.0)
paper_trail (5.2.3)
activerecord (>= 3.0, < 6.0)
@@ -719,7 +719,7 @@ GEM
tilt (~> 1.1, != 1.3.0)
state_machine (1.2.0)
stringex (1.5.1)
stripe (4.5.0)
stripe (4.9.0)
faraday (~> 0.13)
net-http-persistent (~> 3.0)
therubyracer (0.12.0)
@@ -858,7 +858,7 @@ DEPENDENCIES
spree_paypal_express!
spring (= 1.7.2)
spring-commands-rspec
stripe (~> 4.5.0)
stripe (~> 4.9.0)
therubyracer (= 0.12.0)
timecop
truncate_html

View File

@@ -8,8 +8,8 @@
//= require jquery
//= require jquery-migrate-min
//= require jquery_ujs
//= require jquery.ui.all
//= require shared/jquery-ui-timepicker-addon
//= require jquery-ui
//= require jquery-ui-timepicker-addon
//= require angular
//= require angular-resource
//= require angular-animate

View File

@@ -10,17 +10,19 @@ angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.e
# using $parse instead of scope[attrs.datetimepicker] for cases
# where attrs.datetimepicker is 'foo.bar.lol'
$(element).datetimepicker
dateFormat: 'yy-mm-dd'
timeFormat: 'HH:mm:ss'
showOn: "button"
buttonImage: "<%= asset_path 'datepicker/cal.gif' %>"
buttonImageOnly: true
stepMinute: 15
onSelect: (dateText, inst) ->
scope.$apply(->
dateFormat: 'yy-mm-dd'
timeFormat: 'HH:mm'
showOn: 'button'
controlType: 'select'
oneLine: true
buttonImage: "<%= asset_path 'datepicker/cal.gif' %>"
buttonImageOnly: true
stepMinute: 15
onSelect: (dateText, inst) ->
scope.$apply(->
element.val(dateText)
parsed = $parse(attrs.datetimepicker)
parsed.assign(scope, dateText)
parsed = $parse(attrs.datetimepicker)
parsed.assign(scope, dateText)
)

View File

@@ -1,12 +1,15 @@
$(document).ready(function() {
$('.datetimepicker').datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:mm',
dayNames: Spree.translations.abbr_day_names,
dayNamesMin: Spree.translations.abbr_day_names,
monthNames: Spree.translations.month_names,
prevText: Spree.translations.previous,
nextText: Spree.translations.next,
showOn: "button",
showOn: 'button',
controlType: 'select',
oneLine: true,
buttonImage: "<%= asset_path 'datepicker/cal.gif' %>",
buttonImageOnly: true,
stepMinute: 15

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
.container
.row.modal-centered
%h2 {{'welcome_to_ofn' | t}}
%h5 {{'signup_or_login' | t}}:
%h2 {{'js.registration.welcome_to_ofn' | t}}
%h5 {{'js.registration.signup_or_login' | t}}:
%div{"ng-controller" => "AuthenticationCtrl"}
%tabset
%ng-include{src: "'signup.html'"}
@@ -9,9 +9,9 @@
%ng-include{src: "'forgot.html'"}
%div{ ng: { show: "active('/signup')"} }
%hr
{{'have_an_account' | t}}
{{'js.registration.have_an_account' | t}}
%a{ href: "", ng: { click: "select('/login')"}}
{{'action_login' | t}}
{{'js.registration.action_login' | t}}
%a.close-reveal-modal{"ng-click" => "$close()"}
%i.ofn-i_009-close

View File

@@ -7,9 +7,10 @@
*= require admin/spree_backend
*= require admin/spree_auth
*= require shared/jquery-ui-timepicker-addon
*= require jquery-ui-timepicker-addon
*= require shared/textAngular
*= require shared/ng-tags-input.min
*= require admin/custom
*= require_self
*/

View File

@@ -0,0 +1,2 @@
/* Custom fix */
.ui-timepicker-div.ui-timepicker-oneLine dl dd { width: 25%; }

View File

@@ -1,10 +0,0 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-timepicker-rtl{ direction: rtl; }
.ui-timepicker-rtl dl { text-align: right; }
.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }

View File

@@ -1,8 +1,7 @@
require 'open_food_network/products_cache_integrity_checker'
class Admin::CacheSettingsController < Spree::Admin::BaseController
def show
def edit
@results = Exchange.cachable.map do |exchange|
checker = OpenFoodNetwork::ProductsCacheIntegrityChecker.new(exchange.receiver, exchange.order_cycle)
@@ -10,4 +9,10 @@ class Admin::CacheSettingsController < Spree::Admin::BaseController
end
end
def update
Spree::Config.set(params[:preferences])
respond_to do |format|
format.html { redirect_to main_app.edit_admin_cache_settings_path }
end
end
end

View File

@@ -79,11 +79,9 @@ module Admin
end
def save_uploaded_file(upload)
filename = 'import' + Time.zone.now.strftime('%d-%m-%Y-%H-%M-%S')
extension = '.' + upload.original_filename.split('.').last
directory = 'tmp/product_import'
Dir.mkdir(directory) unless File.exist?(directory)
File.open(Rails.root.join(directory, filename + extension), 'wb') do |f|
extension = File.extname(upload.original_filename)
directory = Dir.mktmpdir 'product_import'
File.open(File.join(directory, "import#{extension}"), 'wb') do |f|
data = UploadSanitizer.new(upload.read).call
f.write(data)
f.path

View File

@@ -25,7 +25,7 @@ class SubscriptionConfirmJob
def proxy_orders
ProxyOrder.not_canceled.where('confirmed_at IS NULL AND placed_at IS NOT NULL')
.joins(:order_cycle).merge(recently_closed_order_cycles)
.joins(:order).merge(Spree::Order.complete)
.joins(:order).merge(Spree::Order.complete.not_state('canceled'))
end
def recently_closed_order_cycles

View File

@@ -1,3 +1,21 @@
# Validates the combination of on_demand and count_on_hand values.
#
# `on_demand` can have three values: true, false or nil
# `count_on_hand` can either be: nil or a number
#
# This means that a variant override can be in six different stock states
# but only three of them are valid.
#
# | on_demand | count_on_hand | stock_overridden? | use_producer_stock_settings? | valid? |
# |-----------|---------------|-------------------|------------------------------|--------|
# | 1 | nil | false | false | true |
# | 0 | x | true | false | true |
# | nil | nil | false | true | true |
# | 1 | x | ? | ? | false |
# | 0 | nil | ? | ? | false |
# | nil | x | ? | ? | false |
#
# This module has one method for each invalid case.
module StockSettingsOverrideValidation
extend ActiveSupport::Concern

View File

@@ -37,4 +37,7 @@ Spree::AppConfiguration.class_eval do
# Number localization
preference :enable_localized_number?, :boolean, default: false
# Enable cache
preference :enable_products_cache?, :boolean, default: true
end

View File

@@ -36,9 +36,15 @@ class VariantOverride < ActiveRecord::Base
end
def stock_overridden?
# If count_on_hand is present, it means on_demand is false
# See StockSettingsOverrideValidation for details
count_on_hand.present?
end
def use_producer_stock_settings?
on_demand.nil?
end
def move_stock!(quantity)
unless stock_overridden?
Bugsnag.notify RuntimeError.new "Attempting to move stock of a VariantOverride without a count_on_hand specified."

View File

@@ -1,6 +0,0 @@
# Disabled until this form takes order cycles into account
# Deface::Override.new(:virtual_path => "spree/checkout/edit",
# :insert_after => "[data-hook='checkout_summary_box']",
# :partial => "spree/checkout/other_available_distributors",
# :name => "add_change_distributor_form_to_checkout_address",
# :original => '60b9b1a39079f4efa85ff0425108edf671349d4f')

View File

@@ -1,5 +0,0 @@
Deface::Override.new(:virtual_path => "spree/products/show",
:insert_after => "[data-hook='product_show']",
:text => "<%= javascript_include_tag main_app.distributors_enterprises_path(:format => :js) %>",
:name => "add_distributor_details_js_to_product",
:original => 'b05ac497efeeebd4464f29891fd2c4a0f60c24d9')

View File

@@ -1,5 +0,0 @@
Deface::Override.new(:virtual_path => "spree/products/show",
:insert_before => "[data-hook='cart_form']",
:partial => "spree/products/distributor_details",
:name => "add_distributor_details_to_product",
:original => '789e3f5f6f36a8cd4115d7342752a37735659298')

View File

@@ -1,5 +0,0 @@
Deface::Override.new(:virtual_path => "spree/products/_cart_form",
:replace => "[data-hook='product_price'] .add-to-cart",
:partial => "spree/products/add_to_cart",
:name => "add_distributor_to_add_to_cart_form",
:original => '294014222132c795048fc6c7866971a332672c87')

View File

@@ -1,5 +0,0 @@
Deface::Override.new(:virtual_path => "spree/products/show",
:insert_bottom => "[data-hook='product_left_part_wrap']",
:partial => "spree/products/source",
:name => "add_source_to_product",
:original => 'bce3ba4847b3eac8ae061774a664ac4951d3d9db')

View File

@@ -1,5 +0,0 @@
Deface::Override.new(:virtual_path => "spree/checkout/_payment",
:replace => "code[erb-loud]:contains('submit_tag t(:save_and_continue)')",
:text => "<%= submit_tag I18n.t(:process_my_order), :class => 'continue button primary' %>",
:name => "replace_checkout_payment_button",
:original => 'ce2043a01931b3bc16b045302ebb0e0bb9150b67')

View File

@@ -1,5 +0,0 @@
Deface::Override.new(:virtual_path => "spree/checkout/_address",
:replace => "[data-hook='shipping_fieldset_wrapper']",
:partial => "spree/checkout/distributor",
:name => "replace_shipping_address_form_with_distributor_details",
:original => '53e219f90a2e1ba702a767261d0c2afe100ac751')

View File

@@ -1,4 +1,4 @@
/ insert_bottom "[data-hook='admin_configurations_sidebar_menu']"
%li
= link_to t('admin.cache_settings.show.title'), main_app.admin_cache_settings_path
= link_to t('admin.cache_settings.edit.title'), main_app.edit_admin_cache_settings_path

View File

@@ -1,4 +0,0 @@
/ insert_bottom "[data-hook='admin_product_sub_tabs']"
-# Commenting out for now, until product import is finished
-# = tab :product_import, label: "Import", url: main_app.admin_product_import_path, match_path: '/product_import'

View File

@@ -1,3 +0,0 @@
/ insert_bottom "[data-hook='admin_product_sub_tabs']"
= tab :variant_overrides, url: main_app.admin_inventory_path, match_path: '/inventory'

View File

@@ -1,5 +0,0 @@
/ replace_contents '#shipping_method p#minstrs'
= form.label :special_instructions, t(:delivery_instructions)
%br/
= form.text_area :special_instructions, :cols => 40, :rows => 7

View File

@@ -1,2 +0,0 @@
/ replace_contents '#shipping_method legend'
= t(:delivery_method)

View File

@@ -1,16 +0,0 @@
<!-- insert_after '[data-hook="checkout_summary_box"]'
sequence :before => 'add_change_distributor_form_to_checkout_address' -->
<% # Add a new 'Save and Continue/Process My Order' button under Order Summary on the checkout pages %>
<div id="add_new_save_checkout_button" class="columns omega four">
<%= submit_tag @order.state == "payment" ? t(:process_my_order) : t(:save_and_continue),
:class => "continue button primary large",
:form=> "checkout_form_#{@order.state}" %>
<script>
//Show additional button only if form attribute is supported
if ($("#add_new_save_checkout_button input[type=submit]")[0].form) {
$("#add_new_save_checkout_button").show();
}
</script>
</div>

View File

@@ -1,16 +0,0 @@
/ replace_contents '#product-variants'
%h6.product-section-title= t(:variants)
%ul
- has_checked = false
- @product.variants.active(current_currency).each_with_index do |v,index|
- next if v.option_values.empty? || (!v.in_stock && !Spree::Config[:show_zero_stock_products])
- next if current_order_cycle.present? && !current_order_cycle.has_variant?(v) # All copied from spree apart from this line
- checked = !has_checked && (v.in_stock || Spree::Config[:allow_backorders])
- has_checked = true if checked
%li
= radio_button_tag "products[#{@product.id}]", v.id, checked, :disabled => !v.in_stock && !Spree::Config[:allow_backorders], 'data-price' => v.price_in(current_currency).display_price
%label{:for => ['products', @product.id, v.id].join('_')}
%span.variant-description= variant_options v
- if variant_price v
%span.price.diff= variant_price v

View File

@@ -1 +0,0 @@
/ remove '#taxon-crumbs'

View File

@@ -1,6 +1,19 @@
- content_for :page_title do
= t(:cache_settings)
= form_tag main_app.admin_cache_settings_path, :method => :put do
.field
= hidden_field_tag 'preferences[enable_products_cache?]', '0'
= check_box_tag 'preferences[enable_products_cache?]', '1', Spree::Config[:enable_products_cache?]
= label_tag nil, t('.enable_products_cache')
.form-buttons
= button t(:update), 'icon-refresh'
%br
%br
%h4= t(:cache_state)
%br
%table.index
%thead
%tr

View File

@@ -2,7 +2,7 @@
#{t('admin.product_import.title')}
= render partial: 'ams_data'
= render partial: 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'
.import-wrapper{ng: {app: 'admin.productImport', controller: 'ImportFormCtrl'}}

View File

@@ -1,7 +1,7 @@
- content_for :page_title do
#{t('admin.product_import.title')}
= render partial: 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'
= render 'upload_sidebar'

View File

@@ -0,0 +1,8 @@
= content_for :sub_menu do
%ul#sub_nav.inline-menu
= tab :products, match_path: '/products'
= tab :option_types, match_path: '/option_types'
= tab :properties
= tab :prototypes
= tab :variant_overrides, url: main_app.admin_inventory_path, match_path: '/inventory'
= tab :import, url: main_app.admin_product_import_path, match_path: '/product_import'

View File

@@ -5,4 +5,4 @@
%h1.page-title= t("admin.variant_overrides.index.title")
%a.with-tip{ 'data-powertip' => "#{t("admin.variant_overrides.index.description")}" }=t('admin.whats_this')
= render :partial => 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'

View File

@@ -4,9 +4,9 @@
.row
.small-12.columns
%header
%h2 {{'enterprise_about_headline' | t}}
%h2= t(".headline")
%h5
{{'enterprise_about_message' | t}}
= t(".message")
%span{ ng: { class: "{brick: !enterprise.is_primary_producer, turquoise: enterprise.is_primary_producer}" } }
{{ enterprise.name }}
@@ -14,33 +14,33 @@
.row
.small-12.columns
.alert-box.info{ "ofn-inline-alert" => true, ng: { show: "visible" } }
%h6{ "ng-bind" => "'enterprise_success' | t:{enterprise: enterprise.name}" }
%span {{'enterprise_registration_exit_message' | t}}
%h6{ "ng-bind" => "'registration.steps.about.success' | t:{enterprise: enterprise.name}" }
%span= t(".registration_exit_message")
%a.close{ ng: { click: "close()" } } &times;
.small-12.large-8.columns
.row
.small-12.columns
.field
%label{ for: 'enterprise_description' } {{'enterprise_description' | t}}:
%input.chunky{ id: 'enterprise_description', placeholder: "{{'enterprise_description_placeholder' | t}}", ng: { model: 'enterprise.description' } }
%label{ for: 'enterprise_description' }= t(".enterprise_description")
%input.chunky{ id: 'enterprise_description', placeholder: "{{'registration.steps.about.enterprise_description_placeholder' | t}}", ng: { model: 'enterprise.description' } }
.row
.small-12.columns
.field
%label{ for: 'enterprise_long_desc' } {{'enterprise_long_desc' | t}}:
%textarea.chunky{ id: 'enterprise_long_desc', rows: 6, placeholder: "{{'enterprise_long_desc_placeholder' | t}}", ng: { model: 'enterprise.long_description' } }
%small{ "ng-bind" => "'enterprise_long_desc_length' | t:{num: enterprise.long_description.length}" }
%label{ for: 'enterprise_long_desc' }= t(".enterprise_long_desc")
%textarea.chunky{ id: 'enterprise_long_desc', rows: 6, placeholder: "{{'registration.steps.about.enterprise_long_desc_placeholder' | t}}", ng: { model: 'enterprise.long_description' } }
%small{ "ng-bind" => "'registration.steps.about.enterprise_long_desc_length' | t:{num: enterprise.long_description.length}" }
.small-12.large-4.columns
.row
.small-12.columns
.field
%label{ for: 'enterprise_abn' } {{'enterprise_abn' | t}}:
%input.chunky{ id: 'enterprise_abn', placeholder: "{{'enterprise_abn_placeholder' | t}}", ng: { model: 'enterprise.abn' } }
%label{ for: 'enterprise_abn' }= t(".enterprise_abn")+":"
%input.chunky{ id: 'enterprise_abn', placeholder: "{{'registration.steps.about.enterprise_abn_placeholder' | t}}", ng: { model: 'enterprise.abn' } }
.row
.small-12.columns
.field
%label{ for: 'enterprise_acn' } {{'enterprise_acn' | t}}:
%input.chunky{ id: 'enterprise_acn', placeholder: "{{'enterprise_acn_placeholder' | t}}", ng: { model: 'enterprise.acn' } }
%label{ for: 'enterprise_acn' }= t(".enterprise_acn")+":"
%input.chunky{ id: 'enterprise_acn', placeholder: "{{'registration.steps.about.enterprise_acn_placeholder' | t}}", ng: { model: 'enterprise.acn' } }
.row
.small-12.columns
.field
@@ -50,7 +50,7 @@
%input{ id: 'enterprise_charges_sales_tax_false', type: 'radio', name: 'charges_sales_tax', value: 'false', required: true, ng: { model: 'enterprise.charges_sales_tax' } }
%label{ for: 'enterprise_charges_sales_tax_false' } {{'say_no' | t}}
%span.error.small-12.columns{ ng: { show: "about.charges_sales_tax.$error.required && submitted" } }
{{'enterprise_tax_required' | t}}
= t(".enterprise_tax_required")
.row.buttons.pad-top
.small-12.columns

View File

@@ -4,26 +4,26 @@
.row
.small-12.columns
%header
%h2 {{'registration_greeting' | t}}
%h5{ "ng-bind" => "'who_is_managing_enterprise' | t:{enterprise: enterprise.name}" }
%h2= t('registration.steps.introduction.registration_greeting')
%h5{ "ng-bind" => "'registration.steps.contact.who_is_managing_enterprise' | t:{enterprise: enterprise.name}" }
%form{ name: 'contact', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('type',contact)" } }
.row.content
.small-12.medium-12.large-7.columns
.row
.small-12.columns.field
%label{ for: 'enterprise_contact' } {{'enterprise.registration.modal.steps.contact.contact_field' | t}}:
%input.chunky.small-12.columns{ id: 'enterprise_contact', name: 'contact_name', required: true, placeholder: "{{'enterprise.registration.modal.steps.contact.contact_field_placeholder' | t}}", ng: { model: 'enterprise.contact_name' } }
%label{ for: 'enterprise_contact' }= t(".contact_field")
%input.chunky.small-12.columns{ id: 'enterprise_contact', name: 'contact_name', required: true, placeholder: "{{'registration.steps.contact.contact_field_placeholder' | t}}", ng: { model: 'enterprise.contact_name' } }
%span.error.small-12.columns{ ng: { show: "contact.contact_name.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.contact.contact_field_required' | t}}
= t(".contact_field_required")
.row
.small-12.columns.field
%label{ for: 'enterprise_email_address' } {{'admin.enterprises.form.contact.email_address' | t}}:
%label{ for: 'enterprise_email_address' }= t("admin.enterprises.form.contact.email_address")+":"
%input.chunky.small-12.columns{ id: 'enterprise_email_address', name: 'email_address', type: 'email', placeholder: t('admin.enterprises.form.contact.email_address_placeholder'), ng: { model: 'enterprise.email_address' } }
.row
.small-12.columns.field
%label{ for: 'enterprise_phone' } {{'enterprise.registration.modal.steps.contact.phone_field' | t}}:
%input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "{{'enterprise.registration.modal.steps.contact.phone_field_placeholder' | t}}", ng: { model: 'enterprise.phone' } }
%label{ for: 'enterprise_phone' }= t(".phone_field")+":"
%input.chunky.small-12.columns{ id: 'enterprise_phone', name: 'phone', placeholder: "{{'registration.steps.contact.phone_field_placeholder' | t}}", ng: { model: 'enterprise.phone' } }
.small-12.medium-12.large-5.hide-for-small-only
.row.buttons

View File

@@ -4,60 +4,59 @@
.row
.small-12.columns
%header
%h2 {{'enterprise.registration.modal.steps.details.headline' | t}}
%h5{ ng: { if: "::enterprise.type != 'own'" } } {{'enterprise.registration.modal.steps.details.enterprise' | t}}
%h5{ ng: { if: "::enterprise.type == 'own'" } } {{'enterprise.registration.modal.steps.details.producer' | t}}
%h2= t('.headline')
%h5{ ng: { if: "::enterprise.type != 'own'" } }= t(".enterprise")
%h5{ ng: { if: "::enterprise.type == 'own'" } }= t(".producer")
%form{ name: 'details', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "selectIfValid('contact',details)" } }
.row
.small-12.medium-9.large-12.columns.end
.field
%label{ for: 'enterprise_name', ng: { if: "::enterprise.type != 'own'" } } {{'enterprise.registration.modal.steps.details.enterprise_name_field' | t}}
%label{ for: 'enterprise_name', ng: { if: "::enterprise.type == 'own'" } } {{'enterprise.registration.modal.steps.details.producer_name_field' | t}}
%input.chunky{ id: 'enterprise_name', name: 'name', placeholder: "{{'enterprise.registration.modal.steps.details.producer_name_field_placeholder' | t}}", required: true, ng: { model: 'enterprise.name' } }
%label{ for: 'enterprise_name', ng: { if: "::enterprise.type != 'own'" } }= t(".enterprise_name_field")
%label{ for: 'enterprise_name', ng: { if: "::enterprise.type == 'own'" } }= t(".producer_name_field")
%input.chunky{ id: 'enterprise_name', name: 'name', placeholder: "{{'registration.steps.details.producer_name_field_placeholder' | t}}", required: true, ng: { model: 'enterprise.name' } }
%span.error{ ng: { show: "details.name.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.details.producer_name_field_error' | t}}
= t(".producer_name_field_error")
.row
.small-12.medium-9.large-6.columns
.field
%label{ for: 'enterprise_address' } {{'enterprise.registration.modal.steps.details.address1_field' | t}}
%input.chunky{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "{{'enterprise.registration.modal.steps.details.address1_field_placeholder' | t}}", required: true, ng: { model: 'enterprise.address.address1' } }
%label{ for: 'enterprise_address' }= t(".address1_field")
%input.chunky{ id: 'enterprise_address', name: 'address1', required: true, placeholder: "{{'registration.steps.details.address1_field_placeholder' | t}}", required: true, ng: { model: 'enterprise.address.address1' } }
%span.error{ ng: { show: "details.address1.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.details.address1_field_error' | t}}
= t(".address1_field_error")
.field
%label{ for: 'enterprise_address2' } {{'enterprise.registration.modal.steps.details.address2_field' | t}}
%label{ for: 'enterprise_address2' }= t(".address2_field")
%input.chunky{ id: 'enterprise_address2', name: 'address2', required: false, placeholder: "", required: false, ng: { model: 'enterprise.address.address2' } }
.small-12.medium-9.large-6.columns.end
.row
.small-12.medium-8.large-8.columns
.field
%label{ for: 'enterprise_city' } {{'enterprise.registration.modal.steps.details.suburb_field' | t}}
%input.chunky{ id: 'enterprise_city', name: 'city', required: true, placeholder: "{{'enterprise.registration.modal.steps.details.suburb_field_placeholder' | t}}", ng: { model: 'enterprise.address.city' } }
%label{ for: 'enterprise_city' }= t('.suburb_field')
%input.chunky{ id: 'enterprise_city', name: 'city', required: true, placeholder: "{{'registration.steps.details.suburb_field_placeholder' | t}}", ng: { model: 'enterprise.address.city' } }
%span.error{ ng: { show: "details.city.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.details.suburb_field_error' | t}}
= t(".suburb_field_error")
.small-12.medium-4.large-4.columns
.field
%label{ for: 'enterprise_zipcode' } {{'enterprise.registration.modal.steps.details.postcode_field' | t}}
%input.chunky{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "{{'enterprise.registration.modal.steps.details.postcode_field_placeholder' | t}}", ng: { model: 'enterprise.address.zipcode' } }
%label{ for: 'enterprise_zipcode' }= t(".postcode_field")
%input.chunky{ id: 'enterprise_zipcode', name: 'zipcode', required: true, placeholder: "{{'registration.steps.details.postcode_field_placeholder' | t}}", ng: { model: 'enterprise.address.zipcode' } }
%span.error{ ng: { show: "details.zipcode.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.details.postcode_field_error' | t}}
= t(".postcode_field_error")
.row
.small-12.medium-4.large-4.columns
.field
%label{ for: 'enterprise_state' } {{'enterprise.registration.modal.steps.details.state_field' | t}}
%label{ for: 'enterprise_state' }= t(".state_field")
%select.chunky{ id: 'enterprise_state', name: 'state', ng: { model: 'enterprise.address.state_id', options: 's.id as s.abbr for s in enterprise.country.states', show: 'countryHasStates()', required: 'countryHasStates()' } }
%span.error{ ng: { show: "details.state.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.details.state_field_error' | t}}
= t(".state_field_error")
.small-12.medium-8.large-8.columns
.field
%label{ for: 'enterprise_country' } {{'enterprise.registration.modal.steps.details.country_field' | t}}
%label{ for: 'enterprise_country' }= t(".country_field")
%select.chunky{ id: 'enterprise_country', name: 'country', required: true, ng: { init: "setDefaultCountry(#{Spree::Config[:default_country_id]})", model: 'enterprise.country', options: 'c as c.name for c in countries' } }
%span.error{ ng: { show: "details.country.$error.required && submitted" } }
{{'enterprise.registration.modal.steps.details.country_field_error' | t}}
= t(".country_field_error")
.row.buttons
.small-12.columns

View File

@@ -3,10 +3,10 @@
.row
.small-12.columns.pad-top
%header
%h2 {{'registration_finished_headline' | t}}
%h2= t(".headline")
.panel.callout
%p{ "ng-bind" => "'registration_finished_thanks' | t:{enterprise: enterprise.name}" }
%p {{'registration_finished_login' | t}}
%p{ "ng-bind" => "'registration.steps.finished.thanks' | t:{enterprise: enterprise.name}" }
%p= t(".login")
.row
.small-12.columns.text-center
%a.button.primary{ type: "button", href: "/" } {{'registration_finished_action' | t}} &gt;
%a.button.primary{ type: "button", href: "/" }= "#{t(".action")} >"

View File

@@ -2,35 +2,35 @@
.row
.small-12.columns
%header
%h2 {{'registration_greeting' | t}}
%h2= t(".registration_greeting")
%h4
%small
%i.ofn-i_040-hub
{{'registration_intro' | t}}
= t(".registration_intro")
.row{ 'data-equalizer' => true }
.small-12.medium-12.large-6.columns.pad-top{ 'data-equalizer-watch' => true }
%h5 {{'registration_checklist' | t}}:
%h5= t(".registration_checklist")+":"
%ul.check-list
%li
{{'registration_time' | t}}
= t(".registration_time")
%li
{{'registration_enterprise_address' | t}}
= t(".registration_enterprise_address")
%li
{{'registration_contact_details' | t}}
= t(".registration_contact_details")
%li
{{'registration_logo' | t}}
= t(".registration_logo")
%li
{{'registration_promo_image' | t}}
= t(".registration_promo_image")
%li
{{'registration_about_us' | t}}
= t(".registration_about_us")
.small-9.medium-8.large-5.columns.pad-top.end{ 'data-equalizer-watch' => true}
%h5
{{'registration_outcome_headline' | t}}
%p{ "ng-bind-html" => "t('registration_outcome1_html')" }
%p {{'registration_outcome2' | t}}
%p {{'registration_outcome3' | t}}
= t(".registration_outcome_headline")
%p= t(".registration_outcome1_html")
%p= t(".registration_outcome2")
%p= t(".registration_outcome3")
.row{'ng-init' => "tos_required=#{Spree::Config.enterprises_require_tos}" }
%hr
@@ -43,4 +43,4 @@
%label{for: "accept_terms"} #{t(:enterprise_tos_agree)}
.small-12.medium-6.columns
%input.button.primary.left{ type: "button", value: "{{'registration_action' | t}}", ng: { click: "select('details')", disabled: "tos_required && !tos_accepted", model: "tos_accepted"} }
%input.button.primary.left{ type: "button", value: "{{'registration.steps.introduction.registration_action' | t}}", ng: { click: "select('details')", disabled: "tos_required && !tos_accepted", model: "tos_accepted"} }

View File

@@ -2,16 +2,16 @@
.row
.small-12.columns
%header
%h2 {{'limit_reached_headline' | t}}
%h4 {{'limit_reached_message' | t}}
%h2= t(".headline")
%h4= t(".message")
.row
.small-12.medium-3.large-2.columns.text-right.hide-for-small-only
%img{:src => "/assets/potatoes.png"}
.small-12.medium-9.large-10.columns
%p
{{'limit_reached_text' | t}}
= t(".text")
%strong Open Food Network.
.row
.small-12.columns
%hr
%input.button.primary{ type: "button", value: "{{'limit_reached_action' | t}}", ng: { click: "close()" } }
%input.button.primary{ type: "button", value: "{{'registration.steps.limit_reached.action' | t}}", ng: { click: "close()" } }

View File

@@ -5,42 +5,42 @@
.row
.small-12.columns.center
%h4
{{'select_logo' | t}}
= t(".select_logo")
.row
.small-12.columns.center
%span.small
{{'logo_tip' | t}}
= t(".logo_tip")
.row.pad-top
.small-12.columns
.image-select.small-12.columns
%label.small-12.columns.button{ for: 'image-select' } {{'logo_label' | t}}
%label.small-12.columns.button{ for: 'image-select' }= t(".logo_label")
%input#image-select{ type: 'file', hidden: true, 'nv-file-select' => true, uploader: "imageUploader", options: '{ alias: imageStep }' }
.row.show-for-large-up
.large-12.columns
%span#or.large-12.columns
{{'action_or' | t}}
= t("action_or")
.row.show-for-large-up
.large-12.columns
#image-over{ 'nv-file-over' => true, uploader: "imageUploader" }
{{'logo_drag' | t}}
= t(".logo_drag")
.small-12.medium-12.large-6.columns
.row
.small-12.columns.center
.row
.small-12.columns.center
%h4
{{'review_logo' | t}}
= t(".review_logo")
.row
.small-12.columns.center
%span.small
{{'review_logo_tip' | t}}
= t(".review_logo_tip")
.row.pad-top
.small-12.columns.center
#image-placeholder.logo
%img{ ng: { show: "imageSrc() && !imageUploader.isUploading", src: '{{ imageSrc() }}' } }
.message{ ng: { hide: "imageSrc() || imageUploader.isUploading" } }
{{'logo_placeholder' | t}}
= t(".logo_placeholder")
.loading{ ng: { hide: "!imageUploader.isUploading" } }
%img.spinner{ src: "/assets/spinning-circles.svg" }
%br/
{{'uploading' | t}}
= t("registration.steps.images.uploading")

View File

@@ -3,42 +3,42 @@
.row
.small-12.columns.center
%h4
{{'select_promo_image' | t}}
= t(".select_promo_image")
.row
.small-12.medium-12.large-5.columns.center
.row
.small-12.columns.center
%span.small
{{'promo_image_tip' | t}}
= t(".promo_image_tip")
.row.pad-top
.small-12.columns
.image-select.small-12.columns
%label.small-12.columns.button{ for: 'image-select' } {{'promo_image_label' | t}}
%label.small-12.columns.button{ for: 'image-select' }= t(".promo_image_label")
%input#image-select{ type: 'file', hidden: true, 'nv-file-select' => true, uploader: "imageUploader", options: '{ alias: imageStep }' }
.large-2.columns
%span#or.horizontal.large-12.columns
{{'action_or' | t}}
= t("action_or")
.large-5.columns
#image-over{ 'nv-file-over' => true, uploader: "imageUploader" }
{{'promo_image_drag' | t}}
= t(".promo_image_drag")
.small-12.medium-12.large-12.columns.pad-top
.row
.small-12.columns.center
%h4
{{'review_promo_image' | t}}
= t(".review_promo_image")
.row
.small-12.columns.center
.row
.small-12.columns.center
%span.small
{{'review_promo_image_tip' | t}}
= t(".review_promo_image_tip")
.row.pad-top
.small-12.columns.center
#image-placeholder.promo
%img{ ng: { show: "imageSrc() && !imageUploader.isUploading", src: '{{ imageSrc() }}' } }
.message{ ng: { hide: "imageSrc() || imageUploader.isUploading" } }
{{'promo_image_placeholder' | t}}
= t(".promo_image_placeholder")
.loading{ ng: { hide: "!imageUploader.isUploading" } }
%img.spinner{ src: "/assets/spinning-circles.svg" }
%br/
{{'uploading' | t}}
= t("registration.steps.images.uploading")

View File

@@ -5,8 +5,8 @@
.row
.small-12.columns
%header
%h2 {{'enterprise_final_step' | t}}
%h5{ "ng-bind" => "'enterprise_social_text' | t:{enterprise: enterprise.name}" }
%h2= t(".enterprise_final_step")
%h5{ "ng-bind" => "'registration.steps.social.enterprise_social_text' | t:{enterprise: enterprise.name}" }
%form{ name: 'social', novalidate: true, ng: { controller: "RegistrationFormCtrl", submit: "update('finished',social)" } }
.row.content
@@ -14,29 +14,29 @@
.row
.small-12.columns
.field
%label{ for: 'enterprise_website' } {{'website' | t}}:
%input.chunky{ id: 'enterprise_website', placeholder: "{{'website_placeholder' | t}}", ng: { model: 'enterprise.website' } }
%label{ for: 'enterprise_website' }= t(".website")+":"
%input.chunky{ id: 'enterprise_website', placeholder: "{{'registration.steps.social.website_placeholder' | t}}", ng: { model: 'enterprise.website' } }
.row
.small-12.columns
.field
%label{ for: 'enterprise_facebook' } {{'facebook' | t}}:
%input.chunky{ id: 'enterprise_facebook', placeholder: "{{'facebook_placeholder' | t}}", ng: { model: 'enterprise.facebook' } }
%label{ for: 'enterprise_facebook' }= t(".facebook")+":"
%input.chunky{ id: 'enterprise_facebook', placeholder: "{{'registration.steps.social.facebook_placeholder' | t}}", ng: { model: 'enterprise.facebook' } }
.row
.small-12.columns
.field
%label{ for: 'enterprise_linkedin' } {{'linkedin' | t}}:
%input.chunky{ id: 'enterprise_linkedin', placeholder: "{{'linkedin_placeholder' | t}}", ng: { model: 'enterprise.linkedin' } }
%label{ for: 'enterprise_linkedin' }= t(".linkedin")+":"
%input.chunky{ id: 'enterprise_linkedin', placeholder: "{{'registration.steps.social.linkedin_placeholder' | t}}", ng: { model: 'enterprise.linkedin' } }
.small-12.large-5.columns
.row
.small-12.columns
.field
%label{ for: 'enterprise_twitter' } {{'twitter' | t}}:
%input.chunky{ id: 'enterprise_twitter', placeholder: "{{'twitter_placeholder' | t}}", ng: { model: 'enterprise.twitter' } }
%label{ for: 'enterprise_twitter' }= t(".twitter")+":"
%input.chunky{ id: 'enterprise_twitter', placeholder: "{{'registration.steps.social.twitter_placeholder' | t}}", ng: { model: 'enterprise.twitter' } }
.row
.small-12.columns
.field
%label{ for: 'enterprise_instagram' } {{'instagram' | t}}:
%input.chunky{ id: 'enterprise_instagram', placeholder: "{{'instagram_placeholder' | t}}", ng: { model: 'enterprise.instagram' } }
%label{ for: 'enterprise_instagram' }= t(".instagram")+":"
%input.chunky{ id: 'enterprise_instagram', placeholder: "{{'registration.steps.social.instagram_placeholder' | t}}", ng: { model: 'enterprise.instagram' } }
.row.buttons
.small-12.columns

View File

@@ -1,5 +1,5 @@
%script{ type: "text/ng-template", id: "registration/steps.html" }
.row#progress-bar
.small-12.medium-2.columns.item{ ng: { repeat: 'step in steps', class: "{active: (currentStep() == step),'show-for-medium-up': (currentStep() != step)}" } }
{{ $index+1 + ". " + ('enterprise.registration.modal.steps.' + step + '.title' | t) }}
{{ $index+1 + ". " + ('registration.steps.' + step + '.title' | t) }}

View File

@@ -1,4 +1,4 @@
= render :partial => 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'
= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => 'Group Buy Options' }
= render :partial => 'spree/shared/error_messages', :locals => { :target => @product }

View File

@@ -7,6 +7,6 @@
%li#new_product_link
= button_link_to t(:new_product), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_product' }
= render :partial => 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'
%div#new_product(data-hook)

View File

@@ -1,4 +1,4 @@
= render :partial => 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'
= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => 'Product Distributions' }
= render :partial => 'spree/shared/error_messages', :locals => { :target => @product }

View File

@@ -1,4 +1,4 @@
= render :partial => 'spree/admin/shared/product_sub_menu'
= render partial: 'admin/shared/product_sub_menu'
= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => t(:Search) }
= render :partial => 'spree/shared/error_messages', :locals => { :target => @product }

View File

@@ -0,0 +1,5 @@
Bugsnag.configure do |config|
config.api_key = ENV['BUGSNAG_API_KEY']
config.notify_release_stages = %w(production staging)
config.use_ssl = true
end

View File

@@ -31,6 +31,16 @@ ca:
on_demand_but_count_on_hand_set: "ha d'estar en blanc si és sota demanda"
limited_stock_but_no_count_on_hand: "cal especificar-se perquè força existències limitades"
activemodel:
attributes:
order_management/reports/enterprise_fee_summary/parameters:
start_at: "Començar"
end_at: "Acabar"
distributor_ids: "Grups"
producer_ids: "Productors"
order_cycle_ids: "Cicles de comanda"
enterprise_fee_ids: "Noms de les comissions"
shipping_method_ids: "Mètodes d'enviament"
payment_method_ids: "Mètodes de Pagament"
errors:
models:
subscription_validator:
@@ -74,6 +84,13 @@ ca:
models:
order_cycle:
cloned_order_cycle_name: "CÒPIA DE %{order_cycle}"
validators:
date_time_string_validator:
not_string_error: "ha de ser una seqüència"
invalid_format_error: "ha de ser vàlid"
integer_array_validator:
not_array_error: "ha de ser una matriu"
invalid_element_error: "ha de contenir només nombres enters vàlids"
enterprise_mailer:
confirmation_instructions:
subject: "Sisplau, confirma l'adreça electrònica d'%{enterprise}"
@@ -318,7 +335,7 @@ ca:
business_model_configuration:
edit:
business_model_configuration: "Model de sostenibilitat"
business_model_configuration_tip: "Configureu la tarifa què es cobrarà a les botigues cada mes per utilitzar la Xarxa Open Food."
business_model_configuration_tip: "Configureu la tarifa què es cobrarà a les botigues cada mes per utilitzar Open Food Network."
bill_calculation_settings: "Configuració del càlcul de ticket"
bill_calculation_settings_tip: "Ajusteu la quantitat que es facturarà a les organitzacions cada mes per utilitzar l'OFN."
shop_trial_length: "Durada de la prova de la botiga (dies)"
@@ -418,9 +435,9 @@ ca:
user_guide: Guia de l'usuari
enterprise_fees:
index:
title: Tarifes de l'organització
title: Comissions de l'organització
enterprise: Organització
fee_type: Tipus de tarifa
fee_type: Tipus de comissió
name: Nom
tax_category: Categoria d'impostos
calculator: Calculadora
@@ -634,8 +651,8 @@ ca:
website_placeholder: 'p. ex.: www.hortajosepribes.com'
enterprise_fees:
name: Nom
fee_type: Tipus de tarifa
manage_fees: Gestioneu les tarifes de l'organització
fee_type: Tipus de comissió
manage_fees: Gestioneu les comissions de l'organització
no_fees_yet: Encara no tens cap tipus de comissió de l'organització
create_button: Crea'n una ara
images:
@@ -737,7 +754,7 @@ ca:
title: Connectar amb Stripe
part1: Stripe és un servei de processament de pagaments que permet que les botigues de l'OFN acceptin els pagaments amb targeta de crèdit de les consumidores.
part2: Per utilitzar aquesta funció heu de connectar el vostre compte Stripe a l'OFN. Si feu clic a "Accepto", us redirigirem al lloc web de Stripe on podeu connectar un compte Stripe existent o bé crear-ne un si encara no en teniu cap.
part3: Això permetrà que Open Food Network accepti pagaments amb targeta de crèdit de consumidores en nom vostre. Tingueu en compte que haureu de mantenir el vostre propi compte de Stripe, pagar-ne les tarifes i mantenir el servei a les consumidores pel teu compte.
part3: Això permetrà que Open Food Network accepti pagaments amb targeta de crèdit de consumidores en nom vostre. Tingueu en compte que haureu de mantenir el vostre propi compte de Stripe, pagar-ne les comissions i mantenir el servei a les consumidores pel teu compte.
i_agree: Accepto
cancel: Cancel·lar
tag_rules:
@@ -775,7 +792,7 @@ ca:
payment_methods_tip: Aquesta organització no té mètodes de pagament
shipping_methods: Mètodes d'enviament
shipping_methods_tip: 'Aquesta organització té mètodes d''enviament '
enterprise_fees: Honoraris de l'organització
enterprise_fees: Comissions de l'organització
enterprise_fees_tip: Aquesta organització no té comissions
admin_index:
name: Nom
@@ -873,7 +890,7 @@ ca:
incoming: Entrant
supplier: Proveïdora
receival_details: Detalls de recepció
fees: Tarifes
fees: Comissions
outgoing: Sortint
distributor: Distribuïdora
products: Productes
@@ -911,7 +928,7 @@ ca:
customer_instructions: Instruccions de la consumidora
customer_instructions_placeholder: Notes de recollida o de lliurament
products: Productes
fees: Tarifes
fees: Comissions
destroy_errors:
orders_present: Una consumidora ha seleccionat aquest Cicle de Comanda i no es pot esborrar. Per evitar que les consumidores hi accedeixin, tanqueu-lo.
schedule_present: Aquest cicle de comanda està vinculat a una programació i no es pot esborrar. Desenllaça o suprimeix primer la programació.
@@ -996,6 +1013,9 @@ ca:
description: Factures per a la importació a Xero
packing:
name: Informes d'embalatge
enterprise_fee_summary:
name: "Resum de les comissions de l'organització"
description: "Resum de les comissions de l'organització recollides"
subscriptions:
subscriptions: Subscripcions
new: Nova subscripció
@@ -1883,7 +1903,7 @@ ca:
shipping_method_destroy_error: "Aquest mètode d'enviament no es pot esborrar perquè s'hi fa referència en una comanda: %{number}."
accounts_and_billing_task_already_running_error: "Ja s'està executant una tasca, espera fins que hagi acabat"
accounts_and_billing_start_task_notice: "Tasca en cua"
fees: "Tarifes"
fees: "Comissions"
item_cost: "Cost de l'article"
bulk: "A granel"
shop_variant_quantity_min: "min"
@@ -1955,7 +1975,7 @@ ca:
process_my_order: "Processa la meva comanda"
delivery_instructions: Instruccions de lliurament
delivery_method: Mètode de lliurament
fee_type: "Tipus de tarifa"
fee_type: "Tipus de comissió"
tax_category: "Categoria d'impostos"
calculator: "Calculadora"
calculator_values: "Valors de la calculadora"
@@ -2000,7 +2020,6 @@ ca:
spree_admin_enterprises_none_text: "Encara no tens cap organització"
spree_admin_enterprises_tabs_hubs: "GRUPS"
spree_admin_enterprises_producers_manage_products: "GESTIONA ELS PRODUCTES"
spree_admin_enterprises_any_active_products_text: "No tens cap producte actiu."
spree_admin_enterprises_create_new_product: "CREA UN NOU PRODUCTE"
spree_admin_single_enterprise_alert_mail_confirmation: "Si us plau confirma l'adreça de correu electrònic de"
spree_admin_single_enterprise_alert_mail_sent: "Hem enviat un correu electrònic a"
@@ -2127,7 +2146,7 @@ ca:
report_header_sales_tax: "Impost sobre vendes (%{currency_symbol})"
report_header_delivery_charge: "Càrrec de lliurament (%{currency_symbol})"
report_header_tax_on_delivery: "Impost sobre el lliurament (%{currency_symbol})"
report_header_tax_on_fees: "Impost sobre les tarifes (%{currency_symbol})"
report_header_tax_on_fees: "Impost sobre les comissions (%{currency_symbol})"
report_header_total_tax: "Impost total (%{currency_symbol})"
report_header_enterprise: Organització
report_header_customer: Consumidora
@@ -2248,7 +2267,7 @@ ca:
shipping: "Enviament"
shipping_methods: "Mètodes d'enviament"
payment_methods: "Mètodes de Pagament"
payment_method_fee: "Tarifa de transacció"
payment_method_fee: "Comissió de transacció"
inventory_settings: "Configuració de l'inventari"
tag_rules: "Regles d'etiqueta"
shop_preferences: "Preferències de la botiga"
@@ -2526,6 +2545,45 @@ ca:
producers:
signup:
start_free_profile: "Comença amb un perfil gratuït i amplia'l quan estiguis preparada."
order_management:
reports:
enterprise_fee_summary:
date_end_before_start_error: "ha de ser després de l'inici"
parameter_not_allowed_error: "No esteu autoritzats a utilitzar un o més filtres seleccionats per a aquest informe."
fee_calculated_on_transfer_through_all: "Tots"
fee_calculated_on_transfer_through_entire_orders: "Comandes completades a través de"
tax_category_various: "Varis"
fee_type:
payment_method: "Transacció de pagament"
shipping_method: "Enviament"
fee_placements:
supplier: "Entrant"
distributor: "Sortint"
coordinator: "Coordinador"
tax_category_name:
shipping_instance_rate: "Tarifa de la plataforma"
formats:
csv:
header:
fee_type: "Tipus de comissió"
enterprise_name: "Propietària de l'organització"
fee_name: "Nom de la comissió"
customer_name: "Consumidora"
fee_placement: "Col·locació de comissions"
fee_calculated_on_transfer_through_name: "Càlcul de comissions a través de transferència"
tax_category_name: "Categoria d'impostos"
total_amount: "€€ SUM"
html:
header:
fee_type: "Tipus de comissió"
enterprise_name: "Propietària de l'organització"
fee_name: "Nom de la comissió"
customer_name: "Consumidora"
fee_placement: "Col·locació de comissions"
fee_calculated_on_transfer_through_name: "Càlcul de comissions a través de transferència"
tax_category_name: "Categoria d'impostos"
total_amount: "€€ SUM"
invalid_filter_parameters: "Els filtres que heu seleccionat per a aquest informe no són vàlids."
spree:
email: Correu electrònic
account_updated: "Compte actualitzat!"
@@ -2569,6 +2627,11 @@ ca:
distributor: "Distribuïdora:"
order_cycle: "Cicle de comanda:"
overview:
products:
active_products:
zero: "No tens cap producte actiu."
one: "Teniu un producte actiu"
other: "Teniu %{count} productes actius"
order_cycles:
order_cycles: "Cicles de comanda"
order_cycles_tip: "Els cicles de comanda determinen quan i on els teus productes estan disponibles per a les consumidores."
@@ -2642,6 +2705,14 @@ ca:
bulk_coop_allocation: 'Compra grupal - Assignació'
bulk_coop_packing_sheets: 'Compra grupal - Fulls de preparació de cistelles'
bulk_coop_customer_payments: 'Compra grupal - Pagaments de les consumidores'
enterprise_fee_summaries:
filters:
date_range: "Interval de dates"
report_format_csv: "Descarrega com a CSV"
generate_report: "Generar informe"
report:
none: "No productora"
select_and_search: "Seleccioneu els filtres i feu clic a GENERAR INFORME per accedir a les dades."
users:
index:
listing_users: "Llistat d'usuàries"

View File

@@ -230,6 +230,7 @@ en:
enterprise_groups: Groups
reports: Reports
variant_overrides: Inventory
import: Import
spree_products: Spree Products
all: All
current: Current
@@ -350,13 +351,14 @@ en:
enable_localized_number: "Use the international thousand/decimal separator logic"
cache_settings:
show:
title: Caching
distributor: Distributor
order_cycle: Order Cycle
status: Status
diff: Diff
error: Error
edit:
title: "Caching"
distributor: "Distributor"
order_cycle: "Order Cycle"
status: "Status"
diff: "Diff"
error: "Error"
enable_products_cache: "Enable Products Cache?"
invoice_settings:
edit:
@@ -1808,24 +1810,60 @@ See the %{link} to find out more about %{sitename}'s features and to start using
choose_password: "Choose a password"
confirm_password: "Confirm password"
action_signup: "Sign up now"
welcome_to_ofn: "Welcome to the Open Food Network!"
signup_or_login: "Start By Signing Up (or logging in)"
have_an_account: "Already have an account?"
action_login: "Log in now."
forgot_password: "Forgot Password?"
password_reset_sent: "An email with instructions on resetting your password has been sent!"
reset_password: "Reset password"
registration_greeting: "Greetings!"
who_is_managing_enterprise: "Who is responsible for managing %{enterprise}?"
update_and_recalculate_fees: "Update And Recalculate Fees"
registration:
steps:
images:
continue: "Continue"
back: "Back"
headline: "Thanks!"
description: "Let's upload some pretty pictures so your profile looks great! :)"
introduction:
registration_greeting: "Hi there!"
registration_intro: "You can now create a profile for your Producer or Hub"
registration_checklist: "You'll need"
registration_time: "5-10 minutes"
registration_enterprise_address: "Enterprise address"
registration_contact_details: "Primary contact details"
registration_logo: "Your logo image"
registration_promo_image: "Landscape image for your profile"
registration_about_us: "'About Us' text"
registration_outcome_headline: "What do I get?"
registration_outcome1_html: "Your profile helps people <strong>find</strong> and <strong>contact</strong> you on the Open Food Network."
registration_outcome2: "Use this space to tell the story of your enterprise, to help drive connections to your social and online presence."
registration_outcome3: "It's also the first step towards trading on the Open Food Network, or opening an online store."
registration_action: "Let's get started!"
details:
title: "Details"
headline: "Let's Get Started"
enterprise: "Woot! First need to know a little bit about your enterprise:"
producer: "Woot! First we need to know a little bit about your farm:"
enterprise_name_field: "Enterprise Name:"
producer_name_field: "Farm Name:"
producer_name_field_placeholder: "e.g. Charlie's Awesome Farm"
producer_name_field_error: "Please choose a unique name for your enterprise"
address1_field: "Address line 1:"
address1_field_placeholder: "e.g. 123 Cranberry Drive"
address1_field_error: "Please enter an address"
address2_field: "Address line 2:"
suburb_field: "Suburb:"
suburb_field_placeholder: "e.g. Northcote"
suburb_field_error: "Please enter a suburb"
postcode_field: "Postcode:"
postcode_field_placeholder: "e.g. 3070"
postcode_field_error: "Postcode required"
state_field: "State:"
state_field_error: "State required"
country_field: "Country:"
country_field_error: "Please select a country"
contact:
title: "Contact"
who_is_managing_enterprise: "Who is responsible for managing %{enterprise}?"
contact_field: "Primary Contact"
contact_field_placeholder: "Contact Name"
contact_field_required: "You need to enter a primary contact."
phone_field: "Phone number"
phone_field_placeholder: "eg. (03) 1234 5678"
type:
title: "Type"
headline: "Last step to add %{enterprise}!"
question: "Are you a producer?"
yes_producer: "Yes, I'm a producer"
@@ -1834,161 +1872,75 @@ See the %{link} to find out more about %{sitename}'s features and to start using
yes_producer_help: "Producers make yummy things to eat and/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it."
no_producer_help: "If youre not a producer, youre probably someone who sells and distributes food. You might be a hub, coop, buying group, retailer, wholesaler or other."
create_profile: "Create Profile"
enterprise:
registration:
modal:
steps:
details:
title: 'Details'
headline: "Let's Get Started"
enterprise: "Woot! First we need to know a little bit about your enterprise:"
producer: "Woot! First we need to know a little bit about your farm:"
enterprise_name_field: "Enterprise Name:"
producer_name_field: "Farm Name:"
producer_name_field_placeholder: "e.g. Charlie's Awesome Farm"
producer_name_field_error: "Please choose a unique name for your enterprise"
address1_field: "Address line 1:"
address1_field_placeholder: "e.g. 123 Cranberry Drive"
address1_field_error: "Please enter an address"
address2_field: "Address line 2:"
suburb_field: "Suburb:"
suburb_field_placeholder: "e.g. Northcote"
suburb_field_error: "Please enter a suburb"
postcode_field: "Postcode:"
postcode_field_placeholder: "e.g. 3070"
postcode_field_error: "Postcode required"
state_field: "State:"
state_field_error: "State required"
country_field: "Country:"
country_field_error: "Please select a country"
contact:
title: 'Contact'
contact_field: 'Primary Contact'
contact_field_placeholder: 'Contact Name'
contact_field_required: "You need to enter a primary contact."
email_field: 'Email address'
email_field_placeholder: 'eg. charlie@thefarm.com'
phone_field: 'Phone number'
phone_field_placeholder: 'eg. (03) 1234 5678'
type:
title: 'Type'
about:
title: 'About'
images:
title: 'Images'
social:
title: 'Social'
# TODO: Remove these once the enterprise.registration.modal keys are translated
enterprise_contact: "Primary Contact"
enterprise_contact_placeholder: "Contact Name"
enterprise_contact_required: "You need to enter a primary contact."
enterprise_email_address: "Email address"
enterprise_email_placeholder: "eg. charlie@thefarm.com"
enterprise_phone: "Phone number"
enterprise_phone_placeholder: "eg. (03) 1234 5678"
# END
about:
title: "About"
headline: "Nice one!"
message: "Now let's flesh out the details about"
success: "Success! %{enterprise} added to the Open Food Network"
registration_exit_message: "If you exit this wizard at any stage, you can continue to create your profile by going to the admin interface."
enterprise_description: "Short Description"
enterprise_description_placeholder: "A short sentence describing your enterprise"
enterprise_long_desc: "Long Description"
enterprise_long_desc_placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words."
enterprise_long_desc_length: "%{num} characters / up to 600 recommended"
enterprise_abn: "ABN"
enterprise_abn_placeholder: "eg. 99 123 456 789"
enterprise_acn: "ACN"
enterprise_acn_placeholder: "eg. 123 456 789"
enterprise_tax_required: "You need to make a selection."
images:
title: "Images"
headline: "Thanks!"
description: "Let's upload some pretty pictures so your profile looks great! :)"
uploading: "Uploading..."
continue: "Continue"
back: "Back"
logo:
select_logo: "Step 1. Select Logo Image"
logo_tip: "Tip: Square images will work best, preferably at least 300×300px"
logo_label: "Choose a logo image"
logo_drag: "Drag and drop your logo here"
review_logo: "Step 2. Review Your Logo"
review_logo_tip: "Tip: for best results, your logo should fill the available space"
logo_placeholder: "Your logo will appear here for review once uploaded"
promo:
select_promo_image: "Step 3. Select Promo Image"
promo_image_tip: "Tip: Shown as a banner, preferred size is 1200×260px"
promo_image_label: "Choose a promo image"
promo_image_drag: "Drag and drop your promo here"
review_promo_image: "Step 4. Review Your Promo Banner"
review_promo_image_tip: "Tip: for best results, your promo image should fill the available space"
promo_image_placeholder: "Your logo will appear here for review once uploaded"
social:
title: "Social"
enterprise_final_step: "Final step!"
enterprise_social_text: "How can people find %{enterprise} online?"
website: "Website"
website_placeholder: "eg. openfoodnetwork.org.au"
facebook: "Facebook"
facebook_placeholder: "eg. www.facebook.com/PageNameHere"
linkedin: "LinkedIn"
linkedin_placeholder: "eg. www.linkedin.com/YourNameHere"
twitter: "Twitter"
twitter_placeholder: "eg. @twitter_handle"
instagram: "Instagram"
instagram_placeholder: "eg. @instagram_handle"
limit_reached:
headline: "Oh no!"
message: "You have reached the limit!"
text: "You have reached the limit for the number of enterprises you are allowed to own on the"
action: "Return to the homepage"
finished:
headline: "Finished!"
thanks: "Thanks for filling out the details for %{enterprise}."
login: "You can change or update your enterprise at any stage by logging into Open Food Network and going to Admin."
action: "Open Food Network home"
back: "Back"
continue: "Continue"
limit_reached_headline: "Oh no!"
limit_reached_message: "You have reached the limit!"
limit_reached_text: "You have reached the limit for the number of enterprises you are allowed to own on the"
limit_reached_action: "Return to the homepage"
select_promo_image: "Step 3. Select Promo Image"
promo_image_tip: "Tip: Shown as a banner, preferred size is 1200×260px"
promo_image_label: "Choose a promo image"
action_or: "OR"
promo_image_drag: "Drag and drop your promo here"
review_promo_image: "Step 4. Review Your Promo Banner"
review_promo_image_tip: "Tip: for best results, your promo image should fill the available space"
promo_image_placeholder: "Your logo will appear here for review once uploaded"
uploading: "Uploading..."
select_logo: "Step 1. Select Logo Image"
logo_tip: "Tip: Square images will work best, preferably at least 300×300px"
logo_label: "Choose a logo image"
logo_drag: "Drag and drop your logo here"
review_logo: "Step 2. Review Your Logo"
review_logo_tip: "Tip: for best results, your logo should fill the available space"
logo_placeholder: "Your logo will appear here for review once uploaded"
enterprise_about_headline: "Nice one!"
enterprise_about_message: "Now let's flesh out the details about"
enterprise_success: "Success! %{enterprise} added to the Open Food Network "
enterprise_registration_exit_message: "If you exit this wizard at any stage, you can continue to create your profile by going to the admin interface."
enterprise_description: "Short Description"
enterprise_description_placeholder: "A short sentence describing your enterprise"
enterprise_long_desc: "Long Description"
enterprise_long_desc_placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words."
enterprise_long_desc_length: "%{num} characters / up to 600 recommended"
enterprise_abn: "ABN"
enterprise_abn_placeholder: "eg. 99 123 456 789"
enterprise_acn: "ACN"
enterprise_acn_placeholder: "eg. 123 456 789"
enterprise_tax_required: "You need to make a selection."
enterprise_final_step: "Final step!"
enterprise_social_text: "How can people find %{enterprise} online?"
website: "Website"
website_placeholder: "eg. openfoodnetwork.org.au"
facebook: "Facebook"
facebook_placeholder: "eg. www.facebook.com/PageNameHere"
linkedin: "LinkedIn"
linkedin_placeholder: "eg. www.linkedin.com/YourNameHere"
twitter: "Twitter"
twitter_placeholder: "eg. @twitter_handle"
instagram: "Instagram"
instagram_placeholder: "eg. @instagram_handle"
registration_greeting: "Hi there!"
registration_intro: "You can now create a profile for your Producer or Hub"
registration_action: "Let's get started!"
registration_checklist: "You'll need"
registration_time: "5-10 minutes"
registration_enterprise_address: "Enterprise address"
registration_contact_details: "Primary contact details"
registration_logo: "Your logo image"
registration_promo_image: "Landscape image for your profile"
registration_about_us: "'About Us' text"
registration_outcome_headline: "What do I get?"
registration_outcome1_html: "Your profile helps people <strong>find</strong> and <strong>contact</strong> you on the Open Food Network."
registration_outcome2: "Use this space to tell the story of your enterprise, to help drive connections to your social and online presence. "
registration_outcome3: "It's also the first step towards trading on the Open Food Network, or opening an online store."
registration_finished_headline: "Finished!"
registration_finished_thanks: "Thanks for filling out the details for %{enterprise}."
registration_finished_login: "You can change or update your enterprise at any stage by logging into Open Food Network and going to Admin."
registration_finished_action: "Open Food Network home"
registration_contact_name: 'Contact Name'
enterprise_limit: Enterprise Limit
# TODO: Remove these once the enterprise.registration.modal keys are translated
registration_type_headline: "Last step to add %{enterprise}!"
registration_type_question: "Are you a producer?"
registration_type_producer: "Yes, I'm a producer"
registration_type_no_producer: "No, I'm not a producer"
registration_type_error: "Please choose one. Are you are producer?"
registration_type_producer_help: "Producers make yummy things to eat and/or drink. You're a producer if you grow it, raise it, brew it, bake it, ferment it, milk it or mould it."
registration_type_no_producer_help: "If youre not a producer, youre probably someone who sells and distributes food. You might be a hub, coop, buying group, retailer, wholesaler or other."
# END
# TODO: Remove these once the enterprise.registration.modal keys are translated
registration_detail_headline: "Let's Get Started"
registration_detail_enterprise: "Woot! First we need to know a little bit about your enterprise:"
registration_detail_producer: "Woot! First we need to know a little bit about your farm:"
registration_detail_name_enterprise: "Enterprise Name:"
registration_detail_name_producer: "Farm Name:"
registration_detail_name_placeholder: "e.g. Charlie's Awesome Farm"
registration_detail_name_error: "Please choose a unique name for your enterprise"
registration_detail_address1: "Address line 1:"
registration_detail_address1_placeholder: "e.g. 123 Cranberry Drive"
registration_detail_address1_error: "Please enter an address"
registration_detail_address2: "Address line 2:"
registration_detail_suburb: "Suburb:"
registration_detail_suburb_placeholder: "e.g. Northcote"
registration_detail_suburb_error: "Please enter a suburb"
registration_detail_postcode: "Postcode:"
registration_detail_postcode_placeholder: "e.g. 3070"
registration_detail_postcode_error: "Postcode required"
registration_detail_state: "State:"
registration_detail_state_error: "State required"
registration_detail_country: "Country:"
registration_detail_country_error: "Please select a country"
# END
shipping_method_destroy_error: "That shipping method cannot be deleted as it is referenced by an order: %{number}."
fees: "Fees"
item_cost: "Item cost"
@@ -2556,11 +2508,43 @@ See the %{link} to find out more about %{sitename}'s features and to start using
orders:
index:
per_page: "%{results} per page"
view_file: View File
compiling_invoices: Compiling Invoices
bulk_invoice_created: Bulk Invoice created
bulk_invoice_failed: Failed to create Bulk Invoice
please_wait: Please wait until the PDF is ready before closing this modal.
view_file: "View File"
compiling_invoices: "Compiling Invoices"
bulk_invoice_created: "Bulk Invoice created"
bulk_invoice_failed: "Failed to create Bulk Invoice"
please_wait: "Please wait until the PDF is ready before closing this modal."
order_state:
address: "address"
adjustments: "adjustments"
awaiting_return: "awaiting return"
canceled: "cancelled"
cart: "cart"
complete: "complete"
confirm: "confirm"
delivery: "delivery"
paused: "paused"
payment: "payment"
pending: "pending"
resumed: "resumed"
returned: "returned"
skrill: "skrill"
shipment_states:
backorder: "backorder"
partial: "partial"
pending: "pending"
ready: "ready"
shipped: "shipped"
payment_states:
balance_due: "balance due"
completed: "completed"
checkout: "checkout"
credit_owed: "credit owed"
failed: "failed"
paid: "paid"
pending: "pending"
processing: "processing"
void: "void"
invalid: "invalid"
resend_user_email_confirmation:
resend: "Resend"
sending: "Resend..."
@@ -2634,6 +2618,12 @@ See the %{link} to find out more about %{sitename}'s features and to start using
spree:
users:
order: "Order"
registration:
welcome_to_ofn: "Welcome to the Open Food Network!"
signup_or_login: "Start By Signing Up (or logging in)"
have_an_account: "Already have an account?"
action_login: "Log in now."
producers:
signup:
start_free_profile: "Start with a free profile, and expand when you're ready!"
@@ -2678,7 +2668,194 @@ See the %{link} to find out more about %{sitename}'s features and to start using
total_amount: "$$ SUM"
invalid_filter_parameters: "The filters you selected for this report are invalid."
order: "Order"
distribution: "Distribution"
order_details: "Order Details"
customer_details: "Customer Details"
adjustments: "Adjustments"
payments: "Payments"
payment: "Payment"
payment_method: "Payment Method"
shipment: "Shipment"
shipment_inc_vat: "Shipment including VAT"
shipping_tax_rate: "Shipping Tax Rate"
category: "Category"
delivery: "Delivery"
temperature_controlled: "Temperature Controlled"
new_product: "New Product"
administration: "Administration"
logged_in_as: "Logged in as"
account: "Account"
logout: "Logout"
date_range: "Date Range"
status: "status"
new: "New"
start: "Start"
stop: "Stop"
first: "First"
previous: "Previous"
last: "Last"
spree:
your_order_is_empty_add_product: "Your order is empty, please search for and add a product above"
add_product: "Add Product"
name_or_sku: "Name or SKU (enter at least first 4 characters of product name)"
resend: Resend
back_to_orders_list: Back To Orders List
select_stock: "Select stock"
location: "Location"
count_on_hand: "Count On Hand"
quantity: "Quantity"
package_from: "package from"
item_description: "Item Description"
price: "Price"
total: "Total"
edit: "Edit"
split: "Split"
delete: "Delete"
cannot_set_shipping_method_without_address: "Cannot set shipping method until customer details are provided."
no_tracking_present: "No tracking details provided."
order_total: "Order Total"
customer_details: "Customer Details"
customer_search: "Customer Search"
choose_a_customer: "Choose a customer"
account: "Account"
billing_address: "Billing Address"
shipping_address: "Shipping Address"
first_name: "First name"
last_name: "Last name"
street_address: "Street Address"
street_address_2: "Street Address (cont'd)"
city: "City"
zip: "Zip"
country: "Country"
state: "State"
phone: "Phone"
update: "Update"
use_billing_address: "Use Billing Address"
adjustments: "Adjustments"
continue: "Continue"
fill_in_customer_info: "Please fill in customer info"
new_payment: "New Payment"
configurations: "Configurations"
general_settings: "General Settings"
site_name: "Site Name"
site_url: "Site URL"
default_seo_title: "Default Seo Title"
default_meta_description: "Default Meta Description"
default_meta_keywords: "Default Meta Keywords"
security_settings: "Security Settings"
allow_ssl_in_development_and_test: "Allow SSL to be used when in development and test modes"
allow_ssl_in_production: "Allow SSL to be used in production mode"
allow_ssl_in_staging: "Allow SSL to be used in staging mode"
check_for_spree_alerts: "Check for Spree alerts"
currency_decimal_mark: "Currency decimal mark"
currency_settings: "Currency Settings"
currency_symbol_position: Put "currency symbol before or after dollar amount?"
currency_thousands_separator: "Currency thousands separator"
hide_cents: "Hide cents"
display_currency: "Display currency"
choose_currency: "Choose Currency"
mail_method_settings: "Mail Method Settings"
general: "General"
enable_mail_delivery: "Enable Mail Delivery"
send_mails_as: "Send Mails As"
smtp_send_all_emails_as_from_following_address: "Send all mails as from the following address."
send_copy_of_all_mails_to: "Send Copy of All Mails To"
smtp_send_copy_to_this_addresses: "Sends a copy of all outgoing mails to this address. For multiple addresses, separate with commas."
intercept_email_address: "Intercept Email Address"
intercept_email_instructions: "Override email recipient and replace with this address."
smtp: "SMTP"
smtp_domain: "SMTP Domain"
smtp_mail_host: "SMTP Mail Host"
smtp_port: "SMTP Port"
secure_connection_type: "Secure Connection Type"
smtp_authentication_type: "SMTP Authentication Type"
smtp_username: "SMTP Username"
smtp_password: "SMTP Password"
image_settings: "Image Settings"
image_settings_warning: "You will need to regenerate thumbnails if you update the paperclip styles. Use rake paperclip:refresh:thumbnails CLASS=Spree::Image to do this."
attachment_default_style: Attachments Style
attachment_default_url: "Attachments Default URL"
attachment_path: "Attachments Path"
attachment_styles: "Paperclip Styles"
attachment_url: "Attachments URL"
add_new_style: "Add New Style"
image_settings_updated: "Image Settings successfully updated."
tax_categories: "Tax Categories"
listing_tax_categories: "Listing Tax Categories"
back_to_tax_categories_list: "Back To Tax Categories List"
tax rate: "Tax Rates"
new_tax_rate: "New Tax Rate"
tax_category: "Tax Category"
rate: "Rate"
tax_rate_amount_explanation: "Tax rates are a decimal amount to aid in calculations, (i.e. if the tax rate is 5% then enter 0.05)"
included_in_price: "Included in Price"
show_rate_in_label: "Show rate in label"
back_to_tax_rates_list: "Back to Tax Rates List"
tax_settings: "Tax Settings"
zones: "Zones"
new_zone: "New Zone"
default_tax: "Default Tax"
default_tax_zone: "Default Tax Zone"
country_based: "Country Based"
state_based: "State Based"
countries: "Countries"
listing_countries: "Listing Countries"
iso_name: "ISO Name"
states_required: "States Required"
editing_country: "Editing Country"
back_to_countries_list: "Back to Countries List"
states: "States"
abbreviation: "Abbreviation"
new_state: "New State"
payment_methods: "Payment Methods"
new_payment_method: "New Payment Method"
provider: "Provider"
taxonomies: "Taxonomies"
new_taxonomy: "New Taxonomy"
back_to_taxonomies_list: "Back to Taxonomies List"
shipping_methods: "Shipping Methods"
shipping_categories: "Shipping Categories"
new_shipping_category: "NEWEW Shipping Categories"
back_to_shipping_categories: "Back To Shipping Categories"
analytics_trackers: "Analytics Trackers"
no_trackers_found: "No Trackers Found"
new_tracker: "New Tracker"
add_one: "Add One"
google_analytics_id: "Analytics ID"
back_to_trackers_list: "Back to Trackers List"
name: "Name"
description: "Description"
type: "Type"
default: "default"
calculator: "Calculator"
zone: "Zone"
display: "Display"
environment: "Environment"
active: "Active"
nore: "More"
no_results: "No results"
create: "Create"
loading: "Loading"
# TODO: remove `email` key once we get to Spree 2.0
email: Email
# TODO: remove 'account_updated' key once we get to Spree 2.0
@@ -2687,6 +2864,12 @@ See the %{link} to find out more about %{sitename}'s features and to start using
date: "Date"
time: "Time"
inventory_error_flash_for_insufficient_quantity: "An item in your cart has become unavailable."
inventory: Inventory
zipcode: Postcode
weight: Weight (per kg)
actions:
update: "Update"
errors:
messages:
blank: "can't be blank"
@@ -2734,15 +2917,22 @@ See the %{link} to find out more about %{sitename}'s features and to start using
results_found: "%{number} Results found."
viewing: "Viewing %{start} to %{end}."
print_invoices: "Print Invoices"
sortable_header:
payment_state: "Payment State"
shipment_state: "Shipment State"
completed_at: "Completed At"
number: "Number"
state: "State"
email: "Customer E-Mail"
invoice:
issued_on: Issued on
tax_invoice: TAX INVOICE
code: Code
from: From
to: To
issued_on: "Issued on"
tax_invoice: "TAX INVOICE"
code: "Code"
from: "From"
to: "To"
form:
distribution_fields:
title: Distribution
title: "Distribution"
distributor: "Distributor:"
order_cycle: "Order cycle:"
overview:
@@ -2875,8 +3065,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
date_picker:
format: ! '%Y-%m-%d'
js_format: 'yy-mm-dd'
inventory: Inventory
zipcode: Postcode
orders:
edit:
login_to_view_order: "Please log in to view your order."
@@ -2927,23 +3115,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
ended: ended
paused: paused
canceled: cancelled
payment_states:
balance_due: balance due
completed: completed
checkout: checkout
credit_owed: credit owed
failed: failed
paid: paid
pending: pending
processing: processing
void: void
invalid: invalid
shipment_states:
backorder: backorder
partial: partial
pending: pending
ready: ready
shipped: shipped
user_mailer:
reset_password_instructions:
request_sent_text: |
@@ -2956,8 +3127,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
If you continue to have problems please feel free to contact us.
confirmation_instructions:
subject: Please confirm your OFN account
weight: Weight (per kg)
zipcode: Postcode
users:
form:
account_settings: Account Settings

2860
config/locales/en_CA.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -31,6 +31,16 @@ es:
on_demand_but_count_on_hand_set: "debe estar en blanco si está bajo demanda"
limited_stock_but_no_count_on_hand: "se debe especificar porque se ha definido estoc limitado"
activemodel:
attributes:
order_management/reports/enterprise_fee_summary/parameters:
start_at: "Inicio"
end_at: "Final"
distributor_ids: "Hubs"
producer_ids: "Productoras"
order_cycle_ids: "Ciclos de Pedido"
enterprise_fee_ids: "Nombres de las comisiones"
shipping_method_ids: "Métodos de envío"
payment_method_ids: "Métodos de Pago"
errors:
models:
subscription_validator:
@@ -74,6 +84,13 @@ es:
models:
order_cycle:
cloned_order_cycle_name: "COPIA DE %{order_cycle}"
validators:
date_time_string_validator:
not_string_error: "debe ser una cadena"
invalid_format_error: "debe ser válido"
integer_array_validator:
not_array_error: "debe ser una matriz"
invalid_element_error: "debe contener solo enteros válidos"
enterprise_mailer:
confirmation_instructions:
subject: "Confirma la dirección de correo electrónico de %{enterprise}"
@@ -851,7 +868,7 @@ es:
pickup_instructions_tip: Estas instrucciones se muestran a las consumidoras después de completar un pedido.
pickup_time_placeholder: "Listo para ( Fecha / Hora)"
receival_instructions_placeholder: "Instrucciones de recepción"
add_fee: 'Añadir tarifa'
add_fee: 'Añadir comisión'
selected: 'seleccionado'
add_exchange_form:
add_supplier: 'Añadir proveedora'
@@ -868,7 +885,7 @@ es:
search_by_order_cycle_name: "Buscar por nombre del Ciclo de Pedido..."
involving: "Involucrando"
any_enterprise: "Cualquier organización"
any_schedule: "Cualquier horario"
any_schedule: "Cualquier programación"
form:
incoming: Entrante
supplier: Proveedora
@@ -882,19 +899,19 @@ es:
delivery_details: Detalles de Recogida / Entrega
debug_info: Información de Debug
index:
schedule: Horario
schedules: Horarios
adding_a_new_schedule: Agregar un nuevo horario
updating_a_schedule: Actualización de un horario
new_schedule: Nuevo horario
create_schedule: Crear horario
update_schedule: Actualizar horario
delete_schedule: Eliminar horario
created_schedule: Horario creado
updated_schedule: Horario actualizado
deleted_schedule: Horario eliminado
schedule_name_placeholder: Nombre del horario
name_required_error: Por favor ingrese un nombre para este horario
schedule: Programación
schedules: Programación
adding_a_new_schedule: Agregar una nueva programación
updating_a_schedule: Actualización de una programación
new_schedule: Nueva programación
create_schedule: Crear programación
update_schedule: Actualizar programación
delete_schedule: Eliminar programación
created_schedule: Programación creada
updated_schedule: Programación actualizada
deleted_schedule: Programación eliminada
schedule_name_placeholder: Nombre de la programación
name_required_error: Por favor ingrese un nombre para esta programación
no_order_cycles_error: Seleccione al menos un ciclo de pedido (arrastrar y soltar)
name_and_timing_form:
name: Nombre
@@ -914,7 +931,7 @@ es:
fees: Comisiones
destroy_errors:
orders_present: Ese ciclo de pedido ha sido seleccionado por un cliente y no puede ser eliminado. Para evitar que los clientes accedan a él, ciérrelo.
schedule_present: Ese ciclo de pedido está vinculado a un horario y no puede ser eliminado. Desvincula o elimina el calendario primero.
schedule_present: Ese ciclo de pedido está vinculado a una programación y no puede ser eliminado. Desvincula o elimina la programación primero.
bulk_update:
no_data: Hm, algo salió mal. No se encontraron datos de ciclo de pedido.
date_warning:
@@ -996,6 +1013,9 @@ es:
description: Facturas para la importación en Xero
packing:
name: Informes de empaquetado
enterprise_fee_summary:
name: "Resumen de las comisiones de la organización"
description: "Resumen de las comisiones de la organización recolectadas"
subscriptions:
subscriptions: Suscripciones
new: Nueva suscripción
@@ -1014,10 +1034,10 @@ es:
set_up_shipping_and_payment_methods_html: Configurar los métodos %{shipping_link} y %{payment_link}
set_up_shipping_and_payment_methods_note_html: Tenga en cuenta que solo se pueden usar <br /> métodos de pago en efectivo y Stripe con las suscripciones
ensure_at_least_one_customer_html: Asegúrese de que exista al menos un %{customer_link}
create_at_least_one_schedule: Crear al menos un horario
create_at_least_one_schedule: Crear al menos una programación
create_at_least_one_schedule_step_1_html: 1. Vaya a la página %{order_cycles_link}
create_at_least_one_schedule_step_2: 2. Crea un ciclo de pedido si aún no lo has hecho
create_at_least_one_schedule_step_3: 3. Haga clic en '+ Nuevo horario' y complete el formulario
create_at_least_one_schedule_step_3: 3. Haga clic en '+ Nueva programación' y complete el formulario
once_you_are_done_you_can_html: Una vez que haya terminado, puede %{reload_this_page_link}
reload_this_page: recarga esta página
steps:
@@ -1028,7 +1048,7 @@ es:
subscription_line_items:
this_is_an_estimate: |
Los precios mostrados son solo una estimación y se calculan en el momento en que se cambia la suscripción.
Si cambias precios o tarifas, los pedidos se actualizarán pero la suscripción seguirá mostrando los valores anteriores.
Si cambias precios o comisiones, los pedidos se actualizarán pero la suscripción seguirá mostrando los valores anteriores.
not_in_open_and_upcoming_order_cycles_warning: "No hay ciclos de pedidos abiertos o próximos para este producto."
details:
details: Detalles
@@ -1616,7 +1636,7 @@ es:
shops_signup_help_text: Usted necesita un mejor retorno. Usted necesita nuevos compradores y socios de logística. Usted necesita que su historia sea contada a través de ventas al por mayor, al detalle y en la mesa de la cocina.
shops_signup_detail: Aquí está el detalle.
orders: Pedidos
orders_fees: Tarifas...
orders_fees: Comisiones...
orders_edit_title: Carrito de compras
orders_edit_headline: Su carrito de compras
orders_edit_time: Pedido listo para
@@ -1688,7 +1708,7 @@ es:
error_not_found_in_database: "%{name} no se encuentra en la base de datos"
error_not_primary_producer: "%{name} no está habilitado como productora"
error_no_permission_for_enterprise: "\"%{name}\": no tiene permiso para administrar productos para esta organización"
item_handling_fees: "Tarifa de manejo de artículo (incluída en el total de artículos)"
item_handling_fees: "Comisiones de manejo de artículos (incluída en el total de artículos)"
january: "Enero"
february: "Febrero"
march: "Marzo"
@@ -1717,7 +1737,7 @@ es:
password_reset_sent: "¡Le enviamos un correo electrónico con instrucciones para restaurar la contraseña!"
reset_password: "Restaurar contraseña"
who_is_managing_enterprise: "¿Quién es responsable de administrar %{enterprise}?"
update_and_recalculate_fees: "Actualizar y recalcular tarifas"
update_and_recalculate_fees: "Actualizar y recalcular comisiones"
registration:
steps:
images:
@@ -1883,7 +1903,7 @@ es:
shipping_method_destroy_error: "Ese método de envío no puede ser eliminado ya que se hace referencia en un pedido: %{number}."
accounts_and_billing_task_already_running_error: "Se está ejecutando una tarea, espere hasta que haya finalizado"
accounts_and_billing_start_task_notice: "Tarea en cola"
fees: "Tarifas"
fees: "Comisiones"
item_cost: "Costo del artículo"
bulk: "Agrupar"
shop_variant_quantity_min: "mínimo"
@@ -1893,11 +1913,11 @@ es:
change_shop: "Cambiar de tienda:"
shop_at: "Comprar en:"
price_breakdown: "Desglose de precios completo"
admin_fee: "Tarifa de administración"
sales_fee: "Tarifa de ventas"
packing_fee: "Tarifa de empaquetado"
transport_fee: "Tarifa de transporte"
fundraising_fee: "Tarifa para recaudación de fondos"
admin_fee: "Comisión de administración"
sales_fee: "Comisión de ventas"
packing_fee: "Comisión de empaquetado"
transport_fee: "Comisión de transporte"
fundraising_fee: "Comisión para recaptación de fondos"
price_graph: "Gráfico de precios"
included_tax: "Impuesto incluido"
balance: "Saldo"
@@ -2000,7 +2020,6 @@ es:
spree_admin_enterprises_none_text: "No tienes ninguna organización"
spree_admin_enterprises_tabs_hubs: "HUBS"
spree_admin_enterprises_producers_manage_products: "GESTIONAR PRODUCTOS"
spree_admin_enterprises_any_active_products_text: "No tienes ningún producto activo"
spree_admin_enterprises_create_new_product: "CREAR UN NUEVO PRODUCTO"
spree_admin_single_enterprise_alert_mail_confirmation: "Confirma la dirección de email para"
spree_admin_single_enterprise_alert_mail_sent: "Te hemos enviado un mail a"
@@ -2127,7 +2146,7 @@ es:
report_header_sales_tax: "Impuesto sobre las Ventas (%{currency_symbol})"
report_header_delivery_charge: "Gastos de Envío (%{currency_symbol})"
report_header_tax_on_delivery: "Impuestos sobre la entrega (%{currency_symbol})"
report_header_tax_on_fees: "Impuesto sobre las tasas (%{currency_symbol})"
report_header_tax_on_fees: "Impuesto sobre las comisiones (%{currency_symbol})"
report_header_total_tax: "Total Impuestos (%{currency_symbol})"
report_header_enterprise: Organización
report_header_customer: Consumidora
@@ -2209,7 +2228,7 @@ es:
report_header_gst_free_income: Ingresos sin IVA
report_header_total_untaxable_produce: Total productos sin impuestos
report_header_total_taxable_produce: Total productos con impuestos
report_header_total_untaxable_fees: Total comisiones sin impuestos
report_header_total_untaxable_fees: Total comisiones no imponibles (sin impuestos)
report_header_total_taxable_fees: Total de impuestos imponibles (impuestos incluidos)
report_header_delivery_shipping_cost: Gastos de envío (impuestos incluidos)
report_header_transaction_fee: Comisión por transacción (sin impuestos)
@@ -2248,7 +2267,7 @@ es:
shipping: "Envío"
shipping_methods: "Métodos de envío"
payment_methods: "Métodos de Pago"
payment_method_fee: "Tarifa de Transacción"
payment_method_fee: "Comisión de Transacción"
inventory_settings: "Configuración del Inventario"
tag_rules: "Reglas de las Etiquetas"
shop_preferences: "Configuración de la tienda"
@@ -2527,6 +2546,45 @@ es:
producers:
signup:
start_free_profile: "Empieze con un perfil gratuito, y amplíelo cuando esté preparado!"
order_management:
reports:
enterprise_fee_summary:
date_end_before_start_error: "debe ser después del comienzo"
parameter_not_allowed_error: "No está autorizado a usar uno o más filtros seleccionados para este informe."
fee_calculated_on_transfer_through_all: "Todos"
fee_calculated_on_transfer_through_entire_orders: "Pedidos completos a través de %{distributor}"
tax_category_various: "Varios"
fee_type:
payment_method: "Transaccion de pago"
shipping_method: "Envío"
fee_placements:
supplier: "Entrante"
distributor: "Saliente"
coordinator: "Coordinadora"
tax_category_name:
shipping_instance_rate: "Tarifa de plataforma"
formats:
csv:
header:
fee_type: "Tipo de Comisión"
enterprise_name: "Propietario de la organización"
fee_name: "Nombre de la comisión"
customer_name: "Consumidora"
fee_placement: "Asignación de comisiones"
fee_calculated_on_transfer_through_name: "Cálculo de comisiones a través de transferencias"
tax_category_name: "Categoría de impuestos"
total_amount: "€€ SUM"
html:
header:
fee_type: "Tipo de Comisión"
enterprise_name: "Propietario de la organización"
fee_name: "Nombre de la comisión"
customer_name: "Consumidora"
fee_placement: "Asignación de comisiones"
fee_calculated_on_transfer_through_name: "Cálculo de comisiones a través de transferencias"
tax_category_name: "Categoría de impuestos"
total_amount: "€€ SUM"
invalid_filter_parameters: "Los filtros que seleccionó para este informe no son válidos."
spree:
email: Email
account_updated: "Cuenta actualizada!"
@@ -2570,6 +2628,11 @@ es:
distributor: "Distribuidora:"
order_cycle: "Ciclo de pedido:"
overview:
products:
active_products:
zero: "No tienes ningún producto activo"
one: "Tiene un producto activo."
other: "Tiene %{count} productos activos"
order_cycles:
order_cycles: "Ciclos de Pedido"
order_cycles_tip: "Los ciclos de pedido determinan cuándo y dónde los productos están disponibles para las consumidoras."
@@ -2643,6 +2706,14 @@ es:
bulk_coop_allocation: 'Bulk Co-op - Asignación'
bulk_coop_packing_sheets: 'Bulk Co-op - Hojas de Empaquetado'
bulk_coop_customer_payments: 'Bulk Co-op - Pagos de las Consumidoras'
enterprise_fee_summaries:
filters:
date_range: "Rango de fechas"
report_format_csv: "Descargar como CSV"
generate_report: "Generar informe"
report:
none: "Ninguno"
select_and_search: "Seleccione los filtros y haga clic en GENERAR INFORME para acceder a sus datos."
users:
index:
listing_users: "Listado de Usuarias"

View File

@@ -17,7 +17,7 @@ module OrderManagement
end
def result
group_data.select_attributes
group_data.exclude_groups_with_zero_total.select_attributes
@scope.all
end
@@ -46,7 +46,7 @@ module OrderManagement
def find_adjustments
chain_to_scope do
Spree::Adjustment
Spree::Adjustment.eligible
end
end
@@ -336,6 +336,10 @@ module OrderManagement
if params.payment_method_ids.present?
end
def exclude_groups_with_zero_total
filter_scope("spree_adjustments.amount != 0")
end
def group_data
chain_to_scope do
group("enterprise_fees.id", "enterprises.id", "customers.id", "hubs.id",

View File

@@ -151,6 +151,94 @@ describe OrderManagement::Reports::EnterpriseFeeSummary::ReportService do
end
end
describe "data exclusions" do
describe "invalid adjustments (through 'eligible') like failed payments" do
let!(:customer_order) { prepare_order(customer: customer) }
before do
# Make the payment fail. See Spree::Payment#revoke_adjustment_eligibility.
payment = customer_order.payments.first
payment.state = "failed"
payment.save!
end
it "is included" do
totals = service.list
expect(totals.length).to eq(1)
expected_result = [
["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer",
nil, nil, "Platform Rate", "1.00"]
]
expected_result.each_with_index do |expected_attributes, row_index|
expect_total_attributes(totals[row_index], expected_attributes)
end
end
end
describe "non-mandatory $0 adjustments (through 'eligible')" do
let!(:variant) { prepare_variant(outgoing_exchange_fees: [enterprise_fee]) }
let!(:enterprise_fee) do
create(:enterprise_fee, :per_item, name: "Sample Enterprise Fee", enterprise: distributor,
fee_type: "admin", amount: 0)
end
let!(:customer_order) { prepare_order(customer: customer) }
before do
# Change "eligible" in enterprise fee adjustment to false. $0 adjustments that are not
# mandatory are set to be ineligible, but there are no non-mandatory adjustments supported
# by the report yet.
adjustment = Spree::Adjustment.where(originator_type: "EnterpriseFee").first
adjustment.eligible = false
adjustment.save!
end
it "is included" do
totals = service.list
expect(totals.length).to eq(2)
expected_result = [
["Payment Transaction", "Sample Distributor", "Sample Payment Method", "Sample Customer",
nil, nil, nil, "2.00"],
["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer",
nil, nil, "Platform Rate", "1.00"]
]
expected_result.each_with_index do |expected_attributes, row_index|
expect_total_attributes(totals[row_index], expected_attributes)
end
end
end
describe "$0 mandatory adjustments" do
let!(:payment_method) do
create(:payment_method, :per_item, amount: 0, name: "Sample Payment Method")
end
let!(:customer_order) { prepare_order(customer: customer) }
it "is included" do
totals = service.list
expect(totals.length).to eq(1)
expected_result = [
["Shipment", "Sample Distributor", "Sample Shipping Method", "Sample Customer",
nil, nil, "Platform Rate", "1.00"]
]
expected_result.each_with_index do |expected_attributes, row_index|
expect_total_attributes(totals[row_index], expected_attributes)
end
end
end
end
describe "handling of more complex cases" do
context "with non-sender fee for incoming exchange and non-receiver fee for outgoing" do
let!(:variant) do

View File

@@ -27,19 +27,21 @@ module OpenFoodNetwork
private
def cached_products_json
if Rails.env.production? || Rails.env.staging?
Rails.cache.fetch("products-json-#{@distributor.id}-#{@order_cycle.id}") do
begin
uncached_products_json
rescue ProductsRenderer::NoProducts
nil
end
return uncached_products_json unless use_cached_products?
Rails.cache.fetch("products-json-#{@distributor.id}-#{@order_cycle.id}") do
begin
uncached_products_json
rescue ProductsRenderer::NoProducts
nil
end
else
uncached_products_json
end
end
def use_cached_products?
Spree::Config[:enable_products_cache?] && (Rails.env.production? || Rails.env.staging?)
end
def uncached_products_json
ProductsRenderer.new(@distributor, @order_cycle).products_json
end

View File

@@ -22,20 +22,18 @@ module OpenFoodNetwork
# Uses variant_override.count_on_hand instead of Stock::Quantifier.stock_items.count_on_hand
def total_on_hand
@variant_override.andand.count_on_hand || super
if @variant_override.present? && @variant_override.stock_overridden?
@variant_override.count_on_hand
else
super
end
end
def on_demand
if @variant_override.andand.on_demand.nil?
if @variant_override.andand.count_on_hand.present?
# If we're overriding the stock level of an on_demand variant, show it as not
# on_demand, so our stock control can take effect.
false
else
super
end
if @variant_override.present? && !@variant_override.use_producer_stock_settings?
@variant_override.on_demand
else
@variant_override.andand.on_demand
super
end
end

View File

@@ -1 +1 @@
producer,sku,name,display_name,category,units,unit_type,variant_unit_name,price,on_hand,available_on,on_demand,shipping_category,tax_category
producer,sku,name,display_name,category,description,units,unit_type,variant_unit_name,price,on_hand,available_on,on_demand,shipping_category,tax_category
1 producer sku name display_name category description units unit_type variant_unit_name price on_hand available_on on_demand shipping_category tax_category

View File

@@ -45,6 +45,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays a column for user's full name" do
@@ -92,6 +93,7 @@ feature %q{
before do
visit spree.admin_bulk_order_management_path
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "sorts by customer name when the customer name header is clicked" do
@@ -260,6 +262,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays a select box for producers, which filters line items by the selected supplier" do
@@ -298,6 +301,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays a select box for distributors, which filters line items by the selected distributor" do
@@ -337,6 +341,7 @@ feature %q{
before do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays a select box for order cycles, which filters line items by the selected order cycle" do
@@ -377,6 +382,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "allows filters to be used in combination" do
@@ -427,6 +433,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays a quick search input" do
@@ -456,6 +463,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays date fields for filtering orders, with default values set" do
@@ -528,6 +536,7 @@ feature %q{
before :each do
visit '/admin/orders/bulk_management'
wait_until { request_monitor_finished 'LineItemsCtrl' }
end
it "displays a checkbox for each line item in the list" do
@@ -570,6 +579,7 @@ feature %q{
expect(page).to have_no_selector "tr#li_#{li2.id}"
check "toggle_bulk"
fill_in "quick_search", with: ''
wait_until { request_monitor_finished 'LineItemsCtrl' }
expect(find("tr#li_#{li1.id} input[type='checkbox'][name='bulk']").checked?).to be true
expect(find("tr#li_#{li2.id} input[type='checkbox'][name='bulk']").checked?).to be false
expect(find("input[type='checkbox'][name='toggle_bulk']").checked?).to be false
@@ -583,6 +593,7 @@ feature %q{
find("div#bulk-actions-dropdown div.menu_item", :text => "Delete Selected" ).click
expect(page).to have_no_selector "tr#li_#{li1.id}"
fill_in "quick_search", with: ''
wait_until { request_monitor_finished 'LineItemsCtrl' }
expect(page).to have_selector "tr#li_#{li2.id}"
expect(page).to have_no_selector "tr#li_#{li1.id}"
end

View File

@@ -117,7 +117,7 @@ feature %q{
end
describe 'listing order cycles with other locales' do
let!(:oc_de) { create(:simple_order_cycle, name: 'oc', orders_open_at: '2012-01-01 00:00:00') }
let!(:oc_de) { create(:simple_order_cycle, name: 'oc', orders_open_at: '2012-01-01 00:00') }
around(:each) do |spec|
I18n.locale = :de
@@ -131,7 +131,7 @@ feature %q{
visit admin_order_cycles_path
within("tr.order-cycle-#{oc_de.id}") do
expect(find('input.datetimepicker', match: :first).value).to start_with '2012-01-01 00:00:00'
expect(find('input.datetimepicker', match: :first).value).to start_with '2012-01-01 00:00'
find('img.ui-datepicker-trigger', match: :first).click
end
@@ -143,7 +143,7 @@ feature %q{
end
within("tr.order-cycle-#{oc_de.id}") do
expect(find('input.datetimepicker', match: :first).value).to eq '2012-01-30 00:00:00'
expect(find('input.datetimepicker', match: :first).value).to eq '2012-01-30 00:00'
end
end
end
@@ -556,7 +556,7 @@ feature %q{
within("tr.order-cycle-#{oc3.id}") do
# Then that date/time should appear on the form
expect(find("input#oc#{oc3.id}_orders_open_at").value).to eq "2040-12-01 00:00:00"
expect(find("input#oc#{oc3.id}_orders_open_at").value).to eq "2040-12-01 00:00"
# Manually fill out time
find("input#oc#{oc3.id}_name").set "Updated Order Cycle 3"

View File

@@ -462,7 +462,7 @@ feature "Product Import", js: true do
def proceed_to_validation
expect(page).to have_selector 'a.button.proceed', visible: true
click_link I18n.t('admin.product_import.import.import')
within("#content") { click_link I18n.t('admin.product_import.import.import') }
expect(page).to have_selector 'form.product-import', visible: true
expect(page).to have_content I18n.t('admin.product_import.import.validation_overview')
end

View File

@@ -109,9 +109,8 @@ feature 'shipping methods' do
click_button I18n.t("actions.create")
expect(page).to have_no_button I18n.t("actions.create")
message = "Shipping method \"Teleport\" has been successfully created!"
expect(page).to have_flash_message message
expect(page).to have_content I18n.t('editing_shipping_method')
expect(flash_message).to eq I18n.t('successfully_created', resource: 'Shipping method "Teleport"')
expect(first('tags-input .tag-list ti-tag-item')).to have_content "local"

View File

@@ -139,7 +139,7 @@ feature "Registration", js: true do
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button 'Login'
expect(page).to have_content I18n.t('limit_reached_headline')
expect(page).to have_content I18n.t('registration.steps.limit_reached.headline')
end
end
end

View File

@@ -166,7 +166,22 @@ describe "filtering products for submission to database", ->
variant_unit_scale: 1
]
# TODO Not an exhaustive test, is there a better way to do this?
it "returns stock properties of a product if no variant is provided", ->
available_on = new Date()
testProduct =
id: 1
name: "TestProduct"
on_hand: 0
on_demand: false
expect(filterSubmitProducts([testProduct])).toEqual [
id: 1
name: "TestProduct"
on_hand: 0
on_demand: false
]
it "only returns the properties of products which ought to be updated", ->
available_on = new Date()
@@ -184,11 +199,10 @@ describe "filtering products for submission to database", ->
created_at: null
updated_at: null
on_hand: 0
on_demand: false
producer_id: 5
group_buy: null
group_buy_unit_size: null
on_demand: false
master:
id: 2
unit_value: 250

View File

@@ -0,0 +1,161 @@
describe 'AdminCreateOrderCycleCtrl', ->
ctrl = null
scope = null
event = null
OrderCycle = null
Enterprise = null
EnterpriseFee = null
beforeEach ->
scope =
order_cycle_form: jasmine.createSpyObj('order_cycle_form', ['$dirty'])
$watch: jasmine.createSpy('$watch')
event =
preventDefault: jasmine.createSpy('preventDefault')
OrderCycle =
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').and.returnValue('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').and.returnValue('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').and.returnValue('variant supplied')
exchangeDirection: jasmine.createSpy('exchangeDirection').and.returnValue('exchange direction')
toggleProducts: jasmine.createSpy('toggleProducts')
setExchangeVariants: jasmine.createSpy('setExchangeVariants')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
removeExchange: jasmine.createSpy('removeExchange')
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
addExchangeFee: jasmine.createSpy('addExchangeFee')
removeExchangeFee: jasmine.createSpy('removeExchangeFee')
removeDistributionOfVariant: jasmine.createSpy('removeDistributionOfVariant')
create: jasmine.createSpy('create')
new: jasmine.createSpy('new').and.returnValue "my order cycle"
Enterprise =
index: jasmine.createSpy('index').and.returnValue('enterprises list')
supplied_products: 'supplied products'
suppliedVariants: jasmine.createSpy('suppliedVariants').and.returnValue('supplied variants')
totalVariants: jasmine.createSpy('totalVariants').and.returnValue('variants total')
EnterpriseFee =
index: jasmine.createSpy('index').and.returnValue('enterprise fees list')
forEnterprise: jasmine.createSpy('forEnterprise').and.returnValue('enterprise fees for enterprise')
ocInstance = {}
module('admin.orderCycles')
inject ($controller) ->
ctrl = $controller 'AdminCreateOrderCycleCtrl', {$scope: scope, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee, ocInstance: ocInstance}
it 'Loads enterprises and supplied products', ->
expect(Enterprise.index).toHaveBeenCalled()
expect(scope.enterprises).toEqual('enterprises list')
expect(scope.supplied_products).toEqual('supplied products')
it 'Loads enterprise fees', ->
expect(EnterpriseFee.index).toHaveBeenCalled()
expect(scope.enterprise_fees).toEqual('enterprise fees list')
it 'Loads order cycles', ->
expect(scope.order_cycle).toEqual('my order cycle')
describe 'Reporting when all resources are loaded', ->
beforeEach inject (RequestMonitor) ->
RequestMonitor.loading = false
Enterprise.loaded = true
EnterpriseFee.loaded = true
OrderCycle.loaded = true
it 'returns true when all resources are loaded', ->
expect(scope.loaded()).toBe(true)
it 'returns false otherwise', ->
EnterpriseFee.loaded = false
expect(scope.loaded()).toBe(false)
it "delegates suppliedVariants to Enterprise", ->
expect(scope.suppliedVariants('enterprise_id')).toEqual('supplied variants')
expect(Enterprise.suppliedVariants).toHaveBeenCalledWith('enterprise_id')
it 'Delegates exchangeSelectedVariants to OrderCycle', ->
expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange')
it "delegates setExchangeVariants to OrderCycle", ->
scope.setExchangeVariants('exchange', 'variants', 'selected')
expect(OrderCycle.setExchangeVariants).toHaveBeenCalledWith('exchange', 'variants', 'selected')
it 'Delegates enterpriseTotalVariants to Enterprise', ->
expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total')
expect(Enterprise.totalVariants).toHaveBeenCalledWith('enterprise')
it 'Delegates productSuppliedToOrderCycle to OrderCycle', ->
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates exchangeDirection to OrderCycle', ->
expect(scope.exchangeDirection('exchange')).toEqual('exchange direction')
expect(OrderCycle.exchangeDirection).toHaveBeenCalledWith('exchange')
it 'Finds enterprises participating in the order cycle that have fees', ->
scope.enterprises =
1: {id: 1, name: 'Eaterprises'}
2: {id: 2, name: 'Pepper Tree Place'}
3: {id: 3, name: 'South East'}
OrderCycle.participatingEnterpriseIds = jasmine.createSpy('participatingEnterpriseIds').and.returnValue([2])
EnterpriseFee.enterprise_fees = [ {enterprise_id: 2} ] # Pepper Tree Place has a fee
expect(scope.enterprisesWithFees()).toEqual([
{id: 2, name: 'Pepper Tree Place'}
])
it 'Delegates enterpriseFeesForEnterprise to EnterpriseFee', ->
scope.enterpriseFeesForEnterprise('123')
expect(EnterpriseFee.forEnterprise).toHaveBeenCalledWith(123)
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addSupplier).toHaveBeenCalledWith('new supplier id')
it 'Adds order cycle distributors', ->
scope.new_distributor_id = 'new distributor id'
scope.addDistributor(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
it 'Removes order cycle exchanges', ->
scope.removeExchange(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchange).toHaveBeenCalledWith('exchange')
it 'Adds coordinator fees', ->
scope.addCoordinatorFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
it 'Removes coordinator fees', ->
scope.removeCoordinatorFee(event, 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeCoordinatorFee).toHaveBeenCalledWith(0)
it 'Adds exchange fees', ->
scope.addExchangeFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addExchangeFee).toHaveBeenCalled()
it 'Removes exchange fees', ->
scope.removeExchangeFee(event, 'exchange', 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchangeFee).toHaveBeenCalledWith('exchange', 0)
it 'Removes distribution of a variant', ->
scope.removeDistributionOfVariant('variant')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('variant')
it 'Submits the order cycle via OrderCycle create', ->
eventMock = {preventDefault: jasmine.createSpy()}
scope.submit(eventMock,'/admin/order_cycles')
expect(eventMock.preventDefault).toHaveBeenCalled()
expect(OrderCycle.create).toHaveBeenCalledWith('/admin/order_cycles')

View File

@@ -0,0 +1,166 @@
describe 'AdminEditOrderCycleCtrl', ->
ctrl = null
scope = null
event = null
location = null
OrderCycle = null
Enterprise = null
EnterpriseFee = null
beforeEach ->
scope =
order_cycle_form: jasmine.createSpyObj('order_cycle_form', ['$dirty', '$setPristine'])
$watch: jasmine.createSpy('$watch')
event =
preventDefault: jasmine.createSpy('preventDefault')
location =
absUrl: ->
'example.com/admin/order_cycles/27/edit'
OrderCycle =
load: jasmine.createSpy('load')
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').and.returnValue('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').and.returnValue('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').and.returnValue('variant supplied')
exchangeDirection: jasmine.createSpy('exchangeDirection').and.returnValue('exchange direction')
toggleProducts: jasmine.createSpy('toggleProducts')
setExchangeVariants: jasmine.createSpy('setExchangeVariants')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
removeExchange: jasmine.createSpy('removeExchange')
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
addExchangeFee: jasmine.createSpy('addExchangeFee')
removeExchangeFee: jasmine.createSpy('removeExchangeFee')
removeDistributionOfVariant: jasmine.createSpy('removeDistributionOfVariant')
update: jasmine.createSpy('update')
Enterprise =
index: jasmine.createSpy('index').and.returnValue('enterprises list')
supplied_products: 'supplied products'
suppliedVariants: jasmine.createSpy('suppliedVariants').and.returnValue('supplied variants')
totalVariants: jasmine.createSpy('totalVariants').and.returnValue('variants total')
EnterpriseFee =
index: jasmine.createSpy('index').and.returnValue('enterprise fees list')
forEnterprise: jasmine.createSpy('forEnterprise').and.returnValue('enterprise fees for enterprise')
module('admin.orderCycles')
inject ($controller) ->
ctrl = $controller 'AdminEditOrderCycleCtrl', {$scope: scope, $location: location, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee}
it 'Loads enterprises and supplied products', ->
expect(Enterprise.index).toHaveBeenCalled()
expect(scope.enterprises).toEqual('enterprises list')
expect(scope.supplied_products).toEqual('supplied products')
it 'Loads enterprise fees', ->
expect(EnterpriseFee.index).toHaveBeenCalled()
expect(scope.enterprise_fees).toEqual('enterprise fees list')
it 'Loads order cycles', ->
expect(OrderCycle.load).toHaveBeenCalledWith('27')
describe 'Reporting when all resources are loaded', ->
beforeEach inject (RequestMonitor) ->
RequestMonitor.loading = false
Enterprise.loaded = true
EnterpriseFee.loaded = true
OrderCycle.loaded = true
it 'returns true when all resources are loaded', ->
expect(scope.loaded()).toBe(true)
it 'returns false otherwise', ->
EnterpriseFee.loaded = false
expect(scope.loaded()).toBe(false)
it "delegates suppliedVariants to Enterprise", ->
expect(scope.suppliedVariants('enterprise_id')).toEqual('supplied variants')
expect(Enterprise.suppliedVariants).toHaveBeenCalledWith('enterprise_id')
it 'Delegates exchangeSelectedVariants to OrderCycle', ->
expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange')
it "delegates setExchangeVariants to OrderCycle", ->
scope.setExchangeVariants('exchange', 'variants', 'selected')
expect(OrderCycle.setExchangeVariants).toHaveBeenCalledWith('exchange', 'variants', 'selected')
it 'Delegates totalVariants to Enterprise', ->
expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total')
expect(Enterprise.totalVariants).toHaveBeenCalledWith('enterprise')
it 'Delegates productSuppliedToOrderCycle to OrderCycle', ->
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates exchangeDirection to OrderCycle', ->
expect(scope.exchangeDirection('exchange')).toEqual('exchange direction')
expect(OrderCycle.exchangeDirection).toHaveBeenCalledWith('exchange')
it 'Finds enterprises participating in the order cycle that have fees', ->
scope.enterprises =
1: {id: 1, name: 'Eaterprises'}
2: {id: 2, name: 'Pepper Tree Place'}
3: {id: 3, name: 'South East'}
OrderCycle.participatingEnterpriseIds = jasmine.createSpy('participatingEnterpriseIds').and.returnValue([2])
EnterpriseFee.enterprise_fees = [ {enterprise_id: 2} ] # Pepper Tree Place has a fee
expect(scope.enterprisesWithFees()).toEqual([
{id: 2, name: 'Pepper Tree Place'}
])
it 'Delegates enterpriseFeesForEnterprise to EnterpriseFee', ->
scope.enterpriseFeesForEnterprise('123')
expect(EnterpriseFee.forEnterprise).toHaveBeenCalledWith(123)
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addSupplier).toHaveBeenCalledWith('new supplier id')
it 'Adds order cycle distributors', ->
scope.new_distributor_id = 'new distributor id'
scope.addDistributor(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
it 'Removes order cycle exchanges', ->
scope.removeExchange(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchange).toHaveBeenCalledWith('exchange')
expect(scope.order_cycle_form.$dirty).toEqual true
it 'Adds coordinator fees', ->
scope.addCoordinatorFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
it 'Removes coordinator fees', ->
scope.removeCoordinatorFee(event, 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeCoordinatorFee).toHaveBeenCalledWith(0)
expect(scope.order_cycle_form.$dirty).toEqual true
it 'Adds exchange fees', ->
scope.addExchangeFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addExchangeFee).toHaveBeenCalled()
it 'Removes exchange fees', ->
scope.removeExchangeFee(event, 'exchange', 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchangeFee).toHaveBeenCalledWith('exchange', 0)
expect(scope.order_cycle_form.$dirty).toEqual true
it 'Removes distribution of a variant', ->
scope.removeDistributionOfVariant('variant')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('variant')
it 'Submits the order cycle via OrderCycle update', ->
eventMock = {preventDefault: jasmine.createSpy()}
scope.submit(eventMock,'/admin/order_cycles')
expect(eventMock.preventDefault).toHaveBeenCalled()
expect(OrderCycle.update).toHaveBeenCalledWith('/admin/order_cycles', scope.order_cycle_form)

View File

@@ -0,0 +1,37 @@
describe 'EnterpriseFee service', ->
$httpBackend = null
EnterpriseFee = null
beforeEach ->
module 'admin.orderCycles'
inject ($injector, _$httpBackend_)->
EnterpriseFee = $injector.get('EnterpriseFee')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/enterprise_fees/for_order_cycle.json').respond [
{id: 1, name: "Yayfee", enterprise_id: 1}
{id: 2, name: "FeeTwo", enterprise_id: 2}
]
it 'loads enterprise fees', ->
enterprise_fees = EnterpriseFee.index()
$httpBackend.flush()
expected_fees = [
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee", enterprise_id: 1})
new EnterpriseFee.EnterpriseFee({id: 2, name: "FeeTwo", enterprise_id: 2})
]
for fee, i in enterprise_fees
expect(fee.id).toEqual(expected_fees[i].id)
it 'reports its loadedness', ->
expect(EnterpriseFee.loaded).toBe(false)
EnterpriseFee.index()
$httpBackend.flush()
expect(EnterpriseFee.loaded).toBe(true)
it 'returns enterprise fees for an enterprise', ->
all_enterprise_fees = EnterpriseFee.index()
$httpBackend.flush()
enterprise_fees = EnterpriseFee.forEnterprise(1)
expect(enterprise_fees).toEqual [
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee", enterprise_id: 1})
]

View File

@@ -0,0 +1,75 @@
describe 'Enterprise service', ->
$httpBackend = null
Enterprise = null
beforeEach ->
module 'admin.orderCycles'
inject ($injector, _$httpBackend_)->
Enterprise = $injector.get('Enterprise')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/enterprises/for_order_cycle.json').respond [
{id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true}
{id: 2, name: 'Two', supplied_products: [3, 4]}
{id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'}
]
it 'loads enterprises as a hash', ->
enterprises = Enterprise.index()
$httpBackend.flush()
expect(enterprises).toEqual
1: new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true})
2: new Enterprise.Enterprise({id: 2, name: 'Two', supplied_products: [3, 4]})
3: new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'})
it 'reports its loadedness', ->
expect(Enterprise.loaded).toBe(false)
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.loaded).toBe(true)
it 'loads producers as an array', ->
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.producer_enterprises).toEqual [new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true})]
it 'loads hubs as an array', ->
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.hub_enterprises).toEqual [new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'})]
it 'collates all supplied products', ->
enterprises = Enterprise.index()
$httpBackend.flush()
expect(Enterprise.supplied_products).toEqual [1, 2, 3, 4, 5, 6]
it "finds supplied variants for an enterprise", ->
spyOn(Enterprise, 'variantsOf').and.returnValue(10)
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.suppliedVariants(1)).toEqual [10, 10]
describe "finding the variants of a product", ->
it "returns the master for products without variants", ->
p =
master_id: 1
variants: []
expect(Enterprise.variantsOf(p)).toEqual [1]
it "returns the variant ids for products with variants", ->
p =
master_id: 1
variants: [{id: 2}, {id: 3}]
expect(Enterprise.variantsOf(p)).toEqual [2, 3]
it 'counts total variants supplied by an enterprise', ->
enterprise =
supplied_products: [
{variants: []},
{variants: []},
{variants: [{}, {}, {}]}
]
expect(Enterprise.totalVariants(enterprise)).toEqual(5)
it 'returns zero when enterprise is null', ->
expect(Enterprise.totalVariants(null)).toEqual(0)

View File

@@ -0,0 +1,520 @@
describe 'OrderCycle service', ->
OrderCycle = null
$httpBackend = null
$window = null
beforeEach ->
$window = {navigator: {userAgent: 'foo'}}
module 'admin.orderCycles', ($provide)->
$provide.value('$window', $window)
null
inject ($injector, _$httpBackend_)->
OrderCycle = $injector.get('OrderCycle')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/order_cycles/123.json').respond
id: 123
name: 'Test Order Cycle'
coordinator_id: 456
coordinator_fees: []
exchanges: [
{sender_id: 1, receiver_id: 456, incoming: true}
{sender_id: 456, receiver_id: 2, incoming: false}
]
$httpBackend.whenGET('/admin/order_cycles/new.json').respond
id: 123
name: 'New Order Cycle'
coordinator_id: 456
coordinator_fees: []
exchanges: []
it 'initialises order cycle', ->
expect(OrderCycle.order_cycle).toEqual {incoming_exchanges: [], outgoing_exchanges: []}
it 'counts selected variants in an exchange', ->
result = OrderCycle.exchangeSelectedVariants({variants: {1: true, 2: false, 3: true}})
expect(result).toEqual(2)
describe "fetching exchange ids", ->
it "gets enterprise ids as ints", ->
OrderCycle.order_cycle.incoming_exchanges = [
{enterprise_id: 1}
{enterprise_id: '2'}
]
OrderCycle.order_cycle.outgoing_exchanges = [
{enterprise_id: 3}
{enterprise_id: '4'}
]
expect(OrderCycle.exchangeIds('incoming')).toEqual [1, 2]
describe "checking for novel enterprises", ->
e1 = {id: 1}
e2 = {id: 2}
beforeEach ->
OrderCycle.order_cycle.incoming_exchanges = [{enterprise_id: 1}]
OrderCycle.order_cycle.outgoing_exchanges = [{enterprise_id: 1}]
it "detects novel suppliers", ->
expect(OrderCycle.novelSupplier(e1)).toBe false
expect(OrderCycle.novelSupplier(e2)).toBe true
it "detects novel suppliers with enterprise as string id", ->
expect(OrderCycle.novelSupplier('1')).toBe false
expect(OrderCycle.novelSupplier('2')).toBe true
it "detects novel distributors", ->
expect(OrderCycle.novelDistributor(e1)).toBe false
expect(OrderCycle.novelDistributor(e2)).toBe true
it "detects novel distributors with enterprise as string id", ->
expect(OrderCycle.novelDistributor('1')).toBe false
expect(OrderCycle.novelDistributor('2')).toBe true
describe 'fetching the direction for an exchange', ->
it 'returns "incoming" for incoming exchanges', ->
exchange = {id: 1}
OrderCycle.order_cycle.incoming_exchanges = [exchange]
OrderCycle.order_cycle.outgoing_exchanges = []
expect(OrderCycle.exchangeDirection(exchange)).toEqual 'incoming'
it 'returns "outgoing" for outgoing exchanges', ->
exchange = {id: 1}
OrderCycle.order_cycle.incoming_exchanges = []
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
expect(OrderCycle.exchangeDirection(exchange)).toEqual 'outgoing'
describe "setting exchange variants", ->
describe "when I have permissions to edit the variants", ->
beforeEach ->
OrderCycle.order_cycle["editable_variants_for_outgoing_exchanges"] = { 1: [1, 2, 3] }
it "sets all variants to the provided value", ->
exchange = { enterprise_id: 1, incoming: false, variants: {2: false}}
OrderCycle.setExchangeVariants(exchange, [1, 2, 3], true)
expect(exchange.variants).toEqual {1: true, 2: true, 3: true}
describe "when I don't have permissions to edit the variants", ->
beforeEach ->
OrderCycle.order_cycle["editable_variants_for_outgoing_exchanges"] = { 1: [] }
it "does not change variants to the provided value", ->
exchange = { enterprise_id: 1, incoming: false, variants: {2: false}}
OrderCycle.setExchangeVariants(exchange, [1, 2, 3], true)
expect(exchange.variants).toEqual {2: false}
describe 'adding suppliers', ->
exchange = null
beforeEach ->
# Initialise OC
OrderCycle.new()
$httpBackend.flush()
it 'adds the supplier to incoming exchanges', ->
OrderCycle.addSupplier('123')
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [
{enterprise_id: '123', incoming: true, active: true, variants: {}, enterprise_fees: []}
]
describe 'adding distributors', ->
exchange = null
beforeEach ->
# Initialise OC
OrderCycle.new()
$httpBackend.flush()
it 'adds the distributor to outgoing exchanges', ->
OrderCycle.addDistributor('123')
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
{enterprise_id: '123', incoming: false, active: true, variants: {}, enterprise_fees: []}
]
describe 'removing exchanges', ->
exchange = null
beforeEach ->
spyOn(OrderCycle, 'removeDistributionOfVariant')
exchange =
enterprise_id: '123'
active: true
incoming: false
variants: {1: true, 2: false, 3: true}
enterprise_fees: []
describe "removing incoming exchanges", ->
beforeEach ->
exchange.incoming = true
OrderCycle.order_cycle.incoming_exchanges = [exchange]
it 'removes the exchange', ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual []
it 'removes distribution of all exchange variants', ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('1')
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalledWith('2')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('3')
describe "removing outgoing exchanges", ->
beforeEach ->
exchange.incoming = false
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
it 'removes the exchange', ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual []
it "does not remove distribution of any variants", ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalled()
it 'adds coordinator fees', ->
# Initialise OC
OrderCycle.new()
$httpBackend.flush()
OrderCycle.addCoordinatorFee()
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{}]
describe 'removing coordinator fees', ->
it 'removes a coordinator fee by index', ->
OrderCycle.order_cycle.coordinator_fees = [
{id: 1}
{id: 2}
{id: 3}
]
OrderCycle.removeCoordinatorFee(1)
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [
{id: 1}
{id: 3}
]
it 'adds exchange fees', ->
exchange = {enterprise_fees: []}
OrderCycle.addExchangeFee(exchange)
expect(exchange.enterprise_fees).toEqual [{}]
describe 'removing exchange fees', ->
it 'removes an exchange fee by index', ->
exchange =
enterprise_fees: [
{id: 1}
{id: 2}
{id: 3}
]
OrderCycle.removeExchangeFee(exchange, 1)
expect(exchange.enterprise_fees).toEqual [
{id: 1}
{id: 3}
]
it 'finds participating enterprise ids', ->
OrderCycle.order_cycle.incoming_exchanges = [
{enterprise_id: 1}
{enterprise_id: 2}
]
OrderCycle.order_cycle.outgoing_exchanges = [
{enterprise_id: 2}
{enterprise_id: 3}
]
expect(OrderCycle.participatingEnterpriseIds()).toEqual [1, 2, 3]
describe 'fetching all variants supplied on incoming exchanges', ->
it 'collects variants from incoming exchanges', ->
OrderCycle.order_cycle.incoming_exchanges = [
{variants: {1: true, 2: false}}
{variants: {3: false, 4: true}}
{variants: {5: true, 6: false}}
]
expect(OrderCycle.incomingExchangesVariants()).toEqual [1, 4, 5]
describe 'checking whether a product is supplied to the order cycle', ->
product_master_present = product_variant_present = product_master_absent = product_variant_absent = null
beforeEach ->
product_master_present =
name: "Linseed (500g)"
master_id: 1
variants: []
product_variant_present =
name: "Linseed (500g)"
master_id: 2
variants: [{id: 3}, {id: 4}]
product_master_absent =
name: "Linseed (500g)"
master_id: 5
variants: []
product_variant_absent =
name: "Linseed (500g)"
master_id: 6
variants: [{id: 7}, {id: 8}]
spyOn(OrderCycle, 'incomingExchangesVariants').and.returnValue([1, 3])
it 'returns true for products whose master is supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_master_present)).toBeTruthy()
it 'returns true for products for whom a variant is supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_present)).toBeTruthy()
it 'returns false for products whose master is not supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_master_absent)).toBeFalsy()
it 'returns false for products whose variants are not supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_absent)).toBeFalsy()
describe 'checking whether a variant is supplied to the order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'incomingExchangesVariants').and.returnValue([1, 3])
it 'returns true for variants that are supplied', ->
expect(OrderCycle.variantSuppliedToOrderCycle({id: 1})).toBeTruthy()
it 'returns false for variants that are not supplied', ->
expect(OrderCycle.variantSuppliedToOrderCycle({id: 999})).toBeFalsy()
describe 'remove all distribution of a variant', ->
it 'removes the variant from every outgoing exchange', ->
OrderCycle.order_cycle.outgoing_exchanges = [
{variants: {123: true, 234: true}}
{variants: {123: true, 333: true}}
]
OrderCycle.removeDistributionOfVariant('123')
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
{variants: {123: false, 234: true}}
{variants: {123: false, 333: true}}
]
describe 'loading an order cycle, reporting loadedness', ->
it 'reports its loadedness', ->
expect(OrderCycle.loaded).toBe(false)
OrderCycle.load('123')
$httpBackend.flush()
expect(OrderCycle.loaded).toBe(true)
describe 'loading a new order cycle', ->
beforeEach ->
OrderCycle.new()
$httpBackend.flush()
it 'loads basic fields', ->
expect(OrderCycle.order_cycle.id).toEqual(123)
expect(OrderCycle.order_cycle.name).toEqual('New Order Cycle')
expect(OrderCycle.order_cycle.coordinator_id).toEqual(456)
it 'initialises the incoming and outgoing exchanges', ->
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual []
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual []
it 'removes the original exchanges array', ->
expect(OrderCycle.order_cycle.exchanges).toBeUndefined()
describe 'loading an existing order cycle', ->
beforeEach ->
OrderCycle.load('123')
$httpBackend.flush()
it 'loads basic fields', ->
expect(OrderCycle.order_cycle.id).toEqual(123)
expect(OrderCycle.order_cycle.name).toEqual('Test Order Cycle')
expect(OrderCycle.order_cycle.coordinator_id).toEqual(456)
it 'splits exchanges into incoming and outgoing', ->
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [
sender_id: 1
enterprise_id: 1
incoming: true
active: true
]
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
receiver_id: 2
enterprise_id: 2
incoming: false
active: true
]
it 'removes the original exchanges array', ->
expect(OrderCycle.order_cycle.exchanges).toBeUndefined()
describe 'creating an order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'confirmNoDistributors').and.returnValue true
it 'redirects to the destination page on success', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPOST('/admin/order_cycles.json', {
order_cycle: 'this is the submit data'
}).respond {success: true}
OrderCycle.create('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual('/destination/page')
it 'does not redirect on error', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPOST('/admin/order_cycles.json', {
order_cycle: 'this is the submit data'
}).respond 400, { errors: [] }
OrderCycle.create('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual(undefined)
describe 'updating an order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'confirmNoDistributors').and.returnValue true
it 'redirects to the destination page on success', ->
form = jasmine.createSpyObj('order_cycle_form', ['$dirty', '$setPristine'])
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPUT('/admin/order_cycles.json?reloading=1', {
order_cycle: 'this is the submit data'
}).respond {success: true}
OrderCycle.update('/destination/page', form)
$httpBackend.flush()
expect($window.location).toEqual('/destination/page')
expect(form.$setPristine.calls.count()).toBe 1
it 'does not redirect on error', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPUT('/admin/order_cycles.json?reloading=1', {
order_cycle: 'this is the submit data'
}).respond 400, { errors: [] }
OrderCycle.update('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual(undefined)
describe 'preparing data for form submission', ->
it 'calls all the methods', ->
OrderCycle.order_cycle = {foo: 'bar'}
spyOn(OrderCycle, 'removeInactiveExchanges')
spyOn(OrderCycle, 'translateCoordinatorFees')
spyOn(OrderCycle, 'translateExchangeFees')
OrderCycle.dataForSubmit()
expect(OrderCycle.removeInactiveExchanges).toHaveBeenCalled()
expect(OrderCycle.translateCoordinatorFees).toHaveBeenCalled()
expect(OrderCycle.translateExchangeFees).toHaveBeenCalled()
it 'removes inactive exchanges', ->
data =
incoming_exchanges: [
{enterprise_id: "1", active: false}
{enterprise_id: "2", active: true}
{enterprise_id: "3", active: false}
]
outgoing_exchanges: [
{enterprise_id: "4", active: true}
{enterprise_id: "5", active: false}
{enterprise_id: "6", active: true}
]
data = OrderCycle.removeInactiveExchanges(data)
expect(data.incoming_exchanges).toEqual [
{enterprise_id: "2", active: true}
]
expect(data.outgoing_exchanges).toEqual [
{enterprise_id: "4", active: true}
{enterprise_id: "6", active: true}
]
it 'converts coordinator fees into a list of ids', ->
order_cycle =
coordinator_fees: [
{id: 1}
{id: 2}
]
data = OrderCycle.translateCoordinatorFees(order_cycle)
expect(data.coordinator_fees).toBeUndefined()
expect(data.coordinator_fee_ids).toEqual [1, 2]
it "preserves original data when converting coordinator fees", ->
OrderCycle.order_cycle =
coordinator_fees: [
{id: 1}
{id: 2}
]
data = OrderCycle.deepCopy()
data = OrderCycle.translateCoordinatorFees(data)
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{id: 1}, {id: 2}]
expect(OrderCycle.order_cycle.coordinator_fee_ids).toBeUndefined()
describe "converting exchange fees into a list of ids", ->
order_cycle = null
data = null
beforeEach ->
order_cycle =
incoming_exchanges: [
enterprise_fees: [
{id: 1}
{id: 2}
]
]
outgoing_exchanges: [
enterprise_fees: [
{id: 3}
{id: 4}
]
]
OrderCycle.order_cycle = order_cycle
data = OrderCycle.deepCopy()
data = OrderCycle.translateExchangeFees(data)
it 'converts exchange fees into a list of ids', ->
expect(data.incoming_exchanges[0].enterprise_fees).toBeUndefined()
expect(data.outgoing_exchanges[0].enterprise_fees).toBeUndefined()
expect(data.incoming_exchanges[0].enterprise_fee_ids).toEqual [1, 2]
expect(data.outgoing_exchanges[0].enterprise_fee_ids).toEqual [3, 4]
it "preserves original data when converting exchange fees", ->
expect(order_cycle.incoming_exchanges[0].enterprise_fees).toEqual [{id: 1}, {id: 2}]
expect(order_cycle.outgoing_exchanges[0].enterprise_fees).toEqual [{id: 3}, {id: 4}]
expect(order_cycle.incoming_exchanges[0].enterprise_fee_ids).toBeUndefined()
expect(order_cycle.outgoing_exchanges[0].enterprise_fee_ids).toBeUndefined()
describe "confirming when there are no distributors", ->
order_cycle_with_exchanges = order_cycle_without_exchanges = null
beforeEach ->
order_cycle_with_exchanges =
outgoing_exchanges: [{}]
order_cycle_without_exchanges =
outgoing_exchanges: []
it "returns true when there are distributors", ->
spyOn(window, 'confirm')
OrderCycle.order_cycle = order_cycle_with_exchanges
expect(OrderCycle.confirmNoDistributors()).toBe true
expect(window.confirm).not.toHaveBeenCalled()
it "returns true when there are no distributors but the user confirms", ->
spyOn(window, 'confirm').and.returnValue(true)
OrderCycle.order_cycle = order_cycle_without_exchanges
expect(OrderCycle.confirmNoDistributors()).toBe true
expect(window.confirm).toHaveBeenCalled()
it "returns false when there are no distributors and the user does not confirm", ->
spyOn(window, 'confirm').and.returnValue(false)
OrderCycle.order_cycle = order_cycle_without_exchanges
expect(OrderCycle.confirmNoDistributors()).toBe false
expect(window.confirm).toHaveBeenCalled()

View File

@@ -1,968 +0,0 @@
describe 'OrderCycle controllers', ->
describe 'AdminCreateOrderCycleCtrl', ->
ctrl = null
scope = null
event = null
OrderCycle = null
Enterprise = null
EnterpriseFee = null
beforeEach ->
scope =
order_cycle_form: jasmine.createSpyObj('order_cycle_form', ['$dirty'])
$watch: jasmine.createSpy('$watch')
event =
preventDefault: jasmine.createSpy('preventDefault')
OrderCycle =
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').and.returnValue('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').and.returnValue('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').and.returnValue('variant supplied')
exchangeDirection: jasmine.createSpy('exchangeDirection').and.returnValue('exchange direction')
toggleProducts: jasmine.createSpy('toggleProducts')
setExchangeVariants: jasmine.createSpy('setExchangeVariants')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
removeExchange: jasmine.createSpy('removeExchange')
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
addExchangeFee: jasmine.createSpy('addExchangeFee')
removeExchangeFee: jasmine.createSpy('removeExchangeFee')
removeDistributionOfVariant: jasmine.createSpy('removeDistributionOfVariant')
create: jasmine.createSpy('create')
new: jasmine.createSpy('new').and.returnValue "my order cycle"
Enterprise =
index: jasmine.createSpy('index').and.returnValue('enterprises list')
supplied_products: 'supplied products'
suppliedVariants: jasmine.createSpy('suppliedVariants').and.returnValue('supplied variants')
totalVariants: jasmine.createSpy('totalVariants').and.returnValue('variants total')
EnterpriseFee =
index: jasmine.createSpy('index').and.returnValue('enterprise fees list')
forEnterprise: jasmine.createSpy('forEnterprise').and.returnValue('enterprise fees for enterprise')
ocInstance = {}
module('admin.orderCycles')
inject ($controller) ->
ctrl = $controller 'AdminCreateOrderCycleCtrl', {$scope: scope, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee, ocInstance: ocInstance}
it 'Loads enterprises and supplied products', ->
expect(Enterprise.index).toHaveBeenCalled()
expect(scope.enterprises).toEqual('enterprises list')
expect(scope.supplied_products).toEqual('supplied products')
it 'Loads enterprise fees', ->
expect(EnterpriseFee.index).toHaveBeenCalled()
expect(scope.enterprise_fees).toEqual('enterprise fees list')
it 'Loads order cycles', ->
expect(scope.order_cycle).toEqual('my order cycle')
describe 'Reporting when all resources are loaded', ->
beforeEach inject (RequestMonitor) ->
RequestMonitor.loading = false
Enterprise.loaded = true
EnterpriseFee.loaded = true
OrderCycle.loaded = true
it 'returns true when all resources are loaded', ->
expect(scope.loaded()).toBe(true)
it 'returns false otherwise', ->
EnterpriseFee.loaded = false
expect(scope.loaded()).toBe(false)
it "delegates suppliedVariants to Enterprise", ->
expect(scope.suppliedVariants('enterprise_id')).toEqual('supplied variants')
expect(Enterprise.suppliedVariants).toHaveBeenCalledWith('enterprise_id')
it 'Delegates exchangeSelectedVariants to OrderCycle', ->
expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange')
it "delegates setExchangeVariants to OrderCycle", ->
scope.setExchangeVariants('exchange', 'variants', 'selected')
expect(OrderCycle.setExchangeVariants).toHaveBeenCalledWith('exchange', 'variants', 'selected')
it 'Delegates enterpriseTotalVariants to Enterprise', ->
expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total')
expect(Enterprise.totalVariants).toHaveBeenCalledWith('enterprise')
it 'Delegates productSuppliedToOrderCycle to OrderCycle', ->
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates exchangeDirection to OrderCycle', ->
expect(scope.exchangeDirection('exchange')).toEqual('exchange direction')
expect(OrderCycle.exchangeDirection).toHaveBeenCalledWith('exchange')
it 'Finds enterprises participating in the order cycle that have fees', ->
scope.enterprises =
1: {id: 1, name: 'Eaterprises'}
2: {id: 2, name: 'Pepper Tree Place'}
3: {id: 3, name: 'South East'}
OrderCycle.participatingEnterpriseIds = jasmine.createSpy('participatingEnterpriseIds').and.returnValue([2])
EnterpriseFee.enterprise_fees = [ {enterprise_id: 2} ] # Pepper Tree Place has a fee
expect(scope.enterprisesWithFees()).toEqual([
{id: 2, name: 'Pepper Tree Place'}
])
it 'Delegates enterpriseFeesForEnterprise to EnterpriseFee', ->
scope.enterpriseFeesForEnterprise('123')
expect(EnterpriseFee.forEnterprise).toHaveBeenCalledWith(123)
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addSupplier).toHaveBeenCalledWith('new supplier id')
it 'Adds order cycle distributors', ->
scope.new_distributor_id = 'new distributor id'
scope.addDistributor(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
it 'Removes order cycle exchanges', ->
scope.removeExchange(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchange).toHaveBeenCalledWith('exchange')
it 'Adds coordinator fees', ->
scope.addCoordinatorFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
it 'Removes coordinator fees', ->
scope.removeCoordinatorFee(event, 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeCoordinatorFee).toHaveBeenCalledWith(0)
it 'Adds exchange fees', ->
scope.addExchangeFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addExchangeFee).toHaveBeenCalled()
it 'Removes exchange fees', ->
scope.removeExchangeFee(event, 'exchange', 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchangeFee).toHaveBeenCalledWith('exchange', 0)
it 'Removes distribution of a variant', ->
scope.removeDistributionOfVariant('variant')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('variant')
it 'Submits the order cycle via OrderCycle create', ->
eventMock = {preventDefault: jasmine.createSpy()}
scope.submit(eventMock,'/admin/order_cycles')
expect(eventMock.preventDefault).toHaveBeenCalled()
expect(OrderCycle.create).toHaveBeenCalledWith('/admin/order_cycles')
describe 'AdminEditOrderCycleCtrl', ->
ctrl = null
scope = null
event = null
location = null
OrderCycle = null
Enterprise = null
EnterpriseFee = null
beforeEach ->
scope =
order_cycle_form: jasmine.createSpyObj('order_cycle_form', ['$dirty', '$setPristine'])
$watch: jasmine.createSpy('$watch')
event =
preventDefault: jasmine.createSpy('preventDefault')
location =
absUrl: ->
'example.com/admin/order_cycles/27/edit'
OrderCycle =
load: jasmine.createSpy('load')
exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').and.returnValue('variants selected')
productSuppliedToOrderCycle: jasmine.createSpy('productSuppliedToOrderCycle').and.returnValue('product supplied')
variantSuppliedToOrderCycle: jasmine.createSpy('variantSuppliedToOrderCycle').and.returnValue('variant supplied')
exchangeDirection: jasmine.createSpy('exchangeDirection').and.returnValue('exchange direction')
toggleProducts: jasmine.createSpy('toggleProducts')
setExchangeVariants: jasmine.createSpy('setExchangeVariants')
addSupplier: jasmine.createSpy('addSupplier')
addDistributor: jasmine.createSpy('addDistributor')
removeExchange: jasmine.createSpy('removeExchange')
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
removeCoordinatorFee: jasmine.createSpy('removeCoordinatorFee')
addExchangeFee: jasmine.createSpy('addExchangeFee')
removeExchangeFee: jasmine.createSpy('removeExchangeFee')
removeDistributionOfVariant: jasmine.createSpy('removeDistributionOfVariant')
update: jasmine.createSpy('update')
Enterprise =
index: jasmine.createSpy('index').and.returnValue('enterprises list')
supplied_products: 'supplied products'
suppliedVariants: jasmine.createSpy('suppliedVariants').and.returnValue('supplied variants')
totalVariants: jasmine.createSpy('totalVariants').and.returnValue('variants total')
EnterpriseFee =
index: jasmine.createSpy('index').and.returnValue('enterprise fees list')
forEnterprise: jasmine.createSpy('forEnterprise').and.returnValue('enterprise fees for enterprise')
module('admin.orderCycles')
inject ($controller) ->
ctrl = $controller 'AdminEditOrderCycleCtrl', {$scope: scope, $location: location, OrderCycle: OrderCycle, Enterprise: Enterprise, EnterpriseFee: EnterpriseFee}
it 'Loads enterprises and supplied products', ->
expect(Enterprise.index).toHaveBeenCalled()
expect(scope.enterprises).toEqual('enterprises list')
expect(scope.supplied_products).toEqual('supplied products')
it 'Loads enterprise fees', ->
expect(EnterpriseFee.index).toHaveBeenCalled()
expect(scope.enterprise_fees).toEqual('enterprise fees list')
it 'Loads order cycles', ->
expect(OrderCycle.load).toHaveBeenCalledWith('27')
describe 'Reporting when all resources are loaded', ->
beforeEach inject (RequestMonitor) ->
RequestMonitor.loading = false
Enterprise.loaded = true
EnterpriseFee.loaded = true
OrderCycle.loaded = true
it 'returns true when all resources are loaded', ->
expect(scope.loaded()).toBe(true)
it 'returns false otherwise', ->
EnterpriseFee.loaded = false
expect(scope.loaded()).toBe(false)
it "delegates suppliedVariants to Enterprise", ->
expect(scope.suppliedVariants('enterprise_id')).toEqual('supplied variants')
expect(Enterprise.suppliedVariants).toHaveBeenCalledWith('enterprise_id')
it 'Delegates exchangeSelectedVariants to OrderCycle', ->
expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected')
expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange')
it "delegates setExchangeVariants to OrderCycle", ->
scope.setExchangeVariants('exchange', 'variants', 'selected')
expect(OrderCycle.setExchangeVariants).toHaveBeenCalledWith('exchange', 'variants', 'selected')
it 'Delegates totalVariants to Enterprise', ->
expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total')
expect(Enterprise.totalVariants).toHaveBeenCalledWith('enterprise')
it 'Delegates productSuppliedToOrderCycle to OrderCycle', ->
expect(scope.productSuppliedToOrderCycle('product')).toEqual('product supplied')
expect(OrderCycle.productSuppliedToOrderCycle).toHaveBeenCalledWith('product')
it 'Delegates variantSuppliedToOrderCycle to OrderCycle', ->
expect(scope.variantSuppliedToOrderCycle('variant')).toEqual('variant supplied')
expect(OrderCycle.variantSuppliedToOrderCycle).toHaveBeenCalledWith('variant')
it 'Delegates exchangeDirection to OrderCycle', ->
expect(scope.exchangeDirection('exchange')).toEqual('exchange direction')
expect(OrderCycle.exchangeDirection).toHaveBeenCalledWith('exchange')
it 'Finds enterprises participating in the order cycle that have fees', ->
scope.enterprises =
1: {id: 1, name: 'Eaterprises'}
2: {id: 2, name: 'Pepper Tree Place'}
3: {id: 3, name: 'South East'}
OrderCycle.participatingEnterpriseIds = jasmine.createSpy('participatingEnterpriseIds').and.returnValue([2])
EnterpriseFee.enterprise_fees = [ {enterprise_id: 2} ] # Pepper Tree Place has a fee
expect(scope.enterprisesWithFees()).toEqual([
{id: 2, name: 'Pepper Tree Place'}
])
it 'Delegates enterpriseFeesForEnterprise to EnterpriseFee', ->
scope.enterpriseFeesForEnterprise('123')
expect(EnterpriseFee.forEnterprise).toHaveBeenCalledWith(123)
it 'Adds order cycle suppliers', ->
scope.new_supplier_id = 'new supplier id'
scope.addSupplier(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addSupplier).toHaveBeenCalledWith('new supplier id')
it 'Adds order cycle distributors', ->
scope.new_distributor_id = 'new distributor id'
scope.addDistributor(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
it 'Removes order cycle exchanges', ->
scope.removeExchange(event, 'exchange')
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchange).toHaveBeenCalledWith('exchange')
expect(scope.order_cycle_form.$dirty).toEqual true
it 'Adds coordinator fees', ->
scope.addCoordinatorFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
it 'Removes coordinator fees', ->
scope.removeCoordinatorFee(event, 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeCoordinatorFee).toHaveBeenCalledWith(0)
expect(scope.order_cycle_form.$dirty).toEqual true
it 'Adds exchange fees', ->
scope.addExchangeFee(event)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.addExchangeFee).toHaveBeenCalled()
it 'Removes exchange fees', ->
scope.removeExchangeFee(event, 'exchange', 0)
expect(event.preventDefault).toHaveBeenCalled()
expect(OrderCycle.removeExchangeFee).toHaveBeenCalledWith('exchange', 0)
expect(scope.order_cycle_form.$dirty).toEqual true
it 'Removes distribution of a variant', ->
scope.removeDistributionOfVariant('variant')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('variant')
it 'Submits the order cycle via OrderCycle update', ->
eventMock = {preventDefault: jasmine.createSpy()}
scope.submit(eventMock,'/admin/order_cycles')
expect(eventMock.preventDefault).toHaveBeenCalled()
expect(OrderCycle.update).toHaveBeenCalledWith('/admin/order_cycles', scope.order_cycle_form)
describe 'OrderCycle services', ->
describe 'Enterprise service', ->
$httpBackend = null
Enterprise = null
beforeEach ->
module 'admin.orderCycles'
inject ($injector, _$httpBackend_)->
Enterprise = $injector.get('Enterprise')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/enterprises/for_order_cycle.json').respond [
{id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true}
{id: 2, name: 'Two', supplied_products: [3, 4]}
{id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'}
]
it 'loads enterprises as a hash', ->
enterprises = Enterprise.index()
$httpBackend.flush()
expect(enterprises).toEqual
1: new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true})
2: new Enterprise.Enterprise({id: 2, name: 'Two', supplied_products: [3, 4]})
3: new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'})
it 'reports its loadedness', ->
expect(Enterprise.loaded).toBe(false)
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.loaded).toBe(true)
it 'loads producers as an array', ->
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.producer_enterprises).toEqual [new Enterprise.Enterprise({id: 1, name: 'One', supplied_products: [1, 2], is_primary_producer: true})]
it 'loads hubs as an array', ->
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.hub_enterprises).toEqual [new Enterprise.Enterprise({id: 3, name: 'Three', supplied_products: [5, 6], sells: 'any'})]
it 'collates all supplied products', ->
enterprises = Enterprise.index()
$httpBackend.flush()
expect(Enterprise.supplied_products).toEqual [1, 2, 3, 4, 5, 6]
it "finds supplied variants for an enterprise", ->
spyOn(Enterprise, 'variantsOf').and.returnValue(10)
Enterprise.index()
$httpBackend.flush()
expect(Enterprise.suppliedVariants(1)).toEqual [10, 10]
describe "finding the variants of a product", ->
it "returns the master for products without variants", ->
p =
master_id: 1
variants: []
expect(Enterprise.variantsOf(p)).toEqual [1]
it "returns the variant ids for products with variants", ->
p =
master_id: 1
variants: [{id: 2}, {id: 3}]
expect(Enterprise.variantsOf(p)).toEqual [2, 3]
it 'counts total variants supplied by an enterprise', ->
enterprise =
supplied_products: [
{variants: []},
{variants: []},
{variants: [{}, {}, {}]}
]
expect(Enterprise.totalVariants(enterprise)).toEqual(5)
it 'returns zero when enterprise is null', ->
expect(Enterprise.totalVariants(null)).toEqual(0)
describe 'EnterpriseFee service', ->
$httpBackend = null
EnterpriseFee = null
beforeEach ->
module 'admin.orderCycles'
inject ($injector, _$httpBackend_)->
EnterpriseFee = $injector.get('EnterpriseFee')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/enterprise_fees/for_order_cycle.json').respond [
{id: 1, name: "Yayfee", enterprise_id: 1}
{id: 2, name: "FeeTwo", enterprise_id: 2}
]
it 'loads enterprise fees', ->
enterprise_fees = EnterpriseFee.index()
$httpBackend.flush()
expected_fees = [
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee", enterprise_id: 1})
new EnterpriseFee.EnterpriseFee({id: 2, name: "FeeTwo", enterprise_id: 2})
]
for fee, i in enterprise_fees
expect(fee.id).toEqual(expected_fees[i].id)
it 'reports its loadedness', ->
expect(EnterpriseFee.loaded).toBe(false)
EnterpriseFee.index()
$httpBackend.flush()
expect(EnterpriseFee.loaded).toBe(true)
it 'returns enterprise fees for an enterprise', ->
all_enterprise_fees = EnterpriseFee.index()
$httpBackend.flush()
enterprise_fees = EnterpriseFee.forEnterprise(1)
expect(enterprise_fees).toEqual [
new EnterpriseFee.EnterpriseFee({id: 1, name: "Yayfee", enterprise_id: 1})
]
describe 'OrderCycle service', ->
OrderCycle = null
$httpBackend = null
$window = null
beforeEach ->
$window = {navigator: {userAgent: 'foo'}}
module 'admin.orderCycles', ($provide)->
$provide.value('$window', $window)
null
inject ($injector, _$httpBackend_)->
OrderCycle = $injector.get('OrderCycle')
$httpBackend = _$httpBackend_
$httpBackend.whenGET('/admin/order_cycles/123.json').respond
id: 123
name: 'Test Order Cycle'
coordinator_id: 456
coordinator_fees: []
exchanges: [
{sender_id: 1, receiver_id: 456, incoming: true}
{sender_id: 456, receiver_id: 2, incoming: false}
]
$httpBackend.whenGET('/admin/order_cycles/new.json').respond
id: 123
name: 'New Order Cycle'
coordinator_id: 456
coordinator_fees: []
exchanges: []
it 'initialises order cycle', ->
expect(OrderCycle.order_cycle).toEqual {incoming_exchanges: [], outgoing_exchanges: []}
it 'counts selected variants in an exchange', ->
result = OrderCycle.exchangeSelectedVariants({variants: {1: true, 2: false, 3: true}})
expect(result).toEqual(2)
describe "fetching exchange ids", ->
it "gets enterprise ids as ints", ->
OrderCycle.order_cycle.incoming_exchanges = [
{enterprise_id: 1}
{enterprise_id: '2'}
]
OrderCycle.order_cycle.outgoing_exchanges = [
{enterprise_id: 3}
{enterprise_id: '4'}
]
expect(OrderCycle.exchangeIds('incoming')).toEqual [1, 2]
describe "checking for novel enterprises", ->
e1 = {id: 1}
e2 = {id: 2}
beforeEach ->
OrderCycle.order_cycle.incoming_exchanges = [{enterprise_id: 1}]
OrderCycle.order_cycle.outgoing_exchanges = [{enterprise_id: 1}]
it "detects novel suppliers", ->
expect(OrderCycle.novelSupplier(e1)).toBe false
expect(OrderCycle.novelSupplier(e2)).toBe true
it "detects novel suppliers with enterprise as string id", ->
expect(OrderCycle.novelSupplier('1')).toBe false
expect(OrderCycle.novelSupplier('2')).toBe true
it "detects novel distributors", ->
expect(OrderCycle.novelDistributor(e1)).toBe false
expect(OrderCycle.novelDistributor(e2)).toBe true
it "detects novel distributors with enterprise as string id", ->
expect(OrderCycle.novelDistributor('1')).toBe false
expect(OrderCycle.novelDistributor('2')).toBe true
describe 'fetching the direction for an exchange', ->
it 'returns "incoming" for incoming exchanges', ->
exchange = {id: 1}
OrderCycle.order_cycle.incoming_exchanges = [exchange]
OrderCycle.order_cycle.outgoing_exchanges = []
expect(OrderCycle.exchangeDirection(exchange)).toEqual 'incoming'
it 'returns "outgoing" for outgoing exchanges', ->
exchange = {id: 1}
OrderCycle.order_cycle.incoming_exchanges = []
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
expect(OrderCycle.exchangeDirection(exchange)).toEqual 'outgoing'
describe "setting exchange variants", ->
describe "when I have permissions to edit the variants", ->
beforeEach ->
OrderCycle.order_cycle["editable_variants_for_outgoing_exchanges"] = { 1: [1, 2, 3] }
it "sets all variants to the provided value", ->
exchange = { enterprise_id: 1, incoming: false, variants: {2: false}}
OrderCycle.setExchangeVariants(exchange, [1, 2, 3], true)
expect(exchange.variants).toEqual {1: true, 2: true, 3: true}
describe "when I don't have permissions to edit the variants", ->
beforeEach ->
OrderCycle.order_cycle["editable_variants_for_outgoing_exchanges"] = { 1: [] }
it "does not change variants to the provided value", ->
exchange = { enterprise_id: 1, incoming: false, variants: {2: false}}
OrderCycle.setExchangeVariants(exchange, [1, 2, 3], true)
expect(exchange.variants).toEqual {2: false}
describe 'adding suppliers', ->
exchange = null
beforeEach ->
# Initialise OC
OrderCycle.new()
$httpBackend.flush()
it 'adds the supplier to incoming exchanges', ->
OrderCycle.addSupplier('123')
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [
{enterprise_id: '123', incoming: true, active: true, variants: {}, enterprise_fees: []}
]
describe 'adding distributors', ->
exchange = null
beforeEach ->
# Initialise OC
OrderCycle.new()
$httpBackend.flush()
it 'adds the distributor to outgoing exchanges', ->
OrderCycle.addDistributor('123')
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
{enterprise_id: '123', incoming: false, active: true, variants: {}, enterprise_fees: []}
]
describe 'removing exchanges', ->
exchange = null
beforeEach ->
spyOn(OrderCycle, 'removeDistributionOfVariant')
exchange =
enterprise_id: '123'
active: true
incoming: false
variants: {1: true, 2: false, 3: true}
enterprise_fees: []
describe "removing incoming exchanges", ->
beforeEach ->
exchange.incoming = true
OrderCycle.order_cycle.incoming_exchanges = [exchange]
it 'removes the exchange', ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual []
it 'removes distribution of all exchange variants', ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('1')
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalledWith('2')
expect(OrderCycle.removeDistributionOfVariant).toHaveBeenCalledWith('3')
describe "removing outgoing exchanges", ->
beforeEach ->
exchange.incoming = false
OrderCycle.order_cycle.outgoing_exchanges = [exchange]
it 'removes the exchange', ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual []
it "does not remove distribution of any variants", ->
OrderCycle.removeExchange(exchange)
expect(OrderCycle.removeDistributionOfVariant).not.toHaveBeenCalled()
it 'adds coordinator fees', ->
# Initialise OC
OrderCycle.new()
$httpBackend.flush()
OrderCycle.addCoordinatorFee()
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{}]
describe 'removing coordinator fees', ->
it 'removes a coordinator fee by index', ->
OrderCycle.order_cycle.coordinator_fees = [
{id: 1}
{id: 2}
{id: 3}
]
OrderCycle.removeCoordinatorFee(1)
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [
{id: 1}
{id: 3}
]
it 'adds exchange fees', ->
exchange = {enterprise_fees: []}
OrderCycle.addExchangeFee(exchange)
expect(exchange.enterprise_fees).toEqual [{}]
describe 'removing exchange fees', ->
it 'removes an exchange fee by index', ->
exchange =
enterprise_fees: [
{id: 1}
{id: 2}
{id: 3}
]
OrderCycle.removeExchangeFee(exchange, 1)
expect(exchange.enterprise_fees).toEqual [
{id: 1}
{id: 3}
]
it 'finds participating enterprise ids', ->
OrderCycle.order_cycle.incoming_exchanges = [
{enterprise_id: 1}
{enterprise_id: 2}
]
OrderCycle.order_cycle.outgoing_exchanges = [
{enterprise_id: 2}
{enterprise_id: 3}
]
expect(OrderCycle.participatingEnterpriseIds()).toEqual [1, 2, 3]
describe 'fetching all variants supplied on incoming exchanges', ->
it 'collects variants from incoming exchanges', ->
OrderCycle.order_cycle.incoming_exchanges = [
{variants: {1: true, 2: false}}
{variants: {3: false, 4: true}}
{variants: {5: true, 6: false}}
]
expect(OrderCycle.incomingExchangesVariants()).toEqual [1, 4, 5]
describe 'checking whether a product is supplied to the order cycle', ->
product_master_present = product_variant_present = product_master_absent = product_variant_absent = null
beforeEach ->
product_master_present =
name: "Linseed (500g)"
master_id: 1
variants: []
product_variant_present =
name: "Linseed (500g)"
master_id: 2
variants: [{id: 3}, {id: 4}]
product_master_absent =
name: "Linseed (500g)"
master_id: 5
variants: []
product_variant_absent =
name: "Linseed (500g)"
master_id: 6
variants: [{id: 7}, {id: 8}]
spyOn(OrderCycle, 'incomingExchangesVariants').and.returnValue([1, 3])
it 'returns true for products whose master is supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_master_present)).toBeTruthy()
it 'returns true for products for whom a variant is supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_present)).toBeTruthy()
it 'returns false for products whose master is not supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_master_absent)).toBeFalsy()
it 'returns false for products whose variants are not supplied', ->
expect(OrderCycle.productSuppliedToOrderCycle(product_variant_absent)).toBeFalsy()
describe 'checking whether a variant is supplied to the order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'incomingExchangesVariants').and.returnValue([1, 3])
it 'returns true for variants that are supplied', ->
expect(OrderCycle.variantSuppliedToOrderCycle({id: 1})).toBeTruthy()
it 'returns false for variants that are not supplied', ->
expect(OrderCycle.variantSuppliedToOrderCycle({id: 999})).toBeFalsy()
describe 'remove all distribution of a variant', ->
it 'removes the variant from every outgoing exchange', ->
OrderCycle.order_cycle.outgoing_exchanges = [
{variants: {123: true, 234: true}}
{variants: {123: true, 333: true}}
]
OrderCycle.removeDistributionOfVariant('123')
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
{variants: {123: false, 234: true}}
{variants: {123: false, 333: true}}
]
describe 'loading an order cycle, reporting loadedness', ->
it 'reports its loadedness', ->
expect(OrderCycle.loaded).toBe(false)
OrderCycle.load('123')
$httpBackend.flush()
expect(OrderCycle.loaded).toBe(true)
describe 'loading a new order cycle', ->
beforeEach ->
OrderCycle.new()
$httpBackend.flush()
it 'loads basic fields', ->
expect(OrderCycle.order_cycle.id).toEqual(123)
expect(OrderCycle.order_cycle.name).toEqual('New Order Cycle')
expect(OrderCycle.order_cycle.coordinator_id).toEqual(456)
it 'initialises the incoming and outgoing exchanges', ->
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual []
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual []
it 'removes the original exchanges array', ->
expect(OrderCycle.order_cycle.exchanges).toBeUndefined()
describe 'loading an existing order cycle', ->
beforeEach ->
OrderCycle.load('123')
$httpBackend.flush()
it 'loads basic fields', ->
expect(OrderCycle.order_cycle.id).toEqual(123)
expect(OrderCycle.order_cycle.name).toEqual('Test Order Cycle')
expect(OrderCycle.order_cycle.coordinator_id).toEqual(456)
it 'splits exchanges into incoming and outgoing', ->
expect(OrderCycle.order_cycle.incoming_exchanges).toEqual [
sender_id: 1
enterprise_id: 1
incoming: true
active: true
]
expect(OrderCycle.order_cycle.outgoing_exchanges).toEqual [
receiver_id: 2
enterprise_id: 2
incoming: false
active: true
]
it 'removes the original exchanges array', ->
expect(OrderCycle.order_cycle.exchanges).toBeUndefined()
describe 'creating an order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'confirmNoDistributors').and.returnValue true
it 'redirects to the destination page on success', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPOST('/admin/order_cycles.json', {
order_cycle: 'this is the submit data'
}).respond {success: true}
OrderCycle.create('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual('/destination/page')
it 'does not redirect on error', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPOST('/admin/order_cycles.json', {
order_cycle: 'this is the submit data'
}).respond 400, { errors: [] }
OrderCycle.create('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual(undefined)
describe 'updating an order cycle', ->
beforeEach ->
spyOn(OrderCycle, 'confirmNoDistributors').and.returnValue true
it 'redirects to the destination page on success', ->
form = jasmine.createSpyObj('order_cycle_form', ['$dirty', '$setPristine'])
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPUT('/admin/order_cycles.json?reloading=1', {
order_cycle: 'this is the submit data'
}).respond {success: true}
OrderCycle.update('/destination/page', form)
$httpBackend.flush()
expect($window.location).toEqual('/destination/page')
expect(form.$setPristine.calls.count()).toBe 1
it 'does not redirect on error', ->
OrderCycle.order_cycle = 'this is the order cycle'
spyOn(OrderCycle, 'dataForSubmit').and.returnValue('this is the submit data')
$httpBackend.expectPUT('/admin/order_cycles.json?reloading=1', {
order_cycle: 'this is the submit data'
}).respond 400, { errors: [] }
OrderCycle.update('/destination/page')
$httpBackend.flush()
expect($window.location).toEqual(undefined)
describe 'preparing data for form submission', ->
it 'calls all the methods', ->
OrderCycle.order_cycle = {foo: 'bar'}
spyOn(OrderCycle, 'removeInactiveExchanges')
spyOn(OrderCycle, 'translateCoordinatorFees')
spyOn(OrderCycle, 'translateExchangeFees')
OrderCycle.dataForSubmit()
expect(OrderCycle.removeInactiveExchanges).toHaveBeenCalled()
expect(OrderCycle.translateCoordinatorFees).toHaveBeenCalled()
expect(OrderCycle.translateExchangeFees).toHaveBeenCalled()
it 'removes inactive exchanges', ->
data =
incoming_exchanges: [
{enterprise_id: "1", active: false}
{enterprise_id: "2", active: true}
{enterprise_id: "3", active: false}
]
outgoing_exchanges: [
{enterprise_id: "4", active: true}
{enterprise_id: "5", active: false}
{enterprise_id: "6", active: true}
]
data = OrderCycle.removeInactiveExchanges(data)
expect(data.incoming_exchanges).toEqual [
{enterprise_id: "2", active: true}
]
expect(data.outgoing_exchanges).toEqual [
{enterprise_id: "4", active: true}
{enterprise_id: "6", active: true}
]
it 'converts coordinator fees into a list of ids', ->
order_cycle =
coordinator_fees: [
{id: 1}
{id: 2}
]
data = OrderCycle.translateCoordinatorFees(order_cycle)
expect(data.coordinator_fees).toBeUndefined()
expect(data.coordinator_fee_ids).toEqual [1, 2]
it "preserves original data when converting coordinator fees", ->
OrderCycle.order_cycle =
coordinator_fees: [
{id: 1}
{id: 2}
]
data = OrderCycle.deepCopy()
data = OrderCycle.translateCoordinatorFees(data)
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{id: 1}, {id: 2}]
expect(OrderCycle.order_cycle.coordinator_fee_ids).toBeUndefined()
describe "converting exchange fees into a list of ids", ->
order_cycle = null
data = null
beforeEach ->
order_cycle =
incoming_exchanges: [
enterprise_fees: [
{id: 1}
{id: 2}
]
]
outgoing_exchanges: [
enterprise_fees: [
{id: 3}
{id: 4}
]
]
OrderCycle.order_cycle = order_cycle
data = OrderCycle.deepCopy()
data = OrderCycle.translateExchangeFees(data)
it 'converts exchange fees into a list of ids', ->
expect(data.incoming_exchanges[0].enterprise_fees).toBeUndefined()
expect(data.outgoing_exchanges[0].enterprise_fees).toBeUndefined()
expect(data.incoming_exchanges[0].enterprise_fee_ids).toEqual [1, 2]
expect(data.outgoing_exchanges[0].enterprise_fee_ids).toEqual [3, 4]
it "preserves original data when converting exchange fees", ->
expect(order_cycle.incoming_exchanges[0].enterprise_fees).toEqual [{id: 1}, {id: 2}]
expect(order_cycle.outgoing_exchanges[0].enterprise_fees).toEqual [{id: 3}, {id: 4}]
expect(order_cycle.incoming_exchanges[0].enterprise_fee_ids).toBeUndefined()
expect(order_cycle.outgoing_exchanges[0].enterprise_fee_ids).toBeUndefined()
describe "confirming when there are no distributors", ->
order_cycle_with_exchanges = order_cycle_without_exchanges = null
beforeEach ->
order_cycle_with_exchanges =
outgoing_exchanges: [{}]
order_cycle_without_exchanges =
outgoing_exchanges: []
it "returns true when there are distributors", ->
spyOn(window, 'confirm')
OrderCycle.order_cycle = order_cycle_with_exchanges
expect(OrderCycle.confirmNoDistributors()).toBe true
expect(window.confirm).not.toHaveBeenCalled()
it "returns true when there are no distributors but the user confirms", ->
spyOn(window, 'confirm').and.returnValue(true)
OrderCycle.order_cycle = order_cycle_without_exchanges
expect(OrderCycle.confirmNoDistributors()).toBe true
expect(window.confirm).toHaveBeenCalled()
it "returns false when there are no distributors and the user does not confirm", ->
spyOn(window, 'confirm').and.returnValue(false)
OrderCycle.order_cycle = order_cycle_without_exchanges
expect(OrderCycle.confirmNoDistributors()).toBe false
expect(window.confirm).toHaveBeenCalled()

View File

@@ -58,6 +58,12 @@ xdescribe SubscriptionConfirmJob do
proxy_order.update_attributes!(confirmed_at: 1.second.ago)
expect(proxy_orders).to_not include proxy_order
end
it "ignores orders that have been cancelled" do
setup_email
proxy_order.order.cancel!
expect(proxy_orders).to_not include proxy_order
end
end
describe "performing the job" do

View File

@@ -5,22 +5,60 @@ module OpenFoodNetwork
describe CachedProductsRenderer do
let(:distributor) { double(:distributor, id: 123) }
let(:order_cycle) { double(:order_cycle, id: 456) }
let(:cpr) { CachedProductsRenderer.new(distributor, order_cycle) }
let(:cached_products_renderer) { CachedProductsRenderer.new(distributor, order_cycle) }
# keeps global state unchanged
around do |example|
original_config = Spree::Config[:enable_products_cache?]
example.run
Spree::Config[:enable_products_cache?] = original_config
end
describe "#products_json" do
context "when in testing / development" do
let(:products_renderer) do
double(ProductsRenderer, products_json: 'uncached products')
end
let(:products_renderer) do
double(ProductsRenderer, products_json: 'uncached products')
end
before do
allow(ProductsRenderer)
.to receive(:new)
.with(distributor, order_cycle) { products_renderer }
end
context "products cache toggle" do
before do
allow(ProductsRenderer)
.to receive(:new)
.with(distributor, order_cycle) { products_renderer }
allow(Rails.env).to receive(:production?) { true }
Rails.cache.write "products-json-#{distributor.id}-#{order_cycle.id}", 'products'
end
it "returns uncaches products JSON" do
expect(cpr.products_json).to eq 'uncached products'
context "disabled" do
before do
Spree::Config[:enable_products_cache?] = false
end
it "returns uncached products JSON" do
expect(cached_products_renderer.products_json).to eq 'uncached products'
end
end
context "enabled" do
before do
Spree::Config[:enable_products_cache?] = true
end
it "returns the cached JSON" do
expect(cached_products_renderer.products_json).to eq 'products'
end
end
end
context "when in testing / development" do
before do
allow(Rails.env).to receive(:production?) { false }
end
it "returns uncached products JSON" do
expect(cached_products_renderer.products_json).to eq 'uncached products'
end
end
@@ -30,10 +68,10 @@ module OpenFoodNetwork
end
describe "when the distribution is not set" do
let(:cpr) { CachedProductsRenderer.new(nil, nil) }
let(:cached_products_renderer) { CachedProductsRenderer.new(nil, nil) }
it "raises an exception and returns no products" do
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
expect { cached_products_renderer.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
end
@@ -43,12 +81,12 @@ module OpenFoodNetwork
end
it "returns the cached JSON" do
expect(cpr.products_json).to eq 'products'
expect(cached_products_renderer.products_json).to eq 'products'
end
it "raises an exception when there are no products" do
Rails.cache.write "products-json-#{distributor.id}-#{order_cycle.id}", nil
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
expect { cached_products_renderer.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
end
@@ -70,11 +108,11 @@ module OpenFoodNetwork
describe "when there are products" do
it "returns products as JSON" do
expect(cpr.products_json).to eq 'fresh products'
expect(cached_products_renderer.products_json).to eq 'fresh products'
end
it "caches the JSON" do
cpr.products_json
cached_products_renderer.products_json
expect(cached_json).to eq 'fresh products'
end
end
@@ -91,11 +129,11 @@ module OpenFoodNetwork
end
it "raises an error" do
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
expect { cached_products_renderer.products_json }.to raise_error CachedProductsRenderer::NoProducts
end
it "caches the products as nil" do
expect { cpr.products_json }.to raise_error CachedProductsRenderer::NoProducts
expect { cached_products_renderer.products_json }.to raise_error CachedProductsRenderer::NoProducts
expect(cache_present).to be
expect(cached_json).to be_nil
end

View File

@@ -82,13 +82,6 @@ module OpenFoodNetwork
context "without an on_demand set" do
before { vo.update_column(:on_demand, nil) }
context "when count_on_hand is set" do
it "returns false" do
scoper.scope v
expect(v.on_demand).to be false
end
end
context "when count_on_hand is not set" do
before { vo.update_column(:count_on_hand, nil) }
@@ -97,6 +90,13 @@ module OpenFoodNetwork
expect(v.on_demand).to be true
end
end
context "when count_on_hand is set" do
it "should return validation error on save" do
scoper.scope v
expect{ vo.save! }.to raise_error ActiveRecord::RecordInvalid
end
end
end
end

View File

@@ -152,8 +152,23 @@ module WebHelper
page.driver.browser.switch_to.alert.accept
end
def angular_http_requests_finished(controller=nil)
page.evaluate_script("#{angular_scope(controller)}.injector().get('$http').pendingRequests.length == 0")
end
def request_monitor_finished(controller=nil)
page.evaluate_script("#{angular_scope(controller)}.scope().RequestMonitor.loading == false")
end
private
# Takes an optional angular controller name eg: "LineItemsCtrl",
# otherwise finds the first object in the DOM with an angular scope
def angular_scope(controller=nil)
element = controller ? "[ng-controller=#{controller}]" : '.ng-scope'
"angular.element(document.querySelector('#{element}'))"
end
def wait_for_ajax
wait_until { page.evaluate_script("$.active") == 0 }
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-timepicker-div .ui_tpicker_unit_hide{ display: none; }
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input { background: none; color: inherit; border: none; outline: none; border-bottom: solid 1px #555; width: 95%; }
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input:focus { border-bottom-color: #aaa; }
.ui-timepicker-rtl{ direction: rtl; }
.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
.ui-timepicker-rtl dl dt{ float: right; clear: right; }
.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; }
/* Shortened version style */
.ui-timepicker-div.ui-timepicker-oneLine { padding-right: 2px; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,
.ui-timepicker-div.ui-timepicker-oneLine dt { display: none; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label { display: block; padding-top: 2px; }
.ui-timepicker-div.ui-timepicker-oneLine dl { text-align: right; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd,
.ui-timepicker-div.ui-timepicker-oneLine dl dd > div { display:inline-block; margin:0; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute:before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second:before { content:':'; display:inline-block; }
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec:before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec:before { content:'.'; display:inline-block; }
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide:before{ display: none; }