Compare commits
26 Commits
demo-merge
...
demo
Author | SHA1 | Date |
---|---|---|
Philipp Rothmann | eb6cf00f94 | |
Philipp Rothmann | c76c148f99 | |
FGU | ce7b4d7ce4 | |
Philipp Rothmann | eb719057c4 | |
Philipp Rothmann | 2614f095cb | |
viehlieb | b94ca21022 | |
Philipp Rothmann | 8cb86b2f88 | |
viehlieb | 3d71d266e3 | |
FGU | ee03a2a9af | |
Philipp Rothmann | 237ef5d38b | |
Philipp Rothmann | dfe8beae2c | |
Philipp Rothmann | 75bb400d0d | |
viehlieb | 6f2a3b4f5f | |
viehlieb | d81ae10dc8 | |
viehlieb | 4b5775e107 | |
Philipp Rothmann | 936c1ba878 | |
Philipp Rothmann | b3571515b0 | |
Philipp Rothmann | 28c851823a | |
Philipp Rothmann | 25d4efa71a | |
Philipp Rothmann | 49a04b226c | |
Philipp Rothmann | 69c80eba3e | |
Philipp Rothmann | e6e2cdc2c6 | |
viehlieb | 4bb724495d | |
viehlieb | 0bd04fba41 | |
viehlieb | 46e3794a4e | |
viehlieb | 5c04a43f61 |
|
@ -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_BRANCH}"
|
||||
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_BRANCH}"
|
||||
DOMAIN: "foodsoft.dev.local-it.cloud"
|
||||
LETS_ENCRYPT_ENV: production
|
||||
FOODCOOP_MULTI_INSTALL: true
|
||||
FOODCOOP_NAME: Einkaufskooperative Foobar
|
||||
FOODCOOP_CITY: Berlin
|
||||
FOODCOOP_COUNTRY: Deutschland
|
||||
FOODCOOP_EMAIL: foodsoft@local-it.org
|
||||
FOODCOOP_PHONE: 123456789
|
||||
FOODCOOP_STREET: Einkaufsstraße 5
|
||||
FOODCOOP_ZIP_CODE: 12345
|
||||
FOODCOOP_HOMEPAGE: https://foodsoft.local-it.org
|
||||
FOODCOOP_HELP_URL: https://git.local-it.org/foodsoft/foodsoft
|
||||
FOODCOOP_TIME_ZONE: Berlin
|
||||
FOODCOOP_USE_NICK: true
|
||||
FOODCOOP_LANGUAGE: de
|
||||
FOODCOOP_FOOTER: '<a href="https://foodsoft.local-it.org/">Foodsoft</a> hosted by <a href="https://local-it.org">local-it e,V,</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: demo@local-it.org
|
||||
EMAIL_ERROR: flip@yksflip.de
|
||||
SMTP_ADDRESS: mail.local-it.org
|
||||
SMTP_AUTHENTICATION: login
|
||||
SMTP_DOMAIN: mail.local-it.org
|
||||
SMTP_ENABLE_STARTTLS_AUTO: true
|
||||
SMTP_PORT: 587
|
||||
SMTP_USER_NAME: demo@local-it.org
|
||||
EMAIL_REPLY_DOMAIN:
|
||||
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
|
||||
|
|
5
Gemfile
5
Gemfile
|
@ -23,7 +23,7 @@ gem 'bootsnap', require: false
|
|||
gem 'mysql2'
|
||||
gem 'prawn'
|
||||
gem 'prawn-table'
|
||||
gem 'haml'
|
||||
gem 'haml', '~> 5.0'
|
||||
gem 'haml-rails'
|
||||
gem 'kaminari'
|
||||
gem 'simple_form'
|
||||
|
@ -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"
|
||||
|
|
23
Gemfile.lock
23
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
|
||||
|
@ -234,9 +242,8 @@ GEM
|
|||
rails (>= 4.0.0)
|
||||
globalid (1.0.0)
|
||||
activesupport (>= 5.0)
|
||||
haml (6.1.1)
|
||||
temple (>= 0.8.2)
|
||||
thor
|
||||
haml (5.2.2)
|
||||
temple (>= 0.8.0)
|
||||
tilt
|
||||
haml-rails (2.1.0)
|
||||
actionpack (>= 5.1)
|
||||
|
@ -255,6 +262,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 +328,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 +507,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 +631,7 @@ DEPENDENCIES
|
|||
exception_notification
|
||||
factory_bot_rails
|
||||
faker
|
||||
foodsoft_article_import!
|
||||
foodsoft_discourse!
|
||||
foodsoft_documents!
|
||||
foodsoft_links!
|
||||
|
@ -625,12 +639,13 @@ DEPENDENCIES
|
|||
foodsoft_polls!
|
||||
foodsoft_wiki!
|
||||
gaffe
|
||||
haml
|
||||
haml (~> 5.0)
|
||||
haml-rails
|
||||
hashie (~> 3.4.6)
|
||||
i18n-js (~> 3.0.0.rc8)
|
||||
i18n-spec
|
||||
ice_cube
|
||||
image_processing (~> 1.12)
|
||||
importmap-rails (~> 1.1)
|
||||
inherited_resources
|
||||
jquery-rails
|
||||
|
|
161
README.md
161
README.md
|
@ -1,65 +1,124 @@
|
|||
Foodsoft
|
||||
=========
|
||||
[![Build Status](https://github.com/foodcoops/foodsoft/workflows/Ruby/badge.svg)](https://github.com/foodcoops/foodsoft/actions)
|
||||
[![Coverage Status](https://coveralls.io/repos/foodcoops/foodsoft/badge.svg?branch=master)](https://coveralls.io/r/foodcoops/foodsoft?branch=master)
|
||||
[![Docs Status](https://inch-ci.org/github/foodcoops/foodsoft.svg?branch=master)](http://inch-ci.org/github/foodcoops/foodsoft)
|
||||
[![Code Climate](https://codeclimate.com/github/foodcoops/foodsoft.svg)](https://codeclimate.com/github/foodcoops/foodsoft)
|
||||
[![Docker Status](https://img.shields.io/docker/cloud/build/foodcoops/foodsoft.svg)](https://hub.docker.com/r/foodcoops/foodsoft)
|
||||
[![Documentation](https://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/foodcoops/foodsoft)
|
||||
|
||||
Web-based software to manage a non-profit food coop (product catalog, ordering, accounting, job scheduling).
|
||||
|
||||
A food cooperative is a group of people that buy food from suppliers of their own choosing. A collective do-it-yourself supermarket. Members order their products online and collect them on a specified day. And all put in a bit of work to make that possible. Foodsoft facilitates the process.
|
||||
|
||||
If you're a food coop considering to use foodsoft, please have a look at the [wiki page for foodcoops](https://github.com/foodcoops/foodsoft/wiki/For-foodcoops). When you'd like to experiment with or develop foodsoft, you can read [how to set it up](https://github.com/foodcoops/foodsoft/blob/master/doc/SETUP_DEVELOPMENT.md) on your own computer.
|
||||
|
||||
More information about using this software and contributing can be found on the [wiki](https://github.com/foodcoops/foodsoft/wiki).
|
||||
[Website](https://foodsoft.local-it.org)
|
||||
[Prototypefund](https://prototypefund.de/project/weiterentwicklung-von-foodsoft/)
|
||||
|
||||
|
||||
Developing
|
||||
----------
|
||||
Foodsoft ist ein Tool für [Lebensmittelkooperativen](https://de.wikipedia.org/wiki/Lebensmittelkooperative), welches selbstorganisierte gemeinsame Bestellungen in Großmengen von regionalen und ökologischen Produkten vereinfacht und transparent gestaltet.
|
||||
|
||||
Get foodsoft [running locally](doc/SETUP_DEVELOPMENT.md),
|
||||
then visit our [Developing Guidelines](https://github.com/foodcoops/foodsoft/wiki/Developing-Guidelines)
|
||||
page on the wiki.
|
||||
|
||||
Get a foodsoft dev-environment running in the browser with Gitpod
|
||||
|
||||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/foodcoops/foodsoft)
|
||||
|
||||
Follow these [instructions](doc/SETUP_DEVELOPMENT_GITPOD.md) to complete setup from within the Gitpod workspace.
|
||||
|
||||
Deploying
|
||||
---------
|
||||
|
||||
Setup foodsoft to [run in production](doc/SETUP_PRODUCTION.md), or join an existing
|
||||
[hosting platform](https://foodcoops.net/foodsoft-hosting/).
|
||||
Foodsoft wurde ursprünglich entwickelt und betrieben von [foodcoops.net](https://foodcoops.net/)
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
#### Zielgruppe
|
||||
|
||||
Foodsoft is licensed under the [AGPL](https://www.gnu.org/licenses/agpl-3.0.html)
|
||||
license (version 3 or later). Practically this means that you are free to use,
|
||||
adapt and redistribute the software, as long as you publish any changes you
|
||||
make to the code.
|
||||
Unsere Zielgruppen sind Bürger:innen, Gruppen und Vereine, die eine Einkauskooperative aufbauen wollen und eine Software, die die Bestellung, Verteilung und Abrechnung erleichtert, benötigen.
|
||||
|
||||
For private use, there are no restrictions, but if you give others access to
|
||||
Foodsoft (like running it open to the internet), you must also make your
|
||||
changes available under the same license. This can be as easy as
|
||||
[forking](https://github.com/foodcoops/foodsoft/fork) the project on Github and
|
||||
pushing your changes. You are not required to integrate your changes back into
|
||||
the main Foodsoft version (but if you're up for it that would be very welcome).
|
||||
#### Vorhaben
|
||||
|
||||
To make it a little easier, configuration files are exempt, so you can just
|
||||
install and configure Foodsoft without having to publish your changes. These
|
||||
files are marked as public domain in the file header.
|
||||
* ✅ Technische Schuld reduzieren
|
||||
* ✅ Ruby on Rails Upgrade
|
||||
* ✅ Artikel Import verbessern
|
||||
(Großhandelschnitstelle)
|
||||
* ✅ Userexperience Verbessern
|
||||
|
||||
#### Was ist eine Einkaufskooperative?
|
||||
|
||||
![Wie funktioniert eine Einkauskooperative?](./doc/foodcoop-explained.jpg)
|
||||
|
||||
|
||||
|
||||
State of this Fork
|
||||
------------------
|
||||
|
||||
#### Increase Test Coverage
|
||||
|
||||
1. integration and model tests
|
||||
* [x] fork
|
||||
* [x] upstream [#966](https://github.com/foodcoops/foodsoft/pull/966)
|
||||
1. Controller tests
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/8_increase_test_coverage_controllers)
|
||||
* [ ] upstream [#970](https://github.com/foodcoops/foodsoft/pull/970)
|
||||
|
||||
#### Upgrade
|
||||
|
||||
1. Migrate to RSwag API Tests
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/28_introduce_rswag)
|
||||
* [x] upstream [#969](https://github.com/foodcoops/foodsoft/pull/969)
|
||||
1. Rails v7
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/9_rails_v_7)
|
||||
* [x] upstream [#979](https://github.com/foodcoops/foodsoft/pull/979)
|
||||
disussion [#956](https://github.com/foodcoops/foodsoft/issues/956)
|
||||
1. Javascript Importmap
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/9_rails_v_7_js_importmap)
|
||||
* [x] upstream
|
||||
|
||||
#### Article Order Import/Export
|
||||
|
||||
Updating Articles from large resellers and exporting orders is now much easier!
|
||||
|
||||
1. adds bnn fileformat that is used from large german resellers e.g. naturkost nord
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/11_bnn_import_article_update)
|
||||
[gem](https://git.local-it.org/Foodsoft/foodsoft_article_import)
|
||||
* [ ] upstream
|
||||
1. Import category field
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/56_add_update_of_article_category_to_file_import)
|
||||
* [ ] upstream
|
||||
1. Export order as a custom csv file
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/12_generate_custom_csv_file)
|
||||
* [ ] upstream
|
||||
1. Naturkostnord Plugin
|
||||
* [ ] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/12_nkn_file_plugin)
|
||||
* [ ] upstream
|
||||
|
||||
#### Improve User Experience
|
||||
|
||||
1. Richtext editor for messages. Also allows sending attachements.
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/16_html_message_templates)
|
||||
* [x] upstream
|
||||
1. Show the sum of all order group balances
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/47_finance_ordergroup_sums)
|
||||
* [x] upstream
|
||||
1. UI improvements for group order view
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/uxui_group_order)
|
||||
* [ ] upstream
|
||||
1. Favorites
|
||||
* [ ] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/20_favourites)
|
||||
* [ ] upstream
|
||||
1. Show the per kilo / litre price
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/11_include_kilo_litre_price)
|
||||
* [ ] upstream
|
||||
|
||||
#### Other
|
||||
|
||||
1. Fix broken plugin mechanism
|
||||
* [x] [fork](https://git.local-it.org/Foodsoft/foodsoft/src/branch/downgrade-haml)
|
||||
* [x] upstream
|
||||
|
||||
#### Screenshots
|
||||
|
||||
![rswag](./doc/screenshots/rswag.png)
|
||||
|
||||
---
|
||||
|
||||
![bnn upload](./doc/screenshots/bnn_upload.png)
|
||||
|
||||
---
|
||||
|
||||
![message formatting](./doc/screenshots/message_formatting.png)
|
||||
|
||||
---
|
||||
|
||||
![balance sum](./doc/screenshots/balance_sum.png)
|
||||
|
||||
---
|
||||
|
||||
![custom csv export](./doc/screenshots/custom_csv_export.png)
|
||||
csv export
|
||||
|
||||
---
|
||||
|
||||
![order](./doc/screenshots/order.png)
|
||||
|
||||
If you have any remaining questions, please
|
||||
[open an issue](https://github.com/foodcoops/foodsoft/issues/new) or open a new
|
||||
topic at the [forum](https://forum.foodcoops.net).
|
||||
|
||||
Please see [LICENSE](LICENSE.md) for the full and authoritative text. Some
|
||||
bundled third-party components have [other licenses](vendor/README.md).
|
||||
|
||||
Thanks to [Icons8](http://icons8.com/) for letting us use their icons.
|
||||
|
|
|
@ -179,17 +179,13 @@ function updateBalance() {
|
|||
var balance = groupBalance - total;
|
||||
$('#new_balance').html(I18n.l("currency", balance));
|
||||
$('#total_balance').val(I18n.l("currency", balance));
|
||||
// determine bgcolor and submit button state according to balance
|
||||
var bgcolor = '';
|
||||
if (balance < minimumBalance) {
|
||||
bgcolor = '#FF0000';
|
||||
$('#submit_button').attr('disabled', 'disabled')
|
||||
$('#balance-alert').css('display', 'block')
|
||||
|
||||
} else {
|
||||
$('#submit_button').removeAttr('disabled')
|
||||
}
|
||||
// update bgcolor
|
||||
for (i in itemTotal) {
|
||||
$('#td_price_' + i).css('background-color', bgcolor);
|
||||
$('#balance-alert').css('display', 'none')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -230,7 +230,7 @@ table {
|
|||
margin: .5em 0;
|
||||
|
||||
input:disabled {
|
||||
background-color: red; }
|
||||
background-color: gray; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,6 +241,9 @@ table {
|
|||
tr.order-article:hover .article-info {
|
||||
display: none;
|
||||
}
|
||||
tr.order-article:focus .article-info {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
#order-footer {
|
||||
|
@ -275,10 +278,13 @@ tr.order-article .article-info {
|
|||
display: none;
|
||||
}
|
||||
|
||||
tr.order-article:hover .article-info {
|
||||
tr.order-article:focus .article-info {
|
||||
display: block;
|
||||
}
|
||||
|
||||
tr.order-article:focus {
|
||||
background-color: #E9E9E9;
|
||||
}
|
||||
|
||||
// ********* Articles
|
||||
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
.list .missing-many td, .list .missing-many:hover td {
|
||||
background-color: #ebbebe;
|
||||
.missing-many td {
|
||||
background-color: #ffc590aa;
|
||||
}
|
||||
|
||||
.list .missing-few td, .list .missing-few:hover td {
|
||||
background-color: #ffee75;
|
||||
.missing-many:hover td, .missing-many:focus td {
|
||||
background-color: #ffc590;
|
||||
}
|
||||
|
||||
.list .missing-none td, .list .missing-none:hover td {
|
||||
background-color: #E4EED6;
|
||||
.missing-few td {
|
||||
background-color: #fcf488aa;
|
||||
}
|
||||
|
||||
.missing-few:hover td, .missing-few:focus td {
|
||||
background-color: #fcf488;
|
||||
}
|
||||
|
||||
.missing-none td {
|
||||
background-color: #d0f6ffaa;
|
||||
}
|
||||
|
||||
.missing-none:hover td, .missing-none:focus td {
|
||||
background-color: #d0f6ff;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -49,7 +49,7 @@ class OrdersController < ApplicationController
|
|||
send_order_pdf @order, params[:document]
|
||||
end
|
||||
format.csv do
|
||||
send_data OrderCsv.new(@order).to_csv, filename: @order.name + '.csv', type: 'text/csv'
|
||||
send_data OrderCsv.new(@order, options= {custom_csv: params[:custom_csv]}).to_csv, filename: @order.name + '.csv', type: 'text/csv'
|
||||
end
|
||||
format.text do
|
||||
send_data OrderTxt.new(@order).to_txt, filename: @order.name + '.txt', type: 'text/plain'
|
||||
|
@ -57,6 +57,19 @@ class OrdersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def custom_csv
|
||||
@order = Order.find(params[:id])
|
||||
@view = (params[:view] || 'default').gsub(/[^-_a-zA-Z0-9]/, '')
|
||||
@partial = case @view
|
||||
when 'default' then 'articles'
|
||||
when 'groups' then 'shared/articles_by/groups'
|
||||
when 'articles' then 'shared/articles_by/articles'
|
||||
else 'articles'
|
||||
end
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
# Page to create a new order.
|
||||
def new
|
||||
if params[:order_id]
|
||||
|
|
|
@ -53,4 +53,12 @@ module GroupOrdersHelper
|
|||
return 'missing-many'
|
||||
end
|
||||
end
|
||||
|
||||
def price_per_base_unit(article:, price:)
|
||||
quantity_unit = QuantityUnit.parse(article.unit)
|
||||
return nil unless quantity_unit.present?
|
||||
|
||||
scaled_price, base_unit = quantity_unit.scale_price_to_base_unit(price)
|
||||
"#{number_to_currency(scaled_price)}/#{base_unit}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -155,4 +155,16 @@ module OrdersHelper
|
|||
link_to t('orders.index.action_receive'), receive_order_path(order), class: "btn#{' btn-success' unless order.received?} #{options[:class]}"
|
||||
end
|
||||
end
|
||||
|
||||
def custom_csv_collection
|
||||
[
|
||||
OrderArticle.human_attribute_name(:units_to_order),
|
||||
Article.human_attribute_name(:order_number),
|
||||
Article.human_attribute_name(:name),
|
||||
Article.human_attribute_name(:unit),
|
||||
Article.human_attribute_name(:unit_quantity_short),
|
||||
ArticlePrice.human_attribute_name(:price),
|
||||
OrderArticle.human_attribute_name(:total_price)
|
||||
]
|
||||
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
|
|
@ -2,28 +2,60 @@ require 'csv'
|
|||
|
||||
class OrderCsv < RenderCsv
|
||||
def header
|
||||
[
|
||||
OrderArticle.human_attribute_name(:units_to_order),
|
||||
Article.human_attribute_name(:order_number),
|
||||
Article.human_attribute_name(:name),
|
||||
Article.human_attribute_name(:unit),
|
||||
Article.human_attribute_name(:unit_quantity_short),
|
||||
ArticlePrice.human_attribute_name(:price),
|
||||
OrderArticle.human_attribute_name(:total_price)
|
||||
]
|
||||
params = @options[:custom_csv]
|
||||
arr = if params.nil?
|
||||
[
|
||||
OrderArticle.human_attribute_name(:units_to_order),
|
||||
Article.human_attribute_name(:order_number),
|
||||
Article.human_attribute_name(:name),
|
||||
Article.human_attribute_name(:unit),
|
||||
Article.human_attribute_name(:unit_quantity_short),
|
||||
ArticlePrice.human_attribute_name(:price),
|
||||
OrderArticle.human_attribute_name(:total_price)
|
||||
]
|
||||
else
|
||||
[
|
||||
params[:first],
|
||||
params[:second],
|
||||
params[:third],
|
||||
params[:fourth],
|
||||
params[:fifth],
|
||||
params[:sixth],
|
||||
params[:seventh]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
def data
|
||||
@object.order_articles.ordered.includes([:article, :article_price]).all.map do |oa|
|
||||
yield [
|
||||
oa.units_to_order,
|
||||
oa.article.order_number,
|
||||
oa.article.name,
|
||||
oa.article.unit,
|
||||
oa.price.unit_quantity > 1 ? oa.price.unit_quantity : nil,
|
||||
number_to_currency(oa.price.price * oa.price.unit_quantity),
|
||||
number_to_currency(oa.total_price)
|
||||
match_params(oa, header[0]),
|
||||
match_params(oa, header[1]),
|
||||
match_params(oa, header[2]),
|
||||
match_params(oa, header[3]),
|
||||
match_params(oa, header[4]),
|
||||
match_params(oa, header[5]),
|
||||
match_params(oa, header[6])
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
def match_params(object, attribute)
|
||||
case attribute
|
||||
when OrderArticle.human_attribute_name(:units_to_order)
|
||||
object.units_to_order
|
||||
when Article.human_attribute_name(:order_number)
|
||||
object.article.order_number
|
||||
when Article.human_attribute_name(:name)
|
||||
object.article.name
|
||||
when Article.human_attribute_name(:unit)
|
||||
object.article.unit
|
||||
when Article.human_attribute_name(:unit_quantity_short)
|
||||
object.price.unit_quantity > 1 ? object.price.unit_quantity : nil
|
||||
when ArticlePrice.human_attribute_name(:price)
|
||||
number_to_currency(object.price.price * object.price.unit_quantity)
|
||||
when OrderArticle.human_attribute_name(:total_price)
|
||||
number_to_currency(object.total_price)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
class QuantityUnit
|
||||
def initialize(quantity, unit)
|
||||
@quantity = quantity
|
||||
@unit = unit
|
||||
end
|
||||
|
||||
def self.parse(number_with_unit)
|
||||
# remove whitespace
|
||||
number_with_unit = number_with_unit.gsub(/\s+/, '')
|
||||
# to lowercase
|
||||
number_with_unit = number_with_unit.downcase
|
||||
# remove numerical part
|
||||
number = number_with_unit.gsub(/[^0-9.,]/, '')
|
||||
# remove unit part
|
||||
unit = number_with_unit.gsub(/[^a-zA-Z]/, '')
|
||||
# convert comma to dot
|
||||
number = number.gsub(',', '.')
|
||||
# convert to float
|
||||
number = number.to_f
|
||||
|
||||
return nil unless unit.in?(%w[g kg l ml])
|
||||
|
||||
QuantityUnit.new(number, unit)
|
||||
end
|
||||
|
||||
def scale_price_to_base_unit(price)
|
||||
return nil unless price.is_a?(Numeric)
|
||||
|
||||
factor = if @unit == 'kg' || @unit == 'l'
|
||||
1
|
||||
elsif @unit == 'g' || @unit == 'ml'
|
||||
1000
|
||||
end
|
||||
|
||||
scaled_price = price / @quantity * factor
|
||||
scaled_price.round(2)
|
||||
|
||||
base_unit = if @unit == 'kg' || @unit == 'g'
|
||||
'kg'
|
||||
elsif @unit == 'l' || @unit == 'ml'
|
||||
'L'
|
||||
end
|
||||
|
||||
[scaled_price, base_unit]
|
||||
end
|
||||
|
||||
|
||||
def to_s
|
||||
"#{@quantity} #{@unit}"
|
||||
end
|
||||
|
||||
def quantity
|
||||
@quantity
|
||||
end
|
||||
|
||||
def unit
|
||||
@unit
|
||||
end
|
||||
end
|
|
@ -20,6 +20,7 @@ class RenderCsv
|
|||
end
|
||||
data { |d| csv << d }
|
||||
end
|
||||
ret << I18n.t('.orders.articles.prices_sum') << ";" << "#{number_to_currency(@object.sum(:gross))}/#{number_to_currency(@object.sum(:net))}" if @options[:custom_csv]
|
||||
ret.encode(@options[:encoding], invalid: :replace, undef: :replace)
|
||||
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, :update_category)
|
||||
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]
|
||||
|
|
|
@ -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(:+)
|
|
@ -0,0 +1,15 @@
|
|||
%h4= t '.title'
|
||||
%hr
|
||||
%table.table-condensed
|
||||
%thead
|
||||
%th= t '.package_fill_level'
|
||||
%tbody
|
||||
%tr{class: "missing-none"}
|
||||
%td= t '.missing_none'
|
||||
%tr{class: "missing-few"}
|
||||
%td= t '.missing_few'
|
||||
%tr{class: "missing-many"}
|
||||
%td= t '.missing_many'
|
||||
%hr
|
||||
%b= t('.tolerance') + ':'
|
||||
= t '.tolerance_explained'
|
|
@ -11,170 +11,142 @@
|
|||
var listjsResetPlugin = ['reset', {highlightClass: 'btn-primary'}];
|
||||
var listjsDelayPlugin = ['delay', {delayedSearchTime: 500}];
|
||||
new List(document.body, {
|
||||
valueNames: ['name'],
|
||||
engine: 'unlist',
|
||||
plugins: [listjsResetPlugin, listjsDelayPlugin],
|
||||
// make large pages work too (as we don't have paging - articles may disappear!)
|
||||
page: 10000,
|
||||
indexAsync: true
|
||||
valueNames: ['name'],
|
||||
engine: 'unlist',
|
||||
plugins: [listjsResetPlugin, listjsDelayPlugin],
|
||||
// make large pages work too (as we don't have paging - articles may disappear!)
|
||||
page: 10000,
|
||||
indexAsync: true
|
||||
});
|
||||
});
|
||||
|
||||
- title t('.title'), false
|
||||
|
||||
.alert.alert-error#balance-alert{style: ('display:none')}
|
||||
=t 'group_orders.errors.balance_alert'
|
||||
.row-fluid
|
||||
.well.pull-left
|
||||
= close_button :alert
|
||||
%h2= @order.name
|
||||
%dl.dl-horizontal
|
||||
- unless @order.note.blank?
|
||||
%dt= heading_helper Order, :note
|
||||
%dd= @order.note
|
||||
%dt= heading_helper Order, :created_by
|
||||
%dd= show_user_link(@order.created_by)
|
||||
%dt= heading_helper Order, :ends
|
||||
%dd= format_time(@order.ends)
|
||||
%dt= heading_helper Order, :pickup
|
||||
%dd= format_date(@order.pickup)
|
||||
- unless @order.stockit? or @order.supplier.min_order_quantity.blank?
|
||||
%dt= heading_helper Supplier, :min_order_quantity, short: true
|
||||
%dd= @order.supplier.min_order_quantity
|
||||
%dt= t '.sum_amount'
|
||||
%dd= number_to_currency @order.sum
|
||||
- unless @group_order.new_record?
|
||||
%dt= heading_helper GroupOrder, :updated_by
|
||||
%dd
|
||||
= show_user(@group_order.updated_by)
|
||||
(#{format_time(@group_order.updated_on)})
|
||||
%dt= heading_helper Ordergroup, :account_balance
|
||||
%dd= number_to_currency(@ordering_data[:account_balance])
|
||||
- unless FoodsoftConfig[:charge_members_manually]
|
||||
%dt= heading_helper Ordergroup, :available_funds
|
||||
%dd= number_to_currency(@ordering_data[:available_funds])
|
||||
|
||||
.well.pull-right
|
||||
= close_button :alert
|
||||
= render 'switch_order', current_order: @order
|
||||
|
||||
.row-fluid
|
||||
.well.clear
|
||||
.form-search
|
||||
.span2
|
||||
.well
|
||||
= render 'switch_order', current_order: @order
|
||||
.well
|
||||
= render 'explanations'
|
||||
.well.span9
|
||||
%h2.span9= t '.sub_title', order_name: @order.name
|
||||
.span3
|
||||
%table.table-condensed
|
||||
-if @order.ends
|
||||
%tr
|
||||
%td= heading_helper(Order, :ends) + ': '
|
||||
%td= format_time(@order.ends)
|
||||
- unless @order.stockit? or @order.supplier.min_order_quantity.blank?
|
||||
%tr
|
||||
%td= heading_helper(Supplier, :min_order_quantity)
|
||||
%td= number_to_currency(@order.supplier.min_order_quantity)
|
||||
%tr
|
||||
%td= t('group_orders.form.sum_amount') + ':'
|
||||
%td= number_to_currency(@order.sum)
|
||||
%hr
|
||||
.form-search.pull-right
|
||||
.input-append
|
||||
= text_field_tag :article, params[:article], placeholder: t('.search_article'), class: 'search-query delayed-search resettable'
|
||||
%button.add-on.btn.reset-search{:type => :button, :title => t('.reset_article_search')}
|
||||
%i.icon.icon-remove
|
||||
|
||||
= form_for @group_order do |f|
|
||||
= f.hidden_field :lock_version
|
||||
= f.hidden_field :order_id
|
||||
= f.hidden_field :updated_by_user_id
|
||||
= f.hidden_field :ordergroup_id
|
||||
%table.table.table-hover
|
||||
%thead
|
||||
%tr
|
||||
%th= heading_helper Article, :name
|
||||
- if @order.stockit?
|
||||
%th{style: 'width:120px'}= heading_helper StockArticle, :supplier
|
||||
%th{style: "width:13px;"}
|
||||
%th{style: "width:4.5em;"}= t '.price'
|
||||
%th{style: "width:4.5em;"}= heading_helper Article, :unit
|
||||
- unless @order.stockit?
|
||||
%th{style: "width:70px;"}= heading_helper OrderArticle, :missing_units, short: true
|
||||
%th#col_required= heading_helper GroupOrderArticle, :quantity
|
||||
%th#col_tolerance= heading_helper GroupOrderArticle, :tolerance
|
||||
- else
|
||||
%th(style="width:20px")= heading_helper StockArticle, :available
|
||||
%th#col_required= heading_helper GroupOrderArticle, :quantity
|
||||
%th{style: "width:15px;"}= heading_helper GroupOrderArticle, :total_price
|
||||
%tbody.list
|
||||
- @order.articles_grouped_by_category.each do |category, order_articles|
|
||||
%tr.list-heading.article-category
|
||||
%td
|
||||
= category
|
||||
%i.icon-tag
|
||||
%td{colspan: "9"}
|
||||
- order_articles.each do |order_article|
|
||||
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id][:missing_units])}", valign: "top"}
|
||||
%td.name= order_article.article.name
|
||||
= form_for @group_order do |f|
|
||||
= f.hidden_field :lock_version
|
||||
= f.hidden_field :order_id
|
||||
= f.hidden_field :updated_by_user_id
|
||||
= f.hidden_field :ordergroup_id
|
||||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
%th= heading_helper Article, :name
|
||||
- if @order.stockit?
|
||||
%td= truncate order_article.article.supplier.name, length: 15
|
||||
%td= h order_article.article.origin
|
||||
%td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price])
|
||||
%td= order_article.article.unit
|
||||
%td
|
||||
- if @order.stockit?
|
||||
= @ordering_data[:order_articles][order_article.id][:quantity_available]
|
||||
- else
|
||||
%span{id: "missing_units_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:missing_units]
|
||||
%th{style: 'width:120px'}= heading_helper StockArticle, :supplier
|
||||
%th{style: "width:13px;"}
|
||||
%th{style: "width:4.5em;"}= t '.price'
|
||||
%th{style: "width:4.5em;"}= t '.price_per_base_unit'
|
||||
%th{style: "width:4.5em;"}= heading_helper Article, :unit
|
||||
- unless @order.stockit?
|
||||
%th{style: "width:70px;"}= heading_helper OrderArticle, :missing_units, short: true
|
||||
%th#col_required= heading_helper GroupOrderArticle, :quantity
|
||||
%th#col_tolerance= heading_helper GroupOrderArticle, :tolerance
|
||||
- else
|
||||
%th(style="width:20px")= heading_helper StockArticle, :available
|
||||
%th#col_required= heading_helper GroupOrderArticle, :quantity
|
||||
%th{style: "width:15px;"}= heading_helper GroupOrderArticle, :total_price
|
||||
%tbody.list
|
||||
- @order.articles_grouped_by_category.each do | category, order_articles|
|
||||
%tr.list-heading.article-category
|
||||
%td
|
||||
= category
|
||||
%i.icon-tag
|
||||
%td{colspan: "9"}
|
||||
- order_articles.each do |order_article|
|
||||
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id][:missing_units])}", valign: "top", tabindex: "0"}
|
||||
%td.name= order_article.article.name
|
||||
- if @order.stockit?
|
||||
%td= truncate order_article.article.supplier.name, length: 15
|
||||
%td= h order_article.article.origin
|
||||
%td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price])
|
||||
%td= price_per_base_unit(article: order_article.article, price: @ordering_data[:order_articles][order_article.id][:price])
|
||||
%td= order_article.article.unit
|
||||
%td
|
||||
- if @order.stockit?
|
||||
= @ordering_data[:order_articles][order_article.id][:quantity_available]
|
||||
- else
|
||||
%span{id: "missing_units_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:missing_units]
|
||||
|
||||
%td.quantity
|
||||
%input{id: "q_#{order_article.id}", name: "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", type: "hidden", value: @ordering_data[:order_articles][order_article.id][:quantity], 'data-min' => (@ordering_data[:order_articles][order_article.id][:quantity] if @order.boxfill?), 'data-max' => (@ordering_data[:order_articles][order_article.id][:quantity]+@ordering_data[:order_articles][order_article.id][:missing_units] if @order.boxfill?)}/
|
||||
%span.used{id: "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||
+
|
||||
%span.unused{id: "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||
.btn-group
|
||||
%a.btn.btn-ordering{'data-increase_quantity' => order_article.id}
|
||||
%i.icon-plus
|
||||
%a.btn.btn-ordering{'data-decrease_quantity' => order_article.id}
|
||||
%i.icon-minus
|
||||
%td.quantity
|
||||
.outer{style: "diyplay: inline-block; float: left; width: 50px;"}
|
||||
%input{id: "q_#{order_article.id}", name: "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", type: "hidden", value: @ordering_data[:order_articles][order_article.id][:quantity], 'data-min' => (@ordering_data[:order_articles][order_article.id][:quantity] if @order.boxfill?), 'data-max' => (@ordering_data[:order_articles][order_article.id][:quantity]+@ordering_data[:order_articles][order_article.id][:missing_units] if @order.boxfill?)}/
|
||||
%span.used{id: "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||
+
|
||||
%span.unused{id: "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
|
||||
.btn-group
|
||||
%a.btn.btn-ordering{'data-decrease_quantity' => order_article.id}
|
||||
%i.icon-minus
|
||||
%a.btn.btn-ordering{'data-increase_quantity' => order_article.id}
|
||||