Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c0e632ef2 | ||
|
|
f94e005a91 | ||
|
|
15f89039b3 | ||
|
|
0d3a32a018 | ||
|
|
2641e70eaf | ||
|
|
0ebb698c54 | ||
|
|
3621289fee | ||
|
|
544db390ef | ||
|
|
f357d716b7 | ||
|
|
a49bee1a52 | ||
|
|
286bfd14ea | ||
|
|
068288ddd1 | ||
|
|
30d4c85250 | ||
|
|
6170e5f499 | ||
|
|
b1d56d85c0 | ||
|
|
3c76533541 | ||
|
|
076c03d6c6 | ||
|
|
4f1b4d90a6 | ||
|
|
10f916f262 | ||
|
|
744581bad9 | ||
|
|
b80fe490dc | ||
|
|
179e35a88b | ||
|
|
28b825db07 | ||
|
|
d8c72cf249 | ||
|
|
c4250cc201 | ||
|
|
f54f78b03e | ||
|
|
97a9c1c4e3 | ||
|
|
6ca6e89cd5 | ||
|
|
f5d09537b9 | ||
|
|
a5c34cc6a0 | ||
|
|
5c9fe38c4b | ||
|
|
feff65ab36 | ||
|
|
c8a354e868 | ||
|
|
ccd46e79fc | ||
|
|
6c6eec0b78 | ||
|
|
7662ce8771 | ||
|
|
8c8e9352d3 | ||
|
|
6e28c2a5db | ||
|
|
33d97a2f93 | ||
|
|
5f6c97d146 | ||
|
|
e9a7ccad4a | ||
|
|
93f3d362a4 | ||
|
|
1b84212da5 | ||
|
|
b646670848 | ||
|
|
9f43fded15 | ||
|
|
1537bcd54b | ||
|
|
31caa5e6b3 | ||
|
|
407405389d | ||
|
|
a2b9bf3e54 | ||
|
|
c3eb0a1a80 | ||
|
|
4c8941a829 |
+3
-1
@@ -1,8 +1,8 @@
|
||||
*.n
|
||||
*.php
|
||||
config.xml
|
||||
/package-lock.json
|
||||
www/plugin/*
|
||||
Makefile
|
||||
tmp/*
|
||||
*node_modules*
|
||||
*.map
|
||||
@@ -33,5 +33,7 @@ www/js/libs.js
|
||||
|
||||
www/css/.sass-cache
|
||||
www/css/*.css
|
||||
!www/css/bootstrap.min.css
|
||||
|
||||
|
||||
/package-lock.json
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1.7.1
|
||||
+14
-27
@@ -6,8 +6,11 @@ ENV?="dev"
|
||||
#To compile project with plugins, add PLUGINS=1 or type `export PLUGINS=1`
|
||||
|
||||
install:
|
||||
#copy config file from template
|
||||
cp config.xml.dist config.xml
|
||||
#copy config file from template first time only
|
||||
@if [ ! -f config.xml ]; then \
|
||||
cp config.xml.dist config.xml; \
|
||||
fi
|
||||
|
||||
@if [ $(ENV) = "dev" ]; then \
|
||||
make install_dev; \
|
||||
fi
|
||||
@@ -15,7 +18,7 @@ install:
|
||||
#setup dev environnement from source
|
||||
install_dev:
|
||||
#set config file to debug=1
|
||||
@sed -e 's?debug=.*?debug="1"?g' --in-place config.xml
|
||||
#@sed -e 's?debug=.*?debug="1"?g' --in-place config.xml
|
||||
#install haxe dependencies in .haxelib
|
||||
haxelib newrepo
|
||||
haxelib -always install cagette.hxml
|
||||
@@ -23,12 +26,6 @@ install_dev:
|
||||
#template tools
|
||||
haxelib run templo
|
||||
sudo mv temploc2 /usr/bin
|
||||
#extra plugins
|
||||
@if [ $(PLUGINS) = 1 ]; then \
|
||||
haxelib git cagette-pro git@bitbucket.org:bubar/cagette-pro.git; \
|
||||
haxelib git cagette-hosted git@bitbucket.org:bubar/cagette-hosted.git; \
|
||||
haxelib git cagette-wholesale-order git@github.com:bablukid/cagette-wholesale-order.git; \
|
||||
fi
|
||||
#install npm dependencies
|
||||
npm install
|
||||
npm run libs:dev
|
||||
@@ -37,6 +34,7 @@ install_dev:
|
||||
@make css
|
||||
@make compile
|
||||
@make frontend
|
||||
@make templates
|
||||
@echo "Well, it looks like everything is fine : librairies are installed, backend and frontend has been compiled !"
|
||||
|
||||
|
||||
@@ -46,7 +44,7 @@ compile:
|
||||
echo "compile Cagette.net with plugins"; \
|
||||
haxe cagetteAllPlugins.hxml; \
|
||||
else \
|
||||
echo "compile Cagette.net core"; \
|
||||
echo "compile CagettePéi core"; \
|
||||
haxe cagette.hxml; \
|
||||
fi
|
||||
|
||||
@@ -62,6 +60,8 @@ frontend:
|
||||
else \
|
||||
haxe cagetteJs.hxml; \
|
||||
fi
|
||||
mkdir -p tmp
|
||||
chown www-data:www-data tmp
|
||||
|
||||
#update POT file from source
|
||||
i18n:
|
||||
@@ -69,25 +69,12 @@ i18n:
|
||||
|
||||
#compile templates in each language, required for production env.
|
||||
templates:
|
||||
mkdir -p lang/master/tmp
|
||||
haxe cagette.hxml -D i18n_generation
|
||||
@make LANG=fr ctemplates
|
||||
@make LANG=en ctemplates
|
||||
@make LANG=de ctemplates
|
||||
msgfmt www/lang/texts_fr.po -o www/lang/texts_fr.mo
|
||||
chown www-data:www-data -R www
|
||||
|
||||
ctemplates:
|
||||
(cd lang/$(LANG)/tpl; temploc2 -macros macros.mtt -output ../tmp/ *.mtt */*.mtt */*/*.mtt */*/*/*.mtt */*/*/*/*.mtt)
|
||||
(cd lang/$(LANG)/tpl; temploc2 -macros macros.mtt -output ../tmp/ *.mtt */*.mtt */*/*.mtt)
|
||||
|
||||
#Compile and run unit tests
|
||||
tests:
|
||||
@if [ $(PLUGINS) = 1 ]; then \
|
||||
haxe testsPlugins.hxml; \
|
||||
else \
|
||||
haxe tests.hxml; \
|
||||
fi
|
||||
@docker-compose run --workdir="/var/www/www" neko neko tests.n mysql://root:root@mysql/tests
|
||||
|
||||
cp_plugin:
|
||||
cp -R .haxelib/cagette-hosted/git/tpl/* lang/master/tpl/plugin/hosted/
|
||||
cp -R .haxelib/cagette-pro/git/tpl/* lang/master/tpl/plugin/pro/
|
||||
cp -R .haxelib/cagette-wholesale-order/git/tpl/* lang/master/tpl/plugin/who/
|
||||
|
||||
@@ -1,17 +1,172 @@
|
||||
# Cagette.net
|
||||
Le logiciel libre des circuits courts.
|
||||
CAGETTE PEI
|
||||
===========
|
||||
|
||||
[](https://travis-ci.org/bablukid/cagette)
|
||||
Fourche du logiciel [Cagette.net](https://github.com/CagetteNet) à partir de la version 0.9.2 Novembre 2018
|
||||
|
||||
http://www.cagette.net
|
||||
Certaines portions du code source de Cagette.net n'étant plus disponibles en téléchargement,
|
||||
j'ai repris sur la base d'un existant pour adapter au marché local réunionnais et leurs AMAPéi.
|
||||
|
||||
Documentation : http://www.cagette.net/wiki
|
||||
## INSTALL FROM SCRATCH (debian-buster)
|
||||
|
||||
English :
|
||||
* apt install -y curl
|
||||
* curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
||||
* apt install -y nodejs=8.17.0-1nodesource1
|
||||
* apt install -y sudo haxe apache2 make git imagemagick gettext libapache2-mod-neko mariadb-server
|
||||
* mysql -u root <<EOF
|
||||
CREATE DATABASE cagettepei;
|
||||
GRANT ALL ON cagettepei.* TO 'cagettepei'@'%' IDENTIFIED BY 'cagettepei';
|
||||
EOF
|
||||
* cd /var/www
|
||||
* git clone https://git.artcode.re/cagetters/cagettepei.git
|
||||
* cd cagettepei
|
||||
* make install ENV=dev # first time
|
||||
* make compile # classes
|
||||
* make templates # templates + i18n
|
||||
* vim /etc/apache2/sites-available/cagettepei.conf
|
||||
```
|
||||
<VirtualHost *:80>
|
||||
ServerName cagettepei
|
||||
DirectoryIndex index.n
|
||||
DocumentRoot /var/www/cagettepei/www/
|
||||
</VirtualHost>
|
||||
```
|
||||
* sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
|
||||
* a2dissite 000-default.conf
|
||||
* a2ensite cagettepei.conf
|
||||
* a2enmod neko rewrite
|
||||
* systemctl restart apache2
|
||||
|
||||
Cagette.net is an open source web app to help people build a better and sustainable food system.
|
||||
Some people call it a "foodhub" : A mix between a groupware and a marketplace, helping consumers to order food from local farmers and producers.
|
||||
## CONFIGURATION
|
||||
|
||||
## Build & install
|
||||
* cd /var/www/cagettepei
|
||||
* vim config.xml
|
||||
```
|
||||
<config
|
||||
host="<DOMAIN.TLD>"
|
||||
key="<SECRET_PHRASE>"
|
||||
name = "CagettePéi"
|
||||
default_email = "<EMAIL>"
|
||||
webmaster_email = "<EMAIL>"
|
||||
database="mysql://cagettepei:cagettepei@localhost/cagettepei"
|
||||
|
||||
Read the Developer page on the wiki to know more about this : http://wiki.cagette.net/dev:index
|
||||
smtp_host="localhost"
|
||||
smtp_port="25"
|
||||
smtp_user=""
|
||||
smtp_pass=""
|
||||
|
||||
lang="fr"
|
||||
langs="fr"
|
||||
langnames="Français"
|
||||
maintain="0"
|
||||
debug="0"
|
||||
sqllog="0"
|
||||
cache="1"
|
||||
cachetpl="0"
|
||||
/>
|
||||
```
|
||||
|
||||
ADMIN RESET PASSWORD
|
||||
--------------------
|
||||
|
||||
go to http://localhost for ERROR + table regeneration, then
|
||||
|
||||
* cd /var/www/cagettepei
|
||||
* SECRET=$(grep key= config.xml | cut -d= -f2 | cut -d'"' -f2)
|
||||
* echo "insert into User values (1,'fr',MD5('${SECRET}cagettepei'),1,'Administrateur','Cagette Péi', 'admin', null, null, null, null, null, null, null, null, null, now(), now(),6,null, null)" | mysql -h localhost -u cagettepei -pcagettepei cagettepei
|
||||
|
||||
then, connect with admin / cagettepei
|
||||
|
||||
### change admin password
|
||||
|
||||
* echo "update User set pass=MD5('${SECRET}cagettepei') where id=1" | mysql -h localhost -u cagettepei -pcagettepei cagettepei
|
||||
|
||||
|
||||
SYSTEMD-TIMERS
|
||||
--------------
|
||||
|
||||
* vim /var/www/cagettepei-batch
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
minute);;
|
||||
daily);;
|
||||
*) echo "expected [minute|daily]" && exit 1;;
|
||||
esac
|
||||
|
||||
SELECTOR=$1
|
||||
|
||||
for i in /var/www/cagettepei-* ; do
|
||||
if [[ -d $i ]]; then
|
||||
cd $i/www
|
||||
echo "cron-$SELECTOR in: $i"
|
||||
neko index.n cron/$SELECTOR
|
||||
echo
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
* chmod +x /var/www/cagettepei-batch
|
||||
* vim /etc/systemd/system/cagettepei-batch-minute.service
|
||||
```
|
||||
[Unit]
|
||||
Description=Run batch cagettepei every minute
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
SyslogIdentifier=cagettepei
|
||||
ExecStart=/var/www/cagettepei-batch minute
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
* vim /etc/systemd/system/cagettepei-batch-day.service
|
||||
```
|
||||
[Unit]
|
||||
Description=Run batch cagettepei every day
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
SyslogIdentifier=cagettepei
|
||||
ExecStart=/var/www/cagettepei-batch daily
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
* vim /etc/systemd/system/cagettepei-batch-minute.timer
|
||||
```
|
||||
[Unit]
|
||||
Description=Timer for batch cagettepei every minute
|
||||
Requires=apache2.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar=minutely
|
||||
Unit=cagettepei-batch-minute.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
```
|
||||
|
||||
* vim /etc/systemd/system/cagettepei-batch-day.timer
|
||||
```
|
||||
[Unit]
|
||||
Description=Timer for batch cagettepei every day
|
||||
Requires=apache2.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
Unit=cagettepei-batch-day.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
```
|
||||
* systemctl daemon-reload
|
||||
* systemctl edit apache2 # bind the 2 timers to apache2 cagette
|
||||
```
|
||||
[Unit]
|
||||
BindsTo = cagettepei-batch-minute.timer cagettepei-batch-day.timer
|
||||
```
|
||||
* systemctl enable cagettepei-batch-minute.timer cagettepei-batch-day.timer
|
||||
* systemctl start cagettepei-batch-minute.timer cagettepei-batch-day.timer
|
||||
+24
-7
@@ -1,16 +1,33 @@
|
||||
-lib templo:3.0.0
|
||||
-lib hxevents:0.4.0
|
||||
-lib thx.semver:0.2.2
|
||||
-lib thx.csv:0.2.0
|
||||
# LOCKED LIBS
|
||||
-lib asys:0.3.0
|
||||
-lib datetime:3.1.1
|
||||
-lib history:0.0.1
|
||||
-lib hscript:2.3.0
|
||||
-lib hxevents:0.4.0
|
||||
-lib mime:0.1.2
|
||||
-lib modular:0.10.15
|
||||
-lib smtpmailer:0.4.0
|
||||
-lib templo:3.0.0
|
||||
-lib thx.core:0.43.0
|
||||
-lib thx.csv:0.2.0
|
||||
-lib thx.semver:0.2.2
|
||||
-lib tink_await:0.6.0
|
||||
-lib tink_chunk:0.3.1
|
||||
-lib tink_core:1.18.0
|
||||
-lib tink_io:0.5.0
|
||||
-lib tink_json:0.9.0
|
||||
-lib tink_macro:0.21.1
|
||||
-lib tink_priority:0.1.4
|
||||
-lib tink_streams:0.2.1
|
||||
-lib tink_syntaxhub:0.4.3
|
||||
-lib tink_typecrawler:0.7.0
|
||||
|
||||
-lib sugoi:git:git@artcode.re:cagetters/sugoi.git
|
||||
-lib record-macros:git:git@artcode.re:cagetters/record-macros.git
|
||||
-lib dbadmin:git:git@artcode.re:cagetters/dbadmin.git
|
||||
## GIT
|
||||
-lib sugoi:git:https://git.artcode.re/cagetters/sugoi.git
|
||||
-lib record-macros:git:https://git.artcode.re/cagetters/record-macros.git
|
||||
-lib dbadmin:git:https://git.artcode.re/cagetters/dbadmin.git
|
||||
|
||||
## SCRIPT
|
||||
-cp common
|
||||
-cp src
|
||||
-cp lang/master/tpl
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
-lib templo
|
||||
-lib hxevents
|
||||
-lib thx.semver
|
||||
-lib thx.csv
|
||||
-lib datetime
|
||||
-lib hscript
|
||||
-lib smtpmailer
|
||||
-lib tink_json
|
||||
|
||||
-lib sugoi:git:https://github.com/bablukid/sugoi#master
|
||||
-lib record-macros:git:https://github.com/HaxeFoundation/record-macros#master
|
||||
-lib dbadmin:git:https://github.com/ncannasse/dbadmin.git#master
|
||||
|
||||
-lib cagette-pro:git:https://bubar@bitbucket.org/bubar/cagette-pro.git#master
|
||||
-lib cagette-hosted:git:https://bubar@bitbucket.org/bubar/cagette-hosted.git#master
|
||||
-lib cagette-wholesale-order:git:https://github.com/bablukid/cagette-wholesale-order.git#master
|
||||
|
||||
-cp common
|
||||
-cp src
|
||||
-cp lang/master/tpl
|
||||
|
||||
-D plugins
|
||||
|
||||
|
||||
-neko www/index.n
|
||||
-main App
|
||||
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project version="2">
|
||||
<!-- Output SWF options -->
|
||||
<output>
|
||||
<movie outputType="Application" />
|
||||
<movie input="" />
|
||||
<movie path="www\index.n" />
|
||||
<movie fps="30" />
|
||||
<movie width="800" />
|
||||
<movie height="600" />
|
||||
<movie version="0" />
|
||||
<movie minorVersion="0" />
|
||||
<movie platform="Neko" />
|
||||
<movie background="#FFFFFF" />
|
||||
</output>
|
||||
<!-- Other classes to be compiled into your SWF -->
|
||||
<classpaths>
|
||||
<class path="common" />
|
||||
<class path="src" />
|
||||
<class path="lang\master\tpl" />
|
||||
</classpaths>
|
||||
<!-- Build options -->
|
||||
<build>
|
||||
<option directives="plugins" />
|
||||
<option flashStrict="False" />
|
||||
<option noInlineOnDebug="False" />
|
||||
<option mainClass="App" />
|
||||
<option enabledebug="False" />
|
||||
<option additional="" />
|
||||
</build>
|
||||
<!-- haxelib libraries -->
|
||||
<haxelib>
|
||||
<library name="templo" />
|
||||
<library name="thx.semver" />
|
||||
<library name="thx.csv" />
|
||||
<library name="hxevents" />
|
||||
<library name="hscript" />
|
||||
<library name="record-macros" />
|
||||
<library name="smtpmailer" />
|
||||
<library name="datetime" />
|
||||
<library name="sugoi:git:https://github.com/bablukid/sugoi#i18n" />
|
||||
<library name="record-macros:git:https://github.com/HaxeFoundation/record-macros#maste" />
|
||||
<library name="dbadmin:git:https://github.com/ncannasse/dbadmin.git#master" />
|
||||
<library name="cagette-pro:git:https://bubar@bitbucket.org/bubar/cagette-pro.git#master" />
|
||||
<library name="cagette-connector:git:https://bubar@bitbucket.org/bubar/cagette-connector.git#master" />
|
||||
<library name="cagette-wholesale-order:git:https://bubar@bitbucket.org/bubar/cagette-wholesale-order.git#master" />
|
||||
<library name="cagette-hosted:git:https://bubar@bitbucket.org/bubar/cagette-hosted.git#master" />
|
||||
</haxelib>
|
||||
<!-- Class files to compile (other referenced classes will automatically be included) -->
|
||||
<compileTargets>
|
||||
<!-- example: <compile path="..." /> -->
|
||||
</compileTargets>
|
||||
<!-- Paths to exclude from the Project Explorer tree -->
|
||||
<hiddenPaths>
|
||||
<hidden path="project.hxml" />
|
||||
<hidden path="lang\fr\tmp" />
|
||||
<hidden path="preLaunch" />
|
||||
<hidden path="art" />
|
||||
<hidden path="www\file" />
|
||||
<hidden path="config.tpl.xml" />
|
||||
<hidden path="clearFileCache.bat" />
|
||||
<hidden path="obj" />
|
||||
</hiddenPaths>
|
||||
<!-- Executed before build -->
|
||||
<preBuildCommand />
|
||||
<!-- Executed after build -->
|
||||
<postBuildCommand alwaysRun="False" />
|
||||
<!-- Other project options -->
|
||||
<options>
|
||||
<option showHiddenPaths="True" />
|
||||
<option testMovie="Custom" />
|
||||
<option testMovieCommand="" />
|
||||
</options>
|
||||
<!-- Plugin storage -->
|
||||
<storage />
|
||||
</project>
|
||||
@@ -1,17 +0,0 @@
|
||||
-dce no
|
||||
-cp common
|
||||
-cp js
|
||||
-lib sugoi:git:https://github.com/bablukid/sugoi#i18n
|
||||
-lib hxleaflet:git:https://github.com/bablukid/hxleaflet
|
||||
-lib cagette-hosted
|
||||
-lib react
|
||||
-lib react-router-4
|
||||
-lib modular
|
||||
-lib tink_json
|
||||
|
||||
-D plugins
|
||||
-D no-deprecation-warnings
|
||||
|
||||
-main App
|
||||
-js www/js/app.js
|
||||
|
||||
+7
-2
@@ -1,12 +1,17 @@
|
||||
-dce no
|
||||
-cp common
|
||||
-cp js
|
||||
-lib sugoi:git:git@artcode.re:cagetters/sugoi.git
|
||||
-lib hxleaflet:git:git@artcode.re:cagetters/hxleaflet.git
|
||||
-lib sugoi:git:https://git.artcode.re/cagetters/sugoi.git
|
||||
-lib hxleaflet:git:https://git.artcode.re/cagetters/hxleaflet.git
|
||||
-lib react:1.4.0
|
||||
-lib react-router-4:0.2.3
|
||||
-lib modular:0.10.15
|
||||
-lib tink_json:0.9.0
|
||||
-lib tink_core:1.18.0
|
||||
-lib tink_io:0.5.0
|
||||
-lib tink_streams:0.2.1
|
||||
-lib thx.core:0.43.0
|
||||
-lib asys:0.3.0
|
||||
-main App
|
||||
-debug
|
||||
-js www/js/app.js
|
||||
|
||||
+14
-24
@@ -1,29 +1,19 @@
|
||||
<config
|
||||
|
||||
database = "mysql://<USER>:<PASSWORD>@<HOST>/<DBNAME>"
|
||||
host = "<URL without http>"
|
||||
name = "<HTML head title>"
|
||||
default_email = "<EMAIL>"
|
||||
webmaster_email = "<EMAIL>"
|
||||
key = "<SECRET_PHRASE>"
|
||||
|
||||
maintain="0"
|
||||
cache="1"
|
||||
cachetpl="0"
|
||||
debug="0"
|
||||
sqllog="0"
|
||||
|
||||
lang="fr"
|
||||
langs="fr"
|
||||
langnames="Français"
|
||||
|
||||
host="www.amapeisudreunion.com"
|
||||
name = "AMAPEI Sud Réunion"
|
||||
default_email = "admin@amapeisudreunion.com"
|
||||
webmaster_email = "postmaster@amapeisudreunion.com"
|
||||
|
||||
database="mysql://cagette:cagette@ct1/cagette"
|
||||
sqllog="0"
|
||||
|
||||
debug="0"
|
||||
cache="1"
|
||||
maintain="0"
|
||||
cachetpl="0"
|
||||
key="carotteMagique"
|
||||
|
||||
smtp_host="localhost"
|
||||
smtp_port="25"
|
||||
smtp_user=""
|
||||
smtp_pass=""
|
||||
|
||||
mt.net.form.Form.HTML5 = "1"
|
||||
mt.net.form.Form.USE_TWITTER_BOOTSTRAP = "1"
|
||||
|
||||
google_geocoding_key="googlekey"
|
||||
/>
|
||||
|
||||
+9
-3
@@ -164,7 +164,13 @@ class ShopCart
|
||||
var groups = new Map<Int,{name:String,products:Array<ProductInfo>}>();
|
||||
var pinned = new Map<Int,{name:String,products:Array<ProductInfo>}>();
|
||||
|
||||
var firstCategGroup = this.categories[0].categs;
|
||||
|
||||
trace(this.categories);
|
||||
var firstCategGroup = null;
|
||||
if (this.categories.length > 0){
|
||||
firstCategGroup = this.categories[0].categs;
|
||||
}
|
||||
|
||||
|
||||
//trace(firstCategGroup);
|
||||
//trace(pinnedCategories);
|
||||
@@ -181,7 +187,7 @@ class ShopCart
|
||||
|
||||
for ( categ in p.categories){
|
||||
|
||||
if (Lambda.find(firstCategGroup, function(c) return c.id == categ) != null){
|
||||
if (firstCategGroup != null && Lambda.find(firstCategGroup, function(c) return c.id == categ) != null){
|
||||
|
||||
//is in this category group
|
||||
var g = groups.get(categ);
|
||||
@@ -442,4 +448,4 @@ class ShopCart
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
This is where the compiled templates are.
|
||||
@@ -1 +0,0 @@
|
||||
This is where the compiled templates are.
|
||||
@@ -1 +0,0 @@
|
||||
This is where the compiled templates are.
|
||||
@@ -112,17 +112,6 @@
|
||||
|
||||
})
|
||||
|
||||
//tracking 24x7
|
||||
var rumMOKey='1d36c37d438ba069db210c73cb74308d';
|
||||
(function(){
|
||||
if(window.performance && window.performance.timing && window.performance.navigation) {
|
||||
var site24x7_rum_beacon=document.createElement('script');
|
||||
site24x7_rum_beacon.async=true;
|
||||
site24x7_rum_beacon.setAttribute('src','//static.site24x7rum.com/beacon/site24x7rum-min.js?appKey='+rumMOKey);
|
||||
document.getElementsByTagName('head')[0].appendChild(site24x7_rum_beacon);
|
||||
}
|
||||
})(window)
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<h1>::groupName::</h1>
|
||||
::else::
|
||||
<div style="margin-bottom:22px;" >
|
||||
<a href="http://www.cagette.net" target="_blank">
|
||||
<a href="https://git.artcode.re/cagetters/cagette" target="_blank">
|
||||
<img src="/img/logo3.png" alt="::NAME::" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -130,7 +130,7 @@
|
||||
<div class="row" id="footer">
|
||||
|
||||
<div class="col-md-9" >
|
||||
<a href="http://www.cagette.net" target="_blank">
|
||||
<a href="https://git.artcode.re/cagetters/cagette" target="_blank">
|
||||
<img src="/img/logo.png" alt="::_("Cagette.net")::"/>
|
||||
</a>
|
||||
</div>
|
||||
@@ -142,13 +142,11 @@
|
||||
<a href="http://www.cagette.net/wiki" target="_blank">::_("Documentation")::</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.cagette.pro" target="_blank">Formations pour producteurs</a>
|
||||
<a href="https://pad1.zourit.net/p/4a3b09afd25b4fdcb3f0a9598db21e61" target="_blank">Proposer une amélioration</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
::if (user!=null && user.isAmapManager()):: <a href="https://cagette.uservoice.com" target="_blank">::_("Propose features")::</a> ::end::
|
||||
<a href="https://pad1.zourit.net/p/4a3b09afd25b4fdcb3f0a9598db21e61" target="_blank">Soumettre une anomalie</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<!--<p style="position: absolute;display: block;top: 96px;width: 700px;">
|
||||
@@ -201,7 +199,7 @@
|
||||
<!--
|
||||
::raw _("Cagette.net is made by <a href='https://www.alilo.fr' target='_blank'><img src='/img/alilo-trans-black.png' /></a>")::<br/>
|
||||
-->
|
||||
<span>version ::VERSION::-::getPlatform()::</span>
|
||||
<span>version ::VERSION::</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
@@ -17,11 +17,11 @@ table.table td{
|
||||
<hr/>
|
||||
|
||||
<div style="color:#666;font-size:12px;">
|
||||
::_("This e-mail was sent from"):: <a href="http://::HOST::">::_("Cagette.net")::</a>.
|
||||
> ::_("This e-mail was sent from"):: <a href="http://::raw HOST::">::_("Cagette.net")::</a>.
|
||||
|
||||
::if group!=null::
|
||||
<br/>
|
||||
::_("You receive this message because you are part of"):: <b>::group.name::</b>
|
||||
::_("You receive this message because you are part of"):: <b>::_("Cagette.net")::</b>
|
||||
::end::
|
||||
|
||||
::if list!=null::
|
||||
@@ -32,9 +32,9 @@ table.table td{
|
||||
::if group!=null::
|
||||
<div style="width:50%;max-width:300px;margin: 12px auto;padding: 8px;text-decoration: none;background: #070;border-radius: 3px;text-align: center;">
|
||||
<a href="http://::HOST::/group/::group.id::" style="color: white;font-weight: bold;text-decoration: none;font-size:1.2em;">
|
||||
→ ::group.name::
|
||||
→ ::_("Cagette.net")::
|
||||
</a>
|
||||
</div>
|
||||
::end::
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div style="max-width:400px;margin:auto;border:solid 1px #AAA;border-radius:8px;padding:12px;text-align:center;font-family:Arial;">
|
||||
|
||||
<img src="http://::HOST::/img/logo2.png" title="Cagette.net" />
|
||||
<img src="http://::HOST::/img/logo2.png" title="CagettePéi" />
|
||||
|
||||
<p>
|
||||
::_("Hello"):: $$nullSafe(::name::),
|
||||
@@ -42,4 +42,4 @@
|
||||
</div>
|
||||
|
||||
|
||||
::end::
|
||||
::end::
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
|
||||
|
||||
::end::
|
||||
::end::
|
||||
|
||||
Generated
+3
-2
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "Cagette.net",
|
||||
"requires": true,
|
||||
"name": "CagettePei",
|
||||
"version": "1.6.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/react": {
|
||||
"version": "16.0.0",
|
||||
|
||||
+4
-5
@@ -1,9 +1,7 @@
|
||||
{
|
||||
"name": "Cagette.net",
|
||||
"name": "CagettePei",
|
||||
"description": "le logiciel libre du circuit court",
|
||||
"author": "François Barbut <francois@alilo.fr>",
|
||||
"license": "GPL-2.0",
|
||||
"homepage": "http://www.cagette.net",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"bootstrap": "^3.3.4",
|
||||
"eonasdan-bootstrap-datetimepicker": "^4.7.14",
|
||||
@@ -48,5 +46,6 @@
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/bablukid/cagette/issues"
|
||||
}
|
||||
},
|
||||
"version": "1.7.1"
|
||||
}
|
||||
|
||||
+2
-1
@@ -16,7 +16,8 @@ class App extends sugoi.BaseApp {
|
||||
* @doc https://github.com/fponticelli/thx.semver
|
||||
*/
|
||||
//public static var VERSION = ([0,9,2] : Version).withPre("july");
|
||||
public static var VERSION = ([0,9,2] : Version).withPre(MyMacros.getGitShortSHA(), MyMacros.getGitCommitDate());
|
||||
//public static var VERSION = ([0,9,2] : Version).withPre(MyMacros.getGitShortSHA(), MyMacros.getGitCommitDate());
|
||||
public static var VERSION = "cagette-péi " + MyMacros.getGitCommitDate();
|
||||
|
||||
public function new(){
|
||||
super();
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ class MyMacros {
|
||||
commitDate = StringTools.replace(commitDate, " ", ".");
|
||||
commitDate = StringTools.replace(commitDate, "-", ".");
|
||||
commitDate = StringTools.replace(commitDate, ":", ".");
|
||||
commitDate = commitDate.substr(0,16);
|
||||
//commitDate = commitDate.substr(0,16);
|
||||
commitDate = commitDate.substr(0,10);
|
||||
|
||||
// Generates a string expression
|
||||
return macro $v{commitDate};
|
||||
|
||||
@@ -86,6 +86,17 @@ class Distribution extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getUser(uid:Int):db.User {
|
||||
return db.User.manager.get(uid, false);
|
||||
}
|
||||
|
||||
function getBasket(userId, placeId, date){
|
||||
var user = getUser(userId);
|
||||
var place = db.Place.manager.get(placeId, false);
|
||||
return db.Basket.getOrCreate(user, place, date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attendance sheet to print ( mutidistrib )
|
||||
@@ -174,18 +185,25 @@ class Distribution extends Controller
|
||||
var data = new Array<Dynamic>();
|
||||
|
||||
for (o in orders3) {
|
||||
|
||||
|
||||
var basket = getBasket(o.userId,view.place.id,view.date);
|
||||
|
||||
data.push( {
|
||||
"name":o.userName,
|
||||
"productName":o.productName,
|
||||
"price":view.formatNum(o.productPrice),
|
||||
"quantity":o.quantity,
|
||||
"fees":view.formatNum(o.fees),
|
||||
"total":view.formatNum(o.total),
|
||||
"paid":o.paid
|
||||
"NUM": basket.num,
|
||||
"ADHERENT":o.userName,
|
||||
"PRODUIT":o.productName,
|
||||
"QTÉ":o.quantity,
|
||||
// "price":view.formatNum(o.productPrice),
|
||||
// "fees":view.formatNum(o.fees),
|
||||
// "total":view.formatNum(o.total),
|
||||
// "paid":o.paid
|
||||
});
|
||||
}
|
||||
|
||||
sugoi.tools.Csv.printCsvDataFromObjects(data, ["name", "productName", "price", "quantity","fees","total", "paid"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette");
|
||||
sugoi.tools.Csv.printCsvDataFromObjects(data, ["NUM","ADHERENT", "PRODUIT", "QTÉ"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette");
|
||||
//sugoi.tools.Csv.printCsvDataFromObjects(data, ["NUM","ADHERENT", "PRODUIT", "QTÉ","price","fees","total","paid"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette");
|
||||
//sugoi.tools.Csv.printCsvDataFromObjects(data, ["NUM","ADHERENT", "PRODUIT", "price", "quantity","fees","total", "paid"],"Export-commandes-"+date.toString().substr(0,10)+"-Cagette");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,299 +0,0 @@
|
||||
package test;
|
||||
|
||||
/**
|
||||
* Test distribution creation
|
||||
*
|
||||
* @author web-wizard
|
||||
*/
|
||||
class TestDistributions extends haxe.unit.TestCase
|
||||
{
|
||||
|
||||
public function new(){
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
override function setup(){
|
||||
TestSuite.initDB();
|
||||
TestSuite.initDatas();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that we can add a distribution outside existing time range for a specific contract and place
|
||||
* Check that we can't add a distribution overlapping with existing distribution for a specific contract and place
|
||||
*/
|
||||
function testOverlapping() {
|
||||
var existingDistrib = TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE;
|
||||
var e1 = null;
|
||||
try {
|
||||
var distrib1 = service.DistributionService.create(existingDistrib.contract,new Date(2018, 5, 1, 18, 0, 0),new Date(2018, 5, 1, 18, 30, 0),
|
||||
existingDistrib.place.id,null,null,null,null,new Date(2018, 4, 1, 18, 0, 0),new Date(2018, 4, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error) {
|
||||
e1 = x;
|
||||
}
|
||||
assertEquals(e1, null);
|
||||
|
||||
//existingDistrib.date <= distrib2.date && existingDistrib.end >= distrib2.date
|
||||
var e2 = null;
|
||||
try {
|
||||
var distrib2 = service.DistributionService.create(existingDistrib.contract,new Date(2017, 5, 1, 19, 30, 0),new Date(2017, 5, 1, 20, 30, 0),
|
||||
existingDistrib.place.id,null,null,null,null,new Date(2017, 4, 1, 18, 0, 0),new Date(2017, 4, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error) {
|
||||
e2 = x;
|
||||
}
|
||||
assertEquals(e2.message, "There is already a distribution at this place overlapping with the time range you've selected.");
|
||||
|
||||
//existingDistrib.date <= distrib3.end && existingDistrib.end >= distrib3.end
|
||||
var e3 = null;
|
||||
try{
|
||||
var distrib3 = service.DistributionService.create(existingDistrib.contract,new Date(2017, 5, 1, 17, 30, 0),new Date(2017, 5, 1, 19, 30, 0),
|
||||
existingDistrib.place.id,null,null,null,null,new Date(2017, 4, 1, 18, 0, 0),new Date(2017, 4, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e3 = x;
|
||||
}
|
||||
assertEquals(e3.message, "There is already a distribution at this place overlapping with the time range you've selected.");
|
||||
|
||||
//existingDistrib.date >= distrib4.date && existingDistrib.end <= distrib4.end
|
||||
var e4 = null;
|
||||
try{
|
||||
var distrib4 = service.DistributionService.create(existingDistrib.contract,new Date(2017, 5, 1, 17, 30, 0),new Date(2017, 5, 1, 21, 30, 0),
|
||||
existingDistrib.place.id,null,null,null,null,new Date(2017, 4, 1, 18, 0, 0),new Date(2017, 4, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e4 = x;
|
||||
}
|
||||
assertEquals(e4.message, "There is already a distribution at this place overlapping with the time range you've selected.");
|
||||
|
||||
//existingDistrib.date > distrib5.end
|
||||
var e5 = null;
|
||||
try{
|
||||
var distrib5 = service.DistributionService.create(existingDistrib.contract,new Date(2017, 5, 1, 17, 30, 0),new Date(2017, 5, 1, 18, 59, 0),
|
||||
existingDistrib.place.id,null,null,null,null,new Date(2017, 4, 1, 18, 0, 0),new Date(2017, 4, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e5 = x;
|
||||
}
|
||||
assertEquals(e5, null);
|
||||
|
||||
//existingDistrib.date > distrib6.end
|
||||
var e6 = null;
|
||||
try{
|
||||
var distrib6 = service.DistributionService.create(existingDistrib.contract,new Date(2017, 3, 1, 17, 30, 0),new Date(2017, 3, 1, 18, 59, 0),
|
||||
existingDistrib.place.id,null,null,null,null,new Date(2017, 2, 1, 18, 0, 0),new Date(2017, 3, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e6 = x;
|
||||
}
|
||||
assertEquals(e6.message, "The distribution start date must be set after the orders end date.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that we can add a distribution outside existing time range for a specific contract and place
|
||||
* Check that we can't add a distribution overlapping with existing distribution for a specific contract and place
|
||||
*/
|
||||
function testEdit() {
|
||||
|
||||
//TO DO
|
||||
assertEquals(true, true);
|
||||
}
|
||||
|
||||
function testCreateCycle() {
|
||||
TestSuite.CONTRAT_LEGUMES.startDate = new Date(2018, 0, 1, 0, 0, 0);
|
||||
TestSuite.CONTRAT_LEGUMES.endDate = new Date(2019, 11, 31, 23, 59, 0);
|
||||
TestSuite.CONTRAT_LEGUMES.update();
|
||||
|
||||
var weeklyDistribCycle = service.DistributionService.createCycle(TestSuite.CONTRAT_LEGUMES,Weekly,new Date(2018, 11, 24, 0, 0, 0),
|
||||
new Date(2019, 0, 24, 0, 0, 0),new Date(2018, 5, 4, 13, 0, 0),new Date(2018, 5, 4, 14, 0, 0),10,2,
|
||||
new Date(2018, 5, 4, 8, 0, 0),new Date(2018, 5, 4, 23, 0, 0),TestSuite.PLACE_DU_VILLAGE.id);
|
||||
|
||||
var weeklyDistribs = Lambda.array(db.Distribution.manager.search($distributionCycle == weeklyDistribCycle, false));
|
||||
assertEquals(weeklyDistribs.length, 5);
|
||||
assertEquals(weeklyDistribs[0].date.toString(), new Date(2018, 11, 24, 13, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[0].end.toString(), new Date(2018, 11, 24, 14, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[1].date.toString(), new Date(2018, 11, 31, 13, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[1].end.toString(), new Date(2018, 11, 31, 14, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[2].date.toString(), new Date(2019, 0, 7, 13, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[2].end.toString(), new Date(2019, 0, 7, 14, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[3].date.toString(), new Date(2019, 0, 14, 13, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[3].end.toString(), new Date(2019, 0, 14, 14, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[4].date.toString(), new Date(2019, 0, 21, 13, 0, 0).toString());
|
||||
assertEquals(weeklyDistribs[4].end.toString(), new Date(2019, 0, 21, 14, 0, 0).toString());
|
||||
service.DistributionService.deleteCycleDistribs(weeklyDistribCycle);
|
||||
|
||||
var monthlyDistribCycle = service.DistributionService.createCycle(TestSuite.CONTRAT_LEGUMES,Monthly,new Date(2018, 9, 30, 0, 0, 0),
|
||||
new Date(2019, 2, 31, 0, 0, 0),new Date(2018, 5, 4, 13, 0, 0),new Date(2018, 5, 4, 14, 0, 0),10,2,
|
||||
new Date(2018, 5, 4, 8, 0, 0),new Date(2018, 5, 4, 23, 0, 0),TestSuite.PLACE_DU_VILLAGE.id);
|
||||
|
||||
var monthlyDistribs = Lambda.array(db.Distribution.manager.search($distributionCycle == monthlyDistribCycle, false));
|
||||
assertEquals(monthlyDistribs.length, 6);
|
||||
assertEquals(monthlyDistribs[0].date.toString(), new Date(2018, 9, 30, 13, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[0].end.toString(), new Date(2018, 9, 30, 14, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[1].date.toString(), new Date(2018, 10, 27, 13, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[1].end.toString(), new Date(2018, 10, 27, 14, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[2].date.toString(), new Date(2018, 11, 25, 13, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[2].end.toString(), new Date(2018, 11, 25, 14, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[3].date.toString(), new Date(2019, 0, 29, 13, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[3].end.toString(), new Date(2019, 0, 29, 14, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[4].date.toString(), new Date(2019, 1, 26, 13, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[4].end.toString(), new Date(2019, 1, 26, 14, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[5].date.toString(), new Date(2019, 2, 26, 13, 0, 0).toString());
|
||||
assertEquals(monthlyDistribs[5].end.toString(), new Date(2019, 2, 26, 14, 0, 0).toString());
|
||||
service.DistributionService.deleteCycleDistribs(monthlyDistribCycle);
|
||||
|
||||
var biweeklyDistribCycle = service.DistributionService.createCycle(TestSuite.CONTRAT_LEGUMES,BiWeekly,new Date(2018, 9, 30, 0, 0, 0),
|
||||
new Date(2019, 0, 31, 0, 0, 0),new Date(2018, 5, 4, 13, 0, 0),new Date(2018, 5, 4, 14, 0, 0),10,2,
|
||||
new Date(2018, 5, 4, 8, 0, 0),new Date(2018, 5, 4, 23, 0, 0),TestSuite.PLACE_DU_VILLAGE.id);
|
||||
|
||||
var biweeklyDistribs = Lambda.array(db.Distribution.manager.search($distributionCycle == biweeklyDistribCycle, false));
|
||||
assertEquals(biweeklyDistribs.length, 7);
|
||||
assertEquals(biweeklyDistribs[0].date.toString(), new Date(2018, 9, 30, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[0].end.toString(), new Date(2018, 9, 30, 14, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[1].date.toString(), new Date(2018, 10, 13, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[1].end.toString(), new Date(2018, 10, 13, 14, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[2].date.toString(), new Date(2018, 10, 27, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[2].end.toString(), new Date(2018, 10, 27, 14, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[3].date.toString(), new Date(2018, 11, 11, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[3].end.toString(), new Date(2018, 11, 11, 14, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[4].date.toString(), new Date(2018, 11, 25, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[4].end.toString(), new Date(2018, 11, 25, 14, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[5].date.toString(), new Date(2019, 0, 8, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[5].end.toString(), new Date(2019, 0, 8, 14, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[6].date.toString(), new Date(2019, 0, 22, 13, 0, 0).toString());
|
||||
assertEquals(biweeklyDistribs[6].end.toString(), new Date(2019, 0, 22, 14, 0, 0).toString());
|
||||
service.DistributionService.deleteCycleDistribs(biweeklyDistribCycle);
|
||||
|
||||
var triweeklyDistribCycle = service.DistributionService.createCycle(TestSuite.CONTRAT_LEGUMES,TriWeekly,new Date(2018, 9, 30, 0, 0, 0),
|
||||
new Date(2019, 0, 31, 0, 0, 0),new Date(2018, 5, 4, 13, 0, 0),new Date(2018, 5, 4, 14, 0, 0),10,2,
|
||||
new Date(2018, 5, 4, 8, 0, 0),new Date(2018, 5, 4, 23, 0, 0),TestSuite.PLACE_DU_VILLAGE.id);
|
||||
|
||||
var triweeklyDistribs = Lambda.array(db.Distribution.manager.search($distributionCycle == triweeklyDistribCycle, false));
|
||||
assertEquals(triweeklyDistribs.length, 5);
|
||||
assertEquals(triweeklyDistribs[0].date.toString(), new Date(2018, 9, 30, 13, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[0].end.toString(), new Date(2018, 9, 30, 14, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[1].date.toString(), new Date(2018, 10, 20, 13, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[1].end.toString(), new Date(2018, 10, 20, 14, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[2].date.toString(), new Date(2018, 11, 11, 13, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[2].end.toString(), new Date(2018, 11, 11, 14, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[3].date.toString(), new Date(2019, 0, 1, 13, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[3].end.toString(), new Date(2019, 0, 1, 14, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[4].date.toString(), new Date(2019, 0, 22, 13, 0, 0).toString());
|
||||
assertEquals(triweeklyDistribs[4].end.toString(), new Date(2019, 0, 22, 14, 0, 0).toString());
|
||||
service.DistributionService.deleteCycleDistribs(triweeklyDistribCycle);
|
||||
}
|
||||
|
||||
function testDelete() {
|
||||
//A variable contract with a distribution that has orders
|
||||
var ordersDistrib = TestSuite.DISTRIB_LEGUMES_RUE_SAUCISSE;
|
||||
var ordersDistribId = ordersDistrib.id;
|
||||
var chicken = TestSuite.CHICKEN;
|
||||
var order = service.OrderService.make(TestSuite.FRANCOIS, 1, chicken, ordersDistrib.id);
|
||||
|
||||
var e = null;
|
||||
try{
|
||||
service.DistributionService.delete(ordersDistrib);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e = x;
|
||||
}
|
||||
assertEquals(e.message, "Deletion non possible: some orders are saved for this delivery.");
|
||||
assertTrue(db.Distribution.manager.get(ordersDistribId) != null);
|
||||
|
||||
//A variable contract with a distribution that has no orders
|
||||
var noOrdersDistrib = TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE;
|
||||
var noOrdersDistribId = noOrdersDistrib.id;
|
||||
|
||||
var e = null;
|
||||
try{
|
||||
service.DistributionService.delete(noOrdersDistrib);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e = x;
|
||||
}
|
||||
assertEquals(e, null);
|
||||
assertEquals(db.Distribution.manager.get(noOrdersDistribId), null);
|
||||
|
||||
//An Amap contract with a distribution that has orders
|
||||
var amapDistrib = TestSuite.DISTRIB_CONTRAT_AMAP;
|
||||
var amapDistribId = amapDistrib.id;
|
||||
var panier = TestSuite.PANIER_AMAP_LEGUMES;
|
||||
var amapOrder = service.OrderService.make(TestSuite.FRANCOIS, 1, panier, amapDistrib.id);
|
||||
|
||||
var e = null;
|
||||
try{
|
||||
service.DistributionService.delete(amapDistrib);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e = x;
|
||||
}
|
||||
assertEquals(e, null);
|
||||
assertEquals(db.Distribution.manager.get(amapDistribId), null);
|
||||
|
||||
}
|
||||
|
||||
function testUpdateAmapContractOperations(){
|
||||
|
||||
var t = sugoi.i18n.Locale.texts;
|
||||
|
||||
//Take an amap contract with payments enabled
|
||||
//Take 2 users and make orders for each
|
||||
var amapDistrib = TestSuite.DISTRIB_CONTRAT_AMAP;
|
||||
var contract = amapDistrib.contract;
|
||||
var panier = TestSuite.PANIER_AMAP_LEGUMES;
|
||||
var francoisOrder = service.OrderService.make(TestSuite.FRANCOIS, 1, panier, amapDistrib.id);
|
||||
db.Operation.onOrderConfirm([francoisOrder]);
|
||||
var sebOrder = service.OrderService.make(TestSuite.SEB, 3, panier, amapDistrib.id);
|
||||
db.Operation.onOrderConfirm([sebOrder]);
|
||||
|
||||
//Check initial operation names and amounts
|
||||
var francoisOperation = db.Operation.findCOrderTransactionFor(contract, TestSuite.FRANCOIS);
|
||||
assertEquals(francoisOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 1 deliveries");
|
||||
assertEquals(francoisOperation.amount, -13);
|
||||
var sebOperation = db.Operation.findCOrderTransactionFor(contract, TestSuite.SEB);
|
||||
assertEquals(sebOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 1 deliveries");
|
||||
assertEquals(sebOperation.amount, -39);
|
||||
|
||||
//Add a distrib
|
||||
var distrib = null;
|
||||
var e = null;
|
||||
try{
|
||||
distrib = service.DistributionService.create(contract,new Date(2018, 5, 1, 18, 0, 0),new Date(2018, 5, 1, 18, 30, 0),
|
||||
amapDistrib.place.id,null,null,null,null,new Date(2018, 4, 1, 18, 0, 0),new Date(2018, 4, 30, 18, 30, 0));
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e = x;
|
||||
}
|
||||
//Check names and amounts are modified accordingly
|
||||
assertEquals(francoisOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 2 deliveries");
|
||||
assertEquals(francoisOperation.amount, -26);
|
||||
var sebOperation = db.Operation.findCOrderTransactionFor(contract, TestSuite.SEB);
|
||||
assertEquals(sebOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 2 deliveries");
|
||||
assertEquals(sebOperation.amount, -78);
|
||||
|
||||
//Add a distrib cycle
|
||||
var weeklyDistribCycle = service.DistributionService.createCycle(contract,Weekly,new Date(2018, 11, 24, 0, 0, 0),
|
||||
new Date(2019, 0, 24, 0, 0, 0),new Date(2018, 5, 4, 13, 0, 0),new Date(2018, 5, 4, 14, 0, 0),10,2,
|
||||
new Date(2018, 5, 4, 8, 0, 0),new Date(2018, 5, 4, 23, 0, 0),TestSuite.PLACE_DU_VILLAGE.id);
|
||||
//Check names and amounts are modified accordingly
|
||||
assertEquals(francoisOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 7 deliveries");
|
||||
assertEquals(francoisOperation.amount, -91);
|
||||
var sebOperation = db.Operation.findCOrderTransactionFor(contract, TestSuite.SEB);
|
||||
assertEquals(sebOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 7 deliveries");
|
||||
assertEquals(sebOperation.amount, -273);
|
||||
|
||||
//Delete the distrib cycle
|
||||
service.DistributionService.deleteCycleDistribs(weeklyDistribCycle);
|
||||
//Check names and amounts are modified accordingly
|
||||
assertEquals(francoisOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 2 deliveries");
|
||||
assertEquals(francoisOperation.amount, -26);
|
||||
var sebOperation = db.Operation.findCOrderTransactionFor(contract, TestSuite.SEB);
|
||||
assertEquals(sebOperation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 2 deliveries");
|
||||
assertEquals(sebOperation.amount, -78);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,473 +0,0 @@
|
||||
package test;
|
||||
import Common;
|
||||
import service.OrderService;
|
||||
/**
|
||||
* Test order making, updating and deleting
|
||||
*
|
||||
* @author fbarbut
|
||||
*/
|
||||
class TestOrders extends haxe.unit.TestCase
|
||||
{
|
||||
|
||||
public function new(){
|
||||
super();
|
||||
}
|
||||
|
||||
var c : db.Contract;
|
||||
var p : db.Product;
|
||||
var bob : db.User;
|
||||
|
||||
/**
|
||||
* get a contract + a user + a product + empty orders
|
||||
*/
|
||||
override function setup(){
|
||||
|
||||
TestSuite.initDB();
|
||||
TestSuite.initDatas();
|
||||
|
||||
db.Basket.emptyCache();
|
||||
|
||||
c = TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE.contract;
|
||||
|
||||
p = TestSuite.STRAWBERRIES;
|
||||
p.lock();
|
||||
p.stock = 8;
|
||||
p.update();
|
||||
|
||||
bob = db.User.manager.get(1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Test Basket creation and numbering
|
||||
**/
|
||||
public function testBasket(){
|
||||
|
||||
var d = TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE;
|
||||
|
||||
var o = OrderService.make(TestSuite.FRANCOIS, 3, TestSuite.STRAWBERRIES, d.id);
|
||||
assertEquals(1, o.basket.num);
|
||||
|
||||
var o = OrderService.make(TestSuite.SEB, 1, TestSuite.STRAWBERRIES, d.id);
|
||||
assertEquals(2, o.basket.num);
|
||||
|
||||
//order again, should keep existing basket number
|
||||
var o = OrderService.make(TestSuite.FRANCOIS, 1, TestSuite.APPLES, d.id);
|
||||
assertEquals(1, o.basket.num);
|
||||
|
||||
//check bug of 2018-07 : changing the date and place of the distribution leads to lost basket (because basket were indexed on user-date-place)
|
||||
d.lock();
|
||||
d.date = new Date(2028,1,1,0,0,0);
|
||||
|
||||
var place = new db.Place();
|
||||
place.name = "Chez Momo";
|
||||
place.zipCode = "54";
|
||||
place.amap = d.contract.amap;
|
||||
place.insert();
|
||||
|
||||
d.place = place;
|
||||
d.update();
|
||||
|
||||
//Seb's basket is still 2
|
||||
var basket = db.Basket.get(TestSuite.SEB,place,d.date);
|
||||
assertEquals(2, basket.num);
|
||||
|
||||
var o = OrderService.make(TestSuite.SEB, 1, TestSuite.APPLES, d.id);
|
||||
assertEquals(2, o.basket.num);
|
||||
|
||||
var o2 = OrderService.edit(o,5,true,null,false);
|
||||
assertEquals(2, o2.basket.num);
|
||||
|
||||
//order to a different distrib in same contract should start a new numbering
|
||||
var d2 = service.DistributionService.create(d.contract,new Date(2026,6,6,0,0,0),new Date(2026,6,6,1,0,0),place.id,null,null,null,null,new Date(2026,6,4,0,0,0),new Date(2026,6,5,0,0,0));
|
||||
var o = OrderService.make(TestSuite.SEB, 12, TestSuite.APPLES, d2.id);
|
||||
assertEquals(1, o.basket.num);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* make orders & stock management
|
||||
*/
|
||||
public function testStocks(){
|
||||
|
||||
var stock = p.stock;
|
||||
|
||||
assertTrue(c.type == db.Contract.TYPE_VARORDER);
|
||||
assertTrue(c.flags.has(db.Contract.ContractFlags.StockManagement));
|
||||
assertTrue(stock == 8);
|
||||
|
||||
//bob orders 3 strawberries, stock fall to 2
|
||||
//order is update to 6 berries
|
||||
App.current.eventDispatcher.addOnce(function(e:Event){
|
||||
switch(e){
|
||||
case StockMove(e):
|
||||
assertTrue(e.move==-3);
|
||||
assertTrue(e.product==p);
|
||||
default:
|
||||
}
|
||||
});
|
||||
var o = OrderService.make(bob, 3, p, TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE.id);
|
||||
assertTrue(p.stock == 5);
|
||||
assertTrue(o.quantity == 3);
|
||||
|
||||
//bob orders 6 more. stock fall to 0, order is reduced to 5
|
||||
//quantity is not 9 but 8
|
||||
App.current.eventDispatcher.addOnce(function(e:Event){
|
||||
switch(e){
|
||||
case StockMove(e):
|
||||
assertTrue(e.move==-5);
|
||||
assertTrue(e.product==p);
|
||||
default:
|
||||
}
|
||||
});
|
||||
var o = OrderService.make(bob, 6, p, TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE.id);
|
||||
assertTrue(p.stock == 0);
|
||||
assertTrue(o.quantity == 8);
|
||||
|
||||
//bob orders again but cant order anything
|
||||
var o = OrderService.make(bob, 3, p, TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE.id);
|
||||
assertTrue(p.stock == 0);
|
||||
assertTrue(o.quantity == 8);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* test edit orders and stock management
|
||||
*/
|
||||
function testOrderEdit(){
|
||||
|
||||
var o = db.UserContract.manager.select( $user == bob && $product == p, true);
|
||||
|
||||
//no order, stock at 8
|
||||
assertEquals(p.stock , 8);
|
||||
assertEquals(o , null);
|
||||
|
||||
//bob orders 3 strawberries
|
||||
var o = OrderService.make(bob, 3, p , TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE.id);
|
||||
assertEquals(o.product.name, p.name);
|
||||
assertEquals(o.quantity, 3);
|
||||
assertEquals(p.stock , 5);
|
||||
|
||||
//order edit, order 6 berries
|
||||
App.current.eventDispatcher.addOnce(function(e:Event){
|
||||
switch(e){
|
||||
case StockMove(e):
|
||||
assertTrue(e.move==-3);
|
||||
assertTrue(e.product==p);
|
||||
default:
|
||||
}
|
||||
});
|
||||
var o = OrderService.edit(o, 6);
|
||||
assertTrue(p.stock == 2);
|
||||
assertTrue(o.quantity == 6);
|
||||
|
||||
//order edit, order 9 berries. ( 3 more, but stock fall to 0, reduced to 2 )
|
||||
App.current.eventDispatcher.addOnce(function(e:Event){
|
||||
switch(e){
|
||||
case StockMove(e):
|
||||
assertEquals( -2.0 , e.move );
|
||||
assertEquals( p , e.product);
|
||||
default:
|
||||
}
|
||||
});
|
||||
var o = OrderService.edit(o, 9);
|
||||
assertEquals(0.0 , p.stock);
|
||||
assertEquals(8.0 , o.quantity);
|
||||
|
||||
//order more, but stock at 0
|
||||
var o = OrderService.edit(o, 12);
|
||||
assertEquals(0.0 , p.stock);
|
||||
assertEquals(8.0 , o.quantity);
|
||||
|
||||
//order less
|
||||
var o = OrderService.edit(o, 6);
|
||||
assertEquals(2.0 , p.stock);
|
||||
assertEquals(6.0 , o.quantity);
|
||||
|
||||
|
||||
//floatQt : ordering float quantities should throw an exception
|
||||
var err = null;
|
||||
try{
|
||||
var o = OrderService.edit(o, 6.4);
|
||||
}catch(e:tink.core.Error){
|
||||
err = e.message;
|
||||
}
|
||||
assertTrue( err!=null );
|
||||
}
|
||||
|
||||
/**
|
||||
* test orders with multiweight product
|
||||
*/
|
||||
function testOrderWithMultiWeightProduct(){
|
||||
|
||||
var chicken = TestSuite.CHICKEN;
|
||||
var distrib = db.Distribution.manager.select($contract == chicken.contract, false);
|
||||
|
||||
var order = OrderService.make(bob, 1, chicken, distrib.id);
|
||||
assertEquals(1.0, order.quantity);
|
||||
assertEquals(chicken.id, order.product.id);
|
||||
assertEquals(chicken.price, order.productPrice);
|
||||
|
||||
//order 2 more, should not aggregate because multiWeight is true
|
||||
var order2 = OrderService.make(bob, 2, chicken, distrib.id);
|
||||
|
||||
assertTrue(order2.id != order.id);
|
||||
|
||||
//we should get 3 different orders
|
||||
var orders = distrib.getOrders();
|
||||
|
||||
//trace(OrderService.prepare(orders));
|
||||
|
||||
assertEquals(3, orders.length);
|
||||
for ( o in orders){
|
||||
assertEquals(o.user.id, bob.id);
|
||||
assertEquals(o.product.id, chicken.id);
|
||||
assertEquals(1.0, o.quantity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author fbarbut
|
||||
* @date 2018-01-26
|
||||
* order a product, edit and set qt to zero, order again.
|
||||
* the same record should be re-used ( if not multiweight )
|
||||
*/
|
||||
function testMakeOrderAndZeroQuantity(){
|
||||
var fraises = TestSuite.STRAWBERRIES;
|
||||
var distrib = db.Distribution.manager.select($contract == fraises.contract, false);
|
||||
|
||||
var order = OrderService.make(bob, 1, fraises, distrib.id);
|
||||
|
||||
order = OrderService.edit(order, 0);
|
||||
|
||||
assertEquals(0.0, order.quantity);
|
||||
|
||||
var order2 = OrderService.make(bob, 1, fraises, distrib.id);
|
||||
|
||||
var bobOrders = [];
|
||||
for ( o in distrib.getOrders()) if (o.user.id == bob.id) bobOrders.push(o);
|
||||
|
||||
assertFalse(fraises.multiWeight);
|
||||
assertEquals(1, bobOrders.length);
|
||||
assertEquals(1.0, bobOrders[0].quantity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test order deletion and operation deletion in various contexts
|
||||
@author jbarbic
|
||||
*/
|
||||
function testDelete(){
|
||||
|
||||
var t = sugoi.i18n.Locale.texts;
|
||||
|
||||
//[Test case] Should throw an error when trying to delete order and that the quantity is not zero
|
||||
var amapDistrib = TestSuite.DISTRIB_CONTRAT_AMAP;
|
||||
var amapContract = amapDistrib.contract;
|
||||
var order = OrderService.make(TestSuite.FRANCOIS, 1, TestSuite.PANIER_AMAP_LEGUMES, amapDistrib.id);
|
||||
var orderId = order.id;
|
||||
db.Operation.onOrderConfirm([order]);
|
||||
var e1 = null;
|
||||
try {
|
||||
service.OrderService.delete(order);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e1 = x;
|
||||
}
|
||||
assertEquals(e1.message, "Deletion not possible: quantity is not zero.");
|
||||
assertTrue(db.UserContract.manager.get(orderId) != null);
|
||||
|
||||
//[Test case] Amap contract and quantity zero with payments disabled
|
||||
//Check that order is deleted
|
||||
order = OrderService.edit(order, 0);
|
||||
var e2 = null;
|
||||
try {
|
||||
OrderService.delete(order);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e2 = x;
|
||||
}
|
||||
assertEquals(e2, null);
|
||||
assertEquals(db.UserContract.manager.get(orderId), null);
|
||||
|
||||
//[Test case] Amap contract and quantity zero with payments enabled and 2 orders
|
||||
//Check that first order is deleted but operation amount is at 0
|
||||
//Check that operation is deleted only at the second order deletion
|
||||
var order1 = OrderService.make(TestSuite.FRANCOIS, 1, TestSuite.PANIER_AMAP_LEGUMES, amapDistrib.id);
|
||||
db.Operation.onOrderConfirm([order1]);
|
||||
var order1Id = order1.id;
|
||||
order1 = OrderService.edit(order1, 0);
|
||||
db.Operation.onOrderConfirm([order1]);
|
||||
var order2 = OrderService.make(TestSuite.FRANCOIS, 1, TestSuite.PANIER_AMAP_LEGUMES, amapDistrib.id);
|
||||
db.Operation.onOrderConfirm([order2]);
|
||||
var order2Id = order2.id;
|
||||
order2 = OrderService.edit(order2, 0);
|
||||
db.Operation.onOrderConfirm([order2]);
|
||||
var operation = db.Operation.findCOrderTransactionFor(amapContract, TestSuite.FRANCOIS);
|
||||
var operationId = operation.id;
|
||||
var e3 = null;
|
||||
try {
|
||||
service.OrderService.delete(order1);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e3 = x;
|
||||
}
|
||||
assertEquals(e3, null);
|
||||
assertEquals(db.UserContract.manager.get(order1Id), null);
|
||||
assertTrue(db.Operation.manager.get(operationId) != null);
|
||||
assertEquals(operation.name, "Contrat AMAP Légumes (La ferme de la Galinette) 1 deliveries");
|
||||
assertEquals(operation.amount, 0);
|
||||
var e4 = null;
|
||||
try {
|
||||
service.OrderService.delete(order2);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e4 = x;
|
||||
}
|
||||
assertEquals(null, e4);
|
||||
assertEquals(null, db.UserContract.manager.get(order2Id));
|
||||
assertEquals(null, db.Operation.manager.get(operationId));
|
||||
|
||||
//[Test case] Var Order contract and quantity zero with payments disabled
|
||||
//Check that order is deleted
|
||||
var variableDistrib = TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE;
|
||||
|
||||
var g = variableDistrib.contract.amap;
|
||||
g.lock();
|
||||
g.flags.unset(HasPayments);
|
||||
g.update();
|
||||
|
||||
var order = OrderService.make(TestSuite.FRANCOIS, 2, TestSuite.STRAWBERRIES, variableDistrib.id);
|
||||
var orderId = order.id;
|
||||
db.Operation.onOrderConfirm([order]);
|
||||
order = OrderService.edit(order, 0);
|
||||
db.Operation.onOrderConfirm([order]);
|
||||
var e1 = null;
|
||||
try {
|
||||
service.OrderService.delete(order);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e1 = x;
|
||||
}
|
||||
assertEquals(false,variableDistrib.contract.amap.hasPayments() );
|
||||
assertEquals(null, e1);
|
||||
assertEquals(null, db.UserContract.manager.get(orderId));
|
||||
|
||||
//[Test case] Var Order contract and quantity zero with payments enabled and 2 orders
|
||||
//Check that first order is deleted
|
||||
//Check that operation is deleted only at the second order deletion
|
||||
variableDistrib = TestSuite.DISTRIB_FRUITS_PLACE_DU_VILLAGE;
|
||||
var variableContract = variableDistrib.contract;
|
||||
var g = variableDistrib.contract.amap;
|
||||
g.lock();
|
||||
g.flags.set(HasPayments);
|
||||
g.update();
|
||||
assertTrue(variableContract.amap.hasPayments());
|
||||
|
||||
var order1 = OrderService.make(TestSuite.FRANCOIS, 2, TestSuite.STRAWBERRIES, variableDistrib.id);
|
||||
db.Operation.onOrderConfirm([order1]);
|
||||
var order1Id = order1.id;
|
||||
|
||||
var order2 = OrderService.make(TestSuite.FRANCOIS, 3, TestSuite.APPLES, variableDistrib.id);
|
||||
db.Operation.onOrderConfirm([order2]);
|
||||
var order2Id = order2.id;
|
||||
|
||||
order1 = OrderService.edit(order1, 0);
|
||||
db.Operation.onOrderConfirm([order1]);
|
||||
|
||||
order2 = OrderService.edit(order2, 0);
|
||||
db.Operation.onOrderConfirm([order2]);
|
||||
|
||||
assertEquals(2, variableContract.getUserOrders(TestSuite.FRANCOIS,variableDistrib).length); //François has 2 orders
|
||||
var basket = db.Basket.get(TestSuite.FRANCOIS,variableDistrib.place,variableDistrib.date);
|
||||
assertEquals(2, basket.getOrders().length);
|
||||
|
||||
var operation1 = db.Operation.findVOrderTransactionFor(order1.distribution.getKey(), TestSuite.FRANCOIS, variableContract.amap);
|
||||
var operation1Id = operation1.id;
|
||||
var operation2 = db.Operation.findVOrderTransactionFor(order2.distribution.getKey(), TestSuite.FRANCOIS, variableContract.amap);
|
||||
var operation2Id = operation2.id;
|
||||
assertEquals(operation1Id,operation2Id);
|
||||
var e2 = null;
|
||||
try {
|
||||
//delete strawberries order
|
||||
service.OrderService.delete(order1);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e2 = x;
|
||||
}
|
||||
assertEquals(null, e2);
|
||||
assertEquals(null, db.UserContract.manager.get(order1Id) ); //order 1 is deleted
|
||||
assertTrue( db.Operation.manager.get(operation1Id) != null); //operation should be here
|
||||
assertEquals(0.0,operation1.amount);
|
||||
assertEquals(1 , basket.getOrders().length);
|
||||
var e3 = null;
|
||||
try {
|
||||
//delete apple order
|
||||
service.OrderService.delete(order2);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e3 = x;
|
||||
}
|
||||
assertEquals(null, e3);
|
||||
assertEquals(null, db.UserContract.manager.get(order2Id)); //order 2 is deleted
|
||||
assertEquals(null, db.Operation.manager.get(operation1Id)); //operation should be deleted
|
||||
assertEquals(0 , basket.getOrders().length);
|
||||
|
||||
//[Test case] 2 VarOrderContracts and quantity zero with payments enabled and 1 order each
|
||||
//Check that first order is deleted but operation amount is at 0
|
||||
//Check that operation is deleted only at the second order deletion
|
||||
var variableDistrib1 = TestSuite.DISTRIB_LEGUMES_RUE_SAUCISSE;
|
||||
var order1 = OrderService.make(TestSuite.FRANCOIS, 2, TestSuite.COURGETTES, variableDistrib1.id);
|
||||
assertTrue(order1.basket!=null);
|
||||
// trace("WE GOT A BASKET "+order1.basket.id);
|
||||
// trace("... THEN RE-GET BASKET user "+TestSuite.FRANCOIS.id+" place "+variableDistrib1.place.id+" date "+variableDistrib1.date);
|
||||
var basket = db.Basket.get(TestSuite.FRANCOIS,variableDistrib1.place,variableDistrib1.date);
|
||||
assertTrue(basket!=null);
|
||||
assertEquals(1, basket.getOrders().length);
|
||||
db.Operation.onOrderConfirm([order1]);
|
||||
var order1Id = order1.id;
|
||||
|
||||
var variableDistrib2 = TestSuite.DISTRIB_PATISSERIES;
|
||||
var order2 = OrderService.make(TestSuite.FRANCOIS, 3, TestSuite.FLAN, variableDistrib2.id);
|
||||
db.Operation.onOrderConfirm([order2]);
|
||||
var order2Id = order2.id;
|
||||
|
||||
order1 = OrderService.edit(order1, 0);
|
||||
db.Operation.onOrderConfirm([order1]);
|
||||
|
||||
order2 = OrderService.edit(order2, 0);
|
||||
db.Operation.onOrderConfirm([order2]);
|
||||
|
||||
//check basket
|
||||
var basket = db.Basket.get(TestSuite.FRANCOIS,variableDistrib1.place,variableDistrib1.date);
|
||||
assertEquals(2, basket.getOrders().length);
|
||||
|
||||
var operation = db.Operation.findVOrderTransactionFor(order1.distribution.getKey(), TestSuite.FRANCOIS, variableDistrib1.contract.amap);
|
||||
var operationId = operation.id;
|
||||
|
||||
|
||||
var e4 = null;
|
||||
try {
|
||||
service.OrderService.delete(order1);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e4 = x;
|
||||
}
|
||||
assertEquals(e4, null);
|
||||
assertEquals(db.UserContract.manager.get(order1Id), null);
|
||||
assertTrue(db.Operation.manager.get(operationId) != null); //op should still be here
|
||||
assertEquals(0.0,operation.amount);//...with amount 0
|
||||
|
||||
var e5 = null;
|
||||
try {
|
||||
service.OrderService.delete(order2);
|
||||
}
|
||||
catch(x:tink.core.Error){
|
||||
e5 = x;
|
||||
}
|
||||
assertEquals(e5, null);
|
||||
assertEquals(db.UserContract.manager.get(order2Id), null);
|
||||
assertEquals(null, db.Operation.manager.get(operationId), null); //op should have been deleted
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package test;
|
||||
|
||||
/**
|
||||
* Test payments
|
||||
*
|
||||
* @author web-wizard
|
||||
*/
|
||||
class TestPayments extends haxe.unit.TestCase
|
||||
{
|
||||
|
||||
public function new(){
|
||||
super();
|
||||
}
|
||||
|
||||
override function setup(){
|
||||
TestSuite.initDB();
|
||||
TestSuite.initDatas();
|
||||
db.Basket.emptyCache();
|
||||
}
|
||||
|
||||
function testValidateDistribution() {
|
||||
|
||||
//Take a contract with payments enabled
|
||||
//Take 2 users and make orders for each
|
||||
var distrib = TestSuite.DISTRIB_LEGUMES_RUE_SAUCISSE;
|
||||
var contract = distrib.contract;
|
||||
var product = TestSuite.COURGETTES;
|
||||
var francoisOrder = service.OrderService.make(TestSuite.FRANCOIS, 1, product, distrib.id);
|
||||
var francoisOrderOperation = db.Operation.onOrderConfirm([francoisOrder]);
|
||||
var sebOrder = service.OrderService.make(TestSuite.SEB, 3, product, distrib.id);
|
||||
var sebOrderOperation = db.Operation.onOrderConfirm([sebOrder]);
|
||||
//They both pay by check
|
||||
var francoisPayment = db.Operation.makePaymentOperation(TestSuite.FRANCOIS,contract.amap, payment.Check.TYPE, product.price, "Payment by check", francoisOrderOperation[0]);
|
||||
var sebPayment = db.Operation.makePaymentOperation(TestSuite.SEB,contract.amap, payment.Check.TYPE, 3 * product.price, "Payment by check", sebOrderOperation[0] );
|
||||
|
||||
//Autovalidate this old distrib and check that all the payments are validated
|
||||
service.PaymentService.validateDistribution(distrib);
|
||||
|
||||
//distrib should be validated
|
||||
assertTrue(contract.amap.hasPayments());
|
||||
assertEquals(true, distrib.validated);
|
||||
|
||||
//orders should be marked as paid
|
||||
assertEquals(true, francoisOrder.paid);
|
||||
assertEquals(true, sebOrder.paid);
|
||||
|
||||
//order operation is not pending
|
||||
var francoisOperation = db.Operation.findVOrderTransactionFor(francoisOrder.distribution.getKey(), TestSuite.FRANCOIS, contract.amap, false);
|
||||
var sebOperation = db.Operation.findVOrderTransactionFor(sebOrder.distribution.getKey(), TestSuite.SEB, contract.amap, false);
|
||||
assertEquals(francoisOperation.pending, false);
|
||||
assertEquals(sebOperation.pending, false);
|
||||
|
||||
//payment operation is not pending
|
||||
assertEquals(francoisPayment.pending, false);
|
||||
assertEquals(sebPayment.pending, false);
|
||||
|
||||
//basket are validated
|
||||
var b = db.Basket.get(TestSuite.SEB,distrib.place,distrib.date);
|
||||
assertEquals(true, b.isValidated());
|
||||
var b = db.Basket.get(TestSuite.FRANCOIS,distrib.place,distrib.date);
|
||||
assertEquals(true, b.isValidated());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
package test;
|
||||
import Common;
|
||||
import test.TestSuite;
|
||||
import service.ReportService;
|
||||
import service.OrderService;
|
||||
|
||||
/**
|
||||
* Test order reports
|
||||
*
|
||||
* @author fbarbut
|
||||
*/
|
||||
class TestReports extends haxe.unit.TestCase
|
||||
{
|
||||
|
||||
public function new(){
|
||||
|
||||
super();
|
||||
}
|
||||
|
||||
override function setup(){
|
||||
|
||||
TestSuite.initDB();
|
||||
TestSuite.initDatas();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function testOrdersByProduct(){
|
||||
|
||||
//record orders
|
||||
var seb = TestSuite.SEB;
|
||||
var francois = TestSuite.FRANCOIS;
|
||||
var julie = TestSuite.JULIE;
|
||||
|
||||
//distrib de légumes
|
||||
var d = TestSuite.DISTRIB_LEGUMES_RUE_SAUCISSE;
|
||||
var carrots = TestSuite.CARROTS;
|
||||
var courgettes = TestSuite.COURGETTES;
|
||||
var poulet = TestSuite.CHICKEN;
|
||||
|
||||
OrderService.make(seb,4,courgettes,d.id);
|
||||
OrderService.make(seb,1,poulet,d.id);
|
||||
|
||||
OrderService.make(francois,6,courgettes,d.id);
|
||||
OrderService.make(francois,2,poulet,d.id);
|
||||
OrderService.make(francois,3,carrots,d.id);
|
||||
|
||||
OrderService.make(julie,8,carrots,d.id);
|
||||
OrderService.make(julie,3,poulet,d.id);
|
||||
|
||||
//record orders on ANOTHER distrib
|
||||
var d2 = service.DistributionService.create(
|
||||
d.contract,
|
||||
new Date(2018,2,12,0,0,0),
|
||||
new Date(2018,2,12,0,3,0),
|
||||
d.contract.amap.getPlaces().first().id,
|
||||
null,null,null,null,
|
||||
new Date(2018,2,8,0,0,0),
|
||||
new Date(2018,2,11,0,0,0)
|
||||
);
|
||||
OrderService.make(julie,6,carrots,d2.id);
|
||||
OrderService.make(julie,1,poulet,d2.id);
|
||||
|
||||
var orders = ReportService.getOrdersByProduct(d);
|
||||
|
||||
//courgettes x 10
|
||||
var courgettesOrder = Lambda.find(orders, function(o) return o.pid==courgettes.id);
|
||||
assertEquals( 10.0 , courgettesOrder.quantity );
|
||||
assertEquals( 35.0 , courgettesOrder.totalTTC );
|
||||
assertEquals( 33.18 , tools.FloatTool.clean(courgettesOrder.totalHT) );
|
||||
|
||||
//the report stays the same, even if the product has a new price.
|
||||
courgettes.lock();
|
||||
courgettes.price+=4;
|
||||
courgettes.update();
|
||||
var orders = ReportService.getOrdersByProduct(d);
|
||||
var courgettesOrder = Lambda.find(orders, function(o) return o.pid==courgettes.id);
|
||||
assertEquals( 10.0 , courgettesOrder.quantity );
|
||||
assertEquals( 35.0 , courgettesOrder.totalTTC );
|
||||
assertEquals( 33.18 , tools.FloatTool.clean(courgettesOrder.totalHT) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* run once at the beginning
|
||||
*/
|
||||
/*override function setup(){
|
||||
|
||||
sys.db.Manager.cnx.request("TRUNCATE TABLE UserContract;");
|
||||
|
||||
var bubar = db.User.manager.get(1);
|
||||
var seb = db.User.manager.get(2);
|
||||
|
||||
//fruits from group 1
|
||||
var fraises = db.Product.manager.get(2);
|
||||
fraises.stock = 30;
|
||||
var pommes = db.Product.manager.get(3);
|
||||
var distrib = fraises.contract.getDistribs().first();
|
||||
|
||||
db.UserContract.make(bubar, 4, fraises, distrib.id);
|
||||
db.UserContract.make(seb, 2, pommes, distrib.id);
|
||||
|
||||
//vegetables from group 2
|
||||
var courgettes = db.Product.manager.get(4);
|
||||
var carottes = db.Product.manager.get(5);
|
||||
var distrib = courgettes.contract.getDistribs().first();
|
||||
|
||||
db.UserContract.make(bubar, 1, carottes ,distrib.id);
|
||||
db.UserContract.make(seb, 5, courgettes ,distrib.id);
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* test a simple report with just a time frame
|
||||
*/
|
||||
/*public function testTimeFrameReport(){
|
||||
|
||||
var fraises = db.Product.manager.get(2);
|
||||
var pommes = db.Product.manager.get(3);
|
||||
var courgettes = db.Product.manager.get(4);
|
||||
var carottes = db.Product.manager.get(5);
|
||||
|
||||
//check we got the right products
|
||||
assertEquals("Fraises",fraises.name);
|
||||
assertEquals("Pommes",pommes.name);
|
||||
assertEquals("Courgettes",courgettes.name);
|
||||
assertEquals("Carottes", carottes.name);
|
||||
|
||||
var options = { startDate:new Date(2017, 5, 1, 0, 0, 0), endDate:new Date(2017, 5, 31, 0, 0, 0), groups:[], contracts:[] };
|
||||
|
||||
var rep = new pro.OrderReport(options);
|
||||
|
||||
var data = rep.byProduct();
|
||||
|
||||
assertEquals(4,data.length); //should be the 4 products
|
||||
|
||||
for ( d in data){
|
||||
switch(d.pname){
|
||||
case "Fraises": assertEquals(d.qt, 4);
|
||||
case "Pommes": assertEquals(d.qt, 2);
|
||||
case "Carottes": assertEquals(d.qt, 1);
|
||||
case "Courgettes": assertEquals(d.qt, 5);
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* test a report with time frame + group
|
||||
*/
|
||||
/*public function testGroupReport(){
|
||||
|
||||
var options = { startDate:new Date(2017, 5, 1, 0, 0, 0), endDate:new Date(2017, 5, 31, 0, 0, 0), groups:[1], contracts:[] };
|
||||
|
||||
var rep = new pro.OrderReport(options);
|
||||
var data = rep.byProduct();
|
||||
assertEquals(2,data.length); //should be the 2 products
|
||||
|
||||
for ( d in data){
|
||||
switch(d.pname){
|
||||
case "Fraises": assertEquals(d.qt, 4);
|
||||
case "Pommes": assertEquals(d.qt, 2);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,413 +0,0 @@
|
||||
package test;
|
||||
import Common;
|
||||
/**
|
||||
* CAGETTE.NET TEST SUITE
|
||||
* @author fbarbut
|
||||
*/
|
||||
class TestSuite
|
||||
{
|
||||
|
||||
static function main() {
|
||||
|
||||
connectDb();
|
||||
var r = new haxe.unit.TestRunner();
|
||||
|
||||
//Cagette core tests
|
||||
r.add(new test.TestUser());
|
||||
r.add(new test.TestOrders());
|
||||
r.add(new test.TestTools());
|
||||
r.add(new test.TestDistributions());
|
||||
r.add(new test.TestPayments());
|
||||
r.add(new test.TestReports());
|
||||
|
||||
#if plugins
|
||||
//Cagette-pro tests, keep in this order
|
||||
r.add(new pro.test.TestProductService());
|
||||
r.add(new pro.test.TestRemoteCatalog());
|
||||
r.add(new pro.test.TestDistribService());
|
||||
r.add(new pro.test.TestReports());
|
||||
//wholesale-order tests
|
||||
r.add(new who.test.TestWho());
|
||||
#end
|
||||
|
||||
r.run();
|
||||
}
|
||||
|
||||
static function connectDb() {
|
||||
var dbstr = Sys.args()[0];
|
||||
var dbreg = ~/([^:]+):\/\/([^:]+):([^@]*?)@([^:]+)(:[0-9]+)?\/(.*?)$/;
|
||||
if( !dbreg.match(dbstr) )
|
||||
throw "Configuration requires a valid database attribute, format is : mysql://user:password@host:port/dbname";
|
||||
var port = dbreg.matched(5);
|
||||
var dbparams = {
|
||||
user:dbreg.matched(2),
|
||||
pass:dbreg.matched(3),
|
||||
host:dbreg.matched(4),
|
||||
port:port == null ? 3306 : Std.parseInt(port.substr(1)),
|
||||
database:dbreg.matched(6),
|
||||
socket:null
|
||||
};
|
||||
|
||||
sys.db.Manager.cnx = sys.db.Mysql.connect(dbparams);
|
||||
sys.db.Manager.initialize();
|
||||
}
|
||||
|
||||
|
||||
public static function initDB(){
|
||||
//NUKE EVERYTHING BWAAAAH !!
|
||||
sys.db.Manager.cleanup(); //cleanup cache objects
|
||||
sql("DROP DATABASE tests;");
|
||||
sql("CREATE DATABASE tests;");
|
||||
sql("USE tests;");
|
||||
|
||||
var tables : Array<Dynamic> = [
|
||||
|
||||
//cagette
|
||||
db.TxpProduct.manager,
|
||||
db.TxpCategory.manager,
|
||||
db.TxpSubCategory.manager,
|
||||
db.Category.manager,
|
||||
db.CategoryGroup.manager,
|
||||
db.ProductCategory.manager,
|
||||
|
||||
db.Basket.manager,
|
||||
db.UserContract.manager,
|
||||
db.UserAmap.manager,
|
||||
db.Operation.manager,
|
||||
|
||||
db.User.manager,
|
||||
db.Amap.manager,
|
||||
db.Contract.manager,
|
||||
db.Product.manager,
|
||||
db.Vendor.manager,
|
||||
db.Place.manager,
|
||||
db.Distribution.manager,
|
||||
db.DistributionCycle.manager,
|
||||
|
||||
//sugoi tables
|
||||
sugoi.db.Cache.manager,
|
||||
sugoi.db.Error.manager,
|
||||
sugoi.db.File.manager,
|
||||
sugoi.db.Session.manager,
|
||||
sugoi.db.Variable.manager,
|
||||
];
|
||||
|
||||
for(t in tables) createTable(t);
|
||||
|
||||
#if plugins
|
||||
//add Cpro datas : we need those tables even in cagette core tests
|
||||
pro.test.ProTestSuite.initDB();
|
||||
pro.test.ProTestSuite.initDatas();
|
||||
#end
|
||||
}
|
||||
|
||||
public static function createTable( m ){
|
||||
if ( sys.db.TableCreate.exists(m) ){
|
||||
drop(m);
|
||||
}
|
||||
// Sys.println("Creating table "+ m.dbInfos().name);
|
||||
sys.db.TableCreate.create(m);
|
||||
}
|
||||
|
||||
public static function truncate(m){
|
||||
sql("TRUNCATE TABLE "+m.dbInfos().name+";");
|
||||
}
|
||||
|
||||
public static function drop(m){
|
||||
sql("DROP TABLE "+m.dbInfos().name+";");
|
||||
}
|
||||
|
||||
public static function sql(sql){
|
||||
return sys.db.Manager.cnx.request(sql);
|
||||
}
|
||||
|
||||
//shortcut to datas
|
||||
public static var FRANCOIS:db.User = null;
|
||||
public static var SEB:db.User = null;
|
||||
public static var JULIE:db.User = null;
|
||||
|
||||
public static var CHICKEN:db.Product = null;
|
||||
public static var STRAWBERRIES:db.Product = null;
|
||||
public static var APPLES:db.Product = null;
|
||||
public static var AMAP_DU_JARDIN:db.Amap = null;
|
||||
public static var LOCAVORES:db.Amap = null;
|
||||
public static var PANIER_AMAP_LEGUMES:db.Product = null;
|
||||
public static var DISTRIB_CONTRAT_AMAP:db.Distribution = null;
|
||||
public static var DISTRIB_FRUITS_PLACE_DU_VILLAGE:db.Distribution = null;
|
||||
public static var DISTRIB_LEGUMES_RUE_SAUCISSE:db.Distribution = null;
|
||||
public static var CONTRAT_LEGUMES:db.Contract = null;
|
||||
public static var PLACE_DU_VILLAGE:db.Place = null;
|
||||
public static var COURGETTES:db.Product = null;
|
||||
public static var CARROTS:db.Product = null;
|
||||
public static var FLAN:db.Product = null;
|
||||
public static var CROISSANT:db.Product = null;
|
||||
public static var DISTRIB_PATISSERIES:db.Distribution = null;
|
||||
|
||||
public static function initDatas(){
|
||||
|
||||
//USERS
|
||||
|
||||
var f = new db.User();
|
||||
f.firstName = "François";
|
||||
f.lastName = "B";
|
||||
f.email = "francois@alilo.fr";
|
||||
f.insert();
|
||||
|
||||
FRANCOIS = f;
|
||||
|
||||
var u = new db.User();
|
||||
u.firstName = "Seb";
|
||||
u.lastName = "Z";
|
||||
u.email = "sebastien@alilo.fr";
|
||||
u.insert();
|
||||
|
||||
SEB = u;
|
||||
|
||||
var u = new db.User();
|
||||
u.firstName = "Julie";
|
||||
u.lastName = "B";
|
||||
u.email = "julie@alilo.fr";
|
||||
u.insert();
|
||||
|
||||
JULIE = u;
|
||||
|
||||
initApp(u);
|
||||
|
||||
//GROUP "AMAP du Jardin public"
|
||||
var a = new db.Amap();
|
||||
a.name = "AMAP du Jardin public";
|
||||
a.contact = f;
|
||||
a.flags.set(db.Amap.AmapFlags.HasPayments);
|
||||
a.insert();
|
||||
AMAP_DU_JARDIN = a;
|
||||
|
||||
var place = new db.Place();
|
||||
place.name = "Place du village";
|
||||
place.zipCode = "00000";
|
||||
place.city = "St Martin";
|
||||
place.amap = a;
|
||||
place.insert();
|
||||
|
||||
PLACE_DU_VILLAGE = place;
|
||||
|
||||
//VENDOR "Ferme de la galinette"
|
||||
var v = new db.Vendor();
|
||||
v.name = "La ferme de la Galinette";
|
||||
v.email = "galinette@gmail.com";
|
||||
v.zipCode = "00000";
|
||||
v.city = "Bourligheim";
|
||||
v.insert();
|
||||
|
||||
var c = new db.Contract();
|
||||
c.name = "Contrat AMAP Légumes";
|
||||
c.startDate = new Date(2017, 1, 1, 0, 0, 0);
|
||||
c.endDate = new Date(2030, 12, 31, 23, 59, 0);
|
||||
c.vendor = v;
|
||||
c.amap = a;
|
||||
c.type = db.Contract.TYPE_CONSTORDERS;
|
||||
c.insert();
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Panier Légumes";
|
||||
p.price = 13;
|
||||
p.contract = c;
|
||||
p.insert();
|
||||
|
||||
PANIER_AMAP_LEGUMES = p;
|
||||
|
||||
var d = new db.Distribution();
|
||||
d.date = new Date(2017, 5, 1, 19, 0, 0);
|
||||
d.end = new Date(2017, 5, 1, 20, 0, 0);
|
||||
d.orderStartDate = new Date(2017, 4, 1, 20, 0, 0);
|
||||
d.orderEndDate = new Date(2017, 4, 30, 20, 0, 0);
|
||||
d.contract = c;
|
||||
d.place = place;
|
||||
d.insert();
|
||||
|
||||
DISTRIB_CONTRAT_AMAP = d;
|
||||
|
||||
//varying contract for strawberries with stock mgmt
|
||||
var c = new db.Contract();
|
||||
c.name = "Commande fruits";
|
||||
c.vendor = v;
|
||||
c.startDate = new Date(2017, 1, 1, 0, 0, 0);
|
||||
c.endDate = new Date(2030, 12, 31, 23, 59, 0);
|
||||
c.flags.set(db.Contract.ContractFlags.StockManagement);
|
||||
c.type = db.Contract.TYPE_VARORDER;
|
||||
c.amap = a;
|
||||
c.insert();
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Fraises";
|
||||
p.qt = 1;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 10;
|
||||
p.organic = true;
|
||||
p.contract = c;
|
||||
p.stock = 8;
|
||||
p.insert();
|
||||
|
||||
STRAWBERRIES = p;
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Pommes";
|
||||
p.qt = 1;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 6;
|
||||
p.organic = true;
|
||||
p.contract = c;
|
||||
p.stock = 12;
|
||||
p.insert();
|
||||
|
||||
APPLES = p;
|
||||
|
||||
var d = new db.Distribution();
|
||||
d.date = new Date(2017, 5, 1, 19, 0, 0);
|
||||
d.end = new Date(2017, 5, 1, 20, 0, 0);
|
||||
d.orderStartDate = new Date(2017, 4, 1, 20, 0, 0);
|
||||
d.orderEndDate = new Date(2017, 4, 30, 20, 0, 0);
|
||||
d.contract = c;
|
||||
d.place = place;
|
||||
d.insert();
|
||||
|
||||
DISTRIB_FRUITS_PLACE_DU_VILLAGE = d;
|
||||
|
||||
//second group
|
||||
var a = new db.Amap();
|
||||
a.name = "Les Locavores de la Rue Saucisse";
|
||||
a.contact = f;
|
||||
a.flags.set(db.Amap.AmapFlags.HasPayments);
|
||||
a.insert();
|
||||
LOCAVORES = a;
|
||||
|
||||
var place = new db.Place();
|
||||
place.name = "Rue Saucisse";
|
||||
place.zipCode = "00000";
|
||||
place.city = "St Martin";
|
||||
place.amap = a;
|
||||
place.insert();
|
||||
|
||||
var v = new db.Vendor();
|
||||
v.name = "La ferme de la courgette enragée";
|
||||
v.email = "courgette@gmail.com";
|
||||
v.zipCode = "00000";
|
||||
v.city = "Bourligeac";
|
||||
v.insert();
|
||||
|
||||
var c = new db.Contract();
|
||||
c.name = "Commande Legumes";
|
||||
c.startDate = new Date(2017, 1, 1, 0, 0, 0);
|
||||
c.endDate = new Date(2030, 12, 31, 23, 59, 0);
|
||||
c.vendor = v;
|
||||
c.amap = a;
|
||||
c.type = db.Contract.TYPE_VARORDER;
|
||||
c.insert();
|
||||
|
||||
CONTRAT_LEGUMES = c;
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Courgettes";
|
||||
p.qt = 1;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 3.5;
|
||||
p.vat = 5.5;
|
||||
p.organic = true;
|
||||
p.contract = c;
|
||||
p.insert();
|
||||
|
||||
COURGETTES = p;
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Carottes";
|
||||
p.qt = 1;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 2.8;
|
||||
p.vat = 5.5;
|
||||
p.contract = c;
|
||||
p.insert();
|
||||
|
||||
CARROTS = p;
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Poulet";
|
||||
p.qt = 1.5;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 15;
|
||||
p.vat = 5.5;
|
||||
p.multiWeight = true;
|
||||
p.hasFloatQt = true;
|
||||
p.contract = c;
|
||||
p.insert();
|
||||
|
||||
CHICKEN = p;
|
||||
|
||||
var d = service.DistributionService.create(c,new Date(2017, 5, 1, 19, 0, 0),new Date(2017, 5, 1, 19, 2, 0),place.id,null,null,null,null,new Date(2017, 4, 10, 19, 0, 0),new Date(2017, 4, 20, 19, 0, 0));
|
||||
DISTRIB_LEGUMES_RUE_SAUCISSE = d;
|
||||
|
||||
//PASTRY
|
||||
|
||||
var c = new db.Contract();
|
||||
c.name = "Commande Pâtisseries";
|
||||
c.startDate = new Date(2017, 1, 1, 0, 0, 0);
|
||||
c.endDate = new Date(2017, 12, 31, 23, 59, 0);
|
||||
c.vendor = v;
|
||||
c.amap = a;
|
||||
c.type = db.Contract.TYPE_VARORDER;
|
||||
c.insert();
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Flan";
|
||||
p.qt = 1;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 3.5;
|
||||
p.organic = true;
|
||||
p.contract = c;
|
||||
p.insert();
|
||||
|
||||
FLAN = p;
|
||||
|
||||
var p = new db.Product();
|
||||
p.name = "Croissant";
|
||||
p.qt = 1;
|
||||
p.unitType = Common.Unit.Kilogram;
|
||||
p.price = 2.8;
|
||||
p.contract = c;
|
||||
p.insert();
|
||||
|
||||
CROISSANT = p;
|
||||
|
||||
var d = new db.Distribution();
|
||||
d.date = new Date(2017, 5, 1, 19, 0, 0);
|
||||
d.contract = c;
|
||||
d.place = place;
|
||||
d.insert();
|
||||
|
||||
DISTRIB_PATISSERIES = d;
|
||||
}
|
||||
|
||||
static function initApp(u:db.User){
|
||||
|
||||
//setup App
|
||||
var app = App.current = new App();
|
||||
App.config.DEBUG = true;
|
||||
app.initLang("en");
|
||||
|
||||
app.eventDispatcher = new hxevents.Dispatcher<Event>();
|
||||
app.plugins = [];
|
||||
//internal plugins
|
||||
app.plugins.push(new plugin.Tutorial());
|
||||
|
||||
//optionnal plugins
|
||||
#if plugins
|
||||
//app.plugins.push( new hosted.HostedPlugIn() );
|
||||
app.plugins.push( new pro.ProPlugIn() );
|
||||
app.plugins.push( new connector.ConnectorPlugIn() );
|
||||
//app.plugins.push( new pro.LemonwayEC() );
|
||||
app.plugins.push( new who.WhoPlugIn() );
|
||||
#end
|
||||
|
||||
App.current.user = u;
|
||||
App.current.view = new View();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package test;
|
||||
import Common;
|
||||
|
||||
/**
|
||||
* Test various tools
|
||||
*
|
||||
* @author fbarbut
|
||||
*/
|
||||
class TestTools extends haxe.unit.TestCase
|
||||
{
|
||||
|
||||
public function new(){
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
function testDateRanges(){
|
||||
// test last hour range
|
||||
var now = Date.fromString("2018-01-01 00:30:12");
|
||||
var r = tools.DateTool.getLastHourRange(now);
|
||||
assertEquals("2017-12-31 23:00:00",r.from.toString());
|
||||
assertEquals("2018-01-01 00:00:00",r.to.toString());
|
||||
|
||||
// test last minute
|
||||
var now = Date.fromString("2018-01-01 00:30:12");
|
||||
var r = tools.DateTool.getLastMinuteRange(now);
|
||||
assertEquals("2018-01-01 00:29:00",r.from.toString());
|
||||
assertEquals("2018-01-01 00:30:00",r.to.toString());
|
||||
}
|
||||
|
||||
|
||||
function testFloatTool(){
|
||||
|
||||
assertEquals( true , tools.FloatTool.isEqual(10.0,10.000) );
|
||||
assertEquals( true , tools.FloatTool.isEqual(10.0,10) );
|
||||
assertEquals( true , tools.FloatTool.isEqual(10,10) );
|
||||
assertEquals( true , tools.FloatTool.isEqual(10.00000001,10) );
|
||||
assertEquals( false , tools.FloatTool.isEqual(10.02,10) );
|
||||
|
||||
assertEquals( false , tools.FloatTool.isInt(10.08) );
|
||||
assertEquals( true , tools.FloatTool.isInt(10.00) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@admin
|
||||
public function doTests() {
|
||||
|
||||
var assertTrue = function(val, ?desc="") {
|
||||
if (val) {
|
||||
Sys.println("OK : <br/>");
|
||||
}else {
|
||||
Sys.println("ERROR : "+desc+"<br/>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//test les fonctions de cotisation
|
||||
|
||||
var amap = db.Amap.manager.get(1);
|
||||
|
||||
amap.membershipRenewalDate = new Date(2015, 0, 1,0,0,0);
|
||||
amap.update();
|
||||
|
||||
assertTrue(amap.getMembershipYear(new Date(2015, 3, 3, 0, 0, 0) ) == 2015);
|
||||
assertTrue(amap.getPeriodName(new Date(2015, 3, 3, 0, 0, 0)) == "2015");
|
||||
|
||||
assertTrue(amap.getMembershipYear(new Date(2014, 8, 8, 0, 0, 0) ) == 2014);
|
||||
assertTrue(amap.getPeriodName(new Date(2014, 8, 8, 0, 0, 0) ) == "2014");
|
||||
|
||||
assertTrue(amap.getMembershipYear(new Date(2013, 11, 12, 0, 0, 0) ) == 2013);
|
||||
assertTrue(amap.getPeriodName(new Date(2013, 11, 12, 0, 0, 0) ) == "2013");
|
||||
|
||||
amap.membershipRenewalDate = new Date(2015, 8, 1,0,0,0);
|
||||
amap.update();
|
||||
|
||||
assertTrue(amap.getMembershipYear(new Date(2015, 3, 3, 0, 0, 0) ) == 2014);
|
||||
assertTrue(amap.getPeriodName(new Date(2015, 3, 3, 0, 0, 0)) == "2014-2015");
|
||||
|
||||
var d = amap.getMembershipYear(new Date(2015, 8, 8, 0, 0, 0) );
|
||||
assertTrue( d == 2015, "le 8 sept 2015, on doit etre en cotis 2015, la c " + d);
|
||||
assertTrue(amap.getPeriodName(new Date(2015, 8, 8, 0, 0, 0)) == "2015-2016");
|
||||
|
||||
var d = new Date(2013, 11, 12, 0, 0, 0) ;
|
||||
assertTrue( amap.getMembershipYear(d) == 2013, "le 12 oct 2013, on doit etre en cotis 2013 , là c " + amap.getMembershipYear(d) );
|
||||
assertTrue(amap.getPeriodName(d) == "2013-2014", "le 12 oct 2013, on doit etre en 2013-2014 , là c " + amap.getPeriodName(d) );
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
|
||||
|
||||
package test;
|
||||
import db.UserAmap;
|
||||
import Common;
|
||||
|
||||
/**
|
||||
* Test user rights to view contracts
|
||||
*
|
||||
* @author web-wizard
|
||||
*/
|
||||
class TestUser extends haxe.unit.TestCase
|
||||
{
|
||||
|
||||
public function new(){
|
||||
super();
|
||||
}
|
||||
|
||||
var contract : db.Contract;
|
||||
var user : db.User;
|
||||
var group1 : db.Amap;
|
||||
var group2 : db.Amap;
|
||||
var userAmap : db.UserAmap;
|
||||
|
||||
/**
|
||||
* get a contract + a user
|
||||
*/
|
||||
override function setup(){
|
||||
TestSuite.initDB();
|
||||
TestSuite.initDatas();
|
||||
|
||||
contract = db.Contract.manager.get(3);
|
||||
user = db.User.manager.get(1);
|
||||
group1 = db.Amap.manager.get(1);
|
||||
group2 = db.Amap.manager.get(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that a user who has admin rights for his/her group can't view a contract from a group
|
||||
he/she doesn't belong to
|
||||
*/
|
||||
function testViewContract(){
|
||||
userAmap = db.UserAmap.getOrCreate(user, group1);
|
||||
userAmap.giveRight(Right.GroupAdmin);
|
||||
assertFalse(user.canManageContract(contract));
|
||||
}
|
||||
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
-lib dbadmin
|
||||
-lib templo
|
||||
-lib sugoi
|
||||
-lib hxevents
|
||||
-lib thx.semver
|
||||
-lib thx.csv
|
||||
-lib datetime
|
||||
-lib hscript
|
||||
-lib smtpmailer
|
||||
-lib record-macros
|
||||
-lib tink_json
|
||||
-cp common
|
||||
-cp src
|
||||
-cp lang/master/tpl
|
||||
-neko www/tests.n
|
||||
-main test.TestSuite
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# JS
|
||||
-js js/test/tests.js
|
||||
-main test.TestAll
|
||||
-cp js
|
||||
-cp common
|
||||
-lib utest
|
||||
-lib hxnodejs
|
||||
-lib sugoi:git:https://github.com/bablukid/sugoi#i18n
|
||||
-D test
|
||||
@@ -1,21 +0,0 @@
|
||||
-lib dbadmin
|
||||
-lib templo
|
||||
-lib sugoi
|
||||
-lib hxevents
|
||||
-lib thx.semver
|
||||
-lib thx.csv
|
||||
-lib datetime
|
||||
-lib hscript
|
||||
-lib smtpmailer
|
||||
-lib record-macros
|
||||
-lib cagette-pro
|
||||
-lib cagette-hosted
|
||||
-lib cagette-wholesale-order
|
||||
-lib tink_json
|
||||
-cp common
|
||||
-cp src
|
||||
-cp lang/master/tpl
|
||||
-neko www/tests.n
|
||||
-D plugins
|
||||
-main test.TestSuite
|
||||
|
||||
Vendored
+6
File diff suppressed because one or more lines are too long
Executable → Regular
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
+2817
-2816
File diff suppressed because it is too large
Load Diff
+23
-1141
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user