Compare commits
15 commits
demo
...
demo-merge
Author | SHA1 | Date | |
---|---|---|---|
27b4177a4c | |||
bdeb47edec | |||
1c6413a67e | |||
|
f4f61f02db | ||
44f5d13920 | |||
f62dfc918b | |||
|
a355399f8e | ||
|
8cf500dc42 | ||
|
7694d0bdcf | ||
|
3c17b3abea | ||
|
9ce8524b49 | ||
|
ad62cbd086 | ||
|
a2c8c6e0e0 | ||
91a38bc73b | |||
782194cd08 |
59 changed files with 1537 additions and 137 deletions
145
.drone.yml
Normal file
145
.drone.yml
Normal file
|
@ -0,0 +1,145 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: build and test
|
||||
|
||||
steps:
|
||||
- name: rubocop
|
||||
image: circleci/ruby:2.7-bullseye-node-browsers-legacy
|
||||
commands:
|
||||
- sudo apt install --no-install-recommends -y libmagic-dev
|
||||
- sudo -E bundle install
|
||||
- sudo -E bundle exec rubocop
|
||||
volumes:
|
||||
- name: gem-cache
|
||||
path: /bundle
|
||||
- name: tmp
|
||||
path: /drone/src/tmp
|
||||
failure: ignore
|
||||
|
||||
|
||||
- name: build_test
|
||||
image: circleci/ruby:2.7-bullseye-node-browsers-legacy
|
||||
commands:
|
||||
- sudo apt install --no-install-recommends -y libmagic-dev
|
||||
- echo 'Wait for db container'; sleep 30
|
||||
- bundle config set path '/bundle'
|
||||
- bundle config set without 'production'
|
||||
- sudo -E bundle install
|
||||
- sudo -E bundle exec rake foodsoft:setup_development_docker || true
|
||||
- sudo -E bundle exec rake rspec-rerun:spec
|
||||
volumes:
|
||||
- name: gem-cache
|
||||
path: /bundle
|
||||
- name: tmp
|
||||
path: /drone/src/tmp
|
||||
environment:
|
||||
RAILS_LOG_TO_STDOUT: true
|
||||
RAILS_ENV: test
|
||||
COVERAGE: lcov
|
||||
DATABASE_URL: mysql2://user:password@mariadb/test?encoding=utf8mb4
|
||||
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true
|
||||
PARALLEL_TEST_PROCESSORS: 60
|
||||
|
||||
services:
|
||||
- name: mariadb
|
||||
image: mariadb
|
||||
environment:
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_DATABASE: test
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
|
||||
volumes:
|
||||
- name: gem-cache
|
||||
host:
|
||||
path: /tmp/cache
|
||||
- name: tmp
|
||||
temp: {}
|
||||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: docker build and deploy
|
||||
steps:
|
||||
- name: build and publish docker image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry: git.local-it.org
|
||||
repo: git.local-it.org/foodsoft/foodsoft
|
||||
username: philipp
|
||||
password:
|
||||
from_secret: docker_registry
|
||||
tags:
|
||||
- latest
|
||||
- ${DRONE_BRANCH}
|
||||
- ${DRONE_COMMIT:0:8}
|
||||
cache_from:
|
||||
- "git.local-it.org/foodsoft/foodsoft:latest"
|
||||
- "git.local-it.org/foodsoft/foodsoft:${DRONE_BRANCH}"
|
||||
- name: deployment
|
||||
image: git.local-it.org/philipp/stack-ssh-deply:latest
|
||||
settings:
|
||||
stack: "foodsoft_${DRONE_COMMIT:0:8}"
|
||||
compose: "deployment/compose.yml"
|
||||
deploy_key:
|
||||
from_secret: drone_deploy_key
|
||||
host: "dev.local-it.cloud"
|
||||
user: "root"
|
||||
port: 22
|
||||
reg_user: philipp
|
||||
reg_pass:
|
||||
from_secret: docker_registry
|
||||
reg_url: git.local-it.org
|
||||
image: git.local-it.org/foodsoft/foodsoft:${DRONE_COMMIT:0:8}
|
||||
generate_secrets: true
|
||||
networks:
|
||||
- proxy
|
||||
environment:
|
||||
IMAGE: git.local-it.org/foodsoft/foodsoft:${DRONE_COMMIT:0:8}
|
||||
STACK_NAME: "foodsoft_${DRONE_COMMIT:0:8}"
|
||||
DOMAIN: "${DRONE_COMMIT:0:8}.foodsoft.dev.local-it.cloud"
|
||||
LETS_ENCRYPT_ENV: production
|
||||
FOODCOOP_MULTI_INSTALL: true
|
||||
FOODCOOP_NAME: example
|
||||
FOODCOOP_CITY: XXX
|
||||
FOODCOOP_COUNTRY: XXX
|
||||
FOODCOOP_EMAIL: info@example.org
|
||||
FOODCOOP_PHONE: XXX
|
||||
FOODCOOP_STREET: XXX
|
||||
FOODCOOP_ZIP_CODE: XXX
|
||||
FOODCOOP_HOMEPAGE: https://order.example.org
|
||||
FOODCOOP_HELP_URL: https://order.example.org
|
||||
FOODCOOP_TIME_ZONE: Berlin
|
||||
FOODCOOP_USE_NICK: true
|
||||
FOODCOOP_LANGUAGE: de
|
||||
FOODCOOP_FOOTER: '<a href="https://example.org/">example</a> hosted by <a href="https://yourhoster.org">Your Tech Co-op</a>.'
|
||||
USE_APPLE_POINTS: false
|
||||
STOP_ORDERING_UNDER: 75
|
||||
MINIMUM_BALANCE: 0
|
||||
MYSQL_DB: foodsoft
|
||||
MYSQL_HOST: db
|
||||
MYSQL_PORT: 3306
|
||||
MYSQL_USER: foodsoft
|
||||
EMAIL_SENDER: noreply@example.org
|
||||
EMAIL_ERROR: systems@example.org
|
||||
SMTP_ADDRESS: mail.example.com
|
||||
SMTP_AUTHENTICATION: plain
|
||||
SMTP_DOMAIN: mail.example.com
|
||||
SMTP_ENABLE_STARTTLS_AUTO: true
|
||||
SMTP_PORT: 587
|
||||
SMTP_USER_NAME: foodsoft
|
||||
EMAIL_REPLY_DOMAIN: example.org
|
||||
SMTP_SERVER_HOST: 0.0.0.0
|
||||
SMTP_SERVER_PORT: 2525
|
||||
SECRET_DB_PASSWORD_VERSION: v1
|
||||
SECRET_DB_ROOT_PASSWORD_VERSION: v1
|
||||
SECRET_SHARED_LISTS_DB_PASSWORD_VERSION: v1
|
||||
SECRET_SMTP_PASSWORD_VERSION: v1
|
||||
SECRET_SECRET_KEY_BASE_VERSION: v1
|
||||
APP_CONFIG_VERSION: v1
|
||||
DB_CONFIG_VERSION: v1
|
||||
ENTRYPOINT_VERSION: v1
|
||||
PRODUCTION_ENV_VERSION: v1
|
||||
trigger:
|
||||
branch:
|
||||
- demo
|
|
@ -53,9 +53,10 @@ RUN export DATABASE_URL=mysql2://localhost/temp?encoding=utf8 && \
|
|||
rm -Rf /var/lib/apt/lists/* /var/cache/apt/*
|
||||
|
||||
# Make relevant dirs and files writable for app user
|
||||
RUN mkdir -p tmp && \
|
||||
RUN mkdir -p tmp storage && \
|
||||
chown nobody config/app_config.yml && \
|
||||
chown nobody tmp
|
||||
chown nobody tmp && \
|
||||
chown nobody storage
|
||||
|
||||
# Run app as unprivileged user
|
||||
USER nobody
|
||||
|
|
3
Gemfile
3
Gemfile
|
@ -49,6 +49,7 @@ gem 'attribute_normalizer'
|
|||
gem 'ice_cube'
|
||||
# At time of development 01-06-2022 mmddyyyy necessary fix for config_helper.rb form builder was not in rubygems so we pull from github, see: https://github.com/gregschmit/recurring_select/pull/152
|
||||
gem 'recurring_select', git: 'https://github.com/gregschmit/recurring_select'
|
||||
gem 'foodsoft_article_import', git: 'https://git.local-it.org/Foodsoft/foodsoft_article_import', tag: 'v1.0'
|
||||
gem 'roo'
|
||||
gem 'roo-xls'
|
||||
gem 'spreadsheet'
|
||||
|
@ -127,5 +128,5 @@ group :test do
|
|||
end
|
||||
|
||||
gem "importmap-rails", "~> 1.1"
|
||||
|
||||
gem "image_processing", "~> 1.12"
|
||||
gem "terser", "~> 1.1"
|
||||
|
|
16
Gemfile.lock
16
Gemfile.lock
|
@ -1,3 +1,11 @@
|
|||
GIT
|
||||
remote: https://git.local-it.org/Foodsoft/foodsoft_article_import
|
||||
revision: 49a0c1ddb3bb67a357c692c63af0cda2db7c45b0
|
||||
tag: v1.0
|
||||
specs:
|
||||
foodsoft_article_import (1.0.0)
|
||||
roo (~> 2.9.0)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/gregschmit/recurring_select
|
||||
revision: 29febc4c4abdd6c30636c33a7d2daecb09973ecf
|
||||
|
@ -255,6 +263,9 @@ GEM
|
|||
i18n-spec (0.6.0)
|
||||
iso
|
||||
ice_cube (0.16.4)
|
||||
image_processing (1.12.2)
|
||||
mini_magick (>= 4.9.5, < 5)
|
||||
ruby-vips (>= 2.0.17, < 3)
|
||||
importmap-rails (1.1.5)
|
||||
actionpack (>= 6.0.0)
|
||||
railties (>= 6.0.0)
|
||||
|
@ -318,6 +329,7 @@ GEM
|
|||
mime-types (3.4.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2022.0105)
|
||||
mini_magick (4.12.0)
|
||||
mini_mime (1.1.2)
|
||||
minitest (5.17.0)
|
||||
mono_logger (1.1.1)
|
||||
|
@ -496,6 +508,8 @@ GEM
|
|||
ruby-prof (1.4.5)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby-units (3.0.0)
|
||||
ruby-vips (2.1.4)
|
||||
ffi (~> 1.12)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.3.2)
|
||||
sass-rails (6.0.0)
|
||||
|
@ -618,6 +632,7 @@ DEPENDENCIES
|
|||
exception_notification
|
||||
factory_bot_rails
|
||||
faker
|
||||
foodsoft_article_import!
|
||||
foodsoft_discourse!
|
||||
foodsoft_documents!
|
||||
foodsoft_links!
|
||||
|
@ -631,6 +646,7 @@ DEPENDENCIES
|
|||
i18n-js (~> 3.0.0.rc8)
|
||||
i18n-spec
|
||||
ice_cube
|
||||
image_processing (~> 1.12)
|
||||
importmap-rails (~> 1.1)
|
||||
inherited_resources
|
||||
jquery-rails
|
||||
|
|
31
app/assets/stylesheets/actiontext.css
Normal file
31
app/assets/stylesheets/actiontext.css
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
|
||||
* the trix-editor content (whether displayed or under editing). Feel free to incorporate this
|
||||
* inclusion directly in any other asset bundle and remove this file.
|
||||
*
|
||||
*= require trix
|
||||
*/
|
||||
|
||||
/*
|
||||
* We need to override trix.css’s image gallery styles to accommodate the
|
||||
* <action-text-attachment> element we wrap around attachments. Otherwise,
|
||||
* images in galleries will be squished by the max-width: 33%; rule.
|
||||
*/
|
||||
.trix-content .attachment-gallery > action-text-attachment,
|
||||
.trix-content .attachment-gallery > .attachment {
|
||||
flex: 1 0 33%;
|
||||
padding: 0 0.5em;
|
||||
max-width: 33%;
|
||||
}
|
||||
|
||||
.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
|
||||
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
|
||||
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
|
||||
flex-basis: 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
.trix-content action-text-attachment .attachment {
|
||||
padding: 0 !important;
|
||||
max-width: 100% !important;
|
||||
}
|
|
@ -7,4 +7,5 @@
|
|||
*= require list.unlist
|
||||
*= require list.missing
|
||||
*= require recurring_select
|
||||
*= require actiontext
|
||||
*/
|
||||
|
|
|
@ -46,6 +46,11 @@ class ArticlesController < ApplicationController
|
|||
render :layout => false
|
||||
end
|
||||
|
||||
def edit
|
||||
@article = Article.find(params[:id])
|
||||
render :action => 'new', :layout => false
|
||||
end
|
||||
|
||||
def create
|
||||
@article = Article.new(params[:article])
|
||||
if @article.valid? && @article.save
|
||||
|
@ -55,11 +60,6 @@ class ArticlesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@article = Article.find(params[:id])
|
||||
render :action => 'new', :layout => false
|
||||
end
|
||||
|
||||
# Updates one Article and highlights the line if succeded
|
||||
def update
|
||||
@article = Article.find(params[:id])
|
||||
|
@ -148,10 +148,12 @@ class ArticlesController < ApplicationController
|
|||
# Update articles from a spreadsheet
|
||||
def parse_upload
|
||||
uploaded_file = params[:articles]['file'] or raise I18n.t('articles.controller.parse_upload.no_file')
|
||||
type = params[:articles]['type']
|
||||
options = { filename: uploaded_file.original_filename }
|
||||
options[:outlist_absent] = (params[:articles]['outlist_absent'] == '1')
|
||||
options[:convert_units] = (params[:articles]['convert_units'] == '1')
|
||||
@updated_article_pairs, @outlisted_articles, @new_articles = @supplier.sync_from_file uploaded_file.tempfile, options
|
||||
options[:update_category] = (params[:articles]['update_category'] == '1')
|
||||
@updated_article_pairs, @outlisted_articles, @new_articles = @supplier.sync_from_file uploaded_file.tempfile, type, options
|
||||
if @updated_article_pairs.empty? && @outlisted_articles.empty? && @new_articles.empty?
|
||||
redirect_to supplier_articles_path(@supplier), :notice => I18n.t('articles.controller.parse_upload.notice')
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ class Finance::FinancialTransactionsController < ApplicationController
|
|||
sort = "created_on DESC"
|
||||
end
|
||||
|
||||
@q = FinancialTransaction.search(params[:q])
|
||||
@q = FinancialTransaction.ransack(params[:q])
|
||||
@financial_transactions_all = @q.result(distinct: true).includes(:user).order(sort)
|
||||
@financial_transactions_all = @financial_transactions_all.visible unless params[:show_hidden]
|
||||
@financial_transactions_all = @financial_transactions_all.where(ordergroup_id: @ordergroup.id) if @ordergroup
|
||||
|
|
|
@ -11,7 +11,10 @@ class Finance::OrdergroupsController < Finance::BaseController
|
|||
@ordergroups = Ordergroup.undeleted.order(sort)
|
||||
@ordergroups = @ordergroups.include_transaction_class_sum
|
||||
@ordergroups = @ordergroups.where('groups.name LIKE ?', "%#{params[:query]}%") unless params[:query].nil?
|
||||
|
||||
@ordergroups = @ordergroups.page(params[:page]).per(@per_page)
|
||||
|
||||
@total_balances = FinancialTransactionClass.sorted.each_with_object({}) do |c, tmp|
|
||||
tmp[c.id] = c.financial_transactions.reduce(0) { | sum, t | sum + t.amount }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
||||
import "trix"
|
||||
import "@rails/actiontext"
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
# Foodsoft-file import
|
||||
class FoodsoftFile
|
||||
# parses a string from a foodsoft-file
|
||||
# returns two arrays with articles and outlisted_articles
|
||||
# the parsed article is a simple hash
|
||||
def self.parse(file, options = {})
|
||||
SpreadsheetFile.parse file, options do |row, row_index|
|
||||
next if row[2].blank?
|
||||
|
||||
article = { :order_number => row[1],
|
||||
:name => row[2],
|
||||
:note => row[3],
|
||||
:manufacturer => row[4],
|
||||
:origin => row[5],
|
||||
:unit => row[6],
|
||||
:price => row[7],
|
||||
:tax => row[8],
|
||||
:deposit => (row[9].nil? ? "0" : row[9]),
|
||||
:unit_quantity => row[10],
|
||||
:article_category => row[13] }
|
||||
status = row[0] && row[0].strip.downcase == 'x' ? :outlisted : nil
|
||||
yield status, article, row_index
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
require 'roo'
|
||||
|
||||
class SpreadsheetFile
|
||||
def self.parse(file, options = {})
|
||||
filepath = file.is_a?(String) ? file : file.to_path
|
||||
filename = options.delete(:filename) || filepath
|
||||
fileext = File.extname(filename)
|
||||
options[:csv_options] = { col_sep: ';', encoding: 'utf-8' }.merge(options[:csv_options] || {})
|
||||
s = Roo::Spreadsheet.open(filepath, options.merge({ extension: fileext }))
|
||||
|
||||
row_index = 1
|
||||
s.each do |row|
|
||||
if row_index == 1
|
||||
# @todo try to detect headers; for now using the index is ok
|
||||
else
|
||||
yield row, row_index
|
||||
end
|
||||
row_index += 1
|
||||
end
|
||||
row_index
|
||||
end
|
||||
end
|
|
@ -143,20 +143,24 @@ class Article < ApplicationRecord
|
|||
new_unit = new_article.unit
|
||||
end
|
||||
|
||||
return Article.compare_attributes(
|
||||
{
|
||||
:name => [self.name, new_article.name],
|
||||
:manufacturer => [self.manufacturer, new_article.manufacturer.to_s],
|
||||
:origin => [self.origin, new_article.origin],
|
||||
:unit => [self.unit, new_unit],
|
||||
:price => [self.price.to_f.round(2), new_price.to_f.round(2)],
|
||||
:tax => [self.tax, new_article.tax],
|
||||
:deposit => [self.deposit.to_f.round(2), new_article.deposit.to_f.round(2)],
|
||||
# take care of different num-objects.
|
||||
:unit_quantity => [self.unit_quantity.to_s.to_f, new_unit_quantity.to_s.to_f],
|
||||
:note => [self.note.to_s, new_article.note.to_s]
|
||||
}
|
||||
)
|
||||
attribute_hash = {
|
||||
:name => [self.name, new_article.name],
|
||||
:manufacturer => [self.manufacturer, new_article.manufacturer.to_s],
|
||||
:origin => [self.origin, new_article.origin],
|
||||
:unit => [self.unit, new_unit],
|
||||
:price => [self.price.to_f.round(2), new_price.to_f.round(2)],
|
||||
:tax => [self.tax, new_article.tax],
|
||||
:deposit => [self.deposit.to_f.round(2), new_article.deposit.to_f.round(2)],
|
||||
# take care of different num-objects.
|
||||
:unit_quantity => [self.unit_quantity.to_s.to_f, new_unit_quantity.to_s.to_f],
|
||||
:note => [self.note.to_s, new_article.note.to_s]
|
||||
}
|
||||
if options[:update_category] == true
|
||||
new_article_category = new_article.article_category
|
||||
attribute_hash[:article_category] = [self.article_category, new_article_category] unless new_article_category.blank?
|
||||
end
|
||||
|
||||
Article.compare_attributes(attribute_hash)
|
||||
end
|
||||
|
||||
# Compare attributes from two different articles.
|
||||
|
|
|
@ -8,7 +8,7 @@ module LocalizeInput
|
|||
separator = I18n.t("separator", scope: "number.format")
|
||||
delimiter = I18n.t("delimiter", scope: "number.format")
|
||||
input.gsub!(delimiter, "") if input.match(/\d+#{Regexp.escape(delimiter)}+\d+#{Regexp.escape(separator)}+\d+/) # Remove delimiter
|
||||
input.gsub!(separator, ".") # Replace separator with db compatible character
|
||||
input.gsub!(separator, ".") or input.gsub!(",", ".") # Replace separator with db compatible character
|
||||
input
|
||||
rescue
|
||||
Rails.logger.warn "Can't localize input: #{input}"
|
||||
|
|
|
@ -32,8 +32,8 @@ class GroupOrder < ApplicationRecord
|
|||
# Generate some data for the javascript methods in ordering view
|
||||
def load_data
|
||||
data = {}
|
||||
data[:account_balance] = ordergroup.nil? ? BigDecimal.new('+Infinity') : ordergroup.account_balance
|
||||
data[:available_funds] = ordergroup.nil? ? BigDecimal.new('+Infinity') : ordergroup.get_available_funds(self)
|
||||
data[:account_balance] = ordergroup.nil? ? BigDecimal('+Infinity') : ordergroup.account_balance
|
||||
data[:available_funds] = ordergroup.nil? ? BigDecimal('+Infinity') : ordergroup.get_available_funds(self)
|
||||
|
||||
# load prices and other stuff....
|
||||
data[:order_articles] = {}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
require 'foodsoft_article_import'
|
||||
class Supplier < ApplicationRecord
|
||||
include MarkAsDeletedWithName
|
||||
include CustomFields
|
||||
|
@ -73,15 +74,24 @@ class Supplier < ApplicationRecord
|
|||
# Synchronise articles with spreadsheet.
|
||||
#
|
||||
# @param file [File] Spreadsheet file to parse
|
||||
# @param options [Hash] Options passed to {FoodsoftFile#parse} except when listed here.
|
||||
# @param options [Hash] Options passed to {FoodsoftArticleImport#parse} except when listed here.
|
||||
# @option options [Boolean] :outlist_absent Set to +true+ to remove articles not in spreadsheet.
|
||||
# @option options [Boolean] :convert_units Omit or set to +true+ to keep current units, recomputing unit quantity and price.
|
||||
def sync_from_file(file, options = {})
|
||||
def sync_from_file(file, type, options = {})
|
||||
all_order_numbers = []
|
||||
updated_article_pairs, outlisted_articles, new_articles = [], [], []
|
||||
FoodsoftFile::parse file, options do |status, new_attrs, line|
|
||||
custom_codes_path = File.join(Rails.root, "config", "custom_codes.yml")
|
||||
opts = options.except(:convert_units, :outlist_absent)
|
||||
custom_codes_file_path = custom_codes_path if File.exist?(custom_codes_path)
|
||||
FoodsoftArticleImport.parse(file, custom_file_path: custom_codes_file_path, type: type, **opts) do |new_attrs, status, line|
|
||||
article = articles.undeleted.where(order_number: new_attrs[:order_number]).first
|
||||
new_attrs[:article_category] = ArticleCategory.find_match(new_attrs[:article_category])
|
||||
|
||||
if new_attrs[:article_category].present? && options[:update_category]
|
||||
new_attrs[:article_category] = ArticleCategory.find_match(new_attrs[:article_category]) || ArticleCategory.create_or_find_by!(name: new_attrs[:article_category])
|
||||
else
|
||||
new_attrs[:article_category] = nil
|
||||
end
|
||||
|
||||
new_attrs[:tax] ||= FoodsoftConfig[:tax_default]
|
||||
new_article = articles.build(new_attrs)
|
||||
|
||||
|
@ -89,7 +99,7 @@ class Supplier < ApplicationRecord
|
|||
if article.nil?
|
||||
new_articles << new_article
|
||||
else
|
||||
unequal_attributes = article.unequal_attributes(new_article, options.slice(:convert_units))
|
||||
unequal_attributes = article.unequal_attributes(new_article, options.slice(:convert_units, :update_category))
|
||||
unless unequal_attributes.empty?
|
||||
article.attributes = unequal_attributes
|
||||
updated_article_pairs << [article, unequal_attributes]
|
||||
|
|
14
app/views/active_storage/blobs/_blob.html.erb
Normal file
14
app/views/active_storage/blobs/_blob.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
|
||||
<% if blob.representable? %>
|
||||
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
|
||||
<% end %>
|
||||
|
||||
<figcaption class="attachment__caption">
|
||||
<% if caption = blob.try(:caption) %>
|
||||
<%= caption %>
|
||||
<% else %>
|
||||
<span class="attachment__name"><%= blob.filename %></span>
|
||||
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
|
||||
<% end %>
|
||||
</figcaption>
|
||||
</figure>
|
|
@ -49,7 +49,8 @@
|
|||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= form.text_field 'deposit', class: 'input-mini', style: 'width: 45px'
|
||||
%td= form.select :article_category_id, ArticleCategory.all.map {|a| [ a.name, a.id ] },
|
||||
%td{:style => highlight_new(attrs, :article_category)}
|
||||
= form.select :article_category_id, ArticleCategory.all.map {|a| [ a.name, a.id ] },
|
||||
{include_blank: true}, class: 'input-small'
|
||||
- unless changed_article.errors.empty?
|
||||
%tr.alert
|
||||
|
|
|
@ -71,11 +71,19 @@
|
|||
= form_for :articles, :url => parse_upload_supplier_articles_path(@supplier),
|
||||
:html => { multipart: true, class: "form-horizontal" } do |f|
|
||||
|
||||
|
||||
.control-group
|
||||
%label(for="articles_file")= t '.file_label'
|
||||
%label(for="articles_file")
|
||||
%strong= t '.file_label'
|
||||
= f.file_field "file"
|
||||
%label(for="articles_file")
|
||||
%strong="select the file type you are about to upload"
|
||||
=f.collection_select :type, ["bnn","foodsoft","odin"], :to_s, :to_s
|
||||
|
||||
.control-group
|
||||
%label(for="articles_update_category")
|
||||
= f.check_box "update_category"
|
||||
= t '.options.update_category'
|
||||
%label(for="articles_outlist_absent")
|
||||
= f.check_box "outlist_absent"
|
||||
= t '.options.outlist_absent'
|
||||
|
|
|
@ -22,3 +22,12 @@
|
|||
%td
|
||||
= link_to t('.new_transaction'), new_finance_ordergroup_transaction_path(ordergroup), class: 'btn btn-mini'
|
||||
= link_to t('.account_statement'), finance_ordergroup_transactions_path(ordergroup), class: 'btn btn-mini'
|
||||
%thead
|
||||
%tr
|
||||
%th= t 'Total'
|
||||
%th
|
||||
- FinancialTransactionClass.sorted.each do |c|
|
||||
- name = FinancialTransactionClass.has_multiple_classes ? c.display : heading_helper(Ordergroup, :account_balance)
|
||||
%th.numeric= format_currency @total_balances[c.id]
|
||||
%th.numeric
|
||||
= format_currency @total_balances.values.reduce(:+)
|
3
app/views/layouts/action_text/contents/_content.html.erb
Normal file
3
app/views/layouts/action_text/contents/_content.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="trix-content">
|
||||
<%= yield -%>
|
||||
</div>
|
12
app/views/layouts/email.html.haml
Normal file
12
app/views/layouts/email.html.haml
Normal file
|
@ -0,0 +1,12 @@
|
|||
= yield
|
||||
\
|
||||
%hr
|
||||
%ul
|
||||
%li
|
||||
%a{href: root_url} Foodsoft
|
||||
- if FoodsoftConfig[:homepage]
|
||||
%li
|
||||
%a{href: FoodsoftConfig[:homepage]} Foodcoop
|
||||
- if FoodsoftConfig[:help_url]
|
||||
%li
|
||||
%a{href: FoodsoftConfig[:help_url]}= t '.help'
|
|
@ -67,6 +67,8 @@ module Foodsoft
|
|||
|
||||
config.autoloader = :zeitwerk
|
||||
|
||||
config.active_storage.variant_processor = :mini_magick
|
||||
|
||||
# Ex:- :default =>''
|
||||
|
||||
# CORS for API
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
# Pin npm packages by running ./bin/importmap
|
||||
pin "application", preload: true
|
||||
pin "application", preload: true
|
||||
pin "trix"
|
||||
pin "@rails/actiontext", to: "actiontext.js"
|
||||
|
|
|
@ -3,7 +3,7 @@ class String
|
|||
# remove comma from decimal inputs
|
||||
def self.delocalized_decimal(string)
|
||||
if !string.blank? and string.is_a?(String)
|
||||
BigDecimal.new(string.sub(',', '.'))
|
||||
BigDecimal(string.sub(',', '.'))
|
||||
else
|
||||
string
|
||||
end
|
||||
|
|
|
@ -568,6 +568,7 @@ de:
|
|||
options:
|
||||
convert_units: Derzeitige Einheiten beibehalten, berechne Mengeneinheit und Preis (wie Synchronisieren).
|
||||
outlist_absent: Artikel löschen, die nicht in der hochgeladenen Datei sind.
|
||||
update_category: Kategorien aus der Datei übernehmen und erstellen.
|
||||
sample:
|
||||
juices: Säfte
|
||||
nuts: Nüsse
|
||||
|
@ -1221,6 +1222,7 @@ de:
|
|||
footer_2_foodsoft: 'Foodsoft: %{url}'
|
||||
footer_3_homepage: 'Foodcoop: %{url}'
|
||||
footer_4_help: 'Hilfe: %{url}'
|
||||
help: 'Hilfe'
|
||||
foodsoft: Foodsoft
|
||||
footer:
|
||||
revision: Revision %{revision}
|
||||
|
|
|
@ -569,6 +569,7 @@ en:
|
|||
options:
|
||||
convert_units: Keep current units, recompute unit quantity and price (like synchronize).
|
||||
outlist_absent: Delete articles not in uploaded file.
|
||||
update_category: Create and replace categories from uploaded file.
|
||||
sample:
|
||||
juices: Juices
|
||||
nuts: Nuts
|
||||
|
@ -1224,6 +1225,7 @@ en:
|
|||
footer_2_foodsoft: 'Foodsoft: %{url}'
|
||||
footer_3_homepage: 'Foodcoop: %{url}'
|
||||
footer_4_help: 'Help: %{url}'
|
||||
help: 'Help'
|
||||
foodsoft: Foodsoft
|
||||
footer:
|
||||
revision: revision %{revision}
|
||||
|
|
|
@ -515,6 +515,7 @@ es:
|
|||
options:
|
||||
convert_units: Mantener unidades actuales, recomputar la cantidad y precio de unidades (como sincronizar).
|
||||
outlist_absent: Borrar artículos que no están en el archivo subido.
|
||||
update_category: Toma las categorías del archivo subido.
|
||||
sample:
|
||||
juices: Jugos
|
||||
nuts: Nueces
|
||||
|
@ -1082,6 +1083,7 @@ es:
|
|||
layouts:
|
||||
email:
|
||||
footer_4_help: 'Ayuda: %{url}'
|
||||
help: 'Ayuda'
|
||||
footer:
|
||||
revision: revisión %{revision}
|
||||
header:
|
||||
|
|
|
@ -834,6 +834,7 @@ fr:
|
|||
email:
|
||||
footer_3_homepage: 'Boufcoop: %{url}'
|
||||
footer_4_help: 'Aide: %{url}'
|
||||
help: 'Aide'
|
||||
footer:
|
||||
revision: révision %{revision}
|
||||
header:
|
||||
|
|
|
@ -539,6 +539,7 @@ nl:
|
|||
options:
|
||||
convert_units: Bestaande eenheden behouden, herbereken groothandelseenheid en prijs (net als synchronizeren).
|
||||
outlist_absent: Artikelen die niet in het bestand voorkomen, verwijderen.
|
||||
upload_category: Categorieën overnemen uit bestand.
|
||||
sample:
|
||||
juices: Sappen
|
||||
nuts: Noten
|
||||
|
@ -1194,6 +1195,7 @@ nl:
|
|||
footer_2_foodsoft: 'Foodsoft: %{url}'
|
||||
footer_3_homepage: 'Foodcoop: %{url}'
|
||||
footer_4_help: 'Help: %{url}'
|
||||
help: 'Help'
|
||||
foodsoft: Foodsoft
|
||||
footer:
|
||||
revision: revisie %{revision}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# This migration comes from action_text (originally 20180528164100)
|
||||
class CreateActionTextTables < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
# Use Active Record's configured type for primary and foreign keys
|
||||
primary_key_type, foreign_key_type = primary_and_foreign_key_types
|
||||
|
||||
create_table :action_text_rich_texts, id: primary_key_type do |t|
|
||||
t.string :name, null: false
|
||||
t.text :body, size: :long
|
||||
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
|
||||
|
||||
t.timestamps
|
||||
|
||||
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def primary_and_foreign_key_types
|
||||
config = Rails.configuration.generators
|
||||
setting = config.options[config.orm][:primary_key_type]
|
||||
primary_key_type = setting || :primary_key
|
||||
foreign_key_type = setting || :bigint
|
||||
[primary_key_type, foreign_key_type]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
class MigrateMessageBodyToActionText < ActiveRecord::Migration[7.0]
|
||||
include ActionView::Helpers::TextHelper
|
||||
def change
|
||||
rename_column :messages, :body, :body_old
|
||||
Message.all.each do |message|
|
||||
message.update_attribute(:body, simple_format(message.body_old))
|
||||
end
|
||||
remove_column :messages, :body_old
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -10,7 +10,17 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_01_06_144440) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_02_15_085312) do
|
||||
create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "body", size: :long
|
||||
t.string "record_type", null: false
|
||||
t.bigint "record_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
|
||||
end
|
||||
|
||||
create_table "active_storage_attachments", id: :integer, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
|
@ -282,7 +292,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_06_144440) do
|
|||
create_table "messages", id: :integer, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
|
||||
t.integer "sender_id"
|
||||
t.string "subject", null: false
|
||||
t.text "body"
|
||||
t.boolean "private", default: false
|
||||
t.datetime "created_at", precision: nil
|
||||
t.integer "reply_to"
|
||||
|
|
144
db/seeds/demo-seeds.rb
Normal file
144
db/seeds/demo-seeds.rb
Normal file
|
@ -0,0 +1,144 @@
|
|||
require_relative 'seed_helper.rb'
|
||||
|
||||
FinancialTransactionClass.create!(:id => 1, :name => 'Standard')
|
||||
FinancialTransactionClass.create!(:id => 2, :name => 'Foodsoft')
|
||||
FinancialTransactionType.create!(:id => 1, :name => "Foodcoop", :financial_transaction_class_id => 1)
|
||||
|
||||
alice = User.create!(:id => 1, :nick => "alice", :password => "secret", :first_name => "Alice", :last_name => "Administrator", :email => "admin@foo.test", :phone => "+4421486548", :created_on => 'Wed, 15 Jan 2014 16:15:33 UTC +00:00')
|
||||
bob = User.create!(:id => 2, :nick => "bob", :password => "secret", :first_name => "Bob", :last_name => "Doe", :email => "bob@doe.test", :created_on => 'Sun, 19 Jan 2014 17:38:22 UTC +00:00')
|
||||
|
||||
|
||||
Workgroup.create!(:id => 1, :name => "Administrators", :description => "System administrators.", :account_balance => 0.0, :created_on => 'Wed, 15 Jan 2014 16:15:33 UTC +00:00', :role_admin => true, :role_suppliers => true, :role_article_meta => true, :role_finance => true, :role_orders => true, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Workgroup.create!(:id => 2, :name => "Finances", :account_balance => 0.0, :created_on => 'Sun, 19 Jan 2014 17:40:03 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => true, :role_orders => false, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 5, :name => "Alice WG", :account_balance => 0.90E2, :created_on => 'Sat, 18 Jan 2014 00:38:48 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :stats => { :jobs_size => 0, :orders_sum => 1021.74 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => true)
|
||||
Ordergroup.create!(:id => 8, :name => "Bob's Family", :account_balance => 0.90E2, :created_on => 'Wed, 09 Apr 2014 12:23:29 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "John Doe", :stats => { :jobs_size => 0, :orders_sum => 0 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
FinancialTransaction.create!(:ordergroup_id => 5, :amount => 0.90E2, :note => "Bank transfer", :user_id => 2, :created_on => 'Mon, 17 Feb 2014 16:19:34 UTC +00:00', :financial_transaction_type_id => 1)
|
||||
FinancialTransaction.create!(:ordergroup_id => 8, :amount => 0.90E2, :note => "Bank transfer", :user_id => 2, :created_on => 'Mon, 17 Feb 2014 16:19:34 UTC +00:00', :financial_transaction_type_id => 1)
|
||||
|
||||
Membership.create!(:group_id => 1, :user_id => 1)
|
||||
Membership.create!(:group_id => 5, :user_id => 1)
|
||||
Membership.create!(:group_id => 2, :user_id => 2)
|
||||
Membership.create!(:group_id => 8, :user_id => 2)
|
||||
|
||||
supplier_category = SupplierCategory.create!(:id => 1, :name => "Other", :financial_transaction_class_id => 1)
|
||||
|
||||
chocolate_supplier = Supplier.create!(
|
||||
name: "Kollektiv CHOCK!",
|
||||
address: "Grabower Straße 1\n12345 Berlin",
|
||||
phone: "0123456789",
|
||||
email: "info@bbakery.test",
|
||||
supplier_category: supplier_category
|
||||
)
|
||||
|
||||
nkn_supplier = Supplier.create!(
|
||||
name: "Naturgut Süd",
|
||||
address: "Somewhere in Hamburg, maybe St. Pauli?",
|
||||
phone: "0123434789",
|
||||
email: "foodsoft@local-it.org",
|
||||
supplier_category: supplier_category
|
||||
)
|
||||
|
||||
chocolate_category = ArticleCategory.create!(name: "Schokolade")
|
||||
|
||||
Article.create!(
|
||||
name: "Vollmilch-Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 3.0, tax: 7.0,
|
||||
unit: "200g", unit_quantity: 5,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "1")
|
||||
|
||||
Article.create!(
|
||||
name: "Weiße Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 3.49, tax: 7.0,
|
||||
unit: "200g", unit_quantity: 5,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "2")
|
||||
|
||||
dark_chocolate = Article.create!(
|
||||
name: "Dunkle Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 2.89, tax: 7.0,
|
||||
unit: "200g", unit_quantity: 5,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "3")
|
||||
|
||||
Article.create!(
|
||||
name: "Himbeer-Schokolade",
|
||||
supplier_id: chocolate_supplier.id,
|
||||
article_category_id: chocolate_category.id,
|
||||
manufacturer: "Grabower Süßwaren GmbH",
|
||||
origin: "D", price: 2.89, tax: 7.0,
|
||||
unit: "170g", unit_quantity: 4,
|
||||
note: "bio, fairtrade, 40% Kakao, vegan",
|
||||
availability: true, order_number: "4")
|
||||
|
||||
previous_order = seed_order(supplier_id: chocolate_supplier.id, starts: 10.days.ago, ends: 7.days.ago)
|
||||
|
||||
GroupOrderArticle.create!(
|
||||
group_order: GroupOrder.create!(order_id: previous_order.id, ordergroup_id: 8),
|
||||
order_article: previous_order.order_articles.find_by(article_id: dark_chocolate.id),
|
||||
quantity: 5, tolerance: 0)
|
||||
|
||||
previous_order.close!(alice)
|
||||
|
||||
seed_order(supplier_id: chocolate_supplier.id, starts: 0.days.ago, ends: 7.days.from_now)
|
||||
|
||||
|
||||
apple = Article.create!(
|
||||
name: "Äpfel Elstar",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: supplier_category.id,
|
||||
manufacturer: "Obsthof Bruno Brugger",
|
||||
origin: "D", price: 3.49, tax: 7.0,
|
||||
unit: "1kg", unit_quantity: 10,
|
||||
note: "lecker, fruchtig, demeter",
|
||||
availability: true, order_number: "5")
|
||||
|
||||
brokkoli = Article.create!(
|
||||
name: "Brokkoli",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: supplier_category.id,
|
||||
manufacturer: "Fattoria degli Orsi",
|
||||
origin: "IT", price: 2.89, tax: 7.0,
|
||||
unit: "400g", unit_quantity: 6,
|
||||
note: "gesund und lecker",
|
||||
availability: true, order_number: "6")
|
||||
|
||||
tomatoes = Article.create!(
|
||||
name: "Tomaten",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: supplier_category.id,
|
||||
manufacturer: "Terra di Puglia",
|
||||
origin: "IT", price: 2.89, tax: 7.0,
|
||||
unit: "500g", unit_quantity: 20,
|
||||
note: "pomodori italianio, demeter",
|
||||
availability: true, order_number: "7")
|
||||
|
||||
rice = Article.create!(
|
||||
name: "Reis",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: supplier_category.id,
|
||||
manufacturer: "Finck",
|
||||
origin: "D", price: 3.29, tax: 7.0,
|
||||
unit: "3kg", unit_quantity: 10,
|
||||
note: "Reis im Vorratssack, demeter",
|
||||
availability: true, order_number: "8")
|
||||
|
||||
spaghetti = Article.create!(
|
||||
name: "Spaghetti",
|
||||
supplier_id: nkn_supplier.id,
|
||||
article_category_id: supplier_category.id,
|
||||
manufacturer: "Pastificio Zanellini spa",
|
||||
origin: "D", price: 2.89, tax: 7.0,
|
||||
unit: "500g", unit_quantity: 4,
|
||||
note: "100% italienisches Hartweizengrieß",
|
||||
availability: true, order_number: "9")
|
||||
|
7
demo_day_nks.bnn
Normal file
7
demo_day_nks.bnn
Normal file
|
@ -0,0 +1,7 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
5;;;;4280001958081;4280001958203;Žpfel Elstar;erntefrisch und knackig;;;obb;;D;C%;DE-™KO-001;120;0301;10;55;;1;10 x1Kg;10;1Kg;1;N;;;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;1;;
|
||||
6;;;;4280001958081;4280001958203;Brokkoli;aus der Erde;;;VIB;;IT;C%;DE-™KO-001;120;03;10;55;;1;4 x400g;4;400g;1;N;;;;1,41;;;;1;;;4,49;3,20;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;2,5;;
|
||||
7;;;;4280001958081;4280001958203;Tomaten;Datteltomaten, demeter;;;TDP;;IT;C%;DE-™KO-001;120;03;10;55;;1;20 x500g;20;500g;1;N;;;;1,41;;;;1;;;4,49;3,00;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;2;;
|
||||
8;;;;4280001958081;4280001958203;Reis;Reispfannen geeignet;;;FIN;;D;C%;DE-™KO-001;120;05;10;55;;1;12 x300g;12;300g;1;N;;;;1,41;;;;1;;;4,49;3,00;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;3,333333;;
|
||||
9;;;;4280001958081;4280001958203;Spaghetti;Vollkorn;;;ZLN;;D;C%;DE-™KO-001;120;06;10;55;;1;4 x500g;4;500g;1;N;;;;1,41;;;;1;;;4,49;3,00;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;2;;
|
||||
10;;;;4280001958081;4280001958203;Kartoffeln;vorwiegend festkochend;;;rsh;;D;C%;DE-™KO-001;120;0311;10;55;;1;6 x5Kg;6;5Kg;1;N;;;;1,41;;;;1;;;4,49;3,00;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;0.2;;
|
65
deployment/.env.sample
Normal file
65
deployment/.env.sample
Normal file
|
@ -0,0 +1,65 @@
|
|||
TYPE=foodsoft
|
||||
|
||||
DOMAIN=order.example.org
|
||||
#EXTRA_DOMAINS=', `www.order.example.com`'
|
||||
LETS_ENCRYPT_ENV=production
|
||||
COMPOSE_FILE="compose.yml"
|
||||
|
||||
# app settings
|
||||
FOODCOOP_MULTI_INSTALL=true # Best for now, see https://github.com/foodcoops/foodsoft/pull/841
|
||||
FOODCOOP_NAME=example
|
||||
FOODCOOP_CITY=XXX
|
||||
FOODCOOP_COUNTRY=XXX
|
||||
FOODCOOP_EMAIL=info@example.org
|
||||
FOODCOOP_PHONE=XXX
|
||||
FOODCOOP_STREET=XXX
|
||||
FOODCOOP_ZIP_CODE=XXX
|
||||
FOODCOOP_HOMEPAGE=https://order.example.org
|
||||
FOODCOOP_HELP_URL=https://order.example.org
|
||||
FOODCOOP_TIME_ZONE=Amsterdam
|
||||
FOODCOOP_USE_NICK=true
|
||||
FOODCOOP_LANGUAGE=en
|
||||
FOODCOOP_FOOTER='<a href="https://example.org/">example</a> hosted by <a href="https://yourhoster.org">Your Tech Co-op</a>.'
|
||||
USE_APPLE_POINTS=false
|
||||
STOP_ORDERING_UNDER=75
|
||||
MINIMUM_BALANCE=0
|
||||
|
||||
# database settings
|
||||
MYSQL_DB=foodsoft
|
||||
MYSQL_HOST=db
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_USER=foodsoft
|
||||
|
||||
# shared supplier list settings
|
||||
# COMPOSE_FILE="$COMPOSE_FILE:compose.sharedlists.yml"
|
||||
# ENABLE_SHARED_LISTS=0
|
||||
# SHARED_LISTS_DB_TYPE=mysql2
|
||||
# SHARED_LISTS_HOST=order.otherfoodcoop.org
|
||||
# SHARED_LISTS_DB_NAME=sharedlists
|
||||
# SHARED_LISTS_USER=example
|
||||
|
||||
# Group order invoices generation pull request
|
||||
# https://github.com/foodcoops/foodsoft/pull/907
|
||||
# COMPOSE_FILE="$COMPOSE_FILE:compose.groupOrderInvoice.yml"
|
||||
|
||||
# outgoing mail settings
|
||||
EMAIL_SENDER=noreply@example.org
|
||||
EMAIL_ERROR=systems@example.org
|
||||
SMTP_ADDRESS=mail.example.com
|
||||
SMTP_AUTHENTICATION=plain
|
||||
SMTP_DOMAIN=mail.example.com
|
||||
SMTP_ENABLE_STARTTLS_AUTO=true
|
||||
SMTP_PORT=587
|
||||
SMTP_USER_NAME=foodsoft
|
||||
|
||||
# incoming mail settings
|
||||
EMAIL_REPLY_DOMAIN=example.org
|
||||
SMTP_SERVER_HOST=0.0.0.0
|
||||
SMTP_SERVER_PORT=2525
|
||||
|
||||
# secret versions
|
||||
SECRET_DB_PASSWORD_VERSION=v1
|
||||
SECRET_DB_ROOT_PASSWORD_VERSION=v1
|
||||
SECRET_SHARED_LISTS_DB_PASSWORD_VERSION=v1
|
||||
SECRET_SMTP_PASSWORD_VERSION=v1
|
||||
SECRET_SECRET_KEY_BASE_VERSION=v1 # length=30
|
168
deployment/app_config.yml.tmpl
Normal file
168
deployment/app_config.yml.tmpl
Normal file
|
@ -0,0 +1,168 @@
|
|||
# {{ env "DOMAIN" }} configuration
|
||||
|
||||
default: &defaults
|
||||
# If you wanna serve more than one foodcoop with one installation
|
||||
# Don't forget to setup databases for each foodcoop. See also MULTI_COOP_INSTALL
|
||||
multi_coop_install: {{ env "FOODCOOP_MULTI_INSTALL" }}
|
||||
|
||||
# If multi_coop_install you have to use a coop name, which you you wanna be selected by default
|
||||
default_scope: "{{ env "FOODCOOP_NAME" }}"
|
||||
|
||||
# name of this foodcoop
|
||||
name: "{{ env "FOODCOOP_NAME" }}"
|
||||
|
||||
# foodcoop contact information (used for FAX messages)
|
||||
contact:
|
||||
street: "{{ env "FOODCOOP_STREET" }}"
|
||||
zip_code: "{{ env "FOODCOOP_ZIP_CODE" }}"
|
||||
city: "{{ env "FOODCOOP_CITY" }}"
|
||||
country: "{{ env "FOODCOOP_COUNTRY" }}"
|
||||
email: "{{ env "FOODCOOP_EMAIL" }}"
|
||||
phone: "{{ env "FOODCOOP_PHONE" }}"
|
||||
|
||||
# Homepage
|
||||
homepage: "{{ env "FOODCOOP_HOMEPAGE" }}"
|
||||
|
||||
# foodsoft documentation URL
|
||||
help_url: "{{ env "FOODCOOP_HELP_URL" }}"
|
||||
|
||||
# documentation URL for the apples&pears work system
|
||||
applepear_url: https://github.com/foodcoops/foodsoft/wiki/%C3%84pfel-u.-Birnen
|
||||
|
||||
# custom foodsoft software URL (used in footer)
|
||||
foodsoft_url: https://foodcoops.github.io
|
||||
|
||||
# Default language
|
||||
default_locale: {{ env "FOODCOOP_LANGUAGE" }}
|
||||
|
||||
# By default, foodsoft takes the language from the webbrowser/operating system.
|
||||
# In case you really want foodsoft in a certain language by default, set this to true.
|
||||
# When members are logged in, the language from their profile settings is still used.
|
||||
ignore_browser_locale: false
|
||||
|
||||
# Default timezone, e.g. UTC, Amsterdam, Berlin, etc.
|
||||
time_zone: "{{ env "FOODCOOP_TIME_ZONE" }}"
|
||||
|
||||
# Currency symbol, and whether to add a whitespace after the unit.
|
||||
currency_unit: €
|
||||
#currency_space: true
|
||||
|
||||
# price markup in percent
|
||||
price_markup: 2.0
|
||||
|
||||
# default vat percentage for new articles
|
||||
tax_default: 7.0
|
||||
|
||||
# tolerance order option: If set to false, article tolerance values do not count
|
||||
# for total article price as long as the order is not finished.
|
||||
tolerance_is_costly: false
|
||||
|
||||
# Ordergroups, which have less than 75 apples should not be allowed to make new orders
|
||||
# Comment out this option to activate this restriction
|
||||
stop_ordering_under: {{ env "STOP_ORDERING_UNDER" }}
|
||||
|
||||
# Comment out to completely hide apple points (be sure to comment stop_ordering_under)
|
||||
use_apple_points: {{ env "USE_APPLE_POINTS" }}
|
||||
|
||||
# ordergroups can only order when their balance is higher than or equal to this
|
||||
# not fully enforced right now, since the check is only client-side
|
||||
minimum_balance: {{ env "MINIMUM_BALANCE" }}
|
||||
|
||||
# how many days there are between two periodic tasks
|
||||
#tasks_period_days: 7
|
||||
|
||||
# how many days upfront periodic tasks are created
|
||||
#tasks_upfront_days: 49
|
||||
|
||||
# default order schedule, used to provide initial dates for new orders
|
||||
# (recurring dates in ical format; no spaces!)
|
||||
#order_schedule:
|
||||
# ends:
|
||||
# recurr: FREQ=WEEKLY;INTERVAL=2;BYDAY=MO
|
||||
# time: '9:00'
|
||||
# # reference point, this is generally the first pickup day; empty is often ok
|
||||
# #initial:
|
||||
|
||||
# When use_nick is enabled, there will be a nickname field in the user form,
|
||||
# and the option to show a nickname instead of full name to foodcoop members.
|
||||
# Members of a user's groups and administrators can still see full names.
|
||||
use_nick: {{ env "FOODCOOP_USE_NICK" }}
|
||||
|
||||
# Most plugins can be enabled/disabled here as well. Messages and wiki are enabled
|
||||
# by default and need to be set to false to disable. Most other plugins needs to
|
||||
# be enabled before they do anything.
|
||||
use_wiki: true
|
||||
use_messages: true
|
||||
use_documents: true
|
||||
use_polls: true
|
||||
|
||||
# Base font size for generated PDF documents
|
||||
#pdf_font_size: 12
|
||||
|
||||
# Page size for generated PDF documents
|
||||
#pdf_page_size: A4
|
||||
|
||||
# Some documents (like group and article PDFs) can include page breaks
|
||||
# after each sublist.
|
||||
#pdf_add_page_breaks: true
|
||||
|
||||
# Alternatively, this can be set for each document.
|
||||
#pdf_add_page_breaks:
|
||||
# order_by_groups: true
|
||||
# order_by_articles: true
|
||||
|
||||
# Page footer (html allowed). Default is a Foodsoft footer. Set to `blank` for no footer.
|
||||
page_footer: {{ env "FOODCOOP_FOOTER" }}
|
||||
|
||||
# Custom CSS for the foodcoop
|
||||
#custom_css: 'body { background-color: #fcffba; }'
|
||||
|
||||
# Uncomment to add tracking code for web statistics, e.g. for Piwik. (Added to bottom of page)
|
||||
#webstats_tracking_code: |
|
||||
# <!-- Piwik -->
|
||||
# ......
|
||||
|
||||
# email address to be used as sender
|
||||
email_sender: "{{ env "EMAIL_SENDER" }}"
|
||||
|
||||
# email address to be used as from
|
||||
email_from: "{{ env "EMAIL_SENDER" }}"
|
||||
|
||||
# domain to be used for reply emails
|
||||
reply_email_domain: {{ env "EMAIL_REPLY_DOMAIN" }}
|
||||
|
||||
# If your foodcoop uses a mailing list instead of internal messaging system
|
||||
#mailing_list: list@example.org
|
||||
#mailing_list_subscribe: list-subscribe@example.org
|
||||
|
||||
# Config for the exception_notification plugin
|
||||
notification:
|
||||
error_recipients:
|
||||
- "{{ env "EMAIL_ERROR" }}"
|
||||
sender_address: "\"Foodsoft error\" <{{ env "EMAIL_SENDER" }}>"
|
||||
email_prefix: "[foodsoft] "
|
||||
|
||||
# http config for this host to generate links in emails (uses environment config when not set)
|
||||
protocol: https
|
||||
host: "{{ env "DOMAIN" }}"
|
||||
#port: 3000
|
||||
|
||||
{{ if eq (env "ENABLE_SHARED_LISTS") "1" }}
|
||||
# Access to sharedlists, the external article-database.
|
||||
# This allows a foodcoop to subscribe to a selection of a supplier's full assortment,
|
||||
# and makes it possible to share data with several foodcoops. Using this requires installing
|
||||
# an additional application with a separate database.
|
||||
shared_lists:
|
||||
adapter: "{{ env "SHARED_LISTS_DB_TYPE" }}"
|
||||
host: "{{ env "SHARED_LISTS_HOST" }}"
|
||||
database: "{{ env "SHARED_LISTS_DB_NAME" }}"
|
||||
username: "{{ env "SHARED_LISTS_USER" }}"
|
||||
password: "{{ secret "shared_lists_db_password" }}"
|
||||
{{ end }}
|
||||
|
||||
# don't remove this, required to run the app
|
||||
production:
|
||||
<<: *defaults
|
||||
|
||||
{{ env "FOODCOOP_NAME" }}:
|
||||
<<: *defaults
|
190
deployment/compose.yml
Normal file
190
deployment/compose.yml
Normal file
|
@ -0,0 +1,190 @@
|
|||
---
|
||||
version: "3.8"
|
||||
|
||||
x-env: &env
|
||||
CERTBOT_DISABLED: 1
|
||||
DOMAIN:
|
||||
EMAIL_ERROR:
|
||||
EMAIL_REPLY_DOMAIN:
|
||||
EMAIL_SENDER:
|
||||
FOODCOOP_CITY:
|
||||
FOODCOOP_COUNTRY:
|
||||
FOODCOOP_EMAIL:
|
||||
FOODCOOP_FOOTER:
|
||||
FOODCOOP_HELP_URL:
|
||||
FOODCOOP_HOMEPAGE:
|
||||
FOODCOOP_MULTI_INSTALL:
|
||||
FOODCOOP_NAME:
|
||||
FOODCOOP_PHONE:
|
||||
FOODCOOP_STREET:
|
||||
FOODCOOP_TIME_ZONE:
|
||||
FOODCOOP_ZIP_CODE:
|
||||
FOODCOOP_USE_NICK:
|
||||
FOODCOOP_LANGUAGE:
|
||||
LOG_LEVEL:
|
||||
MINIMUM_BALANCE:
|
||||
MYSQL_DB:
|
||||
MYSQL_HOST:
|
||||
MYSQL_PORT:
|
||||
MYSQL_USER:
|
||||
QUEUE: foodsoft_notifier
|
||||
REDIS_URL: redis://cache:6379
|
||||
SECRET_KEY_BASE_FILE: /run/secrets/secret_key_base
|
||||
SMTP_ADDRESS:
|
||||
SMTP_AUTHENTICATION:
|
||||
SMTP_DOMAIN:
|
||||
SMTP_ENABLE_STARTTLS_AUTO:
|
||||
SMTP_PASSWORD_FILE: /run/secrets/smtp_password
|
||||
SMTP_PORT:
|
||||
SMTP_USER_NAME:
|
||||
STOP_ORDERING_UNDER:
|
||||
USE_APPLE_POINTS:
|
||||
|
||||
x-configs: &configs
|
||||
- source: app_config
|
||||
target: /usr/src/app/config/app_config.yml
|
||||
- source: db_config
|
||||
target: /usr/src/app/config/database.yml
|
||||
- source: entrypoint
|
||||
target: /usr/src/app/docker-entrypoint.sh
|
||||
mode: 0555
|
||||
|
||||
x-secrets: &secrets
|
||||
- db_password
|
||||
- secret_key_base
|
||||
- smtp_password
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE}
|
||||
networks:
|
||||
- internal
|
||||
- proxy
|
||||
secrets: *secrets
|
||||
configs: *configs
|
||||
entrypoint: &entrypoint /usr/src/app/docker-entrypoint.sh
|
||||
environment:
|
||||
<<: *env
|
||||
FOODSOFT_SERVICE: app
|
||||
RAILS_SERVE_STATIC_FILES: 'true'
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
||||
interval: 15s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 1m
|
||||
deploy:
|
||||
update_config:
|
||||
failure_action: rollback
|
||||
order: start-first
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=3000"
|
||||
- "coop-cloud.${STACK_NAME}.version=1.0.0+4.7.1"
|
||||
|
||||
cron:
|
||||
image: ${IMAGE}
|
||||
secrets: *secrets
|
||||
configs: *configs
|
||||
entrypoint: *entrypoint
|
||||
environment:
|
||||
<<: *env
|
||||
FOODSOFT_SERVICE: cron
|
||||
networks:
|
||||
- internal
|
||||
|
||||
worker:
|
||||
image: ${IMAGE}
|
||||
secrets: *secrets
|
||||
configs: *configs
|
||||
entrypoint: *entrypoint
|
||||
environment:
|
||||
<<: *env
|
||||
FOODSOFT_SERVICE: worker
|
||||
networks:
|
||||
- internal
|
||||
|
||||
smtp:
|
||||
image: ${IMAGE}
|
||||
configs: *configs
|
||||
entrypoint: *entrypoint
|
||||
secrets: *secrets
|
||||
environment:
|
||||
<<: *env
|
||||
FOODSOFT_SERVICE: smtp
|
||||
SMTP_SERVER_HOST:
|
||||
SMTP_SERVER_PORT:
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
deploy:
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.tcp.routers.foodsoft-smtp.rule=HostSNI(`*`)"
|
||||
- "traefik.tcp.routers.foodsoft-smtp.entrypoints=foodsoft-smtp"
|
||||
- "traefik.tcp.services.foodsoft-smtp.loadbalancer.server.port=${SMTP_SERVER_PORT}"
|
||||
|
||||
db:
|
||||
image: "mariadb:10.6"
|
||||
command: "mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_520_ci"
|
||||
environment:
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_DATABASE: ${MYSQL_DB}
|
||||
MYSQL_PASSWORD_FILE: /run/secrets/db_password
|
||||
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
|
||||
secrets:
|
||||
- db_password
|
||||
- db_root_password
|
||||
volumes:
|
||||
- "db:/var/lib/mysql"
|
||||
networks:
|
||||
- internal
|
||||
deploy:
|
||||
labels:
|
||||
backupbot.backup: "true"
|
||||
backupbot.backup.pre-hook: 'mkdir -p /tmp/backup/ && mysqldump --single-transaction -u root -p"$$(cat /run/secrets/db_root_password)" $${MYSQL_DATABASE} > /tmp/backup/backup.sql'
|
||||
backupbot.backup.post-hook: "rm -rf /tmp/backup"
|
||||
backupbot.backup.path: "/tmp/backup/"
|
||||
cache:
|
||||
image: "redis:6"
|
||||
networks:
|
||||
- internal
|
||||
|
||||
networks:
|
||||
internal:
|
||||
proxy:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
db:
|
||||
|
||||
configs:
|
||||
app_config:
|
||||
name: ${STACK_NAME}_app_config_${APP_CONFIG_VERSION}
|
||||
file: app_config.yml.tmpl
|
||||
template_driver: golang
|
||||
db_config:
|
||||
name: ${STACK_NAME}_db_config_${DB_CONFIG_VERSION}
|
||||
file: database.yml.tmpl
|
||||
template_driver: golang
|
||||
entrypoint:
|
||||
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_VERSION}
|
||||
file: entrypoint.sh.tmpl
|
||||
template_driver: golang
|
||||
|
||||
secrets:
|
||||
db_password:
|
||||
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
|
||||
external: true
|
||||
db_root_password:
|
||||
name: ${STACK_NAME}_db_root_password_${SECRET_DB_ROOT_PASSWORD_VERSION}
|
||||
external: true
|
||||
smtp_password:
|
||||
name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION}
|
||||
external: true
|
||||
secret_key_base:
|
||||
name: ${STACK_NAME}_secret_key_base_${SECRET_SECRET_KEY_BASE_VERSION}
|
||||
external: true
|
9
deployment/database.yml.tmpl
Normal file
9
deployment/database.yml.tmpl
Normal file
|
@ -0,0 +1,9 @@
|
|||
production:
|
||||
adapter: "mysql2"
|
||||
encoding: "utf8mb4"
|
||||
collation: "utf8mb4_unicode_520_ci"
|
||||
username: "{{ env "MYSQL_USER" }}"
|
||||
password: "{{ secret "db_password" }}"
|
||||
database: "{{ env "MYSQL_DB" }}"
|
||||
host: "{{ env "MYSQL_HOST" }}"
|
||||
port: "{{ env "MYSQL_PORT" }}"
|
44
deployment/entrypoint.sh.tmpl
Normal file
44
deployment/entrypoint.sh.tmpl
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
file_env() {
|
||||
local var="$1"
|
||||
local fileVar="${var}_FILE"
|
||||
local def="${2:-}"
|
||||
|
||||
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local val="$def"
|
||||
|
||||
if [ "${!var:-}" ]; then
|
||||
val="${!var}"
|
||||
elif [ "${!fileVar:-}" ]; then
|
||||
val="$(< "${!fileVar}")"
|
||||
fi
|
||||
|
||||
export "$var"="$val"
|
||||
unset "$fileVar"
|
||||
}
|
||||
|
||||
file_env "SECRET_KEY_BASE"
|
||||
file_env "SMTP_PASSWORD"
|
||||
|
||||
echo "------------------------------------------------------------------------------"
|
||||
echo "Running entrypoint commands against '$FOODSOFT_SERVICE' service"
|
||||
echo "------------------------------------------------------------------------------"
|
||||
|
||||
if [ "$FOODSOFT_SERVICE" == "app" ]; then
|
||||
bundle exec rake db:setup || true
|
||||
bundle exec rake db:migrate || true
|
||||
./proc-start web
|
||||
elif [ "$FOODSOFT_SERVICE" == "cron" ]; then
|
||||
./proc-start cron
|
||||
elif [ "$FOODSOFT_SERVICE" == "worker" ]; then
|
||||
./proc-start worker
|
||||
elif [ "$FOODSOFT_SERVICE" == "smtp" ]; then
|
||||
./proc-start mail
|
||||
fi
|
|
@ -32,7 +32,7 @@ class CurrentOrders::ArticlesController < ApplicationController
|
|||
else
|
||||
@order_articles = OrderArticle.where(order_id: @current_orders.all.map(&:id))
|
||||
end
|
||||
@q = OrderArticle.search(params[:q])
|
||||
@q = OrderArticle.ransack(params[:q])
|
||||
@order_articles = @order_articles.ordered.merge(@q.result).includes(:article, :article_price)
|
||||
@order_article = @order_articles.where(id: params[:id]).first
|
||||
end
|
||||
|
|
|
@ -20,8 +20,8 @@ class MessagesController < ApplicationController
|
|||
@message.group_id = original_message.group_id
|
||||
@message.private = original_message.private
|
||||
@message.subject = I18n.t('messages.model.reply_subject', :subject => original_message.subject)
|
||||
@message.body = I18n.t('messages.model.reply_header', :user => original_message.sender.display, :when => I18n.l(original_message.created_at, :format => :short)) + "\n"
|
||||
original_message.body.each_line { |l| @message.body += I18n.t('messages.model.reply_indent', :line => l) }
|
||||
@message.body = I18n.t('messages.model.reply_header', :user => original_message.sender.display, :when => I18n.l(original_message.created_at, :format => :short)) + "\n" \
|
||||
+ "<blockquote>" + original_message.body.to_trix_html + "</blockquote>"
|
||||
else
|
||||
redirect_to new_message_url, alert: I18n.t('messages.new.error_private')
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module MessagesHelper
|
|||
body = ""
|
||||
else
|
||||
subject = message.subject
|
||||
body = truncate(message.body, :length => length - subject.length)
|
||||
body = truncate(message.body.to_plain_text, :length => length - subject.length)
|
||||
end
|
||||
"<b>#{link_to(h(subject), message)}</b> <span style='color:grey'>#{h(body)}</span>".html_safe
|
||||
end
|
||||
|
|
|
@ -22,6 +22,8 @@ class Message < ApplicationRecord
|
|||
validates_presence_of :message_recipients, :subject, :body
|
||||
validates_length_of :subject, :in => 1..255
|
||||
|
||||
has_rich_text :body
|
||||
|
||||
after_initialize do
|
||||
@recipients_ids ||= []
|
||||
@send_method ||= 'recipients'
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
= f.input :recipient_tokens, :input_html => { 'data-pre' => User.where(id: @message.recipients_ids).map(&:token_attributes).to_json }
|
||||
= f.input :private, inline_label: t('.hint_private')
|
||||
= f.input :subject, input_html: {class: 'input-xxlarge'}
|
||||
= f.input :body, input_html: {class: 'input-xxlarge', rows: 13}
|
||||
= f.rich_text_area :body, input_html: {class: 'input-xxlarge', rows: 13}
|
||||
.form-actions
|
||||
= f.submit class: 'btn btn-primary'
|
||||
= link_to t('ui.or_cancel'), :back
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
- if @message.can_toggle_private?(current_user)
|
||||
= link_to t('.change_visibility'), toggle_private_message_path(@message), method: :post, class: 'btn btn-mini'
|
||||
%hr/
|
||||
%p= simple_format(h(@message.body))
|
||||
.trix-content= @message.body
|
||||
%hr/
|
||||
%p
|
||||
= link_to t('.reply'), new_message_path(:message => {:reply_to => @message.id}), class: 'btn'
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
= raw @message.body
|
||||
%hr
|
||||
%ul
|
||||
- if @message.group
|
||||
%li= t '.footer_group', group: @message.group.name
|
||||
%li
|
||||
%a{href: new_message_url('message[reply_to]' => @message.id)}= t '.reply'
|
||||
%li
|
||||
%a{href: message_url(@message)}= t '.see_message_online'
|
||||
%li
|
||||
%a{href: my_profile_url}= t '.messaging_options'
|
|
@ -138,6 +138,9 @@ de:
|
|||
Antworten: %{reply_url}
|
||||
Nachricht online einsehen: %{msg_url}
|
||||
Nachrichten-Einstellungen: %{profile_url}
|
||||
reply: Antworten
|
||||
see_message_online: Nachricht online einsehen
|
||||
messaging_options: Nachrichten-Einstellungen
|
||||
footer_group: |
|
||||
Gesendet an Gruppe: %{group}
|
||||
navigation:
|
||||
|
|
|
@ -140,6 +140,9 @@ en:
|
|||
Reply: %{reply_url}
|
||||
See message online: %{msg_url}
|
||||
Messaging options: %{profile_url}
|
||||
reply: Reply
|
||||
see_message_online: See message online
|
||||
messaging_options: Messaging options
|
||||
footer_group: |
|
||||
Sent to group: %{group}
|
||||
navigation:
|
||||
|
|
|
@ -67,6 +67,9 @@ fr:
|
|||
Répondre: %{reply_url}
|
||||
Afficher ce message dans ton navigateur: %{msg_url}
|
||||
Préférences des messages: %{profile_url}
|
||||
reply: Répondre
|
||||
see_message_online: Afficher ce message dans ton navigateur
|
||||
messaging_options: Préférences des messages
|
||||
simple_form:
|
||||
labels:
|
||||
settings:
|
||||
|
|
|
@ -140,6 +140,9 @@ nl:
|
|||
Antwoorden: %{reply_url}
|
||||
Bericht online lezen: %{msg_url}
|
||||
Berichtinstellingen: %{profile_url}
|
||||
reply: Antwoorden
|
||||
see_message_online: Bericht online lezen
|
||||
messaging_options: Berichtinstellingen
|
||||
footer_group: |
|
||||
Verzenden aan groep: %{group}
|
||||
navigation:
|
||||
|
|
|
@ -187,8 +187,8 @@ describe ArticlesController, type: :controller do
|
|||
describe '#parse_upload' do
|
||||
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join('spec/fixtures/files/upload_test.csv'), original_filename: 'upload_test.csv') }
|
||||
|
||||
it 'updates particles from spreadsheet' do
|
||||
post_with_supplier :parse_upload, params: { articles: { file: file, outlist_absent: '1', convert_units: '1' } }
|
||||
it 'updates articles from spreadsheet' do
|
||||
post_with_supplier :parse_upload, params: { articles: { file: file, outlist_absent: '1', convert_units: '1', type: 'foodsoft' } }
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
|
|
50
spec/controllers/finance/ordergroups_controller_spec.rb
Normal file
50
spec/controllers/finance/ordergroups_controller_spec.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Finance::OrdergroupsController do
|
||||
let(:user) { create(:user, :role_finance, :role_orders, :ordergroup) }
|
||||
let(:fin_trans_type1) { create(:financial_transaction_type) }
|
||||
let(:fin_trans_type2) { create(:financial_transaction_type) }
|
||||
let(:fin_trans1) do
|
||||
create(:financial_transaction,
|
||||
user: user,
|
||||
ordergroup: user.ordergroup,
|
||||
financial_transaction_type: fin_trans_type1)
|
||||
end
|
||||
let(:fin_trans2) do
|
||||
create(:financial_transaction,
|
||||
user: user,
|
||||
ordergroup: user.ordergroup,
|
||||
financial_transaction_type: fin_trans_type1)
|
||||
end
|
||||
let(:fin_trans3) do
|
||||
create(:financial_transaction,
|
||||
user: user,
|
||||
ordergroup: user.ordergroup,
|
||||
financial_transaction_type: fin_trans_type2)
|
||||
end
|
||||
|
||||
before { login user }
|
||||
|
||||
describe 'GET index' do
|
||||
before do
|
||||
fin_trans1
|
||||
fin_trans2
|
||||
fin_trans3
|
||||
end
|
||||
|
||||
it 'renders index page' do
|
||||
get_with_defaults :index
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response).to render_template('finance/ordergroups/index')
|
||||
end
|
||||
|
||||
it 'calculates total balance sums correctly' do
|
||||
get_with_defaults :index
|
||||
expect(assigns(:total_balances).size).to eq(2)
|
||||
expect(assigns(:total_balances)[fin_trans_type1.id]).to eq(fin_trans1.amount + fin_trans2.amount)
|
||||
expect(assigns(:total_balances)[fin_trans_type2.id]).to eq(fin_trans3.amount)
|
||||
end
|
||||
end
|
||||
end
|
5
spec/fixtures/bnn_file_01.bnn
vendored
Normal file
5
spec/fixtures/bnn_file_01.bnn
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
29932;;;;4280001958081;4280001958203;Walnoten (ongeroosterd);bio;;;med;;GR;C%;DE-?KO-001;120;1302;10;55;;1;;1;1 kg;1;N;930190;99260;;1,41;;;;1;;;4,49;2,34;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
28391;;;;4280001958081;4280001958203;Pijnboompitten;dem;;;med;;GR;C%;DE-?KO-001;120;1302;10;55;;1;;1;100 g;10;N;930190;99260;;1,41;;;;1;;;5,56;2.89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;;
|
||||
1829;;;;4280001958081;4280001958203;Appelsap (verpakt);;;;med;;GR;C%;DE-?KO-001;120;1302;10;55;;1;4x250 ml;10;4x250 ml;10;N;930190;99260;;3,21;;;;1;;;4,49;2.89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;ml;28,571;;
|
||||
177813;;;;4280001958081;4280001958203;Tomaten;bio;;;med;;GR;C%;DE-?KO-001;120;1302;10;55;;1;;1;500 g;20;N;930190;99260;;1,20;;;;1;;;4,49;2.89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;g;28,571;;
|
2
spec/fixtures/bnn_file_02.bnn
vendored
Normal file
2
spec/fixtures/bnn_file_02.bnn
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1
|
||||
1;;;;4280001958081;4280001958203;Tomatoes;organic;;;med;;GR;C%;DE-?KO-001;120;1302;10;55;;1;;20;500 g;1;N;930190;99260;;1,41;;;;1;;;4,49;1,20;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;g;28,571;;
|
273
spec/fixtures/odin_file_01.xml
vendored
Normal file
273
spec/fixtures/odin_file_01.xml
vendored
Normal file
|
@ -0,0 +1,273 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xmlproduct>
|
||||
<leverancierkop>
|
||||
<leveranciersnummer>1039</leveranciersnummer>
|
||||
<versienummer>1.08</versienummer>
|
||||
<naam>Estafette Associatie C.V.</naam>
|
||||
<plaats>Geldermalsen</plaats>
|
||||
</leverancierkop>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>Walnoten (ongeroosterd)</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>1</inhoud>
|
||||
<eenheid>kg</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>Het warme woud</merk>
|
||||
<kwaliteit>bio</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>NL</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>6</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>29932</bestelnummer>
|
||||
<sve>10</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>2.34</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>Pijnboompitten</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>100</inhoud>
|
||||
<eenheid>g</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>NELEMAN</merk>
|
||||
<kwaliteit>dem</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>TR</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>6</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>28391</bestelnummer>
|
||||
<sve>10</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>5.56</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>Appelsap (verpakt)</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>4x250</inhoud>
|
||||
<eenheid>ml</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0.4</statiegeld>
|
||||
<merk>Appelgaarde</merk>
|
||||
<kwaliteit></kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>DE</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>6</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>1829</bestelnummer>
|
||||
<sve>10</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>3.21</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>Tomaten</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>500</inhoud>
|
||||
<eenheid>g</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>De röde hof</merk>
|
||||
<kwaliteit>bio</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>DE</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>6</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>177813</bestelnummer>
|
||||
<sve>20</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>1.2</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
</xmlproduct>
|
75
spec/fixtures/odin_file_02.xml
vendored
Normal file
75
spec/fixtures/odin_file_02.xml
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xmlproduct>
|
||||
<leverancierkop>
|
||||
<leveranciersnummer>1039</leveranciersnummer>
|
||||
<versienummer>1.08</versienummer>
|
||||
<naam>Estafette Associatie C.V.</naam>
|
||||
<plaats>Geldermalsen</plaats>
|
||||
</leverancierkop>
|
||||
<product>
|
||||
<eancode>8719325207668</eancode>
|
||||
<omschrijving>Tomatoes</omschrijving>
|
||||
<kassaomschrijving>Nucli rose</kassaomschrijving>
|
||||
<plucode></plucode>
|
||||
<weegschaalartikel>0</weegschaalartikel>
|
||||
<wichtartikel>0</wichtartikel>
|
||||
<pluartikel>0</pluartikel>
|
||||
<inhoud>500</inhoud>
|
||||
<eenheid>g</eenheid>
|
||||
<verpakkingce>Stuk</verpakkingce>
|
||||
<statiegeld>0</statiegeld>
|
||||
<merk>De röde hof</merk>
|
||||
<kwaliteit>organic</kwaliteit>
|
||||
<keurmerkbio></keurmerkbio>
|
||||
<keurmerkoverig></keurmerkoverig>
|
||||
<herkomst>Somewhere, UK</herkomst>
|
||||
<herkomstregio></herkomstregio>
|
||||
<btw>6</btw>
|
||||
<cblcode>1017515</cblcode>
|
||||
<bestelnummer>1</bestelnummer>
|
||||
<sve>20</sve>
|
||||
<status>Actief</status>
|
||||
<ingredienten>druiven*</ingredienten>
|
||||
<d204>0</d204>
|
||||
<d209>0</d209>
|
||||
<d210>2</d210>
|
||||
<d212>2</d212>
|
||||
<d213>0</d213>
|
||||
<d214>0</d214>
|
||||
<d234>0</d234>
|
||||
<d215>2</d215>
|
||||
<d239>2</d239>
|
||||
<d216>0</d216>
|
||||
<d217>2</d217>
|
||||
<d220>0</d220>
|
||||
<d221>2</d221>
|
||||
<d223>0</d223>
|
||||
<d236>2</d236>
|
||||
<d235>2</d235>
|
||||
<d238>2</d238>
|
||||
<d225>2</d225>
|
||||
<d228>1</d228>
|
||||
<d232>0</d232>
|
||||
<d237>2</d237>
|
||||
<d240>0</d240>
|
||||
<d241>2</d241>
|
||||
<d242>2</d242>
|
||||
<lengteverpakking></lengteverpakking>
|
||||
<breedteverpakking></breedteverpakking>
|
||||
<hoogteverpakking></hoogteverpakking>
|
||||
<proefdiervrij>0</proefdiervrij>
|
||||
<vegetarisch>0</vegetarisch>
|
||||
<veganistisch>0</veganistisch>
|
||||
<rauwemelk>0</rauwemelk>
|
||||
<bewaartemperatuur>1</bewaartemperatuur>
|
||||
<gebruikstips></gebruikstips>
|
||||
<soortleverancier>2</soortleverancier>
|
||||
<geriefartikel>0</geriefartikel>
|
||||
<prijs>
|
||||
<prijslijn>adviesprijs</prijslijn>
|
||||
<ingangsdatum>2022-08-18</ingangsdatum>
|
||||
<inkoopprijs>1.2</inkoopprijs>
|
||||
<consumentenprijs>7.95</consumentenprijs>
|
||||
</prijs>
|
||||
</product>
|
||||
</xmlproduct>
|
|
@ -1,9 +1,9 @@
|
|||
require_relative '../spec_helper'
|
||||
|
||||
feature ArticlesController do
|
||||
let(:user) { create :user, groups: [create(:workgroup, role_article_meta: true)] }
|
||||
let(:supplier) { create :supplier }
|
||||
let!(:article_category) { create :article_category }
|
||||
let(:user) { create(:user, groups: [create(:workgroup, role_article_meta: true)]) }
|
||||
let(:supplier) { create(:supplier) }
|
||||
let!(:article_category) { create(:article_category) }
|
||||
|
||||
before { login user }
|
||||
|
||||
|
@ -18,7 +18,7 @@ feature ArticlesController do
|
|||
it 'can create a new article' do
|
||||
click_on I18n.t('articles.index.new')
|
||||
expect(page).to have_selector('form#new_article')
|
||||
article = build :article, supplier: supplier, article_category: article_category
|
||||
article = build(:article, supplier: supplier, article_category: article_category)
|
||||
within('#new_article') do
|
||||
fill_in 'article_name', :with => article.name
|
||||
fill_in 'article_unit', :with => article.unit
|
||||
|
@ -49,6 +49,7 @@ feature ArticlesController do
|
|||
let(:file) { Rails.root.join(test_file) }
|
||||
|
||||
it do
|
||||
find("#articles_type option[value='foodsoft']").select_option
|
||||
find('input[type="submit"]').click
|
||||
expect(find("tr:nth-child(1) #new_articles__note").value).to eq "bio ◎"
|
||||
expect(find("tr:nth-child(2) #new_articles__name").value).to eq "Pijnboompitten"
|
||||
|
@ -64,56 +65,124 @@ feature ArticlesController do
|
|||
end
|
||||
end
|
||||
|
||||
describe "can update existing article" do
|
||||
let!(:article) { create :article, supplier: supplier, name: 'Foobar', order_number: 1, unit: '250 g' }
|
||||
Dir.glob('spec/fixtures/bnn_file_01.*') do |test_file|
|
||||
describe "can import articles from #{test_file}" do
|
||||
let(:file) { Rails.root.join(test_file) }
|
||||
|
||||
it do
|
||||
find('input[type="submit"]').click
|
||||
expect(find("#articles_#{article.id}_name").value).to eq 'Tomatoes'
|
||||
find('input[type="submit"]').click
|
||||
article.reload
|
||||
expect(article.name).to eq 'Tomatoes'
|
||||
expect([article.unit, article.unit_quantity, article.price]).to eq ['500 g', 20, 1.2]
|
||||
it do
|
||||
find("#articles_type option[value='bnn']").select_option
|
||||
find('input[type="submit"]').click
|
||||
expect(find("tr:nth-child(1) #new_articles__note").value).to eq "bio"
|
||||
expect(find("tr:nth-child(1) #new_articles__name").value).to eq "Walnoten (ongeroosterd)"
|
||||
# set article category
|
||||
4.times do |i|
|
||||
all("tr:nth-child(#{i + 1}) select > option")[1].select_option
|
||||
end
|
||||
find('input[type="submit"]').click
|
||||
|
||||
expect(page).to have_content("Pijnboompitten")
|
||||
|
||||
expect(supplier.articles.count).to eq 4
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "handles missing data" do
|
||||
it do
|
||||
find('input[type="submit"]').click # to overview
|
||||
find('input[type="submit"]').click # missing category, re-show form
|
||||
expect(find('tr.alert')).to be_present
|
||||
expect(supplier.articles.count).to eq 0
|
||||
describe "updates" do
|
||||
file_paths = ['spec/fixtures/foodsoft_file_02.csv', 'spec/fixtures/bnn_file_02.bnn', 'spec/fixtures/odin_file_02.xml']
|
||||
let(:filename) { 'foodsoft_file_02.csv' }
|
||||
let(:file) { Rails.root.join("spec/fixtures/#{filename}") }
|
||||
let(:val) { 'foodsoft' }
|
||||
let(:type) { %w[foodsoft bnn odin] }
|
||||
|
||||
all("tr select > option")[1].select_option
|
||||
find('input[type="submit"]').click # now it should succeed
|
||||
expect(supplier.articles.count).to eq 1
|
||||
end
|
||||
before do
|
||||
visit upload_supplier_articles_path(supplier_id: supplier.id)
|
||||
attach_file 'articles_file', file
|
||||
find("#articles_type option[value='#{val}']").select_option
|
||||
end
|
||||
|
||||
describe "can remove an existing article" do
|
||||
let!(:article) { create :article, supplier: supplier, name: 'Foobar', order_number: 99999 }
|
||||
file_paths.each_with_index do |test_file, index|
|
||||
describe "updates article for #{test_file}" do
|
||||
let(:article) { create(:article, supplier: supplier, name: 'Foobar', order_number: 1, unit: '250 g') }
|
||||
let(:file) { Rails.root.join(test_file) }
|
||||
let(:val) { type[index] }
|
||||
|
||||
it do
|
||||
check('articles_outlist_absent')
|
||||
find('input[type="submit"]').click
|
||||
expect(find("#outlisted_articles_#{article.id}", visible: :all)).to be_present
|
||||
it do
|
||||
article.reload
|
||||
find('input[type="submit"]').click
|
||||
expect(find("#articles_#{article.id}_name").value).to eq 'Tomatoes'
|
||||
find('input[type="submit"]').click
|
||||
article.reload
|
||||
expect(article.name).to eq 'Tomatoes'
|
||||
if type[index] == "odin"
|
||||
expect([article.unit, article.unit_quantity, article.price]).to eq ['500gr', 20, 1.20]
|
||||
else
|
||||
expect([article.unit, article.unit_quantity, article.price]).to eq ['500 g', 20, 1.20]
|
||||
end
|
||||
end
|
||||
|
||||
all("tr select > option")[1].select_option
|
||||
find('input[type="submit"]').click
|
||||
expect(article.reload.deleted?).to be true
|
||||
it "handles missing data" do
|
||||
find('input[type="submit"]').click # to overview
|
||||
find('input[type="submit"]').click # missing category, re-show form
|
||||
expect(find('tr.alert')).to be_present
|
||||
expect(supplier.articles.count).to eq 0
|
||||
|
||||
all("tr select > option")[1].select_option
|
||||
find('input[type="submit"]').click # now it should succeed
|
||||
expect(supplier.articles.count).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "can convert units when updating" do
|
||||
let!(:article) { create :article, supplier: supplier, order_number: 1, unit: '250 g' }
|
||||
describe "takes over category from file" do
|
||||
it do
|
||||
find(:css, '#articles_update_category[value="1"]').set(true) # check take over category from file
|
||||
expect(ArticleCategory.count).to eq 1 # new Category vegetables should be created from file
|
||||
find('input[type="submit"]').click # upload file
|
||||
find('input[type="submit"]').click # submit changes
|
||||
expect(ArticleCategory.count).to eq 2 # it is
|
||||
expect(supplier.articles.count).to eq 1
|
||||
expect(supplier.articles.first.article_category.name).to eq "Vegetables"
|
||||
end
|
||||
end
|
||||
|
||||
it do
|
||||
check('articles_convert_units')
|
||||
find('input[type="submit"]').click
|
||||
expect(find("#articles_#{article.id}_name").value).to eq 'Tomatoes'
|
||||
find('input[type="submit"]').click
|
||||
article.reload
|
||||
expect([article.unit, article.unit_quantity, article.price]).to eq ['250 g', 40, 0.6]
|
||||
describe "overwrites article_category from file" do
|
||||
let!(:article_category) { create(:article_category, name: "Fruit") }
|
||||
let(:article) { create(:article, supplier: supplier, name: 'Tomatoes', order_number: 1, unit: '250 g', article_category: article_category) }
|
||||
|
||||
it do
|
||||
find(:css, '#articles_update_category[value="1"]').set(true) # check take over category from file
|
||||
find('input[type="submit"]').click #upload file
|
||||
find('input[type="submit"]').click #submit changes
|
||||
expect(supplier.articles.count).to eq 1
|
||||
expect(supplier.articles.first.article_category.name).to eq "Vegetables"
|
||||
end
|
||||
end
|
||||
|
||||
describe "can remove an existing article" do
|
||||
let!(:article) { create(:article, supplier: supplier, name: 'Foobar', order_number: 99999) }
|
||||
|
||||
it do
|
||||
check('articles_outlist_absent')
|
||||
find('input[type="submit"]').click
|
||||
expect(find("#outlisted_articles_#{article.id}", visible: :all)).to be_present
|
||||
|
||||
all("tr select > option")[1].select_option
|
||||
find('input[type="submit"]').click
|
||||
expect(article.reload.deleted?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "can convert units when updating" do
|
||||
let!(:article) { create(:article, supplier: supplier, order_number: 1, unit: '250 g') }
|
||||
|
||||
it do
|
||||
check('articles_convert_units')
|
||||
find('input[type="submit"]').click
|
||||
expect(find("#articles_#{article.id}_name").value).to eq 'Tomatoes'
|
||||
find('input[type="submit"]').click
|
||||
article.reload
|
||||
expect([article.unit, article.unit_quantity, article.price]).to eq ['250 g', 40, 0.6]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Supplier do
|
|||
options = { filename: 'foodsoft_file_01.csv' }
|
||||
options[:outlist_absent] = true
|
||||
options[:convert_units] = true
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_from_file(Rails.root.join('spec/fixtures/foodsoft_file_01.csv'), options)
|
||||
updated_article_pairs, outlisted_articles, new_articles = supplier.sync_from_file(Rails.root.join('spec/fixtures/foodsoft_file_01.csv'), "foodsoft", options)
|
||||
expect(new_articles.length).to be > 0
|
||||
expect(updated_article_pairs.first[1][:name]).to eq 'Tomaten'
|
||||
expect(outlisted_articles.first).to eq article2
|
||||
|
|
Loading…
Reference in a new issue