Compare commits

...

157 Commits

Author SHA1 Message Date
Alexis Lahouze
5df62de278 Begin conversion to typescript. 2017-07-10 00:52:39 +02:00
Alexis Lahouze
cae86d3014 Separate schedule module into different files. 2017-07-08 12:20:17 +02:00
Alexis Lahouze
e5857bc68e Use angular strap modal instead of angular-ui-bootstrap one. 2017-07-08 12:12:20 +02:00
Alexis Lahouze
319c0adc16 Remove angular-ui-bootstrap dependency. 2017-07-08 09:39:18 +02:00
Alexis Lahouze
28afd8f563 Remove unneeded $q. 2017-07-08 09:34:55 +02:00
Alexis Lahouze
30549dd6d8 Use angular strap modal instead of angular-ui-bootstrap one. 2017-07-08 09:33:52 +02:00
Alexis Lahouze
8194978bcc Add vim tagline. 2017-07-08 09:20:10 +02:00
Alexis Lahouze
1ff7c98f93 Move needed libraries to the right places. 2017-07-08 09:19:35 +02:00
Alexis Lahouze
36e25fc1b7 Separate account module into different files. 2017-07-08 09:19:02 +02:00
Alexis Lahouze
d4400b788d Use angular strap modal instead of angular-ui-bootstrap one. 2017-07-08 09:14:19 +02:00
Alexis Lahouze
0c85266ab2 Separate login module into different files. 2017-07-08 00:51:59 +02:00
Alexis Lahouze
292486f8fd Add event release on . 2017-07-08 00:18:16 +02:00
Alexis Lahouze
0268280a73 Rename factory to service. 2017-07-08 00:17:37 +02:00
Alexis Lahouze
9a7d3938aa Use anonymous function as interceptor. 2017-07-08 00:17:15 +02:00
Alexis Lahouze
d6eb6781c6 Move template imports in controller. 2017-07-07 23:12:48 +02:00
Alexis Lahouze
9386b4a4b9 Import order. 2017-07-07 23:11:27 +02:00
Alexis Lahouze
d4faff7a6c Separate operations module into different files. 2017-07-07 22:52:27 +02:00
Alexis Lahouze
06ca00e627 Move templates in routing. Module import order. 2017-07-07 22:36:04 +02:00
Alexis Lahouze
fbeb3fd362 Separate app.config in another file. 2017-07-07 22:31:49 +02:00
Alexis Lahouze
2fb98fdeed Force AngularJS to use jQuery. 2017-07-07 01:16:49 +02:00
Alexis Lahouze
6556227f88 Remove usage of . 2017-07-07 01:16:33 +02:00
Alexis Lahouze
bebe2aa874 Use modal from Angular-Strap instead of the one in angular-ui-bootstrap. 2017-07-07 01:14:18 +02:00
Alexis Lahouze
0833536d5e Fix dependencies. 2017-07-06 10:39:14 +02:00
Alexis Lahouze
a7f37e88a9 Exports module name instead of module itself. 2017-07-06 10:35:15 +02:00
Alexis Lahouze
d7de013954 Fix category loading. 2017-07-05 23:19:24 +02:00
Alexis Lahouze
facc1c5a0d Add account injection. 2017-07-05 21:58:17 +02:00
Alexis Lahouze
0340f333b6 Upgrade dev dependencies. 2017-07-05 21:57:49 +02:00
Alexis Lahouze
3b925d4b37 Freeze webpack-dev-server version to avoid error on run. 2017-07-05 21:57:35 +02:00
Alexis Lahouze
c14d88f421 Fix indent. 2017-07-05 21:48:20 +02:00
Alexis Lahouze
c558994c6d Change chart height. 2017-07-05 21:36:45 +02:00
Alexis Lahouze
2a2738ddeb Initialize account from parent. 2017-07-05 21:36:23 +02:00
Alexis Lahouze
7ace852f43 Fix date timezones to avoid operation saved on the day before the one entered. 2017-07-05 09:35:09 +02:00
Alexis Lahouze
4fed3c9320 Remove unneeded ng-click from submit buttons. 2017-07-04 21:57:54 +02:00
Alexis Lahouze
4fdbb40e92 Fix ng-submit for login form. 2017-07-04 21:57:30 +02:00
Alexis Lahouze
c06dea22f6 Style. 2017-07-04 21:54:31 +02:00
Alexis Lahouze
0fa2f06a0e Fix account form validation and disable submit button is form is invalid. 2017-07-04 21:54:21 +02:00
Alexis Lahouze
fe2355a405 Fix account form submit on enter. 2017-07-04 21:53:32 +02:00
Alexis Lahouze
a3e9ba02ac Fix authorized overdraft input field. 2017-07-04 21:50:34 +02:00
Alexis Lahouze
e90f4d21e8 Fix login form submit on enter. 2017-07-04 21:20:13 +02:00
Alexis Lahouze
4218b741db Add red line for account authorized overdraft. 2017-07-04 21:13:08 +02:00
Alexis Lahouze
2e6bc006f5 Add regions to separate past and future operations. 2017-07-04 20:37:03 +02:00
Alexis Lahouze
003ad498db Cleanup . 2017-07-04 20:36:18 +02:00
Alexis Lahouze
6f477b6d22 Unload chart data before loading new one. 2017-07-04 20:35:53 +02:00
Alexis Lahouze
0f547a532c Rename row 'x' to 'date', swap expenses and revenues. 2017-07-04 20:35:18 +02:00
Alexis Lahouze
ab14ead2dc Cleanup. 2017-07-02 00:13:40 +02:00
Alexis Lahouze
7004b6cf44 Reimplement category chart. 2017-07-02 00:13:04 +02:00
Alexis Lahouze
0cd5dab07c Improve bindings between components. 2017-07-02 00:11:02 +02:00
Alexis Lahouze
08b6643eda Use c3.js instead of chart.js. 2017-07-01 14:50:17 +02:00
Alexis Lahouze
ca64dcd4e2 Use angular-chart.js to draw balance chart. 2017-06-18 00:46:27 +02:00
Alexis Lahouze
86c32772c0 Cleanup unused services. 2017-06-18 00:45:25 +02:00
Alexis Lahouze
1bfd7693dd Cleanup unused events. 2017-06-18 00:44:14 +02:00
Alexis Lahouze
66a19034dd Replace load arguments by controller variables, in order to link them to input controls later. 2017-06-18 00:43:28 +02:00
Alexis Lahouze
a32b344b2c Remove last references to xeditable. 2017-06-17 00:27:24 +02:00
Alexis Lahouze
6fc89eeb9a Remove unused dependencies. 2017-06-17 00:25:21 +02:00
Alexis Lahouze
ddb0b08ef2 Use angular-ui-bootstrap instead of ngBootbox, remove usage of xeditable. 2017-06-17 00:25:01 +02:00
Alexis Lahouze
13320602bf Rename solds to balances. 2017-06-16 23:28:34 +02:00
Alexis Lahouze
396210d924 Add missing dependency. 2017-06-16 23:22:27 +02:00
Alexis Lahouze
50c90b085c Use angular-ui-bootstrap instead of ngBootbox. 2017-06-16 23:22:07 +02:00
Alexis Lahouze
f75e65a3de Fiw operation column name. 2017-06-16 22:27:17 +02:00
Alexis Lahouze
e433aed773 Improve operation workflow. 2017-06-16 22:26:49 +02:00
Alexis Lahouze
4f3c196179 Use angular-ui-bootstrap for Operation deletion confirmation modal. 2017-06-15 17:21:17 +02:00
Alexis Lahouze
69d0e06b57 Remove unused function. 2017-06-15 08:47:15 +02:00
Alexis Lahouze
9acaa4033e Use angular-ui-bootstrap for Operation modal. 2017-06-15 08:46:53 +02:00
Alexis Lahouze
3537470cff Cleanup. 2017-06-14 22:21:25 +02:00
Alexis Lahouze
c6586ad224 Remove unused import. 2017-06-14 22:20:28 +02:00
Alexis Lahouze
e364b1e3ef Remove unused code. 2017-06-14 22:14:40 +02:00
Alexis Lahouze
13766be8cb Fix object field name. 2017-06-14 22:13:25 +02:00
Alexis Lahouze
17d41d7f99 Fix operation order. 2017-06-14 22:12:52 +02:00
Alexis Lahouze
7fbb9d7bcd Remove uninstalled formatter. 2017-06-14 22:12:01 +02:00
Alexis Lahouze
060f9a01b6 Remove unused rule. 2017-06-11 09:24:36 +02:00
Alexis Lahouze
20f50d533a Remove eslint formatter. 2017-06-11 09:24:23 +02:00
Alexis Lahouze
23d1189591 Ignore auth on login API call. 2017-06-11 09:18:19 +02:00
Alexis Lahouze
e494967888 Remove data in login form. 2017-06-11 09:18:00 +02:00
Alexis Lahouze
eba176c000 Add cancelLogin method on LoginService. 2017-06-11 09:17:42 +02:00
Alexis Lahouze
3d5f211824 Style. 2017-06-11 09:17:09 +02:00
Alexis Lahouze
5c4e77d6bb Remove modal config. 2017-06-11 09:17:02 +02:00
Alexis Lahouze
353ca4fef1 Rename module. 2017-06-11 09:16:44 +02:00
Alexis Lahouze
feef3d825c Merge config functions. 2017-06-11 08:07:48 +02:00
Alexis Lahouze
86911c106d Improve login dialog. 2017-06-11 01:14:26 +02:00
Alexis Lahouze
3697ff9f21 Use angular-ui-bootstrap for login modal. 2017-06-11 00:48:03 +02:00
Alexis Lahouze
c907c56c4a Cleanup. 2017-06-10 23:13:08 +02:00
Alexis Lahouze
3f90c33a3a Move up all sources in src directory. 2017-06-10 23:09:57 +02:00
Alexis Lahouze
b5804f5d21 Remove unused style. 2017-06-10 22:55:06 +02:00
Alexis Lahouze
cecfa6db4f Remove unused controller. 2017-06-10 22:54:13 +02:00
Alexis Lahouze
f4d0988fdd Move login handling in a separate module. 2017-06-10 22:50:48 +02:00
Alexis Lahouze
5627746e98 Disable HTML linter. 2017-06-10 22:07:27 +02:00
Alexis Lahouze
9eed69363f Move templates, improve inclusion. 2017-06-10 22:06:36 +02:00
Alexis Lahouze
12414a9dc7 Move modules in subfolders. 2017-06-10 21:10:52 +02:00
Alexis Lahouze
00dac1dec7 Completely remove charts. 2017-06-10 21:01:39 +02:00
Alexis Lahouze
0965498145 Remove unneeded import. 2017-06-10 21:01:01 +02:00
Alexis Lahouze
65c9262257 Force load of some data. 2017-06-10 20:59:25 +02:00
Alexis Lahouze
23f414b2d5 Fix template URL. 2017-06-10 20:46:41 +02:00
Alexis Lahouze
3e287cb7f4 Fix element finding. 2017-06-10 20:36:36 +02:00
Alexis Lahouze
9fe38b2560 Rename accountant-ui dir to src. 2017-06-10 20:24:51 +02:00
Alexis Lahouze
3c4a67a952 Disable buggy graphs. 2017-06-10 18:19:13 +02:00
Alexis Lahouze
548c4ae23e Fix authentication process. 2017-06-10 18:19:00 +02:00
Alexis Lahouze
c3daad9cd7 Fix angular route urls. 2017-06-10 18:08:31 +02:00
Alexis Lahouze
d24da8d56b HTML style. 2017-06-10 18:04:46 +02:00
Alexis Lahouze
de5e89b155 Add style dependencies. 2017-06-10 18:04:02 +02:00
Alexis Lahouze
c8cfed2018 Fix template paths. 2017-06-10 18:03:08 +02:00
Alexis Lahouze
a9c45119d6 Fix API URI. 2017-06-10 18:02:34 +02:00
Alexis Lahouze
5c25d5c79f Use webpack. 2017-06-10 18:02:19 +02:00
Alexis Lahouze
1a43135e55 Improve gitignore. 2017-06-10 17:59:53 +02:00
Alexis Lahouze
150aca8269 Add webpack bootstrap. 2017-06-10 15:48:20 +02:00
Alexis Lahouze
c895d5cc4d Use ejs template for index file. 2017-06-10 15:35:10 +02:00
Alexis Lahouze
28229ea954 Use webpack. 2017-06-10 15:34:10 +02:00
Alexis Lahouze
91a77b776f Remove grunt and bower. 2017-06-10 14:40:00 +02:00
Alexis Lahouze
8b6c179c84 Move less file. 2016-10-15 22:03:34 +02:00
Alexis Lahouze
35b5a4d2a1 Fix name of less subtask. 2016-10-15 21:51:19 +02:00
Alexis Lahouze
cc94ec1ca6 Less linting. 2016-10-15 21:50:02 +02:00
Alexis Lahouze
542bce0ab6 Add less plugin. 2016-10-15 21:40:20 +02:00
Alexis Lahouze
6eeaf76e96 Use less format. 2016-10-15 21:39:25 +02:00
Alexis Lahouze
07ea908c73 Add csslint for frontend linting. 2016-10-15 13:46:08 +02:00
Alexis Lahouze
189d76fc22 Fix typo. 2016-10-15 13:09:17 +02:00
Alexis Lahouze
3d7bafd7e1 Manage modelines. 2016-10-15 13:03:28 +02:00
Alexis Lahouze
47ed5a2b5c Improve grunt tasks dependencies. 2016-10-15 12:50:57 +02:00
Alexis Lahouze
4c0a37495f Fix dist path. 2016-10-15 11:56:02 +02:00
Alexis Lahouze
3435c50ca0 Remove old dependency. 2016-10-15 11:50:38 +02:00
Alexis Lahouze
49135f0873 Upgrade dev dependencies. 2016-10-15 11:48:47 +02:00
Alexis Lahouze
5e2ac3b833 Remove old dependencies. 2016-10-15 11:48:15 +02:00
Alexis Lahouze
cfc0db2507 Style. 2016-10-15 11:46:17 +02:00
Alexis Lahouze
a2996a5074 Update dependencies. 2016-10-15 11:46:03 +02:00
Alexis Lahouze
8cad18d5ea Review toolchain. 2016-10-15 11:45:39 +02:00
Alexis Lahouze
96a553c130 Remove unused jquery from eslint plugins. 2016-10-15 11:44:17 +02:00
Alexis Lahouze
0b713fad34 Add Angular eslint plugin. 2016-10-14 18:19:13 +02:00
Alexis Lahouze
dbef4039bd Add jsonlint dependency. 2016-10-14 18:18:48 +02:00
Alexis Lahouze
727b2fc313 Fix eslint errors again. 2016-10-14 09:20:02 +02:00
Alexis Lahouze
43714c1b1d Remove unused $http in controllers. 2016-10-14 09:02:44 +02:00
Alexis Lahouze
cfe4904084 Remove unecessary globals. 2016-10-14 09:01:21 +02:00
Alexis Lahouze
81434d7fde Fix eslint errors again. 2016-10-14 09:00:55 +02:00
Alexis Lahouze
97d23c5bcd Add vim modeline. 2016-10-14 08:52:24 +02:00
Alexis Lahouze
e39d2813df Fix controller names in views. 2016-10-14 08:52:10 +02:00
Alexis Lahouze
bff2d826dc Fix event handling and emiting. 2016-10-14 08:51:35 +02:00
Alexis Lahouze
8ebe15f22f Move API call in dedicated service. 2016-10-14 08:50:54 +02:00
Alexis Lahouze
f12c89a9ee Fix angular style issues. 2016-10-14 08:21:43 +02:00
Alexis Lahouze
4aed242a48 Fix angular style issues. 2016-10-14 08:19:58 +02:00
Alexis Lahouze
e91bf14298 Fix angular style issues. 2016-10-14 08:19:23 +02:00
Alexis Lahouze
edac1ee6a9 Fix angular style issues. 2016-10-14 07:50:06 +02:00
Alexis Lahouze
a872788def Fix angular style issues. 2016-10-12 23:32:54 +02:00
Alexis Lahouze
032dd9bdc6 Use YAML syntax instead of JSON. 2016-10-12 23:31:50 +02:00
Alexis Lahouze
5811541722 Invert conditions. 2016-10-12 19:59:09 +02:00
Alexis Lahouze
606cde59f8 Use eslint and be compliant. (mostly) 2016-10-12 19:57:19 +02:00
Alexis Lahouze
d7ead2aa5c Style with jscs. 2016-10-09 20:33:59 +02:00
Alexis Lahouze
9f0258905d Style with jscs. 2016-10-09 20:22:21 +02:00
Alexis Lahouze
83b43dfff5 Add wiredep in jsdev task. 2016-10-09 20:20:21 +02:00
Alexis Lahouze
e5721b3573 Style with jscs. 2016-10-09 20:17:11 +02:00
Alexis Lahouze
655d72d4ae Remove too much spaces. 2016-07-15 16:50:05 +02:00
Alexis Lahouze
d0fca63dd7 Add missing Account parameter. 2016-07-15 16:46:27 +02:00
Alexis Lahouze
a045fd77d7 Improve forms. 2016-07-15 16:40:39 +02:00
Alexis Lahouze
f4df257548 Update .gitignore. 2016-06-19 22:18:28 +02:00
Alexis Lahouze
f09ba377b5 Fix flask invokaction from grunt. 2016-06-17 10:54:02 +02:00
Alexis Lahouze
f8a71af4d8 Remove old SQL stuff. 2016-06-17 10:18:24 +02:00
Alexis Lahouze
7aee85c08f Move remaining stuff in manage.py to application. 2016-06-17 10:17:44 +02:00
Alexis Lahouze
38da04a412 Move migrations in application. 2016-06-17 09:52:08 +02:00
Alexis Lahouze
1a9363b723 Update make template for revision making. 2016-06-17 09:51:23 +02:00
Alexis Lahouze
7d1d9bbcc8 Add missing license. 2016-05-24 08:56:32 +02:00
Alexis Lahouze
1660c7a635 Set operation edition in form dialog. 2016-05-24 08:53:15 +02:00
80 changed files with 2144 additions and 2519 deletions

View File

@ -1,3 +0,0 @@
{
"directory": "accountant-ui/bower_components"
}

147
.gitignore vendored
View File

@ -1,100 +1,19 @@
# Created by https://www.gitignore.io
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
.vimrc
.vimtags
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
### grunt ###
# Grunt usually compiles files inside this directory
dist/
# Grunt usually preprocesses files such as coffeescript, compass... inside the .tmp directory
.tmp/
### Bower ###
bower_components
.bower-cache
.bower-registry
.bower-tmp
# Created by https://www.gitignore.io/api/vim,node
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
@ -102,20 +21,64 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# Yarn Lock file
yarn.lock
# dotenv environment variables file
.env
### Local files ###
config.cfg
/flask_session
### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags
# End of https://www.gitignore.io/api/vim,node
/build

35
.jscsrc Normal file
View File

@ -0,0 +1,35 @@
{
"preset": "google",
"fileExtensions": [".js", "jscs"],
"requireSemicolons": true,
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 120,
"validateLineBreaks": "LF",
"validateIndentation": 4,
"disallowTrailingComma": true,
"disallowUnusedParams": true,
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": ["string"],
"safeContextKeyword": "_this",
"jsDoc": {
"checkAnnotations": "closurecompiler",
"checkParamNames": true,
"requireParamTypes": true,
"checkRedundantParams": true,
"checkReturnTypes": true,
"checkRedundantReturns": true,
"requireReturnTypes": true,
"checkTypes": "capitalizedNativeCase",
"checkRedundantAccess": true,
"requireNewlineAfterDescription": true
},
"excludeFiles": [
"test/data/**",
"patterns/*"
]
}

View File

@ -1,21 +0,0 @@
{
"bitwise": true,
"browser": true,
"curly": true,
"eqeqeq": true,
"esnext": true,
"latedef": true,
"noarg": true,
"node": true,
"strict": true,
"undef": true,
"unused": true,
"quotmark": "single",
"indent": 2,
"jquery": true,
"globals": {
"angular": false,
"moment": false,
"Highcharts": false
}
}

View File

@ -1,75 +0,0 @@
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
// Options
var options = {
accountant: {
frontend: {
app: require('./bower.json'),
src: 'accountant-ui',
dist: 'accountant-ui_dist'
}
},
config: {
src: 'grunt-config/*.js'
},
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %>\n'+
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> */\n',
};
var configs = require('load-grunt-configs')(grunt, options);
grunt.initConfig(configs);
grunt.registerTask('dependencies', [
'shell:npm_install',
'shell:bower_install',
'shell:pip_install',
'wiredep:app',
]);
grunt.registerTask('pydev', [
'newer:flake8'
]);
grunt.registerTask('jsdev', [
'newer:jshint',
'newer:jscs'
]);
grunt.registerTask('htmldev', [
'newer:htmllint'
]);
grunt.registerTask('dev', [
'dependencies',
'pydev',
'jsdev',
'htmldev'
]);
grunt.registerTask('serve', [
'dev',
'bgShell:runserver',
'connect:livereload',
'watch'
]);
grunt.registerTask('dist', [
'wiredep',
'clean:dist',
'useminPrepare',
'copy:dist',
'copy:styles',
'cssmin:generated',
'concat:generated',
'ngAnnotate',
'uglify:generated',
'filerev',
'usemin'
]);
};

View File

@ -1,7 +0,0 @@
.italic {
font-style: italic
}
.stroke {
text-decoration: line-through
}

View File

@ -1,96 +0,0 @@
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<!-- Title -->
<title>Accountant</title>
<!-- build:css(accountant-ui) css/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="bower_components/bootstrap-additions/dist/bootstrap-additions.css" />
<link rel="stylesheet" href="bower_components/angular-xeditable/dist/css/xeditable.css" />
<link rel="stylesheet" href="bower_components/angular-ui-notification/dist/angular-ui-notification.css" />
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- Custom styles -->
<!-- build:css(.tmp) css/main.css -->
<!-- include: "type": "css", "files": "css/*.css" -->
<link href="css/main.css" rel="stylesheet" type="text/css">
<!-- /include -->
<!-- endbuild -->
</head>
<!-- htmllint attr-bans="false" -->
<body style="padding-bottom: 50px; padding-top: 70px" ng-app="accountant">
<!-- htmllint attr-bans="$previous" -->
<!-- Navbar -->
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container-fluid">
<!-- Brand -->
<div class="navbar-header">
<a class="navbar-brand" href="#/accounts">&nbsp;Accountant</a>
</div>
</div>
</nav>
<div class="container-fluid" ng-controller="MainController">
<div ng-view></div>
</div>
<!-- build:js(accountant-ui) js/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-strap/dist/angular-strap.js"></script>
<script src="bower_components/angular-strap/dist/angular-strap.tpl.js"></script>
<script src="bower_components/angular-xeditable/dist/js/xeditable.js"></script>
<script src="bower_components/angular-ui-notification/dist/angular-ui-notification.js"></script>
<script src="bower_components/highcharts-ng/dist/highcharts-ng.js"></script>
<script src="bower_components/highstock-release/highstock.js"></script>
<script src="bower_components/highstock-release/highcharts-more.js"></script>
<script src="bower_components/highstock-release/modules/exporting.js"></script>
<script src="bower_components/angular-http-auth/src/http-auth-interceptor.js"></script>
<script src="bower_components/meanie-angular-storage/release/meanie-angular-storage.js"></script>
<script src="bower_components/bootbox/bootbox.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/ngBootbox/dist/ngBootbox.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- Custom Javascript libraries -->
<!-- build:js({.tmp,accountant-ui}) js/scripts.js -->
<!-- include: "type": "js", "files": "js/*.js" -->
<script src="js/accounts.js"></script>
<script src="js/app.js"></script>
<script src="js/operations.js"></script>
<script src="js/scheduler.js"></script>
<!-- /include -->
<!-- endbuild -->
</body>
</html>

View File

@ -1,211 +0,0 @@
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
// vim: set tw=80 ts=2 sw=2 sts=2:
'use strict';
angular.module('accountant.accounts', [
'ngResource',
'ui-notification',
'xeditable',
'ngBootbox'
])
.config(['$resourceProvider', function($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask..
$resourceProvider.defaults.stripTrailingSlashes = false;
}])
.factory('Account', ['$resource', function($resource) {
var Account = $resource(
'/api/account/:id', {
id: '@id'
}
);
Account.prototype.getSolds = function() {
var Solds = $resource('/api/account/:id/solds', {id: this.id});
this.solds = Solds.get();
};
Account.prototype.getBalance = function(begin, end) {
var Balance = $resource(
'/api/account/:id/balance', {
id: this.id,
begin: begin.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD')
});
this.balance = Balance.get();
};
return Account;
}])
.controller(
'AccountController', [
'$scope', '$ngBootbox', 'Account', 'Notification',
function($scope, $ngBootbox, Account, Notification) {
/*
* Return the class for an account current value compared to authorized
* overdraft.
*/
$scope.rowClass = function(account) {
if(!account || !account.authorized_overdraft || !account.current) {
return;
}
if(account.current < account.authorized_overdraft) {
return 'danger';
} else if(account.current < 0) {
return 'warning';
}
};
/*
* Return the class for a value compared to account authorized overdraft.
*/
$scope.valueClass = function(account, value) {
if(!account || !value) {
return;
}
if(value < account.authorized_overdraft) {
return 'text-danger';
} else if(value < 0) {
return 'text-warning';
}
};
/*
* Add an empty account.
*/
$scope.add = function() {
var account = new Account({
authorized_overdraft: 0
});
// Insert account at the begining of the array.
$scope.accounts.splice(0, 0, account);
};
/*
* Cancel account edition. Remove it from array if a new one.
*/
$scope.cancelEdit = function(rowform, account, $index) {
if(!account.id) {
// Account not saved, just remove it from array.
$scope.accounts.splice($index, 1);
} else {
rowform.$cancel();
}
};
/*
* Save account.
*/
$scope.save = function(account) {
//var account = $scope.accounts[$index];
//account = angular.merge(account, $data);
return account.$save().then(function(data) {
Notification.success('Account #' + data.id + ' saved.');
// TODO Alexis Lahouze 2016-03-08 Update solds
return data;
});
};
/*
* Delete an account.
*/
$scope.delete = function(account, $index) {
var id = account.id;
$ngBootbox.confirm(
'Voulez-vous supprimer le compte \'' + account.name + '\' ?',
function(result) {
if(result) {
account.$delete().then(function() {
Notification.success('Account #' + id + ' deleted.');
// Remove account from array.
$scope.accounts.splice($index, 1);
});
}
}
);
};
// Load accounts.
$scope.accounts = Account.query();
}])
.directive(
'accountFormDialog', function($ngBootbox) {
return {
restrict: 'A',
scope: {
account: '=ngModel'
},
link: function(scope, element) {
var title = 'Account';
if(scope.account && scope.account.id) {
title = title + ' #' + scope.account.id;
}
scope.form = {};
element.on('click', function() {
//angular.copy(scope.account, scope.form);
// Open dialog with form.
$ngBootbox.customDialog({
scope: scope,
title: title,
templateUrl: 'views/account.form.tmpl.html',
onEscape: true,
buttons: {
save: {
label: 'Save',
className: 'btn-success',
callback: function() {
// Validate form
console.log(scope.form);
// Save account
console.log(scope.account);
return false;
}
},
cancel: {
label: 'Cancel',
className: 'btn-default',
callback: true
}
}
});
});
}
};
});

View File

@ -1,154 +0,0 @@
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
// vim: set tw=80 ts=2 sw=2 sts=2:
'use strict';
angular.module('accountant', [
'accountant.accounts',
'accountant.operations',
'accountant.scheduler',
'ngRoute',
'ngBootbox',
'http-auth-interceptor',
'Storage.Service'
])
.factory('sessionInjector', ['$storage', function($storage) {
var sessionInjector = {
request : function(config) {
var token = $storage.get('token');
if(token) {
var token_type = $storage.get('token_type');
var authorization = token_type + ' ' + token;
config.headers.Authorization = authorization;
}
return config;
}
};
return sessionInjector;
}])
.config(['$httpProvider', function($httpProvider) {
// Define interceptors.
$httpProvider.interceptors.push('sessionInjector');
}])
.config(['$routeProvider', function($routeProvider) {
// Defining template and controller in function of route.
$routeProvider
.when('/account/:accountId/operations', {
templateUrl: 'views/operations.html',
controller: 'OperationController',
controllerAs: 'operationsCtrl'
})
.when('/account/:accountId/scheduler', {
templateUrl: 'views/scheduler.html',
controller: 'SchedulerController',
controllerAs: 'schedulerCtrl'
})
.when('/accounts', {
templateUrl: 'views/accounts.html',
controller: 'AccountController',
controllerAs: 'accountsCtrl'
})
.otherwise({
redirectTo: '/accounts'
});
}])
.config(['$storageProvider', function($storageProvider) {
// Configure storage
// Set global prefix for stored keys
$storageProvider.setPrefix('accountant');
// Change the default storage engine
// Defaults to 'local'
$storageProvider.setDefaultStorageEngine('session');
// Change the enabled storage engines
// Defaults to ['memory', 'cookie', 'session', 'local']
$storageProvider.setEnabledStorageEngines(['local', 'session']);
}])
.run(function(editableOptions) {
editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
})
.controller('MainController', [
'$scope', '$rootScope', '$http', 'authService', '$storage', '$ngBootbox',
function($scope, $rootScope, $http, authService, $storage, $ngBootbox) {
$scope.dialogShown = false;
$scope.showLoginForm = function() {
// First, if there are registered credentials, use them
if($scope.dialogShown) {
return;
}
$scope.dialogShown = true;
$storage.clear();
$ngBootbox.customDialog({
title: 'Authentification requise',
templateUrl: 'views/login.tmpl.html',
buttons: {
login: {
label: 'Login',
className: 'btn-primary',
callback: function() {
$scope.dialogShown = false;
var email = $('#email').val();
var password = $('#password').val();
$http.post(
'/api/user/login',
{
'email': email,
'password': password
}
).success(function(result) {
// TODO Alexis Lahouze 2015-08-28 Handle callback.
// Call to /api/login to retrieve the token
$storage.set('token_type', result.token_type);
$storage.set('token', result.token);
$storage.set('expiration_date', result.expiration_date);
authService.loginConfirmed();
});
}
},
cancel: {
label: 'Annuler',
className: 'btn-default',
callback: function() {
authService.loginCancelled(null, 'Login cancelled by user action.');
$scope.dialogShown = false;
}
}
}
});
};
$rootScope.$on('event:auth-loginRequired', $scope.showLoginForm);
}])
;

View File

@ -1,466 +0,0 @@
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
// vim: set tw=80 ts=2 sw=2 sts=2:
'use strict';
angular.module('accountant.operations', [
'accountant.accounts',
'ngRoute',
'ngResource',
'ngBootbox',
'ui-notification',
'mgcrea.ngStrap',
'highcharts-ng',
])
.config(['$resourceProvider', function($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask..
$resourceProvider.defaults.stripTrailingSlashes = false;
}])
.factory('Operation', [ '$resource', function($resource) {
return $resource(
'/api/operation/:id', {
id: '@id'
}
);
}])
.factory('OHLC', [ '$resource', '$routeParams',
function($resource, $routeParams) {
return $resource(
'/api/account/:account_id/ohlc', {
account_id: $routeParams.accountId
}
);
}])
.factory('Category', [ '$resource', '$routeParams',
function($resource, $routeParams) {
return $resource(
'/api/account/:account_id/category', {
account_id: $routeParams.accountId
}
);
}])
.factory('Balance', [ '$resource', '$routeParams',
function($resource, $routeParams) {
return $resource(
'/api/account/:account_id/balance', {
account_id: $routeParams.accountId
}
);
}])
/*
* Controller for category chart.
*/
.controller(
'CategoryChartController', [
'$rootScope', '$scope', '$http', 'Category', 'Balance',
function($rootScope, $scope, $http, Category, Balance) {
var colors = Highcharts.getOptions().colors;
$scope.revenueColor = colors[2];
$scope.expenseColor = colors[3];
// Configure pie chart for categories.
$scope.config = {
options: {
chart: {
type: 'pie',
animation: {
duration: 500
}
},
plotOptions: {
pie: {
startAngle: -90
},
series: {
allowPointSelect: 0
}
},
tooltip: {
valueDecimals: 2,
valueSuffix: '€'
}
},
yAxis: {
title: {
text: 'Categories'
}
},
title: {
text: 'Répartition dépenses/recettes'
},
series: [{
name: 'Value',
data: [],
innerSize: '33%',
size: '60%',
dataLabels: {
formatter: function() {
return this.point.name;
},
distance: -40
}
}, {
name: 'Value',
data: [],
innerSize: '66%',
size: '60%',
dataLabels: {
formatter: function() {
return this.point.name !== null && this.percentage >= 2.5 ? this.point.name : null;
},
}
}]
};
$scope.brightenColor = function(color) {
var brightness = 0.2;
return Highcharts.Color(color).brighten(brightness).get();
};
// Load categories, mainly to populate the pie chart.
$scope.load = function(begin, end) {
$scope.config.loading = true;
Category.query({
begin: begin.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD')
}, function(data) {
var expenses = [], revenues = [];
var expenseColor = $scope.brightenColor($scope.expenseColor);
var revenueColor = $scope.brightenColor($scope.revenueColor);
angular.forEach(angular.fromJson(data), function(category) {
expenses.push({
name: category.category,
y: -category.expenses,
color: expenseColor
});
revenues.push({
name: category.category,
y: category.revenues,
color: revenueColor
});
});
// Note: expenses and revenues must be in the same order than in series[0].
$scope.config.series[1].data = revenues.concat(expenses);
$scope.config.loading = false;
});
};
/*
* Get account balance.
*/
$scope.getBalance = function(begin, end) {
Balance.get({
begin: begin.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD')
}, function(balance) {
// Update pie chart subtitle with Balance.
$scope.config.subtitle = {
text: 'Balance: ' + balance.balance
};
$scope.config.series[0].data = [{
name: 'Revenues',
y: balance.revenues,
color: $scope.revenueColor
}, {
name: 'Expenses',
y: -balance.expenses,
color: $scope.expenseColor,
}];
});
};
// Reload categories and account status on range selection.
$rootScope.$on('rangeSelectedEvent', function(e, args) {
$scope.load(args.begin, args.end);
$scope.getBalance(args.begin, args.end);
});
}])
/*
* Controller for the sold chart.
*/
.controller(
'SoldChartController', [
'$rootScope', '$scope', '$http', 'OHLC',
function($rootScope, $scope, $http, OHLC) {
// Configure chart for operations.
$scope.config = {
options: {
chart: {
zoomType: 'x'
},
rangeSelector: {
buttons: [{
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 3,
text: '3m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
selected: 0,
},
navigator: {
enabled: true
},
tooltip: {
crosshairs: true,
shared: true,
valueDecimals: 2,
valueSuffix: '€'
},
scrollbar: {
liveRedraw: false
}
},
series: [{
type: 'ohlc',
name: 'Sold',
data: [],
dataGrouping : {
units : [[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]]
}
}],
title: {
text: 'Sold evolution'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
month: '%e. %b',
year: '%Y'
},
minRange: 3600 * 1000 * 24 * 14, // 2 weeks
events: {
afterSetExtremes: function(e) {
$scope.$emit('rangeSelectedEvent', {
begin: moment.utc(e.min), end: moment.utc(e.max)
});
}
},
currentMin: moment.utc().startOf('month'),
currentMax: moment.utc().endOf('month')
},
yAxis: {
plotLines: [{
color: 'orange',
width: 2,
value: 0.0
}, {
color: 'red',
width: 2,
value: 0.0
}]
},
useHighStocks: true
};
$scope.loadSolds = function() {
$scope.config.loading = true;
OHLC.query({}, function(data) {
$scope.config.series[0].data = [];
angular.forEach(data, function(operation) {
$scope.config.series[0].data.push([
moment.utc(operation.operation_date).valueOf(),
operation.open, operation.high, operation.low, operation.close
]);
});
$scope.$emit('rangeSelectedEvent', {
begin: $scope.config.xAxis.currentMin,
end: $scope.config.xAxis.currentMax
});
$scope.config.loading = false;
});
};
// Reload solds when an operation is saved.
$rootScope.$on('operationSavedEvent', function() {
$scope.loadSolds();
});
// Reload solds when an operation is deleted.
$rootScope.$on('operationDeletedEvent', function() {
$scope.loadSolds();
});
// Update authorized overdraft on account loading.
$rootScope.$on('accountLoadedEvent', function(e, account) {
$scope.config.yAxis.plotLines[1].value = account.authorized_overdraft;
});
// Select beginning and end of month.
$scope.loadSolds();
}])
/*
* Controller for the operations.
*/
.controller(
'OperationController', [
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'Account', 'Operation',
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, Account, Operation) {
// List of operations.
$scope.operations = [];
/*
* Add an empty operation.
*/
$scope.add = function() {
var operation = new Operation({
account_id: $routeParams.accountId
});
$scope.operations.splice(0, 0, operation);
};
/*
* Load operations.
*/
$scope.load = function(begin, end) {
$scope.operations = Operation.query({
account_id: $routeParams.accountId,
begin: begin.format('YYYY-MM-DD'),
end: end.format('YYYY-MM-DD')
});
};
/*
* Cancel edition.
*/
$scope.cancelEdit = function(operation, rowform, $index) {
if(!operation.id) {
$scope.operations.splice($index, 1);
} else {
rowform.$cancel();
}
};
/*
* Toggle pointed indicator for an operation.
*/
$scope.togglePointed = function(operation, rowform) {
operation.pointed = !operation.pointed;
// Save operation if not editing it.
if(!rowform.$visible) {
$scope.save(operation);
}
};
/*
* Toggle cancel indicator for an operation.
*/
$scope.toggleCanceled = function(operation) {
operation.canceled = !operation.canceled;
$scope.save(operation);
};
/*
* Save an operation and emit operationSavedEvent.
*/
$scope.save = function($data, $index) {
// Check if $data is already a resource.
var operation;
if($data.$save) {
operation = $data;
} else {
operation = $scope.operations[$index];
operation = angular.merge(operation, $data);
}
operation.confirmed = true;
return operation.$save().then(function(data) {
Notification.success('Operation #' + data.id + ' saved.');
$scope.$emit('operationSavedEvent', data);
});
};
/*
* Delete an operation and emit operationDeletedEvent.
*/
$scope.delete = function(operation, $index) {
var id = operation.id;
$ngBootbox.confirm(
'Voulez-vous supprimer l\'opération \\\'' + operation.label + '\\\' ?',
function(result) {
if(result) {
operation.$delete().then(function() {
Notification.success('Operation #' + id + ' deleted.');
// Remove operation from array.
$scope.operation.splice($index, 1);
$scope.$emit('operationDeletedEvent', operation);
});
}
}
);
};
$scope.account = Account.get({
id: $routeParams.accountId
});
/*
* Reload operations on rangeSelectedEvent.
*/
$rootScope.$on('rangeSelectedEvent', function(e, args) {
$scope.load(args.begin, args.end);
});
}]);

View File

@ -1,120 +0,0 @@
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
// vim: set tw=80 ts=2 sw=2 sts=2:
'use strict';
angular.module('accountant.scheduler', [
'ngRoute',
'ngBootbox',
'ui-notification',
'mgcrea.ngStrap'
])
.config(['$resourceProvider', function($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask..
$resourceProvider.defaults.stripTrailingSlashes = false;
}])
.factory('ScheduledOperation', ['$resource', function($resource) {
return $resource(
'/api/scheduled_operation/:id', {
id: '@id'
}
);
}])
.controller(
'SchedulerController', [
'$scope', '$rootScope', '$routeParams', '$ngBootbox', 'Notification', 'ScheduledOperation',
function($scope, $rootScope, $routeParams, $ngBootbox, Notification, ScheduledOperation) {
// Operation store.
$scope.operations = [];
/*
* Add a new operation at the beginning of th array.
*/
$scope.add = function() {
var operation = new ScheduledOperation({
account_id: $routeParams.accountId
});
// Insert new operation at the beginning of the array.
$scope.operations.splice(0, 0, operation);
};
/*
* Load operations.
*/
$scope.load = function() {
$scope.operations = ScheduledOperation.query({
account_id: $routeParams.accountId
});
};
/*
* Save operation.
*/
$scope.save = function($data, $index) {
var operation;
if($data.$save) {
operation = $data;
} else {
operation = $scope.operations[$index];
operation = angular.merge(operation, $data);
}
return operation.$save().then(function(data) {
Notification.success('Operation #' + data.id + ' saved.');
});
};
/*
* Cancel operation edition. Delete if new.
*/
$scope.cancelEdit = function(operation, rowform, $index) {
if(!operation.id) {
$scope.operations.splice($index, 1);
} else {
rowform.$cancel();
}
};
/*
* Delete operation.
*/
$scope.delete = function(operation, $index) {
var id = operation.id;
$ngBootbox.confirm(
'Voulez-vous supprimer l\'operation planifiée \\\'' + operation.label + '\\\' ?',
function(result) {
if(result) {
operation.$delete().then(function() {
Notification.success('Operation #' + id + ' deleted.');
// Remove account from array.
$scope.operations.splice($index, 1);
});
}
}
);
};
// Load operations on controller initialization.
$scope.load();
}]);

View File

@ -1,22 +0,0 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<form class="form-horizontal" role="form" name="form">
<div class="form-group">
<label class="col-sm-4 control-label" for="name">Account name</label>
<div class="col-sm-8">
<input id="name" class="form-control"
name="name" ng-model="account.name"
placeholder="Account name" type="text">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="authorized-overdraft">Authorized overdraft</label>
<div class="col-sm-8">
<input id="authorized-overdraft" class="form-control" type="number"
name="authorized_overdraft" ng-model="account.authorized_overdraft"
placeholder="Authorized overdraft">
</input>
</div>
</div>
</form>

View File

@ -1,18 +0,0 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<form class="form-horizontal">
<div class="form-group">
<label for="email" class="col-sm-4 control-label">Adresse email</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="email" ng-model="email"
placeholder="Nom d'utilisateur">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-4 control-label">Mot de passe</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="password" ng-model="password" placeholder="Mot de passe">
</div>
</div>
</form>

View File

@ -1,152 +0,0 @@
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div>
<!-- Chart row -->
<div class="row">
<!-- Sold evolution chart placeholder -->
<div class="col-md-8" ng-controller="SoldChartController">
<highchart id="sold-chart" config="config"></highchart>
</div>
<!-- Category piechart -->
<div class="col-md-4" ng-controller="CategoryChartController">
<highchart id="categories-chart" config="config"></highchart>
</div>
</div>
<div class="row">
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="col-md-1">Date d'op.</th>
<th>Libell&eacute; de l'op&eacute;ration</th>
<th class="col-md-1">Montant</th>
<th class="col-md-1">Solde</th>
<th class="col-md-2">Cat&eacute;gorie</th>
<th class="col-md-2">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="6">
<button class="btn btn-success" ng-click="add()">
Ajouter
</button>
</td>
</tr>
<tr id="{{ operation.id }}" class="form-inline"
ng-class="{stroke: operation.canceled, italic: !operation.confirmed, warning: operation.sold < 0, danger: operation.sold < account.authorized_overdraft}"
ng-repeat="operation in operations | orderBy:['-operation_date', '-value', 'label']">
<td>
<span editable-text="operation.operation_date"
e-data-date-format="yyyy-MM-dd" e-bs-datepicker
e-timezone="UTC"
e-class="input-sm" e-style="width: 100%"
e-name="operation_date" e-form="rowform" e-required>
{{ operation.operation_date | date:"yyyy-MM-dd" }}
</span>
</td>
<td>
<span editable-text="operation.label"
e-placeholder="Libellé de l'opération"
e-class="input-sm" e-style="width: 100%"
e-name="label" e-form="rowform" e-required>
{{ operation.label }}
</span>
</td>
<td>
<span editable-number="operation.value"
e-class="input-sm" e-style="width: 100%"
e-name="value" e-form="rowform" e-required>
{{ operation.value | currency:"€" }}
</span>
</td>
<td ng-class="{'text-warning': operation.sold < 0, 'text-danger': operation.sold < account.authorized_overdraft}">
{{ operation.sold | currency:"€" }}
</td>
<td>
<span editable-text="operation.category"
e-placeholder="Catégorie"
e-class="input-sm" e-style="width: 100%"
e-name="category" e-form="rowform" e-required>
{{ operation.category }}
</span>
</td>
<td>
<form editable-form name="rowform"
onbeforesave="save($data, $index)"
shown="!operation.id">
<div class="btn-group btn-group-xs">
<!-- Save current operation, for editing and non-confirmed non-canceled operation. -->
<button type="submit" class="btn btn-success"
ng-if="!operation.canceled && (!operation.confirmed || rowform.$visible)"
title="Save">
<span class="fa fa-floppy-o"></span>
</button>
<!-- Edit operation, for non-canceled and non-editing operation -->
<button type="button" class="btn btn-default"
ng-if="!operation.canceled && !rowform.$visible"
ng-click="rowform.$show()" title="edit">
<span class="fa fa-pencil-square-o"></span>
</button>
<!-- Cancel edition, for editing operation. -->
<button type="button" class="btn btn-default"
ng-if="rowform.$visible"
ng-click="cancelEdit(operation, rowform)">
<span class="fa fa-times"></span>
</button>
<!-- Toggle pointed operation, for non-canceled operations. -->
<button type="button" class="btn btn-default"
ng-if="!operation.canceled"
ng-click="togglePointed(operation, rowform)"
ng-class="{active: operation.pointed}" title="point">
<span ng-class="{'fa fa-check-square-o': operation.pointed, 'fa fa-square-o': !operation.pointed}"></span>
</button>
<!-- Toggle canceled operation, for non-editing operations. -->
<button type="button" class="btn btn-default"
ng-click="toggleCanceled(operation)"
ng-if="operation.scheduled_operation_id && !rowform.$visible"
ng-class="{active: operation.canceled}" title="cancel">
<span class="fa fa-remove"></span>
</button>
<!-- Delete operation, with confirm. -->
<button type="button" class="btn btn-default"
ng-if="operation.id && !operation.scheduled_operation_id"
ng-click="delete(operation, $index)">
<span class="fa fa-trash-o"></span>
</button>
</div>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -1,142 +0,0 @@
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="row">
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="col-md-1">Date de d&eacute;but</th>
<th class="col-md-1">Date de fin</th>
<th class="col-md-1">Jour</th>
<th class="col-md-1">Fr&eacute;q.</th>
<th>Libell&eacute; de l'op&eacute;ration</th>
<th class="col-md-1">Montant</th>
<th class="col-md-2">Cat&eacute;gorie</th>
<th class="col-md-1">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="8">
<button class="btn btn-success" ng-click="add()">
Ajouter
</button>
</td>
</tr>
<tr id="{{ operation.id }}" class="form-inline"
ng-repeat="operation in operations">
<td class="col-md-1">
<span editable-text="operation.start_date"
e-style="width: 100%"
e-bs-datepicker e-data-date-format="yyyy-MM-dd"
e-name="start_date" e-form="rowform" e-required>
{{ operation.start_date | date: "yyyy-MM-dd" }}
</span>
</td>
<td>
<span editable-text="operation.stop_date"
e-style="width: 100%"
e-bs-datepicker e-data-date-format="yyyy-MM-dd"
e-name="stop_date" e-form="rowform" e-required>
{{ operation.stop_date | date: "yyyy-MM-dd" }}
</span>
</td>
<td>
<span editable-number="operation.day"
e-style="width: 100%"
e-name="day" e-form="rowform" e-required>
{{ operation.day }}
</span>
</td>
<td>
<span editable-number="operation.frequency"
e-style="width: 100%"
e-name="frequency" e-form="rowform" e-required>
{{ operation.frequency }}
</span>
</td>
<td>
<span editable-text="operation.label"
e-style="width: 100%"
e-placeholder="Libellé de l'opération"
e-name="label" e-form="rowform" e-required>
{{ operation.label }}
</span>
</td>
<td>
<span editable-number="operation.value"
e-style="width: 100%"
e-name="value" e-form="rowform" e-required>
{{ operation.value | currency : "€" }}
</span>
</td>
<td>
<span editable-text="operation.category"
e-style="width: 100%"
e-name="category" e-form="rowform">
{{ operation.category }}
</span>
</td>
<td>
<form editable-form name="rowform"
onbeforesave="save($data, $index)"
shown="!operation.id">
<div class="btn-group btn-group-xs">
<!-- Save current operation -->
<button type="submit" class="btn btn-success"
ng-if="rowform.$visible" title="Save">
<span class="fa fa-floppy-o"></span>
</button>
<!-- Edit operation. -->
<button type="button" class="btn btn-default"
ng-if="!rowform.$visible"
ng-click="rowform.$show()" title="edit">
<span class="fa fa-pencil-square-o"></span>
</button>
<!-- Cancel edit. -->
<button type="button" class="btn btn-default"
ng-if="rowform.$visible"
ng-click="cancelEdit(operation, rowform, $index)"
title="Cancel">
<span class="fa fa-times"></span>
</button>
<!-- Remove operation. -->
<button type="button" class="btn btn-default"
ng-if="operation.id"
ng-click="delete(operation, $index)"
title="remove">
<span class="fa fa-trash"></span>
</button>
</div>
</form>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,54 +0,0 @@
{
"name": "accountant",
"version": "0.1.0",
"authors": [
"Alexis Lahouze <xals@lahouze.org>"
],
"license": "AGPL",
"main": [
"accountant-ui/index.html",
"accountant-ui/js/app.js"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "~2.2",
"moment": "~2.12",
"bootstrap": "~3.3.6",
"bootstrap-additions": "~0.3.1",
"angular": "~1.5",
"angular-resource": "~1.5",
"angular-route": "~1.5",
"angular-strap": "~2.3.6",
"angular-xeditable": "~0.1",
"angular-ui-notification": "~0.2",
"highcharts-ng": "~0.0.11",
"highstock-release": "~4.2",
"angular-http-auth": "~1.3",
"meanie-angular-storage": "~1.1",
"font-awesome": ">=4.5.0",
"bootbox": "~4.4.0",
"angular-bootstrap": "~1.3",
"ngBootbox": "^0.1.3"
},
"overrides": {
"bootstrap": {
"main": [
"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js"
]
},
"font-awesome": {
"main": [
"./css/font-awesome.css",
"./fonts/*"
]
}
}
}

View File

@ -1,7 +0,0 @@
module.exports = {
runserver: {
cmd: 'python -m manage runserver -d -r',
fail: true,
bg: true
}
};

View File

@ -1,7 +0,0 @@
'use strict';
module.exports = {
dist: [
'<%= accountant.frontend.dist %>'
]
};

View File

@ -1,40 +0,0 @@
'use strict';
module.exports = {
options: {
port: 5001,
hostname: 'localhost',
base: '<%= accountant.frontend.src %>',
apiUrl: 'http://localhost:5000/api/',
swaggerUiUrl: 'http://localhost:5000/swaggerui/',
livereload: 1337,
},
proxies: [{
context: '/api',
host: '127.0.0.1',
port: 5000,
https: false
}, {
contect: '/swaggerui',
host: '127.0.0.1',
port: 5000,
https: false
}],
livereload: {
options: {
//open: true,
middleware: function(connect, options, middlewares) {
var connectLogger = require('connect-logger');
var connectProxy = require('connect-proxy-layer');
var apiProxy = connectProxy(options.apiUrl);
var swaggerUiProxy = connectProxy(options.swaggerUiUrl);
return [
connectLogger(),
connect().use('/api', apiProxy),
connect().use('/swaggerUi', swaggerUiProxy),
].concat(middlewares);
}
}
}
};

View File

@ -1,22 +0,0 @@
'use strict';
module.exports = {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= accountant.frontend.src %>',
dest: '<%= accountant.frontend.dist %>',
src :[
'*.html',
'views/*.html',
]
}]
},
styles: {
expand: true,
cwd: '<%= accountant.frontend.src %>/css',
dest: '.tmp/css',
src: '{,*/}*.css'
}
};

View File

@ -1,17 +0,0 @@
'use strict';
module.exports = {
options: {
encoding: 'utf-8',
algorithm: 'md5',
length: 8
},
dist: {
src: [
'<%= accountant.frontend.dist %>/css/*.css',
'<%= accountant.frontend.dist %>/js/*.js',
'!<%= accountant.frontend.dist %>/css/*.map.css',
'!<%= accountant.frontend.dist %>/js/*.map.js'
]
},
};

View File

@ -1,7 +0,0 @@
'use strict';
module.exports = {
src: [
'accountant/**/*.py'
]
};

View File

@ -1,16 +0,0 @@
module.exports = {
frontend: {
options: {
'attr-name-style': 'dash',
'attr-req-value': false,
'id-class-ignore-regex': '{{.*?}}',
'id-class-style': 'dash',
'indent-style': 'spaces',
'indent-width': 2
},
src: [
'<%= accountant.frontend.src %>/*.html',
'<%= accountant.frontend.src %>/views/*.html'
]
}
};

View File

@ -1,13 +0,0 @@
'use strict';
module.exports = {
options: {
basePath: '<%= accountant.frontend.src %>',
baseUrl: ''
},
index: {
files: {
'<%= accountant.frontend.src %>/index.html': '<%= accountant.frontend.src %>/index.html'
}
}
};

View File

@ -1,13 +0,0 @@
module.exports = {
options: {
config: '.jscsrc',
verbose: true
},
frontend_js: [
'<%= accountant.frontend.src %>/js/*.js'
],
toolchain: [
'Gruntfile.js',
'grunt-config/*.js'
]
};

View File

@ -1,13 +0,0 @@
module.exports = {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
frontend_js: [
'<%= accountant.frontend.src %>/js/*.js'
],
toolchain: [
'Gruntfile.js',
'grunt-config/*.js'
]
};

View File

@ -1,12 +0,0 @@
'use strict';
module.exports = {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/js',
src: '*.js',
dest: '.tmp/concat/js'
}]
}
};

View File

@ -1,11 +0,0 @@
module.exports = {
npm_install: {
command: 'npm install'
},
bower_install: {
command: 'bower install'
},
pip_install: {
command: 'pip install --upgrade --requirement requirements.txt'
}
};

View File

@ -1,16 +0,0 @@
'use strict';
module.exports = {
html: ['<%= accountant.frontend.dist %>/{,*/}*.html'],
css: ['<%= accountant.frontend.dist %>/css/{,*/}*.css'],
js: ['<%= accountant.frontend.dist %>/js/{,*/}*.js'],
options: {
assetsDir: [
'<%= accountant.frontend.dist %>',
'<%= accountant.frontend.dist %>/css',
],
patterns: {
js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']]
}
}
};

View File

@ -1,17 +0,0 @@
'use strict';
module.exports = {
html: '<%= accountant.frontend.src %>/index.html ',
options: {
dest: '<%= accountant.frontend.dist %>',
flow: {
html: {
steps: {
js: ['concat', 'uglify'],
css: ['cssmin']
},
post: {}
}
}
}
};

View File

@ -1,43 +0,0 @@
'use strict';
module.exports = {
bower: {
files: 'bower.json',
tasks: ['wiredep']
},
js: {
files: [
'<%= accountant.frontend.src %>/js/*.js %>',
'grunt-config/*.js'
],
tasks: ['jsdev']
},
py: {
files: 'accountant/**/*.py',
tasks: ['pydev', 'bgShell:runserver']
},
html: {
files: [
'<%= accountant.frontend.src %>/*.html',
'<%= accountant.frontend.src %>/views/*.html'
],
tasks: ['htmldev']
},
gruntfile: {
files: ['Gruntfile.js', 'grunt-config/*.js']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= accountant.frontend.src %>/{,*/}*.html',
'<%= accountant.frontend.src %>/js/*.js',
'<%= accountant.frontend.src %>/css/*.css'
]
},
requirements: {
files: ['requirements.txt'],
tasks: ['shell:pip_install']
}
};

View File

@ -1,6 +0,0 @@
module.exports = {
app: {
src: ['<%= accountant.frontend.src %>/index.html'],
ignorePath: /\.\.\//
}
};

View File

@ -1,47 +0,0 @@
#!/usr/bin/env python
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand, stamp
from accountant import app, db
from accountant.api.models.users import User
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
@manager.command
def initdb():
""" Create the database ans stamp it. """
tables = db.engine.table_names()
if len(tables) > 1 and 'alembic_version' not in tables:
exit("Database already initialized.")
db.metadata.create_all(bind=db.engine)
stamp()
print("Database created.")
user_manager = Manager(usage="Manage users.")
manager.add_command('user', user_manager)
@user_manager.command
def add(email, password):
""" Add a new user. """
user = User()
user.email = email
user.password = User.hash_password(password)
db.session.add(user)
print("User '%s' successfully added." % email)
if __name__ == "__main__":
manager.run()

View File

@ -1 +0,0 @@
Generic single-database configuration.

View File

@ -1,45 +0,0 @@
# A generic, single database configuration.
[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

View File

@ -1,73 +0,0 @@
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from flask import current_app
config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI'))
target_metadata = current_app.extensions['migrate'].metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata
)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View File

@ -1,22 +0,0 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision}
Create Date: ${create_date}
"""
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

View File

@ -1,34 +0,0 @@
"""Add user support.
Revision ID: 1232daf66ac
Revises: 144929e0f5f
Create Date: 2015-08-31 10:24:40.578432
"""
# revision identifiers, used by Alembic.
revision = '1232daf66ac'
down_revision = '144929e0f5f'
from alembic import op
import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('email', sa.String(length=200), nullable=False),
sa.Column('password', sa.String(length=100), nullable=True),
sa.Column('active', sa.Boolean(), server_default=sa.text('true'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_user_email'), table_name='user')
op.drop_table('user')
### end Alembic commands ###

View File

@ -1,142 +0,0 @@
"""Improve operation scheduling.
Revision ID: 144929e0f5f
Revises: None
Create Date: 2015-07-17 15:04:01.002581
"""
# revision identifiers, used by Alembic.
revision = '144929e0f5f'
down_revision = None
from alembic import op
import sqlalchemy as sa
from accountant.api.models.scheduled_operations import ScheduledOperation
def upgrade():
op.get_bind().execute("DROP VIEW operation")
op.rename_table('entry', 'operation')
# Add column "canceled" in table "entry"
op.add_column(
'operation',
sa.Column(
'canceled',
sa.Boolean(),
nullable=False,
default=False,
server_default=sa.false()
)
)
# Add column "confirmed" in table "entry"
op.add_column(
'operation',
sa.Column(
'confirmed',
sa.Boolean(),
nullable=False,
default=True,
server_default=sa.true()
)
)
# Drop unused table canceled_operation.
op.drop_table('canceled_operation')
op.get_bind().execute(
"alter sequence entry_id_seq rename to operation_id_seq"
)
connection = op.get_bind()
Session = sa.orm.sessionmaker()
session = Session(bind=connection)
# Get all scheduled operations
scheduled_operations = ScheduledOperation.query(session).all()
for scheduled_operation in scheduled_operations:
scheduled_operation.reschedule(session)
def downgrade():
op.create_table(
"canceled_operation",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column(
"scheduled_operation_id", sa.Integer(),
sa.ForeignKey("scheduled_operation.id")),
sa.Column("operation_date", sa.Date, nullable=False)
)
op.drop_column('operation', 'canceled')
op.drop_column('operation', 'confirmed')
op.get_bind().execute(
"alter sequence operation_id_seq rename to entry_id_seq"
)
op.rename_table('operation', 'entry')
op.get_bind().execute(
"""
CREATE VIEW operation AS
SELECT entry.id,
entry.operation_date,
entry.label,
entry.value,
entry.account_id,
entry.category,
entry.pointed,
entry.scheduled_operation_id,
false AS canceled
FROM entry
UNION
SELECT NULL::bigint AS id,
scheduled_operation.operation_date,
scheduled_operation.label,
scheduled_operation.value,
scheduled_operation.account_id,
scheduled_operation.category,
false AS pointed,
scheduled_operation.id AS scheduled_operation_id,
false AS canceled
FROM (
SELECT scheduled_operation_1.id,
scheduled_operation_1.start_date,
scheduled_operation_1.stop_date,
scheduled_operation_1.day,
scheduled_operation_1.frequency,
scheduled_operation_1.label,
scheduled_operation_1.value,
scheduled_operation_1.account_id,
scheduled_operation_1.category,
generate_series(scheduled_operation_1.start_date::timestamp without time zone, scheduled_operation_1.stop_date::timestamp without time zone, scheduled_operation_1.frequency::double precision * '1 mon'::interval) AS operation_date
FROM scheduled_operation scheduled_operation_1) scheduled_operation
LEFT JOIN (
SELECT entry.scheduled_operation_id,
date_trunc('MONTH'::text, entry.operation_date::timestamp with time zone) AS operation_date
FROM entry
UNION
SELECT canceled_operation.scheduled_operation_id,
date_trunc('MONTH'::text, canceled_operation.operation_date::timestamp with time zone) AS operation_date
FROM canceled_operation
) saved_operation ON saved_operation.scheduled_operation_id = scheduled_operation.id AND saved_operation.operation_date = date_trunc('MONTH'::text, scheduled_operation.operation_date)
WHERE saved_operation.scheduled_operation_id IS NULL
UNION
SELECT NULL::bigint AS id,
canceled_operation.operation_date,
scheduled_operation.label,
scheduled_operation.value,
scheduled_operation.account_id,
scheduled_operation.category,
false AS pointed,
scheduled_operation.id AS scheduled_operation_id,
true AS canceled
FROM scheduled_operation
JOIN canceled_operation ON canceled_operation.scheduled_operation_id = scheduled_operation.id;
"""
)

View File

@ -4,31 +4,63 @@
"repository": "https://git.lahouze.org/xals/accountant",
"license": "AGPL-1.0",
"devDependencies": {
"connect-logger": "0.0.1",
"connect-proxy-layer": "^0.1.2",
"grunt": "~1.0",
"grunt-bg-shell": "^2.3.1",
"grunt-contrib-clean": "~1.0",
"grunt-contrib-concat": "~1.0",
"grunt-contrib-connect": "~1.0",
"grunt-contrib-cssmin": "~1.0",
"grunt-contrib-jshint": "~1.0",
"grunt-contrib-uglify": "~1.0",
"grunt-contrib-watch": "~1.0",
"grunt-copy": "^0.1.0",
"grunt-filerev": "^2.3.1",
"grunt-flake8": "^0.1.3",
"grunt-htmllint": "^0.2.7",
"grunt-include-source": "^0.7.1",
"grunt-jscs": "^2.7.0",
"grunt-newer": "^1.1.1",
"grunt-ng-annotate": "~2.0",
"grunt-shell": "^1.1.2",
"grunt-usemin": "^3.1.1",
"grunt-wiredep": "~3.0",
"jshint-stylish": "^2.1.0",
"load-grunt-configs": "^0.4.3",
"load-grunt-tasks": "^3.2.0",
"time-grunt": "^1.3.0"
"@types/angular": "^1.6.25",
"@types/angular-resource": "^1.5.9",
"@types/angular-strap": "^2.2.32",
"@types/angular-ui-notification": "^0.0.4",
"angular-tslint-rules": "^1.0.3",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"bootstrap-webpack": "^0.0.6",
"css-loader": "^0.28.4",
"eslint": "^4.1.1",
"eslint-config-angular": "^0.5",
"eslint-config-webpack": "^1.2.3",
"eslint-loader": "^1.7.1",
"eslint-plugin-angular": "^3.0.0",
"eslint-plugin-html": "^3.0.0",
"eslint-plugin-jquery": "^1.2",
"eslint-plugin-promise": "^3.5",
"eslint-plugin-security": "^1.3",
"eslint-plugin-this": "^0.2",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^0.11.2",
"html-loader": "^0.4.5",
"html-webpack-plugin": "^2.28.0",
"htmllint-loader": "^1.3.8",
"imports-loader": "^0.7.1",
"less": "^2.7.2",
"less-loader": "^4.0.4",
"ngtemplate-loader": "^2.0.0",
"style-loader": "^0.18.2",
"ts-loader": "^2.2.2",
"tslint": "^5.5.0",
"tslint-loader": "^3.5.3",
"url-loader": "^0.5.8",
"webpack": "^2.6.1",
"webpack-dev-server": "2.4.5"
},
"dependencies": {
"angular": "^1.6",
"angular-http-auth": "^1.5",
"angular-messages": "^1.6",
"angular-resource": "^1.6",
"angular-route": "^1.6",
"angular-strap": "^2.3.12",
"angular-ui-notification": "^0.3",
"base64util": "^1.0.2",
"bootbox": "^4.4.0",
"bootstrap": "^3.3.7",
"bootstrap-additions": "^0.3.1",
"c3": "^0.4.13",
"font-awesome": "^4.7.0",
"jquery": "^3.2",
"meanie-angular-storage": "^1.3.1",
"moment": "^2.18"
},
"scripts": {
"build": "webpack --config webpack.config.js",
"dev": "webpack-dev-server --debug --devtool eval --config webpack.config.js --progress --colors --hot --content-base build"
}
}

View File

@ -1,178 +0,0 @@
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: account; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE account (
id integer NOT NULL,
name character varying(200) NOT NULL,
authorized_overdraft integer DEFAULT 0 NOT NULL
);
--
-- Name: account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE account_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: account_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE account_id_seq OWNED BY account.id;
--
-- Name: entry; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE entry (
id bigint NOT NULL,
operation_date date,
label character varying(500) NOT NULL,
comment character varying(500),
value numeric(15,2) NOT NULL,
account_id integer NOT NULL,
category character varying(100),
pointed boolean DEFAULT false NOT NULL
);
--
-- Name: entry_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE entry_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: entry_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE entry_id_seq OWNED BY entry.id;
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY account ALTER COLUMN id SET DEFAULT nextval('account_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY entry ALTER COLUMN id SET DEFAULT nextval('entry_id_seq'::regclass);
--
-- Name: account_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY account
ADD CONSTRAINT account_pkey PRIMARY KEY (id);
--
-- Name: entry_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY entry
ADD CONSTRAINT entry_pkey PRIMARY KEY (id);
--
-- Name: entry_account_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX entry_account_id_idx ON entry USING btree (account_id);
--
-- Name: entry_operation_date_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX entry_operation_date_idx ON entry USING btree (operation_date);
--
-- Name: entry_account_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY entry
ADD CONSTRAINT entry_account_id_fkey FOREIGN KEY (account_id) REFERENCES account(id);
--
-- Name: public; Type: ACL; Schema: -; Owner: -
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--

View File

@ -1,16 +0,0 @@
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@ -1,16 +0,0 @@
create table scheduled_operation(
id serial primary key,
start_date date not null,
stop_date date not null,
day integer not null check (day > 0 and day <= 31),
frequency integer not null check (frequency > 0),
label varchar(500) not null,
value numeric(15,2) not null,
account_id integer not null references account(id),
category varchar(100)
);
create index scheduled_operation_account_id_idx on scheduled_operation(account_id);
alter table entry add column scheduled_operation_id integer references scheduled_operation(id);

View File

@ -1,2 +0,0 @@
alter table entry alter column operation_date set not null;
alter table entry drop column comment;

View File

@ -0,0 +1,7 @@
/// <reference path="../../node_modules/@types/angular/index.d.ts" />
/// <reference path="../../node_modules/@types/angular-resource/index.d.ts" />
export default function AccountConfig ($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask.
$resourceProvider.defaults.stripTrailingSlashes = false;
};

View File

@ -0,0 +1,163 @@
/// <reference types="angular" />
/// <reference types="angular-ui-notification" />
//import accountFormTmpl from './account.form.tmpl.html';
//import accountDeleteTmpl from './account.delete.tmpl.html';
import IAccount from './account.factory';
export interface IAccountController {
rowClass(account: IAccount) : string;
valueClass(account: IAccount, value: number) : string;
add() : void;
save(account: IAccount) : void;
confirmDelete(account: IAccount): void;
delete(account: IAccount): void;
modify(account: IAccount): void;
};
export default class AccountController {
static $inject = ['AccountResource', 'Notification', '$log', '$modal'];
private accounts: IAccount[];
constructor(
public AccountResource: AccountResource,
public Notification: angular.uiNotification.INotificationService,
public $modal: mgcrea.ngStrap.modal.IModalService) {
// Load accounts.
this.accounts = Account.query();
};
/*
* Return the class for an account current value compared to authorized
* overdraft.
*/
rowClass(account : IAccount): string {
if (!account || !account.authorized_overdraft || !account.current) {
return '';
}
if (account.current < account.authorized_overdraft) {
return 'danger';
} else if (account.current < 0) {
return 'warning';
}
};
/*
* Return the class for a value compared to account authorized overdraft.
*/
valueClass (account: IAccount, value: number): string {
if (!account || !value) {
return '';
}
if (value < account.authorized_overdraft) {
return 'text-danger';
} else if (value < 0) {
return 'text-warning';
}
};
/*
* Add an empty account.
*/
add(): void {
var account = new Account({
// eslint-disable-next-line camelcase
authorized_overdraft: 0
});
// Insert account at the begining of the array.
this.modify(account);
};
/*
* Save account.
*/
save(account: IAccount): void {
return account.$save().then(function(data) {
this.Notification.success('Account #' + data.id + ' saved.');
this.accounts = Account.query();
}, function(result){
$log.error('Error while saving account', account, result);
this.Notification.error(
'Error while saving account: ' + result.message
);
});
};
confirmDelete(account: IAccount): void {
var title = "Delete account #" + account.id;
$modal({
templateUrl: accountDeleteTmpl,
controller: function($scope, title, account, $delete) {
$scope.title = title;
$scope.account = account;
$scope.$delete = function() {
$scope.$hide();
$delete($scope.account);
};
},
locals: {
title: title,
account: account,
$delete: this.delete
}
});
};
/*
* Delete an account.
*/
delete(account: IAccount): void {
var id = account.id;
account.$delete().then(function() {
this.Notification.success('account #' + id + ' deleted.');
this.accounts = Account.query();
}, function(result) {
this.Notification.error(
'An error occurred while trying to delete account #' +
id + ':<br />' + result
);
});
};
/*
* Open the popup to modify the account, save it on confirm.
*/
modify(account: IAccount): void {
// FIXME Alexis Lahouze 2017-06-15 i18n
var title = "Account";
if (account.id) {
title = title + " #" + account.id;
}
$modal({
templateUrl: accountFormTmpl,
controller: function($scope, title, account, $save) {
$scope.title = title;
$scope.account = account;
$scope.account.authorized_overdraft *= -1;
$scope.$save = function() {
$scope.$hide();
$scope.account.authorized_overdraft *= -1;
$save($scope.account);
};
},
locals: {
title: title,
account: account,
$save: this.save
}
});
};
};

View File

@ -0,0 +1,23 @@
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
</div>
<div class="modal-body" id="modal-body">
<p>Voulez-vous supprimer le compte #{{ account.id }} ayant pour nom :<br/>{{ account.name }}
</p>
</div>
<div class="modal-footer">
<button class="btn btn-danger" type="button" ng-click="$delete()">
Supprimer
</button>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,19 @@
/// <reference types="angular" />
/// <reference types="angular-resource" />
export interface IAccount extends ng.resource.IResource<IAccount> {
id: number;
name: string;
authorized_overdraft: number;
};
export interface IAccountResource extends ng.resource.IResourceClass<IAccount> {
};
export default function AccountResource($resource) {
return <IAccountResource> $resource(
'/api/account/:id', {
id: '@id'
}
);
};

View File

@ -0,0 +1,72 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
</div>
<form name="form" class="form-horizontal simple-form" novalidate
ng-submit="$save()">
<div class="modal-body" id="modal-body">
<div class="form-group" ng-class="{ 'has-error' : form.name.$invalid && !form.name.$pristine }">
<label class="col-sm-4 control-label" for="name">Account name</label>
<div class="col-sm-8">
<input class="form-control" id="name" name="name"
ng-model="account.name"
type="text" placeholder="Account name"
required />
<div class="help-block" ng-messages="form.name.$error" ng-if="form.name.$invalid">
<p ng-message="required">The account name is required.</p>
</div>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error' : form.authorized_overdraft.$invalid && !form.authorized_overdraft.$pristine }">
<label class="col-sm-4 control-label" for="authorized-overdraft">Authorized overdraft</label>
<div class="col-sm-8">
<div class="input-group">
<div class="input-group-addon">-</div>
<input class="form-control" id="authorized-overdraft"
name="authorized_overdraft"
ng-model="account.authorized_overdraft"
type="number" placeholder="Authorized overdraft"
required min="0"/>
<div class="input-group-addon">.00€</div>
</div>
<div class="help-block" ng-messages="form.authorized_overdraft.$error" ng-if="form.authorized_overdraft.$invalid">
<p ng-message="required">The authorized overdraft is required.</p>
<p ng-message="min">The authorized overdraft must be equal or greater than 0.</p>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit" ng-disabled="form.$invalid"/>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,21 @@
import * as angular from 'angular';
import 'angular-resource';
export interface IAccountBalances
extends ng.resource.IResource<IAccountBalances> {
current: number;
pointed: number;
future: number;
};
export interface IAccountBalancesResource
extends ng.resource.IResourceClass<IAccountBalances> {
};
export default function AccountBalancesResource($resource) {
return <IAccountBalancesResource> $resource(
'/api/account/:id/balances', {
id: '@id'
}
);
};

View File

@ -1,3 +1,5 @@
<!DOCTYPE html>
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<!--
This file is part of Accountant.
@ -14,7 +16,6 @@
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="row">
<table class="table table-striped table-condensed table-hover">
<thead>
@ -30,27 +31,29 @@
<tbody>
<tr>
<td colspan="5">
<button class="btn btn-success btn-success"
ng-click="add()">Ajouter</button>
<button class="btn btn-success" ng-click="accountsCtrl.add()">
Ajouter
</button>
</td>
</tr>
<tr id="{{ account.id }}"
class="form-inline" ng-class="rowClass(account)"
ng-repeat="account in accounts | orderBy:'name'" ng-init="account.getSolds()">
ng-repeat="account in accountsCtrl.accounts | orderBy:'name'"
ng-init="account.getBalances()">
<td>
<a href="#/account/{{ account.id }}/operations">{{ account.name }}</a>
<a href="#!/account/{{ account.id }}/operations">{{ account.name }}</a>
</td>
<td>
<span ng-class="valueClass(account, account.solds.current)">
{{ account.solds.current | currency : "€" }}
<span ng-class="accountsCtrl.valueClass(account, account.balances.current)">
{{ account.balances.current | currency : "€" }}
</span>
</td>
<td>
<span ng-class="valueClass(account, account.solds.pointed)">
{{ account.solds.pointed | currency : "€" }}
<span ng-class="accountsCtrl.valueClass(account, account.balancess.pointed)">
{{ account.balances.pointed | currency : "€" }}
</span>
</td>
@ -62,26 +65,21 @@
<div class="btn-group btn-group-xs">
<!-- Edit account. -->
<button type="button" class="btn btn-success"
account-form-dialog ng-model="account">
ng-model="accountsCtrl.account"
ng-click="accountsCtrl.modify(account)">
<span class="fa fa-pencil-square-o"></span>
</button>
<!-- Cancel account edition. -->
<button type="button" class="btn btn-default"
ng-click="cancelEdit(rowform, account, $index)">
<span class="fa fa-times"></span>
</button>
<!-- Delete account, with confirm. -->
<button type="button" class="btn btn-default"
ng-click="delete(account, $index)">
ng-click="accountsCtrl.confirmDelete(account)">
<span class="fa fa-trash-o"></span>
</button>
<!-- Open account scheduler. -->
<a class="btn btn-default"
ng-if="account.id"
href="#/account/{{ account.id }}/scheduler">
href="#!/account/{{ account.id }}/scheduler">
<span class="fa fa-clock-o"></span>
</a>
</div>

47
src/accounts/index.js Normal file
View File

@ -0,0 +1,47 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
/* jshint node: true */
'use strict';
var angular = require('angular');
var ngResource = require('angular-resource'),
ngMessages = require('angular-messages'),
ngUiNotification = require('angular-ui-notification'),
ngStrap = require('angular-strap');
var AccountBalancesFactory = require('./accountBalances.factory');
var AccountFactory = require('./account.factory');
var AccountConfig = require('./account.config');
var AccountController = require('./account.controller');
module.exports = angular.module('accountant.accounts', [
ngResource,
ngMessages,
ngUiNotification,
ngStrap,
])
.config(AccountConfig)
.factory('Account', AccountFactory)
.factory('AccountBalances', AccountBalancesFactory)
.controller('AccountController', AccountController)
.name;

26
src/app.config.js Normal file
View File

@ -0,0 +1,26 @@
var operationsTmpl = require('./operations/operations.html');
var accountsTmpl = require('./accounts/accounts.html');
var schedulerTmpl = require('./scheduler/scheduler.html');
module.exports = function($routeProvider) {
// Defining template and controller in function of route.
$routeProvider
.when('/account/:accountId/operations', {
templateUrl: operationsTmpl,
controller: 'OperationController',
controllerAs: 'operationsCtrl'
})
.when('/account/:accountId/scheduler', {
templateUrl: schedulerTmpl,
controller: 'SchedulerController',
controllerAs: 'schedulerCtrl'
})
.when('/accounts', {
templateUrl: accountsTmpl,
controller: 'AccountController',
controllerAs: 'accountsCtrl'
})
.otherwise({
redirectTo: '/accounts'
});
};

View File

@ -1,3 +1,4 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
@ -14,13 +15,26 @@
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
ALTER TABLE entry ADD COLUMN pointed BOOLEAN NOT NULL DEFAULT false;
/* jshint node: true */
'use strict';
UPDATE entry SET pointed = operation_date IS NOT NULL;
var angular = require('angular');
UPDATE entry SET operation_date = value_date;
var ngRoute = require('angular-route');
ALTER TABLE entry DROP COLUMN value_date;
var accountModule = require('./accounts'),
loginModule = require('./login'),
operationModule = require('./operations'),
schedulerModule = require('./scheduler');
CREATE INDEX entry_operation_date_idx ON entry USING btree (operation_date);
var routing = require('./app.config');
require('bootstrap-webpack!./bootstrap.config.js');
angular.module('accountant', [
ngRoute,
accountModule,
loginModule,
operationModule,
schedulerModule,
]).config(routing);

64
src/bootstrap.config.js vendored Normal file
View File

@ -0,0 +1,64 @@
/* jshint node: true */
'use strict';
module.exports = {
scripts: {
'transition': true,
'alert': true,
'button': true,
'carousel': true,
'collapse': true,
'dropdown': true,
'modal': true,
'tooltip': true,
'popover': true,
'scrollspy': true,
'tab': true,
'affix': true
},
styles: {
'mixins': true,
'normalize': true,
'print': true,
'scaffolding': true,
'type': true,
'code': true,
'grid': true,
'tables': true,
'forms': true,
'buttons': true,
'component-animations': true,
'glyphicons': true,
'dropdowns': true,
'button-groups': true,
'input-groups': true,
'navs': true,
'navbar': true,
'breadcrumbs': true,
'pagination': true,
'pager': true,
'labels': true,
'badges': true,
'jumbotron': true,
'thumbnails': true,
'alerts': true,
'progress-bars': true,
'media': true,
'list-group': true,
'panels': true,
'wells': true,
'close': true,
'modals': true,
'tooltip': true,
'popovers': true,
'carousel': true,
'utilities': true,
'responsive-utilities': true
}
};

3
src/bootstrap.config.less vendored Normal file
View File

@ -0,0 +1,3 @@
@pre-border-color: @pre-bg; // hide the border.
@import "./main.less";

48
src/index.ejs Normal file
View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<html lang="fr">
<head>
<meta charset="UTF-8">
<!-- Title -->
<title><% htmlWebpackPlugin.options.title %></title>
</head>
<!-- htmllint attr-bans="false" -->
<body style="padding-bottom: 50px; padding-top: 70px" ng-app="accountant">
<!-- htmllint attr-bans="$previous" -->
<!-- Navbar -->
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container-fluid">
<!-- Brand -->
<div class="navbar-header">
<a class="navbar-brand" href="#!/accounts">&nbsp;Accountant</a>
</div>
</div>
</nav>
<div class="container-fluid">
<div ng-view></div>
</div>
<!-- Custom Javascript libraries -->
<script src="<% htmlWebpackPlugin.files.js[0] %>"></script>
</body>
</html>

50
src/login/index.js Normal file
View File

@ -0,0 +1,50 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
/* jshint node: true */
'use strict';
var angular = require('angular');
var ngStorage = require('meanie-angular-storage'),
ngHttpAuth = require('angular-http-auth'),
ngStrap = require('angular-strap');
// Note: ngHttpAuth seems to have no module.exports.
ngHttpAuth = 'http-auth-interceptor';
var LoginService = require('./login.service');
var LoginConfig = require('./login.config');
module.exports = angular.module('accountant.login', [
ngHttpAuth,
ngStorage
])
.service('LoginService', LoginService)
.config(LoginConfig)
.run(function($rootScope, LoginService) {
var onAuthLoginRequired = $rootScope.$on('event:auth-loginRequired', LoginService.loginModal);
$rootScope.$on('$destroy', function() {
onAuthLoginRequired = angular.noop();
});
})
.name;

31
src/login/login.config.js Normal file
View File

@ -0,0 +1,31 @@
module.exports = function($httpProvider, $storageProvider) {
// Define interceptors.
$httpProvider.interceptors.push(function($storage) {
return {
request: function(config) {
var access_token = $storage.session.get('access_token');
if (access_token) {
//var tokenType = $storage.get('token_type');
var tokenType = 'Bearer';
var authorization = tokenType + ' ' + access_token;
config.headers.authorization = authorization;
}
return config;
},
};
});
// Configure storage
// Set global prefix for stored keys
$storageProvider.setPrefix('accountant');
// Change the default storage engine
// Defaults to 'local'
$storageProvider.setDefaultStorageEngine('session');
// Change the enabled storage engines
// Defaults to ['memory', 'cookie', 'session', 'local']
$storageProvider.setEnabledStorageEngines(['local', 'session']);
};

View File

@ -0,0 +1,45 @@
var base64 = require('base64util');
var loginTmpl = require('./login.tmpl.html');
module.exports = function($storage, $http, authService, $modal) {
var login = function(email, password) {
// Encode authentication data.
var authdata = base64.encode(email + ':' + password);
return $http.post('/api/user/login', {}, {
ignoreAuthModule: true,
headers: {
'authorization': 'Basic ' + authdata
}
}).then(function (result) {
$storage.session.set('refresh_token', result.data.refresh_token);
$storage.session.set('access_token', result.data.access_token);
authService.loginConfirmed();
}, function(result) {
loginModal();
});
};
var loginModal = function () {
$storage.session.clear();
$modal({
templateUrl: loginTmpl,
controller: function($scope, $login) {
$scope.$login = function() {
$scope.$hide();
$login($scope.email, $scope.password);
};
},
locals: {
$login: login,
}
});
};
return {
'loginModal': loginModal,
};
};

38
src/login/login.tmpl.html Normal file
View File

@ -0,0 +1,38 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">Authentification requise</h3>
</div>
<form class="form-horizontal" ng-submit="$login()">
<div class="modal-body" id="modal-body">
<div class="form-group">
<label for="email" class="col-sm-4 control-label">Adresse email</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="email" ng-model="email"
placeholder="Nom d'utilisateur">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-4 control-label">Mot de passe</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="password"
ng-model="password" placeholder="Mot de passe">
</div>
</div>
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit" value="OK"/>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</form>
</div>
</div>
</div>

41
src/main.less Normal file
View File

@ -0,0 +1,41 @@
@import '~font-awesome/less/font-awesome';
@import '~angular-ui-notification/src/angular-ui-notification';
@import (inline) '~c3/c3.css';
@import (inline) '~bootstrap-additions/dist/bootstrap-additions.css';
.italic {
font-style: italic;
}
.stroke {
text-decoration: line-through;
}
.c3-ygrid-line.zeroline line {
stroke: orange;
}
.c3-ygrid-line.overdraft line {
stroke: #FF0000;
}
// Needed for modal backdrop opacity.
.modal-backdrop.am-fade {
opacity: .5;
transition: opacity .15s linear;
&.ng-enter {
opacity: 0;
&.ng-enter-active {
opacity: .5;
}
}
&.ng-leave {
opacity: .5;
&.ng-leave-active {
opacity: 0;
}
}
}

View File

@ -0,0 +1,190 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
/* jshint node: true */
'use strict';
var moment = require('moment'),
c3 = require('c3');
var angular = require('angular');
var ngResource = require('angular-resource');
module.exports = angular.module('balanceChartModule', [
ngResource
])
.component('balanceChart', {
template: '<div></div>',
bindings: {
account: '<',
onUpdate: '&'
},
controller: function($routeParams, Balances, $element) {
var vm = this;
vm.loadData = function() {
Balances.query({
id: $routeParams.accountId
}, function(results) {
var headers = [['date', 'balances', 'expenses', 'revenues']];
var rows = results.map(function(result) {
return [
result.operation_date,
result.balance,
result.expenses,
result.revenues
];
});
vm.chart.unload();
vm.chart.load({
rows: headers.concat(rows)
});
var x = vm.chart.x();
var balances = x.balances;
vm.onUpdate(balances[0], balances[balances.length - 1]);
});
};
vm.$onInit = function() {
var tomorrow = moment().endOf('day').valueOf();
vm.chart = c3.generate({
bindto: $element[0].children[0],
size: {
height: 450,
},
data: {
x: 'date',
rows: [],
axes: {
expenses: 'y2',
revenues: 'y2'
},
type: 'bar',
types: {
balances: 'area'
},
groups: [
['expenses', 'revenues']
],
// Disable for the moment because there is an issue when
// using subchart line is not refreshed after subset
// selection.
//regions: {
// balances: [{
// start: tomorrow,
// style: 'dashed'
// }]
//}
},
regions: [{
start: tomorrow,
}],
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d',
rotate: 50,
}
},
y: {
label: {
text: 'Amount',
position: 'outer-middle'
}
},
y2: {
show: true,
label: {
text: 'Amount',
position: 'outer-middle'
}
}
},
grid: {
x: {
show: true,
},
y: {
show: true,
}
},
tooltip: {
format: {
value: function(value, ratio, id, index) {
return value + '€';
}
}
},
subchart: {
show: true,
onbrush: function(domain) {
vm.onUpdate({minDate: domain[0], maxDate: domain[1]});
}
}
});
vm.loadData();
};
vm.setLines = function(account) {
if(vm.chart) {
vm.chart.ygrids([
{ value: 0, axis: 'y2' },
{ value: 0, axis: 'y', class: 'zeroline'},
]);
vm.chart.ygrids.add({
value: account.authorized_overdraft,
axis: 'y',
class: 'overdraft'
});
}
};
vm.$onChanges = function(changes) {
if('account' in changes) {
if('$promise' in vm.account && vm.account.$resolved === false) {
vm.account.$promise.then(function(account) {
vm.setLines(account);
return account;
});
} else {
vm.setLines(vm.account);
}
}
};
}
})
.factory('Balances', function($resource) {
return $resource(
'/api/account/:id/daily_balances', {
id: '@id'
}
);
})
.name;

View File

@ -0,0 +1,137 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
/* jshint node: true */
'use strict';
var moment = require('moment'),
c3 = require('c3');
var angular = require('angular');
var ngResource = require('angular-resource');
module.exports = angular.module('categoryChartModule', [
ngResource
])
.component('categoryChart', {
template: '<div></div>',
bindings: {
minDate: '<',
maxDate: '<'
},
controller: function($routeParams, $element, Categories, Incomes) {
var vm = this;
vm.loadData = function() {
Categories.query({
id: $routeParams.accountId,
begin: vm.minDate ? moment(vm.minDate).format('YYYY-MM-DD') : null,
end: vm.maxDate ? moment(vm.maxDate).format('YYYY-MM-DD') : null
}, function(results) {
var expenses=[],
revenues=[],
colors={},
names={};
var revenuesColor = 'green',
expensesColor = 'orange';
angular.forEach(results, function(result) {
if(result.revenues > 0) {
var revenuesName = 'revenues-' + result.category;
revenues.push([revenuesName, result.revenues]);
names[revenuesName] = result.category;
colors[revenuesName] = revenuesColor;
}
if(result.expenses < 0) {
var expensesName = 'expenses-' + result.category;
expenses.splice(0, 0, [expensesName, -result.expenses]);
names[expensesName] = result.category;
colors[expensesName] = expensesColor;
}
});
vm.chart.unload();
vm.chart.load({
columns: revenues.concat(expenses),
names: names,
colors: colors
});
});
};
vm.$onInit = function() {
vm.chart = c3.generate({
bindto: $element[0].children[0],
data: {
columns: [],
type: 'donut',
order: null,
},
tooltip: {
format: {
value: function(value, ratio, id, index) {
return value + '€';
}
}
},
donut: {
label: {
format: function(value) {
return value + '€';
}
}
},
legend: {
show: false
}
});
//vm.loadData();
};
vm.$onChanges = function() {
vm.loadData();
};
}
})
.factory('Categories', function($resource) {
return $resource(
'/api/account/:id/category', {
id: '@id'
}
);
})
.factory('Incomes', function($resource) {
return $resource(
'/api/account/:id/income', {
id: '@id'
}
);
})
.name;

54
src/operations/index.js Normal file
View File

@ -0,0 +1,54 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
/* jshint node: true */
'use strict';
var moment = require('moment');
var angular = require('angular');
var ngResource = require('angular-resource'),
ngMessages = require('angular-messages'),
ngUiNotification = require('angular-ui-notification'),
ngStrap = require('angular-strap');
var balanceChartModule = require('./balance-chart.component.js'),
categoryChartModule = require('./category-chart.component.js'),
accountModule = require('../accounts');
var OperationFactory = require('./operation.factory');
var OperationConfig = require('./operation.config');
var OperationController = require('./operation.controller');
module.exports = angular.module('accountant.operations', [
ngResource,
ngMessages,
ngUiNotification,
ngStrap,
accountModule,
balanceChartModule,
categoryChartModule
])
.config(OperationConfig)
.factory('Operation', OperationFactory)
.controller('OperationController', OperationController)
.name;

View File

@ -0,0 +1,4 @@
module.exports = function($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask..
$resourceProvider.defaults.stripTrailingSlashes = false;
};

View File

@ -0,0 +1,149 @@
var operationFormTmpl = require('./operation.form.tmpl.html'),
operationDeleteTmpl = require('./operation.delete.tmpl.html');
module.exports = function($routeParams, $modal, Notification, Operation,
Account) {
var vm = this;
/*
* Add an empty operation.
*/
vm.add = function() {
var operation = new Operation({
// eslint-disable-next-line camelcase
account_id: $routeParams.accountId
});
return vm.modify(operation);
};
/*
* Load operations.
*/
vm.load = function(minDate, maxDate) {
vm.minDate = minDate;
vm.maxDate = maxDate;
return Operation.query({
// eslint-disable-next-line camelcase
account_id: $routeParams.accountId,
begin: minDate ? moment(minDate).format('YYYY-MM-DD') : null,
end: maxDate ? moment(maxDate).format('YYYY-MM-DD') : null
});
};
/*
* Toggle pointed indicator for an operation.
*/
vm.togglePointed = function(operation, rowform) {
operation.pointed = !operation.pointed;
vm.save(operation);
};
/*
* Toggle cancel indicator for an operation.
*/
vm.toggleCanceled = function(operation) {
operation.canceled = !operation.canceled;
vm.save(operation);
};
/*
* Save an operation and return a promise.
*/
vm.save = function(operation) {
operation.confirmed = true;
return operation.$save().then(function(operation) {
Notification.success('Operation #' + operation.id + ' saved.');
vm.operations = vm.load();
return operation;
}, function(result){
Notification.error(
'Error while saving operation: ' + result.message
);
});
};
/*
* Delete an operation and return a promise.
*/
vm.confirmDelete = function(operation) {
var title = "Delete operation #" + operation.id;
$modal({
templateUrl: operationDeleteTmpl,
controller: function($scope, title, operation, $delete) {
$scope.title = title;
$scope.operation = operation;
$scope.$delete = function() {
$scope.$hide();
$delete($scope.operation);
};
},
locals: {
title: title,
operation: operation,
$delete: vm.delete
}
});
};
vm.delete = function(operation) {
var id = operation.id;
return operation.$delete().then(function() {
Notification.success('Operation #' + id + ' deleted.');
vm.operations = vm.load();
return operation;
}, function(result) {
Notification.error(
'An error occurred while trying to delete operation #' +
id + ':<br />' + result
);
});
};
/*
* Open the popup to modify the operation, save it on confirm.
* @returns a promise.
*/
vm.modify = function(operation) {
// FIXME Alexis Lahouze 2017-06-15 i18n
var title = "Operation";
if (operation.id) {
title = title + " #" + operation.id;
}
$modal({
templateUrl: operationFormTmpl,
controller: function($scope, title, operation, $save) {
$scope.title = title;
$scope.operation = operation;
$scope.$save = function() {
$scope.$hide();
$save($scope.operation);
};
},
locals: {
title: title,
operation: operation,
$save: vm.save
}
});
};
vm.onUpdate = function(minDate, maxDate) {
vm.operations = vm.load(minDate, maxDate);
};
vm.account = Account.get({id: $routeParams.accountId});
};

View File

@ -0,0 +1,25 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
</div>
<div class="modal-body" id="modal-body">
<p>Voulez-vous supprimer l'opération #{{ operation.id }} ayant pour libellé :<br/>{{ operation.label }}
</p>
</div>
<div class="modal-footer">
<button class="btn btn-danger" type="button" ng-click="$delete()">
Supprimer
</button>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,7 @@
module.exports = function($resource) {
return $resource(
'/api/operation/:id', {
id: '@id'
}
);
};

View File

@ -0,0 +1,77 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<!-- kate: space-indent on; indent-width 2; mixedindent off; -->
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
</div>
<div class="modal-body" id="modal-body">
<form class="form-horizontal simple-form">
<div class="form-group">
<label class="col-sm-4 control-label" for="operation-date">Date</label>
<div class="col-sm-8">
<input class="form-control" id="operation-date" name="operation_date"
type="text" ng-model="operation.operation_date"
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
placeholder="Operation date">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="label">Label</label>
<div class="col-sm-8">
<input class="form-control" id="label" name="label"
ng-model="operation.label" type="text" placeholder="Label">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="value">Montant</label>
<div class="col-sm-8">
<input class="form-control" id="value" name="value"
ng-model="operation.value" type="number" placeholder="Value">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="category">Catégorie</label>
<div class="col-sm-8">
<input class="form-control" id="category" name="category"
ng-model="operation.category" type="text" placeholder="Category">
</input>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="$save()">
OK
</button>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,115 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<div>
<div class="row">
<div class="col-md-9">
<balance-chart on-update="operationsCtrl.onUpdate(minDate, maxDate)"
account="operationsCtrl.account"/>
</div>
<div class="col-md-3">
<category-chart
min-date="operationsCtrl.minDate"
max-date="operationsCtrl.maxDate"/>
</div>
</div>
<div class="row">
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="col-md-1">Date d'op.</th>
<th>Libell&eacute; de l'op&eacute;ration</th>
<th class="col-md-1">Montant</th>
<th class="col-md-1">Solde</th>
<th class="col-md-2">Cat&eacute;gorie</th>
<th class="col-md-2">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="6">
<button class="btn btn-success" ng-click="operationsCtrl.add()">
Ajouter
</button>
</td>
</tr>
<tr id="{{ operation.id }}" class="form-inline"
ng-class="{stroke: operation.canceled, italic: !operation.confirmed,
warning: operation.balance < 0, danger: operation.balance < operationsCtrl.account.authorized_overdraft}"
ng-repeat="operation in operationsCtrl.operations | orderBy:'+':true">
<td>
{{ operation.operation_date | date:"yyyy-MM-dd" }}
</td>
<td>
{{ operation.label }}
</td>
<td>
{{ operation.value | currency:"€" }}
</td>
<td ng-class="{'text-warning': operation.balance < 0, 'text-danger':
operation.balance < operationsCtrl.account.authorized_overdraft}">
{{ operation.balance | currency:"€" }}
</td>
<td>
{{ operation.category }}
</td>
<td>
<div class="btn-group btn-group-xs">
<!-- Edit operation, for non-canceled operation. -->
<button type="button" class="btn btn-default"
ng-if="!operation.canceled"
ng-click="operationsCtrl.modify(operation)" title="edit">
<span class="fa fa-pencil-square-o"></span>
</button>
<!-- Toggle pointed operation, for non-canceled operations. -->
<button type="button" class="btn btn-default"
ng-if="!operation.canceled"
ng-click="operationsCtrl.togglePointed(operation)"
ng-class="{active: operation.pointed}" title="point">
<span ng-class="{'fa fa-check-square-o': operation.pointed, 'fa fa-square-o': !operation.pointed}"></span>
</button>
<!-- Toggle canceled operation. -->
<button type="button" class="btn btn-default"
ng-click="operationsCtrl.toggleCanceled(operation)"
ng-if="operation.scheduled_operation_id && !rowform.$visible"
ng-class="{active: operation.canceled}" title="cancel">
<span class="fa fa-remove"></span>
</button>
<!-- Delete operation, with confirm. -->
<button type="button" class="btn btn-default"
ng-if="operation.id && !operation.scheduled_operation_id"
ng-click="operationsCtrl.confirmDelete(operation)">
<span class="fa fa-trash-o"></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -1,3 +1,4 @@
// vim: set tw=80 ts=4 sw=4 sts=4:
/*
This file is part of Accountant.
@ -14,5 +15,29 @@
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
*/
ALTER TABLE account ADD COLUMN authorized_overdraft INTEGER NOT NULL DEFAULT 0;
/* jshint node: true */
'use strict';
var angular = require('angular');
var ngMessages = require('angular-messages'),
ngUiNotification = require('angular-ui-notification'),
ngStrap = require('angular-strap');
var ScheduleConfig = require('./schedule.config.js');
var ScheduleController = require('./schedule.controller.js');
var ScheduleFactory = require('./schedule.factory.js');
module.exports = angular.module('accountant.scheduler', [
ngMessages,
ngUiNotification,
ngStrap
])
.config(ScheduleConfig)
.factory('ScheduledOperation', ScheduleFactory)
.controller('SchedulerController', ScheduleController)
.name;

View File

@ -0,0 +1,4 @@
module.exports = function($resourceProvider) {
// Keep trailing slashes to avoid redirect by flask..
$resourceProvider.defaults.stripTrailingSlashes = false;
};

View File

@ -0,0 +1,127 @@
var scheduleFormTmpl = require('./schedule.form.tmpl.html'),
scheduleDeleteTmpl = require('./schedule.delete.tmpl.html');
module.exports= function($rootScope, $routeParams, Notification, ScheduledOperation, $log, $modal) {
var vm = this;
// Operation store.
vm.operations = [];
/*
* Add a new operation at the beginning of th array.
*/
vm.add = function() {
var operation = new ScheduledOperation({
// eslint-disable-next-line camelcase
account_id: $routeParams.accountId
});
return vm.modify(operation);
};
/*
* Load operations.
*/
vm.load = function() {
return ScheduledOperation.query({
// eslint-disable-next-line camelcase
account_id: $routeParams.accountId
});
};
/*
* Save operation.
*/
vm.save = function(operation) {
return operation.$save().then(function(operation) {
Notification.success('Scheduled operation #' + operation.id + ' saved.');
vm.operations = vm.load();
return operation;
}, function(result){
$log.error('Error while saving scheduled operation', operation, result);
Notification.error(
'Error while saving scheduled operation: ' + result.message
);
});
};
/*
* Delete an operation and return a promise.
*/
vm.confirmDelete = function(operation) {
var title = "Delete operation #" + operation.id;
$modal({
templateUrl: scheduleDeleteTmpl,
controller: function($scope, title, operation, $delete) {
$scope.title = title;
$scope.operation = operation;
$scope.$delete = function() {
$scope.$hide();
$delete($scope.operation);
};
},
locals: {
title: title,
operation: operation,
$delete: vm.delete
}
});
};
/*
* Delete operation.
*/
vm.delete = function(operation) {
var id = operation.id;
return operation.$delete().then(function() {
Notification.success('Scheduled operation #' + id + ' deleted.');
vm.operations = vm.load();
return operation;
}, function(result) {
Notification.error(
'An error occurred while trying to delete scheduled operation #' +
id + ':<br />' + result
);
});
};
/*
* Open the popup to modify the operation, save it on confirm.
* @returns a promise.
*/
vm.modify = function(operation) {
// FIXME Alexis Lahouze 2017-06-15 i18n
var title = "Operation";
if (operation.id) {
title = title + " #" + operation.id;
}
$modal({
templateUrl: scheduleFormTmpl,
controller: function($scope, title, operation, $save) {
$scope.title = title;
$scope.operation = operation;
$scope.$save = function() {
$scope.$hide();
$save($scope.operation);
};
},
locals: {
title: title,
operation: operation,
$save: vm.save
}
});
};
// Load operations on controller initialization.
vm.operations = vm.load();
};

View File

@ -0,0 +1,25 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
</div>
<div class="modal-body" id="modal-body">
<p>Voulez-vous supprimer l'opération #{{ operation.id }} ayant pour libellé :<br/>{{ operation.label }}
</p>
</div>
<div class="modal-footer">
<button class="btn btn-danger" type="button" ng-click="$delete()">
Supprimer
</button>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,7 @@
module.exports = function($resource) {
return $resource(
'/api/scheduled_operation/:id', {
id: '@id'
}
);
};

View File

@ -0,0 +1,89 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title }}</h3>
</div>
<div class="modal-body" id="modal-body">
<form class="form-horizontal simple-form">
<div class="form-group">
<label class="col-sm-4 control-label" for="start-date">Date de début</label>
<div class="col-sm-8">
<input class="form-control" id="start-date" name="start_date"
type="text" ng-model="operation.start_date"
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
placeholder="Scheduled operation start date">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="stop-date">Date de fin</label>
<div class="col-sm-8">
<input class="form-control" id="stop-date" name="stop_date"
type="text" ng-model="operation.stop_date"
bs-datepicker data-date-format="yyyy-MM-dd" data-timezone="UTC"
placeholder="Scheduled operation stop date">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="day">Jour</label>
<div class="col-sm-8">
<input class="form-control" id="day" name="day"
ng-model="operation.day" type="number" placeholder="Day">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="frequency">Fréquence</label>
<div class="col-sm-8">
<input class="form-control" id="frequency" name="frequency"
ng-model="operation.frequency" type="number" placeholder="Frequency">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="label">Label</label>
<div class="col-sm-8">
<input class="form-control" id="label" name="label"
ng-model="operation.label" type="text" placeholder="Label">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="value">Montant</label>
<div class="col-sm-8">
<input class="form-control" id="value" name="value"
ng-model="operation.value" type="number" placeholder="Value">
</input>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="category">Catégorie</label>
<div class="col-sm-8">
<input class="form-control" id="category" name="category"
ng-model="operation.category" type="text" placeholder="Category">
</input>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="$save()">
OK
</button>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,92 @@
<!--
This file is part of Accountant.
Accountant is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Accountant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="row">
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="col-md-1">Date de d&eacute;but</th>
<th class="col-md-1">Date de fin</th>
<th class="col-md-1">Jour</th>
<th class="col-md-1">Fr&eacute;q.</th>
<th>Libell&eacute; de l'op&eacute;ration</th>
<th class="col-md-1">Montant</th>
<th class="col-md-2">Cat&eacute;gorie</th>
<th class="col-md-1">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="8">
<button class="btn btn-success" ng-click="schedulerCtrl.add()">
Ajouter
</button>
</td>
</tr>
<tr id="{{ operation.id }}" class="form-inline"
ng-repeat="operation in schedulerCtrl.operations">
<td class="col-md-1">
{{ operation.start_date | date: "yyyy-MM-dd" }}
</td>
<td>
{{ operation.stop_date | date: "yyyy-MM-dd" }}
</td>
<td>
{{ operation.day }}
</td>
<td>
{{ operation.frequency }}
</td>
<td>
{{ operation.label }}
</td>
<td>
{{ operation.value | currency : "€" }}
</td>
<td>
{{ operation.category }}
</td>
<td>
<div class="btn-group btn-group-xs">
<!-- Edit operation. -->
<button type="button" class="btn btn-default"
ng-click="schedulerCtrl.modify(operation)" title="edit">
<span class="fa fa-pencil-square-o"></span>
</button>
<!-- Remove operation. -->
<button type="button" class="btn btn-default"
ng-if="operation.id"
ng-click="schedulerCtrl.confirmDelete(operation)"
title="remove">
<span class="fa fa-trash"></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>

0
tsconfig.json Normal file
View File

135
webpack.config.js Normal file
View File

@ -0,0 +1,135 @@
/* jshint esversion: 6 */
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
context: path.resolve(__dirname, 'src'),
entry: './app.js',
devtool: 'source-map',
resolve: {
// Add '.ts' and '.tsx' as a resolvable extension.
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.html']
},
module: {
rules: [{
enforce: 'pre',
test: /webpack\.config\.js$/,
include: path.resolve(__dirname),
loader: 'eslint-loader',
options: {
useEslintrc: false,
emitWarning: true,
emitError: true,
failOnWarning: true,
failOnError: true,
baseConfig: 'webpack',
rules: {
indent: ['error', 4]
},
},
}, {
// typescript linting
enforce: 'pre',
test: /\.tsx?$/,
exclude: /(node_modules|bootstrap)/,
loader: 'tslint-loader',
options: {
configFile: false,
emitErrors: true,
baseConfig: 'angular',
allowJs: true,
configuration: {
extends: ["angular-tslint-rules"],
include: [
'src/**/*'
],
rules: {
indent: ['error', 4]
},
},
},
}, {
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader'
}, {
// Javascript
enforce: 'pre',
test: /\.jsx?$/,
//include: path.resolve(__dirname, 'src'),
exclude: /(node_modules|bootstrap)/,
loader: 'eslint-loader',
options: {
useEslintrc: false,
emitWarning: false,
emitError: true,
failOnWarning: false,
failOnError: true,
baseConfig: 'angular',
rules: {
indent: ['error', 4]
},
plugins: [
'angular',
'html',
'security',
'this',
'jquery',
'promise'
]
},
}, {
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}, {
test: /\.html$/,
use: [
'ngtemplate-loader?relativeTo=/accountant-ui/src',
'html-loader'
]
}, {
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader',
]
}, {
test: /\.css$/,
use: [
'style-loader',
'css-loader',
]
}, {
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
}]
},
plugins: [
new HtmlWebpackPlugin({
title: 'Accountant',
template: 'index.ejs'
}),
new webpack.ProvidePlugin({
"window.jQuery": "jquery"
}),
],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'js/bundle.js',
//publicPath: 'js'
},
devServer: {
proxy: {
'/api': {
target: 'http://localhost:5000',
secure: false
}
},
hot: true,
noInfo: false,
quiet: false,
}
};