Compare commits
500
Commits
93e088a4f8
...
5240d308b8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5240d308b8 | ||
|
|
38ee2d98ac | ||
|
|
9ac6dad1d2 | ||
|
|
9231d177e0 | ||
|
|
0f5c3cb506 | ||
|
|
0049d07cac | ||
|
|
fe7667b9ec | ||
|
|
4cac334d71 | ||
|
|
7db9d409eb | ||
|
|
1cd21b9f49 | ||
|
|
4d81b78d5d | ||
|
|
29af2d5999 | ||
|
|
029846bda2 | ||
|
|
898aa44db0 | ||
|
|
986a3c5f91 | ||
|
|
a0388e34d1 | ||
|
|
444707b60b | ||
|
|
a0effe9e7a | ||
|
|
239d60bc02 | ||
|
|
ff6eae40d3 | ||
|
|
32f4bc1d30 | ||
|
|
f2b40dbbe2 | ||
|
|
e6de05f690 | ||
|
|
690f0d4abc | ||
|
|
06f6ad2dff | ||
|
|
556f75fcc1 | ||
|
|
6177e41e70 | ||
|
|
b61ab594e4 | ||
|
|
6d2151f4db | ||
|
|
48c40b5170 | ||
|
|
dde7c9980d | ||
|
|
8b666d3eea | ||
|
|
127a5efbc3 | ||
|
|
578bbc2954 | ||
|
|
fbfcc32f78 | ||
|
|
8dc8dcad52 | ||
|
|
c99053d2a4 | ||
|
|
e4ee41174d | ||
|
|
46c315815d | ||
|
|
4e589cfeb8 | ||
|
|
a50983d9df | ||
|
|
3224836989 | ||
|
|
94459fe2a5 | ||
|
|
2ee2cf1b1f | ||
|
|
a8f4ff4bb6 | ||
|
|
bd09ecc967 | ||
|
|
a43490102d | ||
|
|
e694355f8c | ||
|
|
281931e19b | ||
|
|
1fb04811d5 | ||
|
|
013276d9e4 | ||
|
|
43b1cdd3ef | ||
|
|
49357f13a7 | ||
|
|
9bb3f4e51f | ||
|
|
2e050d397f | ||
|
|
021aa14f90 | ||
|
|
e0dc9b22ee | ||
|
|
08a8b8cff0 | ||
|
|
e52b66d562 | ||
|
|
7b4f078cda | ||
|
|
b2639fea2c | ||
|
|
adca69b0a0 | ||
|
|
7a7654e75f | ||
|
|
8424d52325 | ||
|
|
e21a8266d1 | ||
|
|
26fd03ae38 | ||
|
|
fa9f2129dd | ||
|
|
892afd409d | ||
|
|
3a73d9aacd | ||
|
|
08846d7b1f | ||
|
|
401770c696 | ||
|
|
6f3fcf31b6 | ||
|
|
d95a190efb | ||
|
|
cc0e02696b | ||
|
|
3cc91463c0 | ||
|
|
0717d02a38 | ||
|
|
ba24d205f9 | ||
|
|
3901a06ad8 | ||
|
|
3b27bcc4d1 | ||
|
|
2ec422f89d | ||
|
|
13d3221262 | ||
|
|
68e094dd2f | ||
|
|
fb4dfe7996 | ||
|
|
f5c1225dfa | ||
|
|
c966892b37 | ||
|
|
5ca0604aa2 | ||
|
|
669503b34b | ||
|
|
cb6ea0ae63 | ||
|
|
add6708ab0 | ||
|
|
b680e50942 | ||
|
|
075efe2712 | ||
|
|
184ec07487 | ||
|
|
6a012858d2 | ||
|
|
311477a87b | ||
|
|
26470d026d | ||
|
|
bb6ef42b41 | ||
|
|
37ae6dae9e | ||
|
|
d1a1ed60ab | ||
|
|
2dd5c5a7cd | ||
|
|
fe77584320 | ||
|
|
73c7be839d | ||
|
|
388aebd781 | ||
|
|
f73d42857e | ||
|
|
082d77f5b6 | ||
|
|
c395d96517 | ||
|
|
93fef53974 | ||
|
|
1a5e36f9e1 | ||
|
|
5a492e03db | ||
|
|
6fe8b41ca9 | ||
|
|
9e4cc15441 | ||
|
|
017cc717e5 | ||
|
|
df283eb533 | ||
|
|
9f65ff3cbd | ||
|
|
38ee5d130d | ||
|
|
7ac55812d6 | ||
|
|
a3970af6c2 | ||
|
|
f58f211664 | ||
|
|
d2c751f2eb | ||
|
|
48b3693944 | ||
|
|
879ffdaa7e | ||
|
|
41536b1beb | ||
|
|
b001e3f999 | ||
|
|
edae10ed4b | ||
|
|
bd678bd2b2 | ||
|
|
5c38e151e8 | ||
|
|
d997add560 | ||
|
|
72881c740b | ||
|
|
71d573cae0 | ||
|
|
65206daf30 | ||
|
|
0549858dea | ||
|
|
02617ce7f6 | ||
|
|
19fea3ed00 | ||
|
|
092eabc0a0 | ||
|
|
e4e285d943 | ||
|
|
8f74873408 | ||
|
|
a5096aad88 | ||
|
|
fbf54d3c64 | ||
|
|
8859c44765 | ||
|
|
1daf8edac5 | ||
|
|
d0ec329115 | ||
|
|
c36370ae83 | ||
|
|
10c343373c | ||
|
|
f7c7bfdd5f | ||
|
|
e8676832ee | ||
|
|
79ff5a7511 | ||
|
|
85de5e92c2 | ||
|
|
baba0b809e | ||
|
|
43fb5c3294 | ||
|
|
447b180790 | ||
|
|
4101cfbcf5 | ||
|
|
e874efc3ac | ||
|
|
9aa9b870f0 | ||
|
|
b8961d7914 | ||
|
|
dc718d33c9 | ||
|
|
d03705f51c | ||
|
|
b085f1872d | ||
|
|
b48763a104 | ||
|
|
f79da8144b | ||
|
|
30d4ca7681 | ||
|
|
f326187794 | ||
|
|
739dc31f29 | ||
|
|
7031ed40b4 | ||
|
|
f73ef79add | ||
|
|
015400b08e | ||
|
|
35a331debd | ||
|
|
bf847dc352 | ||
|
|
16c395719c | ||
|
|
ce188814ec | ||
|
|
e61454792f | ||
|
|
d7ea5d8169 | ||
|
|
e046d86e06 | ||
|
|
81a549ae01 | ||
|
|
74fa071603 | ||
|
|
84db0f9794 | ||
|
|
ac353ec28e | ||
|
|
51f661de17 | ||
|
|
0f2b5fd05d | ||
|
|
dfb0710674 | ||
|
|
211f8b7d46 | ||
|
|
716b1fb11a | ||
|
|
3f55301be2 | ||
|
|
3e16891cfb | ||
|
|
4cba5ea719 | ||
|
|
6e12e9e62a | ||
|
|
cd2e71ed75 | ||
|
|
2c92635ced | ||
|
|
0cedba8ae1 | ||
|
|
a0f6fd0a32 | ||
|
|
0d33fcf118 | ||
|
|
e0a7231f13 | ||
|
|
152a70477d | ||
|
|
f90802a292 | ||
|
|
7af4b12d24 | ||
|
|
027be9df4f | ||
|
|
b7a951b01a | ||
|
|
d685c36410 | ||
|
|
89b2a15e4c | ||
|
|
b185bc5f5b | ||
|
|
81f7b614b4 | ||
|
|
d8da3e49b6 | ||
|
|
db3f0401d9 | ||
|
|
ee63559abd | ||
|
|
75b8a0801d | ||
|
|
3b4c1171e8 | ||
|
|
46c82b1f67 | ||
|
|
46970adb2b | ||
|
|
390964f361 | ||
|
|
a3200a8bc7 | ||
|
|
a946e207da | ||
|
|
2325878e4e | ||
|
|
3d5c0d88c0 | ||
|
|
f4a9d183d7 | ||
|
|
ba42641d03 | ||
|
|
82a23d7413 | ||
|
|
eefd55f7af | ||
|
|
e5480dca8d | ||
|
|
675cebbbc7 | ||
|
|
59858e2bd3 | ||
|
|
4f44cb28d1 | ||
|
|
36e7117e46 | ||
|
|
1e3047c29c | ||
|
|
ccdda4287b | ||
|
|
585f591709 | ||
|
|
bdd2774de9 | ||
|
|
947f50fc31 | ||
|
|
6dfdc458ae | ||
|
|
dd95e0ad49 | ||
|
|
e8bd6ccdbd | ||
|
|
0b55ef9149 | ||
|
|
09165cbb04 | ||
|
|
3e40a0dac4 | ||
|
|
c32a14e537 | ||
|
|
3c78d8f64e | ||
|
|
b56ecc8387 | ||
|
|
3ce1ee7ded | ||
|
|
ab9497c985 | ||
|
|
90f78597d9 | ||
|
|
b79f0495f3 | ||
|
|
c4578672fa | ||
|
|
e60f1798aa | ||
|
|
2e83169b99 | ||
|
|
9c75498ebe | ||
|
|
1553918558 | ||
|
|
79d036d5c9 | ||
|
|
b97f02ef8e | ||
|
|
a6a72541eb | ||
|
|
27263af350 | ||
|
|
721039f637 | ||
|
|
19f6485a41 | ||
|
|
47ed3e7165 | ||
|
|
0a22ab3e41 | ||
|
|
cf865a28d9 | ||
|
|
82aebe4200 | ||
|
|
976ea6be21 | ||
|
|
fd20f72814 | ||
|
|
f3c63671a0 | ||
|
|
b86966caf9 | ||
|
|
1bae87e447 | ||
|
|
6f8e94b949 | ||
|
|
e68db3551e | ||
|
|
98ca889938 | ||
|
|
2855e56e0f | ||
|
|
4fc43ced64 | ||
|
|
3860d2af56 | ||
|
|
344ed0ebab | ||
|
|
7d57edd8e8 | ||
|
|
7d8ec61e02 | ||
|
|
f737336dc3 | ||
|
|
d5f697962c | ||
|
|
471bfe2566 | ||
|
|
f53e662b6d | ||
|
|
3617197f5f | ||
|
|
c08a76dd94 | ||
|
|
11e7f64cad | ||
|
|
115aede1fa | ||
|
|
4830b85493 | ||
|
|
7656bccb21 | ||
|
|
59e19e005e | ||
|
|
1b24a99124 | ||
|
|
afd22ea826 | ||
|
|
30cadb4d0d | ||
|
|
2d2ff222fc | ||
|
|
5dd2bd8859 | ||
|
|
4ef70d0d78 | ||
|
|
1a83d07c1c | ||
|
|
4c9450a257 | ||
|
|
91bcde66bf | ||
|
|
9e25b070fb | ||
|
|
1f8b325258 | ||
|
|
4ac094fc78 | ||
|
|
691e836c68 | ||
|
|
3a89d10454 | ||
|
|
4f98144896 | ||
|
|
ba8b24ac3b | ||
|
|
a6a74a401b | ||
|
|
08fc9ff4d6 | ||
|
|
360ae5a444 | ||
|
|
4084c194a0 | ||
|
|
c6317acfae | ||
|
|
3e5b47f562 | ||
|
|
3adfd9c073 | ||
|
|
6bd2d078a3 | ||
|
|
56c8ce43cd | ||
|
|
055e6cde70 | ||
|
|
725011c1ae | ||
|
|
ad6fb806ff | ||
|
|
c17fa073ec | ||
|
|
5934ae42ad | ||
|
|
82ebfea45f | ||
|
|
3293183279 | ||
|
|
c387c6155a | ||
|
|
899f9a3d46 | ||
|
|
0e66005147 | ||
|
|
b5e1ec051f | ||
|
|
9df1c76500 | ||
|
|
4e35791618 | ||
|
|
712ba4d69e | ||
|
|
63e0f8e64b | ||
|
|
a75a8d5d22 | ||
|
|
e4f8eb6b12 | ||
|
|
4717393816 | ||
|
|
2d8ae7ae9e | ||
|
|
c1c92fef3c | ||
|
|
b438747608 | ||
|
|
384928670d | ||
|
|
16da04f089 | ||
|
|
45200343be | ||
|
|
bacb5bfe64 | ||
|
|
41c35afa87 | ||
|
|
6a7647e177 | ||
|
|
1957dba4ac | ||
|
|
1fe9856eb2 | ||
|
|
c90b98c12e | ||
|
|
bd80d01821 | ||
|
|
303da8dc61 | ||
|
|
4c752d7f23 | ||
|
|
99b53995ea | ||
|
|
ae2279fce0 | ||
|
|
3e7724a8c3 | ||
|
|
79d2e8bea8 | ||
|
|
da6c2ea818 | ||
|
|
3684e72486 | ||
|
|
32e4a2ce64 | ||
|
|
5154e87b23 | ||
|
|
0bfabbe99a | ||
|
|
14ecbcbb7e | ||
|
|
587cb496b4 | ||
|
|
dc9c17ad08 | ||
|
|
940a665255 | ||
|
|
1877562ea8 | ||
|
|
06ac7a46e2 | ||
|
|
fa6370d31a | ||
|
|
1585b33f42 | ||
|
|
1f2bdedcd2 | ||
|
|
d85696b7d9 | ||
|
|
880c671d03 | ||
|
|
f08bd15b1f | ||
|
|
61b49d0b4c | ||
|
|
c686d0d628 | ||
|
|
e3223536a2 | ||
|
|
9649f0aba4 | ||
|
|
5bc6b5f664 | ||
|
|
a3eed0fdc2 | ||
|
|
756729ae8e | ||
|
|
0306ee866a | ||
|
|
e64efb0536 | ||
|
|
a06ed0d33b | ||
|
|
1e8d4b8c9d | ||
|
|
492a8547a9 | ||
|
|
04fc9357eb | ||
|
|
29e36a0797 | ||
|
|
6b2ec54a31 | ||
|
|
20234a8d6c | ||
|
|
b331a29bf8 | ||
|
|
99d50b248a | ||
|
|
ca3d666578 | ||
|
|
4a90cb091a | ||
|
|
464f146a7c | ||
|
|
a22d5d10aa | ||
|
|
b9c8f63441 | ||
|
|
2529ea8a4f | ||
|
|
48d88de462 | ||
|
|
85df179c9b | ||
|
|
d56c86c9af | ||
|
|
a337b6574c | ||
|
|
8d0806b723 | ||
|
|
b97353975a | ||
|
|
db7c961587 | ||
|
|
a13d725ec4 | ||
|
|
9939987a65 | ||
|
|
a925f5e12d | ||
|
|
f9d41aa500 | ||
|
|
57b38e463a | ||
|
|
508a46e537 | ||
|
|
f09d781005 | ||
|
|
2132a5dccb | ||
|
|
3cc06530da | ||
|
|
e0b3edff8a | ||
|
|
b100fd16a1 | ||
|
|
9da34579a0 | ||
|
|
f4dd25b521 | ||
|
|
2cda93f754 | ||
|
|
6ae1e98eb1 | ||
|
|
ccbf38f44f | ||
|
|
7547f93c18 | ||
|
|
64f55de032 | ||
|
|
4e78e7e401 | ||
|
|
a47586deed | ||
|
|
1e558cd5c8 | ||
|
|
c292acff29 | ||
|
|
dca9063a07 | ||
|
|
7042ffcd0d | ||
|
|
47fe49da8c | ||
|
|
74fd297487 | ||
|
|
0474b5df0c | ||
|
|
72d854b0cd | ||
|
|
c4b5359ef9 | ||
|
|
8310f6cab6 | ||
|
|
61ccefb5d7 | ||
|
|
e80119ca71 | ||
|
|
fbbede83f3 | ||
|
|
b33b70cb38 | ||
|
|
cd351ab723 | ||
|
|
0720cee40d | ||
|
|
03f8a0fcc0 | ||
|
|
58a6568efc | ||
|
|
345d9f3712 | ||
|
|
2270350085 | ||
|
|
2ee5dedf9c | ||
|
|
91890ff204 | ||
|
|
5f60266921 | ||
|
|
39d5884bb9 | ||
|
|
dc11ca018e | ||
|
|
bbe525d8a8 | ||
|
|
47a215ec4f | ||
|
|
bf4490feb9 | ||
|
|
17ba21d302 | ||
|
|
3cd3b487f3 | ||
|
|
ff5967e377 | ||
|
|
030887ad6f | ||
|
|
e4f95923eb | ||
|
|
12a16a07cf | ||
|
|
9459db944b | ||
|
|
ed82fdae52 | ||
|
|
1aafc0b09d | ||
|
|
9a3ab88996 | ||
|
|
3b341b29af | ||
|
|
b4dc4b16bc | ||
|
|
4a11cb3290 | ||
|
|
f2ca1746a4 | ||
|
|
b691792de8 | ||
|
|
75ba809761 | ||
|
|
bd37a66247 | ||
|
|
b44e53c3b7 | ||
|
|
c7c5198206 | ||
|
|
f48e4de309 | ||
|
|
00c4d5399a | ||
|
|
95bdafa4bb | ||
|
|
432332c88e | ||
|
|
28cee2ab07 | ||
|
|
592b5378dc | ||
|
|
4bbd878ca5 | ||
|
|
c1b52199a3 | ||
|
|
ccfd8a09e0 | ||
|
|
e21e0e9a2f | ||
|
|
1e24527487 | ||
|
|
9108cebf67 | ||
|
|
bc1b9d89c9 | ||
|
|
13b09ad4a1 | ||
|
|
d7dba9a515 | ||
|
|
068620c810 | ||
|
|
af5e2c0e84 | ||
|
|
d855129fea | ||
|
|
88e4c4ec00 | ||
|
|
440205fdfa | ||
|
|
9ad9070a86 | ||
|
|
ac6589e9aa | ||
|
|
abb4ec17dc | ||
|
|
9fe9a091c9 | ||
|
|
99fbab83b7 | ||
|
|
32668987d0 | ||
|
|
25d1ff3dac | ||
|
|
2c6782ca25 | ||
|
|
12b6795188 | ||
|
|
392be3745c | ||
|
|
10c6f9c509 | ||
|
|
349e3f4a4e | ||
|
|
9420d4fd14 | ||
|
|
f30e8645a3 | ||
|
|
6642aacff5 | ||
|
|
ee9656c5a6 | ||
|
|
c2e563bf6f | ||
|
|
2a1bb14c9f | ||
|
|
53030285de | ||
|
|
42a52cc70a | ||
|
|
33afb23f12 | ||
|
|
52aa27efea | ||
|
|
fc7380f22d | ||
|
|
aa762b8a24 | ||
|
|
3d136095a4 |
@@ -5,8 +5,14 @@ repos
|
||||
.project
|
||||
.settings
|
||||
.gradle
|
||||
.idea
|
||||
*.log
|
||||
*.class
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.bak
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
rebel.xml
|
||||
|
||||
@@ -11,39 +11,41 @@ http://www.youtube.com/watch?v=zN5Dn1Lc_js
|
||||
Online Client Application Demos
|
||||
=============================
|
||||
|
||||
<a target="_blank" href="https://ec2-46-137-62-163.eu-west-1.compute.amazonaws.com:8443/IndividualLendingGeneralJavaScript/IndivLendHome.html?tenantIdentifier=default" title="Client apps: Individual Lending">Individual Lending App</a>
|
||||
<a target="_blank" href="https://demo.openmf.org" title="Client apps: Individual Lending">Individual Lending App</a>
|
||||
|
||||
Mifos Platform API
|
||||
=====================
|
||||
|
||||
<a target="_blank" href="https://ec2-46-137-62-163.eu-west-1.compute.amazonaws.com:8443/api-docs/apiLive.htm" title="mifos platform api beta 1">API Documentation (Demo Server)</a>
|
||||
<a target="_blank" href="https://demo.openmf.org/api-docs/apiLive.htm" title="mifos platform api beta 1">API Documentation (Demo Server)</a>
|
||||
|
||||
Developers
|
||||
==========
|
||||
|
||||
see https://github.com/keithwoodlock/mifosx/wiki for getting started.
|
||||
|
||||
see https://mifosforge.jira.com/wiki/display/MIFOSX/MifosX+Technical
|
||||
|
||||
see https://github.com/keithwoodlock/mifosx/wiki/Screen-Based-Reporting for info around reporting
|
||||
|
||||
see https://github.com/keithwoodlock/mifosx/wiki/Git-Usuage for info around using git
|
||||
|
||||
see https://www.ohloh.net/p/mifosx for activity overview and basic code analysis.
|
||||
|
||||
see https://github.com/keithwoodlock/mifosx/wiki/Developer-deep-dive-into-Http-API for info around resource-oriented API work
|
||||
|
||||
Amazon Public AMI (currently out-of-date and will be updated - so don't use
|
||||
Amazon Public AMI
|
||||
=================
|
||||
|
||||
Launch instance <a target="_blank" href="https://console.aws.amazon.com/ec2/home?region=eu-west-1#launchAmi=ami-7b0e0a0f" title="mifos platform api beta 2">ami-7b0e0a0f</a>
|
||||
Launch instance <a target="_blank" href="https://console.aws.amazon.com/ec2/home?region=eu-west-1#launchAmi=ami-65e6e011" title="Mifos X Public AMI 1">ami-65e6e011</a>
|
||||
|
||||
- mifos-platform-api-beta-2
|
||||
- Mifos X Public AMI 1
|
||||
- Ubuntu11.10, tomcat7.0.21 (with SSL),MySql 5.1.62, Java 1.6_30, Mifos X Platform
|
||||
|
||||
Roadmap
|
||||
==============
|
||||
- Savings (Through collaboration with Hugo and Conflux)
|
||||
- Group Lending (Through collaboration with Soldevho)
|
||||
- Round out **Individual Lending** platform and application cababilities through working with (ENDA, Al Majmoua, GK-maarg http://www.gfspl.in/maarg)
|
||||
- API improvements from feedback
|
||||
- paging support
|
||||
- Ability to refine retrieval of single/list resources
|
||||
|
||||
- Round out Individual Lending platform and application cababilities:
|
||||
- GK-maarg http://www.gfspl.in/maarg) - see see https://mifosforge.jira.com/browse/MIFOSX-31
|
||||
- Elevate Africa, Heavens Family, CEDA Microfinance
|
||||
|
||||
- Solidatory Groups (Joint Liability Groups) & Linking loan functionality to these groups (@michal-At-soldevho - see https://mifosforge.jira.com/browse/MIFOSX-127, https://mifosforge.jira.com/browse/MIFOSX-5)
|
||||
|
||||
- Add spine of Fixed-Term Deposit Accounts and Savings Accounts (@madhukar-At-hugo - see https://mifosforge.jira.com/browse/MIFOSX-1)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
my api notes
|
||||
|
||||
- loan products api should return currencyCode and digitsAfterDecimal
|
||||
|
||||
|
||||
2) "officeId": 1, comes back for clients/template ... seems to suggest a new client defaults to head office rather than select one?
|
||||
+786
-584
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,18 @@
|
||||
.apiClick {
|
||||
text-decoration: underline;
|
||||
cursor: hand;
|
||||
cursor: pointer;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#jpw {
|
||||
text-decoration: underline;
|
||||
cursor: hand;
|
||||
cursor: pointer;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
.tocMatrix {
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<script type="text/javascript" src="jquery-1.7.min.js"></script>
|
||||
<title>Demo use of Mifos X platform</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<script type = "text/javascript">
|
||||
|
||||
|
||||
function setBasicAuthKey(username, password)
|
||||
{
|
||||
basicAuthKey = "";
|
||||
var jqxhr = $.ajax({
|
||||
url : "https://localhost:8443/mifosng-provider/api/v1/authentication?username=" + username + "&password=" + password,
|
||||
type : 'POST',
|
||||
contentType : "application/json; charset=utf-8",
|
||||
dataType : 'json',
|
||||
data : "{}",
|
||||
cache : false,
|
||||
success : function(data, textStatus, jqXHR) {
|
||||
basicAuthKey = data.base64EncodedAuthenticationKey;
|
||||
window.location = "http://www.google.com";
|
||||
return false;
|
||||
},
|
||||
error : function(jqXHR, textStatus, errorThrown) {
|
||||
alert("Invalid Username/Password");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<form name = "logonform">
|
||||
<table>
|
||||
<tr><td>User Name:</td><td><input type="text" name="username"></td></tr>
|
||||
<tr><td>Password: </td><td><input type="password" name="password"></td></tr>
|
||||
<tr><td><input type="button" value="Logon to Rough Approval" name="Submit" onclick= "setBasicAuthKey(document.logonform.username.value, document.logonform.password.value )"></td><td></td></tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
@@ -1,583 +0,0 @@
|
||||
-- This script is the core DDL for mifos platform
|
||||
-- Its includes tables related to lookup/reference data, user adminsitration, organisation modeling, client and loans
|
||||
-- and infrastructure tables needed for 'additional data' and 'screen based reporting' functionality.
|
||||
|
||||
-- It does not include DDL customisations needed for specific 'tenants' for 'additional data' functionality around clients/loans.
|
||||
|
||||
-- This script drops all tables and re-creates from scratch.
|
||||
|
||||
-- drop tables in base-schema
|
||||
|
||||
-- portfolio related tables
|
||||
DROP TABLE IF EXISTS `portfolio_note`;
|
||||
DROP TABLE IF EXISTS `portfolio_loan_transaction`;
|
||||
DROP TABLE IF EXISTS `portfolio_loan_repayment_schedule`;
|
||||
DROP TABLE IF EXISTS `portfolio_loan`;
|
||||
DROP TABLE IF EXISTS `portfolio_client`;
|
||||
DROP TABLE IF EXISTS `portfolio_group`;
|
||||
DROP TABLE IF EXISTS `portfolio_product_loan`;
|
||||
DROP TABLE IF EXISTS `portfolio_product_savings`;
|
||||
DROP TABLE IF EXISTS `portfolio_product_deposit`;
|
||||
-- organisation related tables
|
||||
DROP TABLE IF EXISTS `org_organisation_currency`;
|
||||
DROP TABLE IF EXISTS `org_fund`;
|
||||
DROP TABLE IF EXISTS `portfolio_office_transaction`;
|
||||
SET foreign_key_checks = 0;
|
||||
DROP TABLE IF EXISTS `org_office`;
|
||||
SET foreign_key_checks = 1;
|
||||
-- admin tables
|
||||
DROP TABLE IF EXISTS `admin_role_permission`;
|
||||
DROP TABLE IF EXISTS `admin_appuser_role`;
|
||||
DROP TABLE IF EXISTS `admin_appuser`;
|
||||
DROP TABLE IF EXISTS `admin_permission`;
|
||||
DROP TABLE IF EXISTS `admin_role`;
|
||||
|
||||
-- drop reference/lookup tables
|
||||
DROP TABLE IF EXISTS `ref_currency`;
|
||||
DROP TABLE IF EXISTS `ref_loan_status`;
|
||||
DROP TABLE IF EXISTS `ref_loan_transaction_processing_strategy`;
|
||||
|
||||
-- additional data and report tables
|
||||
DROP TABLE IF EXISTS `stretchydata_dataset_fields`;
|
||||
DROP TABLE IF EXISTS `stretchydata_dataset`;
|
||||
DROP TABLE IF EXISTS `stretchydata_allowed_value`;
|
||||
DROP TABLE IF EXISTS `stretchydata_allowed_list`;
|
||||
DROP TABLE IF EXISTS `stretchydata_datasettype`;
|
||||
DROP TABLE IF EXISTS `stretchy_parameter`;
|
||||
DROP TABLE IF EXISTS `stretchy_report_parameter`;
|
||||
DROP TABLE IF EXISTS `stretchy_report`;
|
||||
DROP TABLE IF EXISTS `rpt_sequence`;
|
||||
|
||||
-- DDL for reference/lookup tables
|
||||
CREATE TABLE `ref_currency` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(3) NOT NULL,
|
||||
`decimal_places` smallint(5) NOT NULL,
|
||||
`display_symbol` varchar(10) DEFAULT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`internationalized_name_code` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code` (`code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `ref_loan_status` (
|
||||
`id` smallint(5) NOT NULL,
|
||||
`display_name` varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `ref_loan_transaction_processing_strategy` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(100) DEFAULT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `ltp_strategy_code` (`code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- DDL for organisation wide related concepts
|
||||
CREATE TABLE `org_fund` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `fund_name_org` (`name`),
|
||||
UNIQUE KEY `fund_externalid_org` (`external_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `org_office` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`parent_id` bigint(20) DEFAULT NULL,
|
||||
`hierarchy` varchar(100) DEFAULT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`opening_date` date NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_org` (`name`),
|
||||
UNIQUE KEY `externalid_org` (`external_id`),
|
||||
KEY `FK2291C477E2551DCC` (`parent_id`),
|
||||
CONSTRAINT `FK2291C477E2551DCC` FOREIGN KEY (`parent_id`) REFERENCES `org_office` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_office_transaction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`from_office_id` bigint(20) DEFAULT NULL,
|
||||
`to_office_id` bigint(20) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` int(11) NOT NULL,
|
||||
`transaction_amount` decimal(19,6) NOT NULL,
|
||||
`transaction_date` date NOT NULL,
|
||||
`description` varchar(100) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK1E37728B93C6C1B6` (`to_office_id`),
|
||||
KEY `FK1E37728B783C5C25` (`from_office_id`),
|
||||
CONSTRAINT `FK1E37728B783C5C25` FOREIGN KEY (`from_office_id`) REFERENCES `org_office` (`id`),
|
||||
CONSTRAINT `FK1E37728B93C6C1B6` FOREIGN KEY (`to_office_id`) REFERENCES `org_office` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `org_organisation_currency` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(3) NOT NULL,
|
||||
`decimal_places` smallint(5) NOT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`display_symbol` varchar(10) DEFAULT NULL,
|
||||
`internationalized_name_code` varchar(50) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- DDL for admin tables
|
||||
CREATE TABLE `admin_permission` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`group_enum` smallint(5) NOT NULL,
|
||||
`code` varchar(100) NOT NULL,
|
||||
`default_description` varchar(500) NOT NULL,
|
||||
`default_name` varchar(100) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `admin_role` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `admin_appuser` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`office_id` bigint(20) DEFAULT NULL,
|
||||
`username` varchar(100) NOT NULL,
|
||||
`firstname` varchar(100) NOT NULL,
|
||||
`lastname` varchar(100) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`email` varchar(100) NOT NULL,
|
||||
`firsttime_login_remaining` bit(1) NOT NULL,
|
||||
`nonexpired` bit(1) NOT NULL,
|
||||
`nonlocked` bit(1) NOT NULL,
|
||||
`nonexpired_credentials` bit(1) NOT NULL,
|
||||
`enabled` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `username_org` (`username`),
|
||||
KEY `FKB3D587CE0DD567A` (`office_id`),
|
||||
CONSTRAINT `FKB3D587CE0DD567A` FOREIGN KEY (`office_id`) REFERENCES `org_office` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `admin_role_permission` (
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
`permission_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`role_id`,`permission_id`),
|
||||
KEY `FK8DEDB04815CEC7AB` (`role_id`),
|
||||
KEY `FK8DEDB048103B544B` (`permission_id`),
|
||||
CONSTRAINT `FK8DEDB048103B544B` FOREIGN KEY (`permission_id`) REFERENCES `admin_permission` (`id`),
|
||||
CONSTRAINT `FK8DEDB04815CEC7AB` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `admin_appuser_role` (
|
||||
`appuser_id` bigint(20) NOT NULL,
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`appuser_id`,`role_id`),
|
||||
KEY `FK7662CE59B4100309` (`appuser_id`),
|
||||
KEY `FK7662CE5915CEC7AB` (`role_id`),
|
||||
CONSTRAINT `FK7662CE5915CEC7AB` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`id`),
|
||||
CONSTRAINT `FK7662CE59B4100309` FOREIGN KEY (`appuser_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- DDL for portfolio tables
|
||||
CREATE TABLE `portfolio_group` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) DEFAULT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`),
|
||||
UNIQUE KEY `external_id` (`external_id`),
|
||||
KEY `FKJPWG000000000003` (`createdby_id`),
|
||||
KEY `FKJPWG000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPWG000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKJPWG000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_group_client` (
|
||||
`group_id` bigint(20) NOT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`group_id`,`client_id`),
|
||||
KEY `client_id` (`client_id`),
|
||||
CONSTRAINT `portfolio_group_client_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `portfolio_group` (`id`),
|
||||
CONSTRAINT `portfolio_group_client_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_client` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`office_id` bigint(20) NOT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`firstname` varchar(50) DEFAULT NULL,
|
||||
`lastname` varchar(50) DEFAULT NULL,
|
||||
`joining_date` date DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `external_id` (`external_id`),
|
||||
KEY `FKCE00CAB3E0DD567A` (`office_id`),
|
||||
KEY `FKAUD0000000000001` (`createdby_id`),
|
||||
KEY `FKAUD0000000000002` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKAUD0000000000001` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKAUD0000000000002` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKCE00CAB3E0DD567A` FOREIGN KEY (`office_id`) REFERENCES `org_office` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_product_loan` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`principal_amount` decimal(19,6) NOT NULL,
|
||||
`arrearstolerance_amount` decimal(19,6) NOT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`fund_id` bigint(20) DEFAULT NULL,
|
||||
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
|
||||
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
|
||||
`interest_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`interest_method_enum` smallint(5) NOT NULL,
|
||||
`interest_calculated_in_period_enum` smallint(5) NOT NULL DEFAULT '1',
|
||||
`repay_every` smallint(5) NOT NULL,
|
||||
`repayment_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`number_of_repayments` smallint(5) NOT NULL,
|
||||
`amortization_method_enum` smallint(5) NOT NULL,
|
||||
`flexible_repayment_schedule` bit(1) NOT NULL,
|
||||
`interest_rebate` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKAUD0000000000003` (`createdby_id`),
|
||||
KEY `FKAUD0000000000004` (`lastmodifiedby_id`),
|
||||
KEY `FKA6A8A7D77240145` (`fund_id`),
|
||||
KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`),
|
||||
CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`),
|
||||
CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `org_fund` (`id`),
|
||||
CONSTRAINT `FKAUD0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKAUD0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_loan` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) DEFAULT NULL,
|
||||
`fund_id` bigint(20) DEFAULT NULL,
|
||||
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
|
||||
`loan_status_id` smallint(5) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`principal_amount` decimal(19,6) NOT NULL,
|
||||
`arrearstolerance_amount` decimal(19,6) NOT NULL,
|
||||
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
|
||||
`interest_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`interest_method_enum` smallint(5) NOT NULL,
|
||||
`interest_calculated_in_period_enum` smallint(5) NOT NULL DEFAULT '1',
|
||||
`term_frequency` smallint(5) NOT NULL,
|
||||
`term_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`repay_every` smallint(5) NOT NULL,
|
||||
`repayment_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`number_of_repayments` smallint(5) NOT NULL,
|
||||
`amortization_method_enum` smallint(5) NOT NULL,
|
||||
`flexible_repayment_schedule` bit(1) NOT NULL,
|
||||
`interest_rebate` bit(1) NOT NULL,
|
||||
`interest_rebate_amount` decimal(19,6) DEFAULT NULL,
|
||||
`submittedon_date` datetime DEFAULT NULL,
|
||||
`approvedon_date` datetime DEFAULT NULL,
|
||||
`expected_disbursedon_date` date DEFAULT NULL,
|
||||
`expected_firstrepaymenton_date` date DEFAULT NULL,
|
||||
`interest_calculated_from_date` date DEFAULT NULL,
|
||||
`disbursedon_date` date DEFAULT NULL,
|
||||
`expected_maturedon_date` date DEFAULT NULL,
|
||||
`maturedon_date` date DEFAULT NULL,
|
||||
`closedon_date` datetime DEFAULT NULL,
|
||||
`rejectedon_date` datetime DEFAULT NULL,
|
||||
`rescheduledon_date` datetime DEFAULT NULL,
|
||||
`withdrawnon_date` datetime DEFAULT NULL,
|
||||
`writtenoffon_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `org_id` (`external_id`),
|
||||
KEY `FKB6F935D87179A0CB` (`client_id`),
|
||||
KEY `FKB6F935D8C8D4B434` (`product_id`),
|
||||
KEY `FK7C885878B1147D1` (`loan_status_id`),
|
||||
KEY `FK7C885877240145` (`fund_id`),
|
||||
KEY `FK_loan_ltp_strategy` (`loan_transaction_strategy_id`),
|
||||
CONSTRAINT `FK_loan_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`),
|
||||
CONSTRAINT `FK7C885877240145` FOREIGN KEY (`fund_id`) REFERENCES `org_fund` (`id`),
|
||||
CONSTRAINT `FK7C885878B1147D1` FOREIGN KEY (`loan_status_id`) REFERENCES `ref_loan_status` (`id`),
|
||||
CONSTRAINT `FKB6F935D87179A0CB` FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`),
|
||||
CONSTRAINT `FKB6F935D8C8D4B434` FOREIGN KEY (`product_id`) REFERENCES `portfolio_product_loan` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_loan_repayment_schedule` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`duedate` date DEFAULT NULL,
|
||||
`installment` smallint(5) DEFAULT NULL,
|
||||
`principal_amount` decimal(19,6) DEFAULT NULL,
|
||||
`principal_completed_derived` decimal(19,6) DEFAULT NULL,
|
||||
`interest_amount` decimal(19,6) DEFAULT NULL,
|
||||
`interest_completed_derived` decimal(19,6) DEFAULT NULL,
|
||||
`interest_waived_derived` decimal(19,6) DEFAULT NULL,
|
||||
`completed_derived` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK488B92AA40BE0710` (`loan_id`),
|
||||
CONSTRAINT `FK488B92AA40BE0710` FOREIGN KEY (`loan_id`) REFERENCES `portfolio_loan` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_loan_transaction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`transaction_type_enum` smallint(5) NOT NULL,
|
||||
`contra_id` bigint(20) DEFAULT NULL,
|
||||
`transaction_date` date NOT NULL,
|
||||
`amount` decimal(19,6) NOT NULL,
|
||||
`principal_portion_derived` decimal(19,6) NOT NULL,
|
||||
`interest_portion_derived` decimal(19,6) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKCFCEA42640BE0710` (`loan_id`),
|
||||
KEY `FKCFCEA426FC69F3F1` (`contra_id`),
|
||||
CONSTRAINT `FKCFCEA42640BE0710` FOREIGN KEY (`loan_id`) REFERENCES `portfolio_loan` (`id`),
|
||||
CONSTRAINT `FKCFCEA426FC69F3F1` FOREIGN KEY (`contra_id`) REFERENCES `portfolio_loan_transaction` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `portfolio_product_savings` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`currency_code` varchar(3) DEFAULT NULL,
|
||||
`currency_digits` smallint(5) DEFAULT NULL,
|
||||
`interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`minimum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`maximum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKJPW0000000000003` (`createdby_id`),
|
||||
KEY `FKJPW0000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPW0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKJPW0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `portfolio_product_deposit` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`minimum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`maximum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`maturity_default_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_min_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_max_interest_rate` decimal(19,6) NOT NULL,
|
||||
`can_renew` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`can_pre_close` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKJPW0000000000003` (`createdby_id`),
|
||||
KEY `FKJPW0000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPX0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKJPX0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_deposit_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`deposit_amount` decimal(19,6) DEFAULT NULL,
|
||||
`maturity_interest_rate` decimal(19,6) NOT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`can_renew` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`can_pre_close` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `deposit_acc_external_id` (`external_id`),
|
||||
KEY `FKKW0000000000001` (`client_id`),
|
||||
KEY `FKKW0000000000002` (`product_id`),
|
||||
CONSTRAINT `FKKW0000000000001` FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`),
|
||||
CONSTRAINT `FKKW0000000000002` FOREIGN KEY (`product_id`) REFERENCES `portfolio_product_deposit` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_note` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`loan_id` bigint(20) DEFAULT NULL,
|
||||
`loan_transaction_id` bigint(20) DEFAULT NULL,
|
||||
`note_type_enum` smallint(5) NOT NULL,
|
||||
`note` varchar(1000) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK7C9708924D26803` (`loan_transaction_id`),
|
||||
KEY `FK7C97089541F0A56` (`createdby_id`),
|
||||
KEY `FK7C970897179A0CB` (`client_id`),
|
||||
KEY `FK7C970898F889C3F` (`lastmodifiedby_id`),
|
||||
KEY `FK7C9708940BE0710` (`loan_id`),
|
||||
CONSTRAINT `FK7C9708924D26803` FOREIGN KEY (`loan_transaction_id`) REFERENCES `portfolio_loan_transaction` (`id`),
|
||||
CONSTRAINT `FK7C9708940BE0710` FOREIGN KEY (`loan_id`) REFERENCES `portfolio_loan` (`id`),
|
||||
CONSTRAINT `FK7C97089541F0A56` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FK7C970897179A0CB` FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`),
|
||||
CONSTRAINT `FK7C970898F889C3F` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- DDL for additional data (aka stretchy data) tables
|
||||
CREATE TABLE `rpt_sequence` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchydata_datasettype` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchy_parameter` (
|
||||
`parameter_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`parameter_name` varchar(45) NOT NULL,
|
||||
`parameter_variable` varchar(45) DEFAULT NULL,
|
||||
`parameter_label` varchar(45) NOT NULL,
|
||||
`parameter_displayType` varchar(45) NOT NULL,
|
||||
`parameter_FormatType` varchar(10) NOT NULL,
|
||||
`parameter_default` varchar(45) NOT NULL,
|
||||
`special` varchar(1) DEFAULT NULL,
|
||||
`selectOne` varchar(1) DEFAULT NULL,
|
||||
`selectAll` varchar(1) DEFAULT NULL,
|
||||
`parameter_sql` text,
|
||||
PRIMARY KEY (`parameter_id`),
|
||||
UNIQUE KEY `name_UNIQUE` (`parameter_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchydata_allowed_list` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchydata_allowed_value` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
`allowed_list_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `stretchydata_allowed_value_fk1` (`allowed_list_id`,`name`),
|
||||
CONSTRAINT `stretchydata_allowed_value_fk1` FOREIGN KEY (`allowed_list_id`) REFERENCES `stretchydata_allowed_list` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchydata_dataset` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
`datasettype_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `stretchydata_dataset_fk1` (`datasettype_id`,`name`),
|
||||
CONSTRAINT `stretchydata_dataset` FOREIGN KEY (`datasettype_id`) REFERENCES `stretchydata_datasettype` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchydata_dataset_fields` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
`data_type` varchar(15) NOT NULL,
|
||||
`data_length` int(11) DEFAULT NULL,
|
||||
`display_type` varchar(45) DEFAULT NULL,
|
||||
`dataset_id` int(11) NOT NULL,
|
||||
`allowed_list_id` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `stretchydata_dataset_fields_fk1` (`dataset_id`,`name`),
|
||||
KEY `stretchydata_dataset_fields_fk2` (`allowed_list_id`),
|
||||
CONSTRAINT `stretchydata_dataset_fields_fk1` FOREIGN KEY (`dataset_id`) REFERENCES `stretchydata_dataset` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT `stretchydata_dataset_fields_fk2` FOREIGN KEY (`allowed_list_id`) REFERENCES `stretchydata_allowed_list` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchy_report` (
|
||||
`report_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`report_name` varchar(100) NOT NULL,
|
||||
`report_type` varchar(20) NOT NULL,
|
||||
`report_subtype` varchar(20) DEFAULT NULL,
|
||||
`report_category` varchar(45) DEFAULT NULL,
|
||||
`report_sql` text,
|
||||
`description` text,
|
||||
`core_report` tinyint(1) DEFAULT '0',
|
||||
`use_report` tinyint(1) DEFAULT '0',
|
||||
PRIMARY KEY (`report_id`),
|
||||
UNIQUE KEY `report_name_UNIQUE` (`report_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchy_report_parameter` (
|
||||
`report_id` int(11) NOT NULL,
|
||||
`parameter_id` int(11) NOT NULL,
|
||||
`report_parameter_name` varchar(45) DEFAULT NULL,
|
||||
PRIMARY KEY (`report_id`,`parameter_id`),
|
||||
UNIQUE KEY `report_id_name_UNIQUE` (`report_id`,`report_parameter_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,978 @@
|
||||
-- drop tables in base-schema
|
||||
SET foreign_key_checks = 0;
|
||||
|
||||
-- drop accounting subsystem
|
||||
DROP TABLE IF EXISTS `acc_gl_account`;
|
||||
DROP TABLE IF EXISTS `acc_gl_closure`;
|
||||
DROP TABLE IF EXISTS `acc_gl_journal_entry`;
|
||||
|
||||
-- drop portfolio subsystem
|
||||
DROP TABLE IF EXISTS `m_appuser`;
|
||||
DROP TABLE IF EXISTS `m_appuser_role`;
|
||||
DROP TABLE IF EXISTS `m_charge`;
|
||||
DROP TABLE IF EXISTS `m_client`;
|
||||
DROP TABLE IF EXISTS `m_client_identifier`;
|
||||
DROP TABLE IF EXISTS `m_code`;
|
||||
DROP TABLE IF EXISTS `m_code_value`;
|
||||
DROP TABLE IF EXISTS `m_currency`;
|
||||
DROP TABLE IF EXISTS `m_deposit_account`;
|
||||
DROP TABLE IF EXISTS `m_deposit_account_transaction`;
|
||||
DROP TABLE IF EXISTS `m_document`;
|
||||
DROP TABLE IF EXISTS `m_fund`;
|
||||
DROP TABLE IF EXISTS `m_group`;
|
||||
DROP TABLE IF EXISTS `m_group_client`;
|
||||
DROP TABLE IF EXISTS `m_loan`;
|
||||
DROP TABLE IF EXISTS `m_loan_charge`;
|
||||
DROP TABLE IF EXISTS `m_loan_officer_assignment_history`;
|
||||
DROP TABLE IF EXISTS `m_loan_repayment_schedule`;
|
||||
DROP TABLE IF EXISTS `m_loan_transaction`;
|
||||
DROP TABLE IF EXISTS `m_note`;
|
||||
DROP TABLE IF EXISTS `m_office`;
|
||||
DROP TABLE IF EXISTS `m_office_transaction`;
|
||||
DROP TABLE IF EXISTS `m_organisation_currency`;
|
||||
DROP TABLE IF EXISTS `m_permission`;
|
||||
DROP TABLE IF EXISTS `m_portfolio_command_source`;
|
||||
DROP TABLE IF EXISTS `m_product_deposit`;
|
||||
DROP TABLE IF EXISTS `m_product_loan`;
|
||||
DROP TABLE IF EXISTS `m_product_loan_charge`;
|
||||
DROP TABLE IF EXISTS `m_product_savings`;
|
||||
DROP TABLE IF EXISTS `m_role`;
|
||||
DROP TABLE IF EXISTS `m_role_permission`;
|
||||
DROP TABLE IF EXISTS `m_saving_account`;
|
||||
DROP TABLE IF EXISTS `m_saving_schedule`;
|
||||
DROP TABLE IF EXISTS `m_staff`;
|
||||
DROP TABLE IF EXISTS `ref_loan_transaction_processing_strategy`;
|
||||
DROP TABLE IF EXISTS `x_registered_table`;
|
||||
|
||||
-- drop reporting related tables
|
||||
DROP TABLE IF EXISTS `r_enum_value`;
|
||||
DROP TABLE IF EXISTS `rpt_sequence`;
|
||||
DROP TABLE IF EXISTS `stretchy_parameter`;
|
||||
DROP TABLE IF EXISTS `stretchy_report`;
|
||||
DROP TABLE IF EXISTS `stretchy_report_parameter`;
|
||||
|
||||
-- drop deprecated 'stretchydata tables' which were used previously for 'additional data'
|
||||
DROP TABLE IF EXISTS `stretchydata_dataset`;
|
||||
DROP TABLE IF EXISTS `stretchydata_dataset_fields`;
|
||||
DROP TABLE IF EXISTS `stretchydata_datasettype`;
|
||||
|
||||
-- drop deprecated a 'additional data' tables
|
||||
drop table IF EXISTS `m_client_xadditional information`;
|
||||
drop table IF EXISTS `m_client_xhighly improbable info`;
|
||||
drop table IF EXISTS `m_loan_xadditional information`;
|
||||
|
||||
-- drop deprecated a 'accounting' tables
|
||||
DROP TABLE IF EXISTS `m_acc_coa`;
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
-- DDL for reference/lookup tables
|
||||
CREATE TABLE `m_currency` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(3) NOT NULL,
|
||||
`decimal_places` smallint(5) NOT NULL,
|
||||
`display_symbol` varchar(10) DEFAULT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`internationalized_name_code` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_organisation_currency` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(3) NOT NULL,
|
||||
`decimal_places` smallint(5) NOT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`display_symbol` varchar(10) DEFAULT NULL,
|
||||
`internationalized_name_code` varchar(50) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `ref_loan_transaction_processing_strategy` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`code` varchar(100) DEFAULT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `ltp_strategy_code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_code` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`code_name` varchar(100) DEFAULT NULL,
|
||||
`is_system_defined` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code_name` (`code_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_code_value` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`code_id` int(11) NOT NULL,
|
||||
`code_value` varchar(100) DEFAULT NULL,
|
||||
`order_position` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code_value` (`code_id`,`code_value`),
|
||||
KEY `FKCFCEA42640BE071Z` (`code_id`),
|
||||
CONSTRAINT `FKCFCEA42640BE071Z` FOREIGN KEY (`code_id`) REFERENCES `m_code` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_document` (
|
||||
`id` int(20) NOT NULL AUTO_INCREMENT,
|
||||
`parent_entity_type` varchar(50) NOT NULL,
|
||||
`parent_entity_id` int(20) NOT NULL DEFAULT '0',
|
||||
`name` varchar(250) NOT NULL,
|
||||
`file_name` varchar(250) NOT NULL,
|
||||
`size` int(20) DEFAULT '0',
|
||||
`type` varchar(50) DEFAULT NULL,
|
||||
`description` varchar(1000) DEFAULT NULL,
|
||||
`location` varchar(500) NOT NULL DEFAULT '0',
|
||||
`createdby_id` int(20) NOT NULL,
|
||||
`lastmodifiedby_id` int(20) NOT NULL,
|
||||
`created_date` datetime NOT NULL,
|
||||
`lastmodified_date` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
/*not a major table - just intended for database reporting use for enums and values that would be hidden in java*/
|
||||
CREATE TABLE `r_enum_value` (
|
||||
`enum_name` varchar(100) NOT NULL,
|
||||
`enum_id` int(11) NOT NULL,
|
||||
`enum_message_property` varchar(100) NOT NULL,
|
||||
`enum_value` varchar(100) NOT NULL,
|
||||
PRIMARY KEY (`enum_name`,`enum_id`),
|
||||
UNIQUE KEY `enum_message_property` (`enum_name`,`enum_message_property`),
|
||||
UNIQUE KEY `enum_value` (`enum_name`,`enum_value`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
/* used to link MySql tables to Mifos X application tables for additional data needs */
|
||||
CREATE TABLE `x_registered_table` (
|
||||
`registered_table_name` varchar(50) NOT NULL,
|
||||
`application_table_name` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`registered_table_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ================= end of reference/lookup tables =============
|
||||
|
||||
-- DDL for office related tables
|
||||
CREATE TABLE `m_office` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`parent_id` bigint(20) DEFAULT NULL,
|
||||
`hierarchy` varchar(100) DEFAULT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`opening_date` date NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_org` (`name`),
|
||||
UNIQUE KEY `externalid_org` (`external_id`),
|
||||
KEY `FK2291C477E2551DCC` (`parent_id`),
|
||||
CONSTRAINT `FK2291C477E2551DCC` FOREIGN KEY (`parent_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_office_transaction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`from_office_id` bigint(20) DEFAULT NULL,
|
||||
`to_office_id` bigint(20) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` int(11) NOT NULL,
|
||||
`transaction_amount` decimal(19,6) NOT NULL,
|
||||
`transaction_date` date NOT NULL,
|
||||
`description` varchar(100) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK1E37728B93C6C1B6` (`to_office_id`),
|
||||
KEY `FK1E37728B783C5C25` (`from_office_id`),
|
||||
CONSTRAINT `FK1E37728B783C5C25` FOREIGN KEY (`from_office_id`) REFERENCES `m_office` (`id`),
|
||||
CONSTRAINT `FK1E37728B93C6C1B6` FOREIGN KEY (`to_office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ============ end of office related tables ==========
|
||||
|
||||
-- DDL for admin tables
|
||||
CREATE TABLE `m_permission` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`grouping` varchar(45) DEFAULT NULL,
|
||||
`code` varchar(100) NOT NULL,
|
||||
`entity_name` varchar(100) DEFAULT NULL,
|
||||
`action_name` varchar(100) DEFAULT NULL,
|
||||
`can_maker_checker` tinyint(1) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `code` (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_role` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_role_permission` (
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
`permission_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`role_id`,`permission_id`),
|
||||
KEY `FK8DEDB04815CEC7AB` (`role_id`),
|
||||
KEY `FK8DEDB048103B544B` (`permission_id`),
|
||||
CONSTRAINT `FK8DEDB048103B544B` FOREIGN KEY (`permission_id`) REFERENCES `m_permission` (`id`),
|
||||
CONSTRAINT `FK8DEDB04815CEC7AB` FOREIGN KEY (`role_id`) REFERENCES `m_role` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_appuser` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`office_id` bigint(20) DEFAULT NULL,
|
||||
`username` varchar(100) NOT NULL,
|
||||
`firstname` varchar(100) NOT NULL,
|
||||
`lastname` varchar(100) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`email` varchar(100) NOT NULL,
|
||||
`firsttime_login_remaining` bit(1) NOT NULL,
|
||||
`nonexpired` bit(1) NOT NULL,
|
||||
`nonlocked` bit(1) NOT NULL,
|
||||
`nonexpired_credentials` bit(1) NOT NULL,
|
||||
`enabled` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `username_org` (`username`),
|
||||
KEY `FKB3D587CE0DD567A` (`office_id`),
|
||||
CONSTRAINT `FKB3D587CE0DD567A` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_appuser_role` (
|
||||
`appuser_id` bigint(20) NOT NULL,
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`appuser_id`,`role_id`),
|
||||
KEY `FK7662CE59B4100309` (`appuser_id`),
|
||||
KEY `FK7662CE5915CEC7AB` (`role_id`),
|
||||
CONSTRAINT `FK7662CE5915CEC7AB` FOREIGN KEY (`role_id`) REFERENCES `m_role` (`id`),
|
||||
CONSTRAINT `FK7662CE59B4100309` FOREIGN KEY (`appuser_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ================ end of user admin tables ===============
|
||||
|
||||
-- DDL for organisation wide related concepts
|
||||
CREATE TABLE `m_portfolio_command_source` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`action_name` varchar(50) NOT NULL,
|
||||
`entity_name` varchar(50) NOT NULL,
|
||||
`api_operation` varchar(30) NOT NULL,
|
||||
`api_resource` varchar(100) NOT NULL,
|
||||
`resource_id` bigint(20) DEFAULT NULL,
|
||||
`api_subresource` varchar(100) DEFAULT NULL,
|
||||
`subresource_id` bigint(20) DEFAULT NULL,
|
||||
`command_as_json` text NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` datetime NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` datetime DEFAULT NULL,
|
||||
`processing_result_enum` smallint(5) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_charge` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`charge_applies_to_enum` smallint(5) NOT NULL,
|
||||
`charge_time_enum` smallint(5) NOT NULL,
|
||||
`charge_calculation_enum` smallint(5) NOT NULL,
|
||||
`amount` decimal(19,6) NOT NULL,
|
||||
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_active` tinyint(1) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_fund` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `fund_name_org` (`name`),
|
||||
UNIQUE KEY `fund_externalid_org` (`external_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_staff` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`is_loan_officer` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`office_id` bigint(20) DEFAULT NULL,
|
||||
`firstname` varchar(50) DEFAULT NULL,
|
||||
`lastname` varchar(50) DEFAULT NULL,
|
||||
`display_name` varchar(100) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `display_name` (`display_name`),
|
||||
KEY `FK_m_staff_m_office` (`office_id`),
|
||||
CONSTRAINT `FK_m_staff_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ============ end of organisation wide related tables ===========
|
||||
|
||||
-- DDL client/group related tables
|
||||
CREATE TABLE `m_group` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`office_id` bigint(20) NOT NULL,
|
||||
`name` varchar(100) DEFAULT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`),
|
||||
UNIQUE KEY `external_id` (`external_id`),
|
||||
KEY `FKJPWG000000000003` (`createdby_id`),
|
||||
KEY `FKJPWG000000000004` (`lastmodifiedby_id`),
|
||||
KEY `office_id` (`office_id`),
|
||||
CONSTRAINT `FKJPWG000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKJPWG000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `m_group_ibfk_1` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_client` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`office_id` bigint(20) NOT NULL,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`firstname` varchar(50) DEFAULT NULL,
|
||||
`lastname` varchar(50) DEFAULT NULL,
|
||||
`display_name` varchar(100) NOT NULL,
|
||||
`image_key` varchar(500) DEFAULT NULL,
|
||||
`joined_date` date DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `external_id` (`external_id`),
|
||||
KEY `FKCE00CAB3E0DD567A` (`office_id`),
|
||||
KEY `FKAUD0000000000001` (`createdby_id`),
|
||||
KEY `FKAUD0000000000002` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKAUD0000000000001` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKAUD0000000000002` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKCE00CAB3E0DD567A` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_client_identifier` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`document_type_id` int(11) NOT NULL,
|
||||
`document_key` varchar(50) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_identifier_key` (`document_type_id`,`document_key`),
|
||||
UNIQUE KEY `unique_client_identifier` (`client_id`,`document_type_id`),
|
||||
KEY `FK_m_client_document_m_client` (`client_id`),
|
||||
KEY `FK_m_client_document_m_code_value` (`document_type_id`),
|
||||
CONSTRAINT `FK_m_client_document_m_client` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FK_m_client_document_m_code_value` FOREIGN KEY (`document_type_id`) REFERENCES `m_code_value` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_group_client` (
|
||||
`group_id` bigint(20) NOT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`group_id`,`client_id`),
|
||||
KEY `client_id` (`client_id`),
|
||||
CONSTRAINT `m_group_client_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`),
|
||||
CONSTRAINT `m_group_client_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ==== end of client/group related tables ==========
|
||||
|
||||
-- DDL for financial products and related tables
|
||||
CREATE TABLE `m_product_deposit` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`minimum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`maximum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`interest_compounded_every` smallint(5) NOT NULL DEFAULT '1',
|
||||
`interest_compounded_every_period_enum` smallint(5) NOT NULL DEFAULT '2',
|
||||
`maturity_default_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_min_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_max_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_compounding_interest_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_renewal_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`lock_in_period` bigint(20) DEFAULT NULL,
|
||||
`lock_in_period_type` smallint(5) NOT NULL DEFAULT '2',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_deposit_product` (`name`),
|
||||
UNIQUE KEY `externalid_deposit_product` (`external_id`),
|
||||
KEY `FKJPW0000000000003` (`createdby_id`),
|
||||
KEY `FKJPW0000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPX0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKJPX0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `m_product_savings` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`currency_code` varchar(3) DEFAULT NULL,
|
||||
`currency_digits` smallint(5) DEFAULT NULL,
|
||||
`interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`min_interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`max_interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`savings_deposit_amount` decimal(19,6) NOT NULL,
|
||||
`savings_product_type` smallint(5) DEFAULT NULL,
|
||||
`tenure_type` smallint(5) DEFAULT NULL,
|
||||
`deposit_every` bigint(20) DEFAULT NULL,
|
||||
`tenure` int(11) DEFAULT NULL,
|
||||
`frequency` int(11) DEFAULT NULL,
|
||||
`interest_type` smallint(5) DEFAULT NULL,
|
||||
`interest_calculation_method` smallint(5) DEFAULT NULL,
|
||||
`min_bal_for_withdrawal` decimal(19,6) NOT NULL,
|
||||
`is_partial_deposit_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`lock_in_period` bigint(20) DEFAULT NULL,
|
||||
`lock_in_period_type` smallint(5) NOT NULL DEFAULT '1',
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKJPW0000000000003` (`createdby_id`),
|
||||
KEY `FKJPW0000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPW0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKJPW0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_product_loan` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`principal_amount` decimal(19,6) NOT NULL,
|
||||
`arrearstolerance_amount` decimal(19,6) DEFAULT NULL,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`fund_id` bigint(20) DEFAULT NULL,
|
||||
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
|
||||
`interest_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`interest_method_enum` smallint(5) NOT NULL,
|
||||
`interest_calculated_in_period_enum` smallint(5) NOT NULL DEFAULT '1',
|
||||
`repay_every` smallint(5) NOT NULL,
|
||||
`repayment_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`number_of_repayments` smallint(5) NOT NULL,
|
||||
`amortization_method_enum` smallint(5) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKAUD0000000000003` (`createdby_id`),
|
||||
KEY `FKAUD0000000000004` (`lastmodifiedby_id`),
|
||||
KEY `FKA6A8A7D77240145` (`fund_id`),
|
||||
KEY `FK_ltp_strategy` (`loan_transaction_strategy_id`),
|
||||
CONSTRAINT `FKA6A8A7D77240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
|
||||
CONSTRAINT `FKAUD0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKAUD0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_product_loan_charge` (
|
||||
`product_loan_id` bigint(20) NOT NULL,
|
||||
`charge_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`product_loan_id`,`charge_id`),
|
||||
KEY `charge_id` (`charge_id`),
|
||||
CONSTRAINT `m_product_loan_charge_ibfk_1` FOREIGN KEY (`charge_id`) REFERENCES `m_charge` (`id`),
|
||||
CONSTRAINT `m_product_loan_charge_ibfk_2` FOREIGN KEY (`product_loan_id`) REFERENCES `m_product_loan` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ============ end of financial product related tables ===========
|
||||
|
||||
-- DDL for loan and loan related tables
|
||||
CREATE TABLE `m_loan` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`group_id` bigint(20) DEFAULT NULL,
|
||||
`product_id` bigint(20) DEFAULT NULL,
|
||||
`fund_id` bigint(20) DEFAULT NULL,
|
||||
`loan_officer_id` bigint(20) DEFAULT NULL,
|
||||
`guarantor_id` bigint(20) DEFAULT NULL,
|
||||
`loan_status_id` smallint(5) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`principal_amount` decimal(19,6) NOT NULL,
|
||||
`arrearstolerance_amount` decimal(19,6) DEFAULT NULL,
|
||||
`nominal_interest_rate_per_period` decimal(19,6) NOT NULL,
|
||||
`interest_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`annual_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`interest_method_enum` smallint(5) NOT NULL,
|
||||
`interest_calculated_in_period_enum` smallint(5) NOT NULL DEFAULT '1',
|
||||
`term_frequency` smallint(5) NOT NULL DEFAULT '0',
|
||||
`term_period_frequency_enum` smallint(5) NOT NULL DEFAULT '2',
|
||||
`repay_every` smallint(5) NOT NULL,
|
||||
`repayment_period_frequency_enum` smallint(5) NOT NULL,
|
||||
`number_of_repayments` smallint(5) NOT NULL,
|
||||
`amortization_method_enum` smallint(5) NOT NULL,
|
||||
`total_charges_due_at_disbursement_derived` decimal(19,6) DEFAULT NULL,
|
||||
`submittedon_date` datetime DEFAULT NULL,
|
||||
`approvedon_date` datetime DEFAULT NULL,
|
||||
`expected_disbursedon_date` date DEFAULT NULL,
|
||||
`expected_firstrepaymenton_date` date DEFAULT NULL,
|
||||
`interest_calculated_from_date` date DEFAULT NULL,
|
||||
`disbursedon_date` date DEFAULT NULL,
|
||||
`expected_maturedon_date` date DEFAULT NULL,
|
||||
`maturedon_date` date DEFAULT NULL,
|
||||
`closedon_date` datetime DEFAULT NULL,
|
||||
`rejectedon_date` datetime DEFAULT NULL,
|
||||
`rescheduledon_date` datetime DEFAULT NULL,
|
||||
`withdrawnon_date` datetime DEFAULT NULL,
|
||||
`writtenoffon_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`loan_transaction_strategy_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `org_id` (`external_id`),
|
||||
KEY `FKB6F935D87179A0CB` (`client_id`),
|
||||
KEY `FKB6F935D8C8D4B434` (`product_id`),
|
||||
KEY `FK7C885877240145` (`fund_id`),
|
||||
KEY `FK_loan_ltp_strategy` (`loan_transaction_strategy_id`),
|
||||
KEY `FK_m_loan_m_staff` (`loan_officer_id`),
|
||||
KEY `group_id` (`group_id`),
|
||||
KEY `FK_m_loan_guarantor` (`guarantor_id`),
|
||||
CONSTRAINT `FK7C885877240145` FOREIGN KEY (`fund_id`) REFERENCES `m_fund` (`id`),
|
||||
CONSTRAINT `FKB6F935D87179A0CB` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FKB6F935D8C8D4B434` FOREIGN KEY (`product_id`) REFERENCES `m_product_loan` (`id`),
|
||||
CONSTRAINT `FK_loan_ltp_strategy` FOREIGN KEY (`loan_transaction_strategy_id`) REFERENCES `ref_loan_transaction_processing_strategy` (`id`),
|
||||
CONSTRAINT `FK_m_loan_guarantor` FOREIGN KEY (`guarantor_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FK_m_loan_m_staff` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`),
|
||||
CONSTRAINT `m_loan_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_loan_charge` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`charge_id` bigint(20) NOT NULL,
|
||||
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`charge_time_enum` smallint(5) NOT NULL,
|
||||
`due_for_collection_as_of_date` date DEFAULT NULL,
|
||||
`charge_calculation_enum` smallint(5) NOT NULL,
|
||||
`calculation_percentage` decimal(19,6) DEFAULT NULL,
|
||||
`calculation_on_amount` decimal(19,6) DEFAULT NULL,
|
||||
`amount` decimal(19,6) NOT NULL,
|
||||
`amount_paid_derived` decimal(19,6) DEFAULT NULL,
|
||||
`amount_waived_derived` decimal(19,6) DEFAULT NULL,
|
||||
`amount_writtenoff_derived` decimal(19,6) DEFAULT NULL,
|
||||
`amount_outstanding_derived` decimal(19,6) NOT NULL DEFAULT '0.000000',
|
||||
`is_paid_derived` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `charge_id` (`charge_id`),
|
||||
KEY `m_loan_charge_ibfk_2` (`loan_id`),
|
||||
CONSTRAINT `m_loan_charge_ibfk_1` FOREIGN KEY (`charge_id`) REFERENCES `m_charge` (`id`),
|
||||
CONSTRAINT `m_loan_charge_ibfk_2` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_loan_officer_assignment_history` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`loan_officer_id` bigint(20) DEFAULT NULL,
|
||||
`start_date` date NOT NULL,
|
||||
`end_date` date DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_m_loan_officer_assignment_history_0001` (`loan_id`),
|
||||
KEY `fk_m_loan_officer_assignment_history_0002` (`loan_officer_id`),
|
||||
CONSTRAINT `fk_m_loan_officer_assignment_history_0001` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
|
||||
CONSTRAINT `fk_m_loan_officer_assignment_history_0002` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_loan_repayment_schedule` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`fromdate` date DEFAULT NULL,
|
||||
`duedate` date NOT NULL,
|
||||
`installment` smallint(5) NOT NULL,
|
||||
`principal_amount` decimal(19,6) DEFAULT NULL,
|
||||
`principal_completed_derived` decimal(19,6) DEFAULT NULL,
|
||||
`principal_writtenoff_derived` decimal(19,6) DEFAULT NULL,
|
||||
`interest_amount` decimal(19,6) DEFAULT NULL,
|
||||
`interest_completed_derived` decimal(19,6) DEFAULT NULL,
|
||||
`interest_writtenoff_derived` decimal(19,6) DEFAULT NULL,
|
||||
`fee_charges_amount` decimal(19,6) DEFAULT NULL,
|
||||
`fee_charges_completed_derived` decimal(19,6) DEFAULT NULL,
|
||||
`fee_charges_writtenoff_derived` decimal(19,6) DEFAULT NULL,
|
||||
`fee_charges_waived_derived` decimal(19,6) DEFAULT NULL,
|
||||
`penalty_charges_amount` decimal(19,6) DEFAULT NULL,
|
||||
`penalty_charges_completed_derived` decimal(19,6) DEFAULT NULL,
|
||||
`penalty_charges_writtenoff_derived` decimal(19,6) DEFAULT NULL,
|
||||
`penalty_charges_waived_derived` decimal(19,6) DEFAULT NULL,
|
||||
`completed_derived` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`interest_waived_derived` decimal(19,6) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK488B92AA40BE0710` (`loan_id`),
|
||||
CONSTRAINT `FK488B92AA40BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_loan_transaction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`transaction_type_enum` smallint(5) NOT NULL,
|
||||
`contra_id` bigint(20) DEFAULT NULL,
|
||||
`transaction_date` date NOT NULL,
|
||||
`amount` decimal(19,6) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`principal_portion_derived` decimal(19,6) DEFAULT NULL,
|
||||
`interest_portion_derived` decimal(19,6) DEFAULT NULL,
|
||||
`fee_charges_portion_derived` decimal(19,6) DEFAULT NULL,
|
||||
`penalty_charges_portion_derived` decimal(19,6) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKCFCEA42640BE0710` (`loan_id`),
|
||||
KEY `FKCFCEA426FC69F3F1` (`contra_id`),
|
||||
CONSTRAINT `FKCFCEA42640BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
|
||||
CONSTRAINT `FKCFCEA426FC69F3F1` FOREIGN KEY (`contra_id`) REFERENCES `m_loan_transaction` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ======== end of loan related tables ==========
|
||||
|
||||
-- DDL for deposit account related tables
|
||||
CREATE TABLE `m_deposit_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`status_enum` smallint(5) NOT NULL DEFAULT '0',
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`deposit_amount` decimal(19,6) DEFAULT NULL,
|
||||
`maturity_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`interest_compounded_every` smallint(5) NOT NULL DEFAULT '1',
|
||||
`interest_compounded_every_period_enum` smallint(5) NOT NULL DEFAULT '2',
|
||||
`projected_commencement_date` date NOT NULL,
|
||||
`actual_commencement_date` date DEFAULT NULL,
|
||||
`matures_on_date` datetime DEFAULT NULL,
|
||||
`projected_interest_accrued_on_maturity` decimal(19,6) NOT NULL,
|
||||
`actual_interest_accrued` decimal(19,6) DEFAULT NULL,
|
||||
`projected_total_maturity_amount` decimal(19,6) NOT NULL,
|
||||
`actual_total_amount` decimal(19,6) DEFAULT NULL,
|
||||
`is_compounding_interest_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`interest_paid` decimal(19,6) NOT NULL DEFAULT '0.000000',
|
||||
`is_interest_withdrawable` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`available_interest` decimal(19,6) DEFAULT '0.000000',
|
||||
`interest_posted_amount` decimal(19,6) DEFAULT '0.000000',
|
||||
`last_interest_posted_date` date DEFAULT NULL,
|
||||
`next_interest_posting_date` date DEFAULT NULL,
|
||||
`is_renewal_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`renewed_account_id` bigint(20) DEFAULT NULL,
|
||||
`is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`lock_in_period` bigint(20) DEFAULT NULL,
|
||||
`lock_in_period_type` smallint(5) NOT NULL DEFAULT '2',
|
||||
`withdrawnon_date` datetime DEFAULT NULL,
|
||||
`rejectedon_date` datetime DEFAULT NULL,
|
||||
`closedon_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `deposit_acc_external_id` (`external_id`),
|
||||
KEY `FKKW0000000000001` (`client_id`),
|
||||
KEY `FKKW0000000000002` (`product_id`),
|
||||
KEY `FKKW0000000000003` (`renewed_account_id`),
|
||||
CONSTRAINT `FKKW0000000000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FKKW0000000000002` FOREIGN KEY (`product_id`) REFERENCES `m_product_deposit` (`id`),
|
||||
CONSTRAINT `FKKW0000000000003` FOREIGN KEY (`renewed_account_id`) REFERENCES `m_deposit_account` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_deposit_account_transaction` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`deposit_account_id` bigint(20) NOT NULL,
|
||||
`transaction_type_enum` smallint(5) NOT NULL,
|
||||
`contra_id` bigint(20) DEFAULT NULL,
|
||||
`transaction_date` date NOT NULL,
|
||||
`amount` decimal(19,6) NOT NULL,
|
||||
`interest` decimal(19,6) NOT NULL,
|
||||
`total` decimal(19,6) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKKW00000000000005` (`deposit_account_id`),
|
||||
KEY `FKKW00000000000006` (`contra_id`),
|
||||
CONSTRAINT `FKKW00000000000005` FOREIGN KEY (`deposit_account_id`) REFERENCES `m_deposit_account` (`id`),
|
||||
CONSTRAINT `FKKW00000000000006` FOREIGN KEY (`contra_id`) REFERENCES `m_deposit_account_transaction` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ======= end of deposit account related tables
|
||||
|
||||
-- DDL for savings account related tables
|
||||
CREATE TABLE `m_saving_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`status_enum` smallint(5) NOT NULL DEFAULT '0',
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) NOT NULL,
|
||||
`deposit_amount_per_period` decimal(19,6) NOT NULL,
|
||||
`savings_product_type` smallint(5) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`total_deposit_amount` decimal(19,6) NOT NULL,
|
||||
`reccuring_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`regular_saving_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`tenure` int(11) NOT NULL,
|
||||
`tenure_type` smallint(5) DEFAULT NULL,
|
||||
`deposit_every` bigint(20) DEFAULT NULL,
|
||||
`frequency` int(11) DEFAULT NULL,
|
||||
`interest_type` smallint(5) DEFAULT NULL,
|
||||
`interest_calculation_method` smallint(5) DEFAULT NULL,
|
||||
`projected_commencement_date` date NOT NULL,
|
||||
`actual_commencement_date` date DEFAULT NULL,
|
||||
`matures_on_date` datetime DEFAULT NULL,
|
||||
`projected_interest_accrued_on_maturity` decimal(19,6) NOT NULL,
|
||||
`actual_interest_accrued` decimal(19,6) DEFAULT NULL,
|
||||
`projected_total_maturity_amount` decimal(19,6) NOT NULL,
|
||||
`actual_total_amount` decimal(19,6) DEFAULT NULL,
|
||||
`is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`lock_in_period` bigint(20) DEFAULT NULL,
|
||||
`lock_in_period_type` smallint(5) NOT NULL DEFAULT '1',
|
||||
`withdrawnon_date` datetime DEFAULT NULL,
|
||||
`rejectedon_date` datetime DEFAULT NULL,
|
||||
`closedon_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `deposit_acc_external_id` (`external_id`),
|
||||
KEY `FKSA0000000000001` (`client_id`),
|
||||
KEY `FKSA0000000000002` (`product_id`),
|
||||
CONSTRAINT `FKSA0000000000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FKSA0000000000002` FOREIGN KEY (`product_id`) REFERENCES `m_product_savings` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `m_saving_schedule` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`saving_account_id` bigint(20) NOT NULL,
|
||||
`duedate` date NOT NULL,
|
||||
`installment` smallint(5) NOT NULL,
|
||||
`deposit` decimal(21,4) NOT NULL,
|
||||
`payment_date` date DEFAULT NULL,
|
||||
`deposit_paid` decimal(21,4) DEFAULT NULL,
|
||||
`completed_derived` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKSS00000000001` (`saving_account_id`),
|
||||
CONSTRAINT `FKSS00000000001` FOREIGN KEY (`saving_account_id`) REFERENCES `m_saving_account` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
-- end of savings account related tables
|
||||
|
||||
-- DDL for notes associated with all client/group and financial accounts
|
||||
CREATE TABLE `m_note` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`loan_id` bigint(20) DEFAULT NULL,
|
||||
`loan_transaction_id` bigint(20) DEFAULT NULL,
|
||||
`deposit_account_id` bigint(20) DEFAULT NULL,
|
||||
`note_type_enum` smallint(5) NOT NULL,
|
||||
`note` varchar(1000) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK7C9708924D26803` (`loan_transaction_id`),
|
||||
KEY `FK7C97089541F0A56` (`createdby_id`),
|
||||
KEY `FK7C970897179A0CB` (`client_id`),
|
||||
KEY `FK7C970898F889C3F` (`lastmodifiedby_id`),
|
||||
KEY `FK7C9708940BE0710` (`loan_id`),
|
||||
KEY `FK_m_note_m_deposit_account` (`deposit_account_id`),
|
||||
CONSTRAINT `FK7C9708924D26803` FOREIGN KEY (`loan_transaction_id`) REFERENCES `m_loan_transaction` (`id`),
|
||||
CONSTRAINT `FK7C9708940BE0710` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
|
||||
CONSTRAINT `FK7C97089541F0A56` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK7C970897179A0CB` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FK7C970898F889C3F` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_note_m_deposit_account` FOREIGN KEY (`deposit_account_id`) REFERENCES `m_deposit_account` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
-- DDL for accounting sub system related tables
|
||||
CREATE TABLE `acc_gl_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
`parent_id` bigint(20) DEFAULT NULL,
|
||||
`gl_code` varchar(45) NOT NULL,
|
||||
`disabled` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`manual_journal_entries_allowed` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`header_account` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`classification` varchar(45) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `acc_gl_code` (`gl_code`),
|
||||
KEY `FK_ACC_0000000001` (`parent_id`),
|
||||
CONSTRAINT `FK_ACC_0000000001` FOREIGN KEY (`parent_id`) REFERENCES `acc_gl_account` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `acc_gl_closure` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`office_id` bigint(20) NOT NULL,
|
||||
`closing_date` date NOT NULL,
|
||||
`is_deleted` int(20) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`comments` varchar(500) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `office_id_closing_date` (`office_id`,`closing_date`),
|
||||
KEY `FK_acc_gl_closure_m_office` (`office_id`),
|
||||
KEY `FK_acc_gl_closure_m_appuser` (`createdby_id`),
|
||||
KEY `FK_acc_gl_closure_m_appuser_2` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FK_acc_gl_closure_m_appuser` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_closure_m_appuser_2` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_closure_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `acc_gl_journal_entry` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`account_id` bigint(20) NOT NULL,
|
||||
`office_id` bigint(20) NOT NULL,
|
||||
`reversal_id` bigint(20) DEFAULT NULL,
|
||||
`transaction_id` varchar(50) NOT NULL,
|
||||
`reversed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`portfolio_generated` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`entry_date` date NOT NULL,
|
||||
`type` varchar(50) NOT NULL,
|
||||
`amount` decimal(19,6) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`entity_type` varchar(50) DEFAULT NULL,
|
||||
`entity_id` bigint(20) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) NOT NULL,
|
||||
`lastmodifiedby_id` bigint(20) NOT NULL,
|
||||
`created_date` datetime NOT NULL,
|
||||
`lastmodified_date` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_acc_gl_journal_entry_m_office` (`office_id`),
|
||||
KEY `FK_acc_gl_journal_entry_m_appuser` (`createdby_id`),
|
||||
KEY `FK_acc_gl_journal_entry_m_appuser_2` (`lastmodifiedby_id`),
|
||||
KEY `FK_acc_gl_journal_entry_acc_gl_journal_entry` (`reversal_id`),
|
||||
KEY `FK_acc_gl_journal_entry_acc_gl_account` (`account_id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_acc_gl_account` FOREIGN KEY (`account_id`) REFERENCES `acc_gl_account` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_acc_gl_journal_entry` FOREIGN KEY (`reversal_id`) REFERENCES `acc_gl_journal_entry` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_m_appuser` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_m_appuser_2` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
-- =========== end of accounting related tables ==========
|
||||
|
||||
-- DDL for reporting related tables
|
||||
CREATE TABLE `rpt_sequence` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchy_parameter` (
|
||||
`parameter_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`parameter_name` varchar(45) NOT NULL,
|
||||
`parameter_variable` varchar(45) DEFAULT NULL,
|
||||
`parameter_label` varchar(45) NOT NULL,
|
||||
`parameter_displayType` varchar(45) NOT NULL,
|
||||
`parameter_FormatType` varchar(10) NOT NULL,
|
||||
`parameter_default` varchar(45) NOT NULL,
|
||||
`special` varchar(1) DEFAULT NULL,
|
||||
`selectOne` varchar(1) DEFAULT NULL,
|
||||
`selectAll` varchar(1) DEFAULT NULL,
|
||||
`parameter_sql` text,
|
||||
PRIMARY KEY (`parameter_id`),
|
||||
UNIQUE KEY `name_UNIQUE` (`parameter_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchy_report` (
|
||||
`report_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`report_name` varchar(100) NOT NULL,
|
||||
`report_type` varchar(20) NOT NULL,
|
||||
`report_subtype` varchar(20) DEFAULT NULL,
|
||||
`report_category` varchar(45) DEFAULT NULL,
|
||||
`report_sql` text,
|
||||
`description` text,
|
||||
`core_report` tinyint(1) DEFAULT '0',
|
||||
`use_report` tinyint(1) DEFAULT '0',
|
||||
PRIMARY KEY (`report_id`),
|
||||
UNIQUE KEY `report_name_UNIQUE` (`report_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `stretchy_report_parameter` (
|
||||
`report_id` int(11) NOT NULL,
|
||||
`parameter_id` int(11) NOT NULL,
|
||||
`report_parameter_name` varchar(45) DEFAULT NULL,
|
||||
PRIMARY KEY (`report_id`,`parameter_id`),
|
||||
UNIQUE KEY `report_id_name_UNIQUE` (`report_id`,`report_parameter_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
-- =========== end of reporting related tables ============
|
||||
@@ -1,47 +1,42 @@
|
||||
-- example of a DDL script to support customised 'additional data' for clients and loans.
|
||||
DROP TABLE IF EXISTS `additional client fields data`;
|
||||
DROP TABLE IF EXISTS `extra family details data`;
|
||||
DROP TABLE IF EXISTS `additional loan fields data`;
|
||||
|
||||
DROP TABLE IF EXISTS `portfolio_client_extra_additional information`;
|
||||
DROP TABLE IF EXISTS `portfolio_client_extra_highly improbable info`;
|
||||
DROP TABLE IF EXISTS `portfolio_loan_extra_additional information`;
|
||||
CREATE TABLE `additional client fields data` (
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`Business Description` varchar(100) DEFAULT NULL,
|
||||
`Years in Business` int(11) DEFAULT NULL,
|
||||
`Gender_cd` int(11) DEFAULT NULL,
|
||||
`Education_cv` varchar(60) DEFAULT NULL,
|
||||
`Next Visit` date DEFAULT NULL,
|
||||
`Highest Rate Paid` decimal(19,6) DEFAULT NULL,
|
||||
`Comment` text,
|
||||
PRIMARY KEY (`client_id`),
|
||||
CONSTRAINT `FK_Additional Client Fields Data_1` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_client_extra_Additional Information` (
|
||||
CREATE TABLE `extra family details data` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`Ethnic Group` varchar(50) DEFAULT NULL,
|
||||
`Ethnic Group Other` varchar(50) DEFAULT NULL,
|
||||
`Household Location` varchar(50) DEFAULT NULL,
|
||||
`Household Location Other` varchar(50) DEFAULT NULL,
|
||||
`Religion` varchar(50) DEFAULT NULL,
|
||||
`Religion Other` varchar(50) DEFAULT NULL,
|
||||
`Knowledge of Person` varchar(50) DEFAULT NULL,
|
||||
`Gender` varchar(10) DEFAULT NULL,
|
||||
`Whois` mediumtext,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`Name` varchar(40) DEFAULT NULL,
|
||||
`Date of Birth` date DEFAULT NULL,
|
||||
`Points Score` int(11) DEFAULT NULL,
|
||||
`Education_cdHighest` int(11) DEFAULT NULL,
|
||||
`Other Notes` text,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `portfolio_client_extra_Additional Information_fk1` FOREIGN KEY (`id`) REFERENCES `portfolio_client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
KEY `FK_Extra Family Details Data_1` (`client_id`),
|
||||
CONSTRAINT `FK_Extra Family Details Data_1` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_client_extra_Highly Improbable Info` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`Fathers Favourite Team` varchar(50) DEFAULT NULL,
|
||||
`Mothers Favourite Team` varchar(50) DEFAULT NULL,
|
||||
`Fathers DOB` date DEFAULT NULL,
|
||||
`Mothers DOB` date DEFAULT NULL,
|
||||
`Fathers Education` varchar(50) DEFAULT NULL,
|
||||
`Mothers Education` varchar(50) DEFAULT NULL,
|
||||
`Number of Children` int(11) DEFAULT NULL,
|
||||
`Favourite Town` varchar(30) DEFAULT NULL,
|
||||
`Closing Comments` mediumtext,
|
||||
`Annual Family Income` decimal(19,6) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `portfolio_client_extra_Highly Improbable Info_fk1` FOREIGN KEY (`id`) REFERENCES `portfolio_client` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `portfolio_loan_extra_Additional Information` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`Business Location` varchar(50) DEFAULT NULL,
|
||||
`Business Location Other` varchar(50) DEFAULT NULL,
|
||||
`Business` varchar(10) DEFAULT NULL,
|
||||
`Business Description` mediumtext,
|
||||
`Business Title` varchar(100) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `portfolio_loan_extra_Additional Information_fk1` FOREIGN KEY (`id`) REFERENCES `portfolio_loan` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `additional loan fields data` (
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`Business Description` varchar(100) DEFAULT NULL,
|
||||
`Years in Business` int(11) DEFAULT NULL,
|
||||
`Gender_cd` int(11) DEFAULT NULL,
|
||||
`Education_cv` varchar(60) DEFAULT NULL,
|
||||
`Next Visit` date DEFAULT NULL,
|
||||
`Highest Rate Paid` decimal(19,6) DEFAULT NULL,
|
||||
`Comment` text,
|
||||
PRIMARY KEY (`loan_id`),
|
||||
CONSTRAINT `FK_Additional Loan Fields Data_1` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,39 @@
|
||||
DROP TABLE IF EXISTS `risk_analysis`;
|
||||
CREATE TABLE `risk_analysis` (
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`proposed_loan_amount` decimal(19,6) DEFAULT NULL,
|
||||
`assets_cash` decimal(19,6) DEFAULT NULL,
|
||||
`assets_bank_accounts` decimal(19,6) DEFAULT NULL,
|
||||
`assets_accounts_receivable` decimal(19,6) DEFAULT NULL,
|
||||
`assets_inventory` decimal(19,6) DEFAULT NULL,
|
||||
`assets_total_fixed_business` decimal(19,6) DEFAULT NULL,
|
||||
`assets_total_business` decimal(19,6) DEFAULT NULL,
|
||||
`assets_total_household` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_accounts_payable` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_business_debts` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_total_business` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_equity_working_capital` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_total_household` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_household_equity` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cash_sales` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cash_sales2` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cost_goods_sold` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cost_goods_sold2` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_gross_profit` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_other_income1` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_total_income2` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_household_expense` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_payments_to_savings` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_operational_expenses` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_disposable_income` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_amount_loan_installment` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_available_surplus` decimal(19,6) DEFAULT NULL,
|
||||
`fi_inventory_turnover` decimal(19,6) DEFAULT NULL,
|
||||
`fi_gross_margin` decimal(19,6) DEFAULT NULL,
|
||||
`fi_indebtedness` decimal(19,6) DEFAULT NULL,
|
||||
`fi_loan_recommendation` decimal(19,6) DEFAULT NULL,
|
||||
`fi_roe` decimal(19,6) DEFAULT NULL,
|
||||
`fi_repayment_capacity` decimal(19,6) DEFAULT NULL,
|
||||
PRIMARY KEY (`client_id`),
|
||||
CONSTRAINT `FK_risk_analysis_1` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,58 @@
|
||||
drop table if exists `Loan Additional Data`;
|
||||
CREATE TABLE `Loan Additional Data` (
|
||||
`loan_id` bigint(20) NOT NULL,
|
||||
`PurposeOfLoan_cd` int(11) NOT NULL,
|
||||
`CollateralType_cd` int(11) NOT NULL,
|
||||
`Collateral notes` text NOT NULL,
|
||||
`YesNo_cd_Guarantor` int(11) NOT NULL,
|
||||
`Guarantor name` varchar(100) DEFAULT NULL,
|
||||
`Guarantor relation` varchar(100) DEFAULT NULL,
|
||||
`Guarantor address` varchar(100) DEFAULT NULL,
|
||||
`Guarantor telepone number` varchar(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`loan_id`),
|
||||
CONSTRAINT `FK_loan_additional_data` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
drop table if exists `Client Additional Data`;
|
||||
CREATE TABLE `Client Additional Data` (
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`Gender_cd` int(11) NOT NULL,
|
||||
`Date of Birth` date NOT NULL,
|
||||
`Home address` text NOT NULL,
|
||||
`Telepone number` varchar(20) NOT NULL,
|
||||
`Telepone number (2nd)` varchar(20) NOT NULL,
|
||||
`Email address` varchar(50) NOT NULL,
|
||||
`EducationLevel_cd` int(11) NOT NULL,
|
||||
`MaritalStatus_cd` int(11) NOT NULL,
|
||||
`Number of children` int(11) NOT NULL,
|
||||
`Citizenship` varchar(50) NOT NULL,
|
||||
`PovertyStatus_cd` int(11) NOT NULL,
|
||||
`YesNo_cd_Employed` int(11) NOT NULL,
|
||||
`FieldOfEmployment_cd_Field of employment` int(11) DEFAULT NULL,
|
||||
`Employer name` varchar(50) DEFAULT NULL,
|
||||
`Number of years` int(11) DEFAULT NULL,
|
||||
`Monthly salary` decimal(19,6) DEFAULT NULL,
|
||||
`YesNo_cd_Self employed` int(11) NOT NULL,
|
||||
`FieldOfEmployment_cd_Field of self-employment` int(11) DEFAULT NULL,
|
||||
`Business address` text DEFAULT NULL,
|
||||
`Number of employees` int(11) DEFAULT NULL,
|
||||
`Monthly salaries paid` decimal(19,6) DEFAULT NULL,
|
||||
`Monthly net income (of business activity)` decimal(19,6) DEFAULT NULL,
|
||||
`Monthly rent` decimal(19,6) DEFAULT NULL,
|
||||
`Other income generating activities` varchar(100) DEFAULT NULL,
|
||||
`YesNo_cd_Bookeeping` int(11) NOT NULL,
|
||||
`YesNo_cd_Loans with other institutions` int(11) NOT NULL,
|
||||
`From whom` varchar(100) DEFAULT NULL,
|
||||
`Amount` decimal(19,6) DEFAULT NULL,
|
||||
`Interest rate p.a` decimal(19,6) DEFAULT NULL,
|
||||
`Number of people depending on overal income` int(11) NOT NULL,
|
||||
`YesNo_cd_Bank account` int(11) NOT NULL,
|
||||
`YesNo_cd_Business plan provided` int(11) NOT NULL,
|
||||
`YesNo_cd_Access to internet` int(11) DEFAULT NULL,
|
||||
`Introduced by` varchar(100) DEFAULT NULL,
|
||||
`Known to introducer since` date NOT NULL,
|
||||
`Last visited by` varchar(100) DEFAULT NULL,
|
||||
`Last visited on` date NOT NULL,
|
||||
PRIMARY KEY (`client_id`),
|
||||
CONSTRAINT `FK_client_additional_data` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
File diff suppressed because one or more lines are too long
@@ -1,53 +0,0 @@
|
||||
-- create roles and associate with permissions
|
||||
INSERT INTO `admin_role` (`id`, `name`, `description`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
||||
VALUES
|
||||
(2,'Field officer','A field officer role allows the user to add client and loans and view reports but nothing else.',1,'2012-04-12 15:59:48','2012-04-12 15:59:48',1),
|
||||
(3,'Data Entry (Portfolio only)','This role allows a user full permissions around client and loan functionality but nothing else.',1,'2012-04-12 16:01:25','2012-04-12 16:01:25',1),
|
||||
(4,'Credit Committe Member','This role allows a user to approve reject or withdraw loans (with reporting).',1,'2012-04-12 16:11:25','2012-04-12 16:11:25',1),
|
||||
(5,'Manager','This role allows a manager to do anything related to portfolio management and also view all reports.',1,'2012-04-12 17:02:11','2012-04-12 17:02:11',1);
|
||||
|
||||
INSERT INTO `admin_role_permission` (`role_id`, `permission_id`)
|
||||
VALUES
|
||||
(2,4),(2,5),(2,6),(2,13),(2,20),(3,3),(4,4),(4,7),(4,8),(4,9),(4,10),(4,11),(4,12),(5,3),(5,4);
|
||||
|
||||
|
||||
-- insert office data required by appuser table/data
|
||||
INSERT INTO `org_office` (`id`, `parent_id`, `hierarchy`, `external_id`, `name`, `opening_date`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
||||
VALUES
|
||||
(2,1,'.2.','2','sub branch 1','2012-01-02',1,'2012-04-14 05:42:40','2012-04-16 11:47:05',1),
|
||||
(3,1,'.3.','3','sub branch 2','2012-03-01',1,'2012-04-16 04:12:02','2012-04-16 11:47:14',1),
|
||||
(4,1,'.4.',NULL,'sub branch 3','2012-04-17',1,'2012-04-17 06:01:10','2012-04-17 06:01:10',1);
|
||||
|
||||
|
||||
-- insert remaining fund/currencies/product data
|
||||
|
||||
INSERT INTO `org_organisation_currency` (`id`, `code`, `decimal_places`, `name`, `display_symbol`, `internationalized_name_code`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
||||
VALUES
|
||||
(17,'KES',2,'Kenyan Shilling','KSh','currency.KES',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
||||
(18,'BND',2,'Brunei Dollar','BND','currency.BND',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
||||
(19,'LBP',2,'Lebanese Pound','L','currency.LBP',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
||||
(20,'GHC',2,'Ghana Cedi','GHC','currency.GHC',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1),
|
||||
(22,'XOF',0,'CFA Franc BCEAO','CFA','currency.XOF',1,'2012-05-01 22:43:02','2012-05-01 22:43:02',1);
|
||||
|
||||
|
||||
INSERT INTO `portfolio_product_loan` (`id`, `currency_code`, `currency_digits`, `principal_amount`, `arrearstolerance_amount`, `name`, `description`, `nominal_interest_rate_per_period`, `interest_period_frequency_enum`, `annual_nominal_interest_rate`, `interest_method_enum`, `repay_every`, `repayment_period_frequency_enum`, `number_of_repayments`, `amortization_method_enum`, `flexible_repayment_schedule`, `interest_rebate`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`, `interest_calculated_in_period_enum`, `fund_id`)
|
||||
VALUES
|
||||
(1,'XOF',0,'100000.000000','1000.000000','Agricultural Loan','An agricultural loan given to farmers to help buy crop, stock and machinery. With an arrears tolerance setting of 1,000 CFA, loans are not marked as \'in arrears\' or \'in bad standing\' if the amount outstanding is less than this. Interest rate is described using monthly percentage rate (MPR) even though the loan typically lasts a year and requires one repayment (typically at time when farmer sells crop)','1.750000',2,'21.000000',0,12,2,1,1,'\0','\0',1,'2012-04-12 22:14:34','2012-04-12 22:14:34',1,1,NULL);
|
||||
|
||||
|
||||
|
||||
-- inserting client
|
||||
|
||||
INSERT INTO `portfolio_client` (`id`, `office_id`, `external_id`, `firstname`, `lastname`, `joining_date`, `createdby_id`, `created_date`, `lastmodified_date`, `lastmodifiedby_id`)
|
||||
VALUES
|
||||
(1,1,NULL,'Willie','O\'Meara','2009-01-04',1,'2012-04-12 22:07:44','2012-04-12 22:07:44',1),
|
||||
(2,1,NULL,'Declan','Browne','2009-01-04',1,'2012-04-12 22:15:39','2012-04-12 22:15:39',1),
|
||||
(3,1,NULL,'Ja','Fallon','2009-01-11',1,'2012-04-12 22:16:30','2012-04-12 22:16:30',1),
|
||||
(4,1,NULL,'Peter','Lambert','2009-01-11',1,'2012-04-12 22:17:01','2012-04-12 22:17:01',1),
|
||||
(5,1,NULL,NULL,'Sunnyville vegetable growers Ltd','2009-01-24',1,'2012-04-12 22:19:18','2012-04-12 22:19:18',1),
|
||||
(6,2,NULL,'Jacques','Lee','2012-04-03',1,'2012-04-14 06:09:22','2012-04-14 06:09:22',1),
|
||||
(7,1,NULL,'Kalilou','Traor','2009-02-04',1,'2012-04-14 09:38:11','2012-04-14 09:38:11',1),
|
||||
(8,1,NULL,'Sidi','Kon','2009-02-11',1,'2012-04-14 09:45:43','2012-04-14 09:45:43',1),
|
||||
(9,1,NULL,'Moustapha','Yattabar','2009-02-18',1,'2012-04-14 10:24:20','2012-04-14 10:24:20',1),
|
||||
(10,1,NULL,NULL,'Mali fruit sales ltd.','2009-02-18',1,'2012-04-14 10:25:37','2012-04-14 10:25:37',1),
|
||||
(11,1,NULL,NULL,'Djenne co-op group','2009-02-25',1,'2012-04-14 10:31:03','2012-04-14 10:31:03',1);
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-8
@@ -1,8 +0,0 @@
|
||||
CREATE TABLE `portfolio_group_client` (
|
||||
`group_id` bigint(20) NOT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`group_id`,`client_id`),
|
||||
FOREIGN KEY (`group_id`) REFERENCES `portfolio_group` (`id`),
|
||||
FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TABLE portfolio_group ADD UNIQUE (name);
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
DROP INDEX external_id ON portfolio_group;
|
||||
ALTER TABLE portfolio_group ADD UNIQUE (external_id);
|
||||
@@ -1,37 +0,0 @@
|
||||
ALTER TABLE `portfolio_product_savings`
|
||||
DROP COLUMN `ft_pre_closure_interest_rate` ,
|
||||
DROP COLUMN `ft_can_pre_close` ,
|
||||
DROP COLUMN `ft_can_renew` ,
|
||||
DROP COLUMN `ft_maturity_max_interest_rate` ,
|
||||
DROP COLUMN `ft_maturity_min_interest_rate` ,
|
||||
DROP COLUMN `ft_maturity_default_interest_rate` ,
|
||||
DROP COLUMN `ft_tenure_months` ,
|
||||
DROP COLUMN `savings_type_enum` ;
|
||||
|
||||
|
||||
CREATE TABLE `portfolio_product_deposit` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`minimum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`maximum_balance` decimal(19,6) DEFAULT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`maturity_default_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_min_interest_rate` decimal(19,6) NOT NULL,
|
||||
`maturity_max_interest_rate` decimal(19,6) NOT NULL,
|
||||
`can_renew` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`can_pre_close` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKJPW0000000000003` (`createdby_id`),
|
||||
KEY `FKJPW0000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPX0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `admin_appuser` (`id`),
|
||||
CONSTRAINT `FKJPX0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `admin_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -1,27 +0,0 @@
|
||||
DROP TABLE if exists `portfolio_deposit_account`;
|
||||
CREATE TABLE `portfolio_deposit_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) NOT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`deposit_amount` decimal(19,6) DEFAULT NULL,
|
||||
`maturity_interest_rate` decimal(19,6) NOT NULL,
|
||||
`tenure_months` int(11) NOT NULL,
|
||||
`can_renew` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`can_pre_close` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `deposit_acc_external_id` (`external_id`),
|
||||
KEY `FKKW0000000000001` (`client_id`),
|
||||
KEY `FKKW0000000000002` (`product_id`),
|
||||
CONSTRAINT `FKKW0000000000001` FOREIGN KEY (`client_id`) REFERENCES `portfolio_client` (`id`),
|
||||
CONSTRAINT `FKKW0000000000002` FOREIGN KEY (`product_id`) REFERENCES `portfolio_product_deposit` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
ALTER TABLE `stretchy_report`
|
||||
ADD COLUMN `description` TEXT NULL DEFAULT NULL AFTER `report_sql` ,
|
||||
ADD COLUMN `core_report` TINYINT(1) NULL DEFAULT '0' AFTER `description` ,
|
||||
ADD COLUMN `use_report` TINYINT(1) NULL DEFAULT '0' AFTER `core_report` ;
|
||||
@@ -0,0 +1,3 @@
|
||||
alter table m_loan add column group_id bigint(20) after client_id;
|
||||
alter table m_loan modify client_id bigint(20);
|
||||
alter table m_loan add constraint foreign key (`group_id`) references `m_group` (`id`);
|
||||
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE `m_client_identifier` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` BIGINT(20) NOT NULL,
|
||||
`document_type_id` INT(11) NOT NULL,
|
||||
`document_key` VARCHAR(500) NOT NULL,
|
||||
`description` VARCHAR(1000) NULL DEFAULT NULL,
|
||||
`createdby_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`lastmodifiedby_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`created_date` DATETIME NULL DEFAULT NULL,
|
||||
`lastmodified_date` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FK_m_client_document_m_client` (`client_id`),
|
||||
INDEX `FK_m_client_document_m_code_value` (`document_type_id`),
|
||||
CONSTRAINT `FK_m_client_document_m_client` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FK_m_client_document_m_code_value` FOREIGN KEY (`document_type_id`) REFERENCES `m_code_value` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
insert into m_code values(9,'Customer Identifier');
|
||||
|
||||
insert into m_code_value values (null,'9','Driving Licence','1');
|
||||
insert into m_code_value values (null,'9','Passport','2');
|
||||
insert into m_code_value values (null,'9','PAN Card','3');
|
||||
insert into m_code_value values (null,'9','Ration Card','4');
|
||||
insert into m_code_value values (null,'9','Other','5');
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
alter table m_loan_repayment_schedule add column principal_writtenoff_derived decimal(19,6) DEFAULT NULL after principal_completed_derived;
|
||||
alter table m_loan_repayment_schedule add column interest_writtenoff_derived decimal(19,6) DEFAULT NULL after interest_completed_derived;
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
ALTER TABLE `m_product_deposit`
|
||||
ADD COLUMN `is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0' AFTER `pre_closure_interest_rate`,
|
||||
ADD COLUMN `lock_in_period` bigint(20) DEFAULT NULL AFTER `is_lock_in_period_allowed`,
|
||||
ADD COLUMN `lock_in_period_type` smallint(5) NOT NULL DEFAULT '2' AFTER `lock_in_period`;
|
||||
|
||||
ALTER TABLE `m_deposit_account`
|
||||
ADD COLUMN `is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0' AFTER `pre_closure_interest_rate`,
|
||||
ADD COLUMN `lock_in_period` bigint(20) DEFAULT NULL AFTER `is_lock_in_period_allowed`,
|
||||
ADD COLUMN `lock_in_period_type` smallint(5) NOT NULL DEFAULT '2' AFTER `lock_in_period`;
|
||||
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE `m_document` (
|
||||
`id` INT(20) NOT NULL AUTO_INCREMENT,
|
||||
`parent_entity_type` VARCHAR(50) NOT NULL,
|
||||
`parent_entity_id` INT(20) NOT NULL DEFAULT '0',
|
||||
`name` VARCHAR(250) NOT NULL,
|
||||
`file_name` VARCHAR(250) NOT NULL,
|
||||
`size` INT(20) NULL DEFAULT '0',
|
||||
`type` VARCHAR(50) NULL DEFAULT NULL,
|
||||
`description` VARCHAR(1000) NULL DEFAULT NULL,
|
||||
`location` VARCHAR(500) NOT NULL DEFAULT '0',
|
||||
`createdby_id` INT(20) NOT NULL,
|
||||
`lastmodifiedby_id` INT(20) NOT NULL,
|
||||
`created_date` DATETIME NOT NULL,
|
||||
`lastmodified_date` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE=InnoDB;
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table m_loan_transaction drop column interest_waived_derived;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
alter table m_product_loan drop column flexible_repayment_schedule;
|
||||
alter table m_product_loan drop column interest_rebate;
|
||||
|
||||
alter table m_loan drop column flexible_repayment_schedule;
|
||||
alter table m_loan drop column interest_rebate;
|
||||
alter table m_loan drop column interest_rebate_amount;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
alter table m_loan_transaction modify column principal_portion_derived decimal(19,6);
|
||||
|
||||
alter table m_loan_transaction modify column interest_portion_derived decimal(19,6);
|
||||
|
||||
alter table m_loan_transaction modify column charges_portion_derived decimal(19,6);
|
||||
|
||||
|
||||
alter table m_product_loan modify column arrearstolerance_amount decimal(19,6);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
drop table `m_client_identifier`;
|
||||
|
||||
CREATE TABLE `m_client_identifier` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`document_type_id` int(11) NOT NULL,
|
||||
`document_key` varchar(50) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_identifier_key` (`document_type_id`, `document_key`),
|
||||
UNIQUE KEY `unique_client_identifier` (`client_id`,`document_type_id`),
|
||||
KEY `FK_m_client_document_m_client` (`client_id`),
|
||||
KEY `FK_m_client_document_m_code_value` (`document_type_id`),
|
||||
CONSTRAINT `FK_m_client_document_m_client` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FK_m_client_document_m_code_value` FOREIGN KEY (`document_type_id`) REFERENCES `m_code_value` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
/* table used as an additional table for GK risk analysis
|
||||
Also putting in default database as well for demos but not used for other tenants*/
|
||||
|
||||
DROP TABLE IF EXISTS `risk_analysis`;
|
||||
CREATE TABLE `risk_analysis` (
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`proposed_loan_amount` decimal(19,6) DEFAULT NULL,
|
||||
`assets_cash` decimal(19,6) DEFAULT NULL,
|
||||
`assets_bank_accounts` decimal(19,6) DEFAULT NULL,
|
||||
`assets_accounts_receivable` decimal(19,6) DEFAULT NULL,
|
||||
`assets_inventory` decimal(19,6) DEFAULT NULL,
|
||||
`assets_total_fixed_business` decimal(19,6) DEFAULT NULL,
|
||||
`assets_total_business` decimal(19,6) DEFAULT NULL,
|
||||
`assets_total_household` decimal(19,6) DEFAULT NULL,
|
||||
|
||||
`liabilities_accounts_payable` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_business_debts` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_total_business` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_equity_working_capital` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_total_household` decimal(19,6) DEFAULT NULL,
|
||||
`liabilities_household_equity` decimal(19,6) DEFAULT NULL,
|
||||
|
||||
`cashflow_cash_sales` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cash_sales2` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cost_goods_sold` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_cost_goods_sold2` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_gross_profit` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_other_income1` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_total_income2` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_household_expense` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_payments_to_savings` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_operational_expenses` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_disposable_income` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_amount_loan_installment` decimal(19,6) DEFAULT NULL,
|
||||
`cashflow_available_surplus` decimal(19,6) DEFAULT NULL,
|
||||
|
||||
`fi_inventory_turnover` decimal(19,6) DEFAULT NULL,
|
||||
`fi_gross_margin` decimal(19,6) DEFAULT NULL,
|
||||
`fi_indebtedness` decimal(19,6) DEFAULT NULL,
|
||||
`fi_loan_recommendation` decimal(19,6) DEFAULT NULL,
|
||||
`fi_roe` decimal(19,6) DEFAULT NULL,
|
||||
`fi_repayment_capacity` decimal(19,6) DEFAULT NULL,
|
||||
|
||||
|
||||
PRIMARY KEY (`client_id`),
|
||||
CONSTRAINT `FK_risk_analysis_1` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `image_key` VARCHAR(500) NULL DEFAULT NULL AFTER `display_name`;
|
||||
@@ -0,0 +1,34 @@
|
||||
alter table m_loan_charge
|
||||
add column due_for_collection_as_of_date date DEFAULT NULL after charge_time_enum;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column fee_charges_amount decimal(19,6) DEFAULT NULL after interest_writtenoff_derived;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column fee_charges_completed_derived decimal(19,6) DEFAULT NULL after fee_charges_amount;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column fee_charges_writtenoff_derived decimal(19,6) DEFAULT NULL after fee_charges_completed_derived;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column fee_charges_waived_derived decimal(19,6) DEFAULT NULL after fee_charges_writtenoff_derived;
|
||||
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column penalty_charges_amount decimal(19,6) DEFAULT NULL after fee_charges_waived_derived;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column penalty_charges_completed_derived decimal(19,6) DEFAULT NULL after penalty_charges_amount;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column penalty_charges_writtenoff_derived decimal(19,6) DEFAULT NULL after penalty_charges_completed_derived;
|
||||
|
||||
alter table m_loan_repayment_schedule
|
||||
add column penalty_charges_waived_derived decimal(19,6) DEFAULT NULL after penalty_charges_writtenoff_derived;
|
||||
|
||||
/**
|
||||
modify existing columns
|
||||
*/
|
||||
alter table `m_loan_repayment_schedule` MODIFY `duedate` date NOT NULL;
|
||||
alter table `m_loan_repayment_schedule` MODIFY `installment` smallint(5) NOT NULL;
|
||||
alter table `m_loan_repayment_schedule` MODIFY `interest_waived_derived` decimal(19,6) DEFAULT NULL;
|
||||
@@ -0,0 +1,8 @@
|
||||
alter table m_loan_repayment_schedule
|
||||
add column `fromdate` date DEFAULT NULL after `loan_id`;
|
||||
|
||||
alter table m_charge
|
||||
add column `is_penalty` tinyint(1) NOT NULL DEFAULT '0' after `amount`;
|
||||
|
||||
alter table m_loan_charge
|
||||
add column `is_penalty` tinyint(1) NOT NULL DEFAULT '0' after `charge_id`;
|
||||
@@ -0,0 +1,8 @@
|
||||
alter table m_loan_transaction
|
||||
drop column `charges_portion_derived`;
|
||||
|
||||
alter table m_loan_transaction
|
||||
add column `fee_charges_portion_derived` decimal(19,6) DEFAULT NULL after `interest_portion_derived`;
|
||||
|
||||
alter table m_loan_transaction
|
||||
add column `penalty_charges_portion_derived` decimal(19,6) DEFAULT NULL after `fee_charges_portion_derived`;
|
||||
@@ -0,0 +1,33 @@
|
||||
DROP TABLE IF EXISTS `m_product_savings`;
|
||||
CREATE TABLE `m_product_savings` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(100) NOT NULL,
|
||||
`description` varchar(500) DEFAULT NULL,
|
||||
`currency_code` varchar(3) DEFAULT NULL,
|
||||
`currency_digits` smallint(5) DEFAULT NULL,
|
||||
`interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`min_interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`max_interest_rate` decimal(19,6) DEFAULT NULL,
|
||||
`savings_deposit_amount` decimal(19,6) NOT NULL,
|
||||
`savings_product_type` smallint(5) DEFAULT NULL,
|
||||
`tenure_type` smallint(5) DEFAULT NULL,
|
||||
`tenure` int(11) DEFAULT NULL,
|
||||
`frequency` int(11) DEFAULT NULL,
|
||||
`interest_type` smallint(5) DEFAULT NULL,
|
||||
`interest_calculation_method` smallint(5) DEFAULT NULL,
|
||||
`min_bal_for_withdrawal` decimal(19,6) NOT NULL,
|
||||
`is_partial_deposit_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`lock_in_period` bigint(20) DEFAULT NULL,
|
||||
`lock_in_period_type` smallint(5) NOT NULL DEFAULT '1',
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKJPW0000000000003` (`createdby_id`),
|
||||
KEY `FKJPW0000000000004` (`lastmodifiedby_id`),
|
||||
CONSTRAINT `FKJPW0000000000003` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FKJPW0000000000004` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,47 @@
|
||||
DROP TABLE if exists `m_saving_account`;
|
||||
CREATE TABLE `m_saving_account` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`status_enum` smallint(5) NOT NULL DEFAULT '0',
|
||||
`external_id` varchar(100) DEFAULT NULL,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`product_id` bigint(20) NOT NULL,
|
||||
`deposit_amount_per_period` decimal(19,6) NOT NULL,
|
||||
`savings_product_type` smallint(5) DEFAULT NULL,
|
||||
`currency_code` varchar(3) NOT NULL,
|
||||
`currency_digits` smallint(5) NOT NULL,
|
||||
`total_deposit_amount` decimal(19,6) NOT NULL,
|
||||
`reccuring_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`regular_saving_nominal_interest_rate` decimal(19,6) NOT NULL,
|
||||
`tenure` int(11) NOT NULL,
|
||||
`tenure_type` smallint(5) DEFAULT NULL,
|
||||
`frequency` int(11) DEFAULT NULL,
|
||||
`interest_type` smallint(5) DEFAULT NULL,
|
||||
`interest_calculation_method` smallint(5) DEFAULT NULL,
|
||||
`projected_commencement_date` date NOT NULL,
|
||||
`actual_commencement_date` date DEFAULT NULL,
|
||||
`matures_on_date` datetime DEFAULT NULL,
|
||||
`projected_interest_accrued_on_maturity` decimal(19,6) NOT NULL,
|
||||
`actual_interest_accrued` decimal(19,6) DEFAULT NULL,
|
||||
`projected_total_maturity_amount` decimal(19,6) NOT NULL,
|
||||
`actual_total_amount` decimal(19,6) DEFAULT NULL,
|
||||
`is_preclosure_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pre_closure_interest_rate` decimal(19,6) NOT NULL,
|
||||
`is_lock_in_period_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`lock_in_period` bigint(20) DEFAULT NULL,
|
||||
`lock_in_period_type` smallint(5) NOT NULL DEFAULT '1',
|
||||
`withdrawnon_date` datetime DEFAULT NULL,
|
||||
`rejectedon_date` datetime DEFAULT NULL,
|
||||
`closedon_date` datetime DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `deposit_acc_external_id` (`external_id`),
|
||||
KEY `FKSA0000000000001` (`client_id`),
|
||||
KEY `FKSA0000000000002` (`product_id`),
|
||||
CONSTRAINT `FKSA0000000000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
|
||||
CONSTRAINT `FKSA0000000000002` FOREIGN KEY (`product_id`) REFERENCES `m_product_savings` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
DROP TABLE if exists `m_acc_coa`;
|
||||
CREATE TABLE `m_acc_coa` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(45) NOT NULL,
|
||||
`parent_id` bigint(20) DEFAULT NULL,
|
||||
`gl_code` varchar(45) NOT NULL,
|
||||
`is_disabled` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`manual_entries_allowed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`category` varchar(45) NOT NULL,
|
||||
`ledger_type` varchar(45) NOT NULL,
|
||||
`description` varchar(500) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `acc_gl_code` (`gl_code`),
|
||||
KEY `FK_ACC_0000000001` (`parent_id`),
|
||||
CONSTRAINT `FK_ACC_0000000001` FOREIGN KEY (`parent_id`) REFERENCES `m_acc_coa` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
alter table m_loan_charge
|
||||
add column `amount_waived_derived` decimal(19,6) DEFAULT NULL after `amount_paid_derived`;
|
||||
|
||||
alter table m_loan_charge
|
||||
add column `amount_writtenoff_derived` decimal(19,6) DEFAULT NULL after `amount_waived_derived`;
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE `m_loan_officer_assignment_history` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`loan_id` bigint(20) NOT NULL ,
|
||||
`loan_officer_id` bigint(20) DEFAULT NULL,
|
||||
`start_date` date NOT NULL,
|
||||
`end_date` date DEFAULT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_m_loan_officer_assignment_history_0001` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`),
|
||||
CONSTRAINT `fk_m_loan_officer_assignment_history_0002` FOREIGN KEY (`loan_officer_id`) REFERENCES `m_staff` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE `m_guarantor_external` (
|
||||
`loan_id` BIGINT(20) NOT NULL,
|
||||
`firstname` VARCHAR(50) NOT NULL,
|
||||
`lastname` VARCHAR(50) NOT NULL,
|
||||
`dob` DATE NULL,
|
||||
`address_line_1` VARCHAR(500) NULL,
|
||||
`address_line_2` VARCHAR(500) NULL,
|
||||
`city` VARCHAR(50) NULL,
|
||||
`state` VARCHAR(50) NULL,
|
||||
`country` VARCHAR(50) NULL,
|
||||
`zip` VARCHAR(20) NULL,
|
||||
`house_phone_number` VARCHAR(20) NULL,
|
||||
`mobile_number` VARCHAR(20) NULL,
|
||||
`comment` VARCHAR(20) NULL,
|
||||
PRIMARY KEY (`loan_id`),
|
||||
CONSTRAINT `FK_m_guarantor_m_loan` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
|
||||
)
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
ALTER TABLE `m_loan`
|
||||
ADD COLUMN `guarantor_id` BIGINT(20) NULL DEFAULT NULL AFTER `loan_officer_id`,
|
||||
ADD CONSTRAINT `FK_m_loan_guarantor` FOREIGN KEY (`guarantor_id`) REFERENCES `m_client` (`id`);
|
||||
|
||||
insert into x_registered_table values ('m_guarantor_external','m_loan');
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE `m_maker_checker` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`task_name` varchar(100) NOT NULL,
|
||||
`task_json` varchar(1000) NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` date NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` date DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,17 @@
|
||||
drop table `m_maker_checker`;
|
||||
CREATE TABLE `m_portfolio_command_source` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`api_operation` varchar(20) NOT NULL,
|
||||
`api_resource` varchar(20) NOT NULL,
|
||||
`resource_id` bigint(20) DEFAULT NULL,
|
||||
`command_as_json` varchar(1000) NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` date NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` date DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
update m_permission p
|
||||
join stretchy_report sr on p.code = concat('CAN_RUN_', sr.report_name)
|
||||
set p.`code` = concat('READ_', sr.report_name),
|
||||
p.default_description = concat('READ_', sr.report_name),
|
||||
p.default_name = concat('READ_', sr.report_name);
|
||||
|
||||
update m_permission p
|
||||
join x_registered_table r on p.code = concat('CAN_READ_', r.registered_table_name)
|
||||
set p.`code` = concat('READ_', r.registered_table_name),
|
||||
p.default_description = concat('READ_', r.registered_table_name),
|
||||
p.default_name = concat('READ_', r.registered_table_name);
|
||||
|
||||
update m_permission p
|
||||
join x_registered_table r on p.code = concat('CAN_UPDATE_', r.registered_table_name)
|
||||
set p.`code` = concat('UPDATE_', r.registered_table_name),
|
||||
p.default_description = concat('UPDATE_', r.registered_table_name),
|
||||
p.default_name = concat('UPDATE_', r.registered_table_name);
|
||||
|
||||
update m_permission p
|
||||
join x_registered_table r on p.code = concat('CAN_CREATE_', r.registered_table_name)
|
||||
set p.`code` = concat('CREATE_', r.registered_table_name),
|
||||
p.default_description = concat('CREATE_', r.registered_table_name),
|
||||
p.default_name = concat('CREATE_', r.registered_table_name);
|
||||
|
||||
update m_permission p
|
||||
join x_registered_table r on p.code = concat('CAN_DELETE_', r.registered_table_name)
|
||||
set p.`code` = concat('DELETE_', r.registered_table_name),
|
||||
p.default_description = concat('DELETE_', r.registered_table_name),
|
||||
p.default_name = concat('DELETE_', r.registered_table_name);
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
UPDATE stretchy_parameter
|
||||
SET `parameter_sql` = 'select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,\r rp.parameter_id, rp.report_parameter_name, p.parameter_name\r from stretchy_report r\r left join stretchy_report_parameter rp on rp.report_id = r.report_id\r left join stretchy_parameter p on p.parameter_id = rp.parameter_id\r where r.use_report is true\r and exists\r (\r select \'f\'\r from m_appuser_role ur \r join m_role r on r.id = ur.role_id\r join m_role_permission rp on rp.role_id = r.id\r join m_permission p on p.id = rp.permission_id\r where ur.appuser_id = ${currentUserId}\r and (p.code in (\'ALL_FUNCTIONS_READ\', \'ALL_FUNCTIONS\') or p.code = concat(\"READ_\", r.report_name))\r )\r order by r.report_name, rp.parameter_id'
|
||||
WHERE parameter_name = 'FullReportList';
|
||||
|
||||
UPDATE stretchy_parameter
|
||||
SET `parameter_sql` = 'select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,\r rp.parameter_id, rp.report_parameter_name, p.parameter_name\r from stretchy_report r\r left join stretchy_report_parameter rp on rp.report_id = r.report_id\r left join stretchy_parameter p on p.parameter_id = rp.parameter_id\r where r.report_category = \'${reportCategory}\'\r and r.use_report is true\r and exists\r (\r select \'f\'\r from m_appuser_role ur \r join m_role r on r.id = ur.role_id\r join m_role_permission rp on rp.role_id = r.id\r join m_permission p on p.id = rp.permission_id\r where ur.appuser_id = ${currentUserId}\r and (p.code in (\'ALL_FUNCTIONS_READ\', \'ALL_FUNCTIONS\') or p.code = concat(\"READ_\", r.report_name))\r )\r order by r.report_name, rp.parameter_id'
|
||||
WHERE parameter_name = 'reportCategoryList';
|
||||
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE m_permission
|
||||
DROP COLUMN `group_enum` ,
|
||||
ADD COLUMN `grouping` VARCHAR(45) NULL AFTER `id` ,
|
||||
ADD COLUMN `order_in_grouping` INT NULL AFTER `grouping` ,
|
||||
ADD UNIQUE INDEX `code` (`code` ASC) ;
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
ALTER TABLE m_permission
|
||||
DROP COLUMN `order_in_grouping` ,
|
||||
ADD COLUMN `entity_name` VARCHAR(100) NULL AFTER `default_name` ,
|
||||
ADD COLUMN `action_name` VARCHAR(100) NULL AFTER `entity_name` ;
|
||||
|
||||
/*
|
||||
this scripts removes all current m_role_permission and m_permission entries
|
||||
and then inserts new m_permission entries and just one m_role_permission entry
|
||||
which gives the role (id 1 - super user) an ALL_FUNCTIONS permission
|
||||
|
||||
If you had other roles set up with specific permissions you will have to set up their permissions again.
|
||||
*/
|
||||
|
||||
delete from m_role_permission;
|
||||
delete from m_permission;
|
||||
|
||||
/* System Supplied Permissons */
|
||||
INSERT INTO `m_permission` VALUES (1,'special','USER_ADMINISTRATION_SUPER_USER','An application user will have permission to execute all tasks related to user administration.','User administration ALL',NULL,NULL),(2,'special','ORGANISATION_ADMINISTRATION_SUPER_USER','An application user will have permission to execute all tasks related to organisation administration.','Organisation adminsitration ALL',NULL,NULL),(3,'special','PORTFOLIO_MANAGEMENT_SUPER_USER','An application user will have permission to execute all tasks related to portfolio management.','Portfolio management ALL',NULL,NULL),(4,'special','REPORTING_SUPER_USER','An application user will have permission to execute and view all reports.','Reporting ALL',NULL,NULL),(5,'portfolio','CREATE_LOAN','Allows an application user to sumit new loan application.','Can submit new loan application','LOAN','CREATE'),(6,'portfolio','CREATEHISTORIC_LOAN','Allows an application user to sumit new loan application where the submitted on date is in the past.','Can submit historic loan application','LOAN','CREATEHISTORIC'),(7,'transaction_loan','APPROVE_LOAN','Allows an application user to approve a loan application.','Can approve loan application','LOAN','APPROVE'),(8,'transaction_loan','APPROVEINPAST_LOAN','Allows an application user to approve a loan application where the approval date is in the past.','Can approve loan application in the past','LOAN','APPROVEINPAST'),(9,'transaction_loan','REJECT_LOAN','Allows an application user to reject a loan application.','Can reject loan application','LOAN','REJECT'),(10,'transaction_loan','REJECTINPAST_LOAN','Allows an application user to reject a loan application where the rejected date is in the past.','Can reject loan application in the past','LOAN','REJECTINPAST'),
|
||||
(11,'transaction_loan','WITHDRAW_LOAN','Allows an application user to mark loan application as withdrawn by client.','Can withdraw loan application','LOAN','WITHDRAW'),(12,'transaction_loan','WITHDRAWINPAST_LOAN','Allows an application user to mark loan application as withdrawn by client where the withdran on date is in the past.','Can withdraw loan application in the past','LOAN','WITHDRAWINPAST'),(13,'portfolio','DELETE_LOAN','Allows an application user to complete delete the loan application if it is submitted but not approved.','Can delete submitted loan application','LOAN','DELETE'),(14,'transaction_loan','APPROVALUNDO_LOAN','Allows an application user to undo a loan approval.','Can undo loan approval','LOAN','APPROVALUNDO'),(15,'transaction_loan','DISBURSE_LOAN','Allows an application user to disburse a loan application.','Can disburse loan','LOAN','DISBURSE'),(16,'transaction_loan','DISBURSEINPAST_LOAN','Allows an application user to disburse a loan where the disbursement date is in the past.','Can disburse loan in the past','LOAN','DISBURSEINPAST'),(17,'transaction_loan','DISBURSALUNDO_LOAN','Allows an application user to undo a loan disbursal if not payments already made.','Can undo loan disbursal','LOAN','DISBURSALUNDO'),(18,'transaction_loan','REPAYMENT_LOAN','Allows an application user to enter a repayment on the loan.','Can enter a repayment against a loan','LOAN','REPAYMENT'),(19,'transaction_loan','REPAYMENTINPAST_LOAN','Allows an application user to enter a repayment on the loan where the repayment date is in the past.','Can enter a repayment against a loan in the past','LOAN','REPAYMENTINPAST'),(20,'portfolio','CREATE_CLIENT','Allows an application user to add a new client.','Can add a new client.','CLIENT','CREATE'),
|
||||
(42,'special','ALL_FUNCTIONS','An application user will have permission to execute all tasks.','ALL',NULL,NULL),(43,'special','ALL_FUNCTIONS_READ','An application user will have permission to execute all read tasks.','ALL READ',NULL,NULL),(112,'organisation','CREATE_CHARGE','Create a Charge','Create a Charge','CHARGE','CREATE'),(113,'organisation','READ_CHARGE','Read Charges','Read Charges','CHARGE','READ'),(114,'organisation','UPDATE_CHARGE','Update a Charge','Update a Charge','CHARGE','UPDATE'),(115,'organisation','DELETE_CHARGE','Delete a Charge','Delete a Charge','CHARGE','DELETE'),(120,'portfolio','READ_CLIENT','Read Clients','Read Clients','CLIENT','READ'),(121,'portfolio','UPDATE_CLIENT','Update a Client','Update a Client','CLIENT','UPDATE'),(122,'portfolio','DELETE_CLIENT','Delete a Client','Delete a Client','CLIENT','DELETE'),(123,'portfolio','CREATE_CLIENTIMAGE','Create/Update Client Image','Create/Update Client Image','CLIENTIMAGE','CREATE'),(124,'portfolio','READ_CLIENTIMAGE','Read Client Images','Read Client Images','CLIENTIMAGE','READ'),(126,'portfolio','DELETE_CLIENTIMAGE','Delete Client Image','Delete Client Image','CLIENTIMAGE','DELETE'),(127,'portfolio','CREATE_CLIENTNOTE','Create a Client Note','Create a Client Note','CLIENTNOTE','CREATE'),(128,'portfolio','READ_CLIENTNOTE','Read Client Notes','Read Client Notes','CLIENTNOTE','READ'),(129,'portfolio','UPDATE_CLIENTNOTE','Update a Client Note','Update a Client Note','CLIENTNOTE','UPDATE'),(130,'portfolio','DELETE_CLIENTNOTE','Delete a Client Note','Delete a Client Note','CLIENTNOTE','DELETE'),(131,'portfolio','CREATE_CLIENTIDENTIFIER','Create a Client Identifier','Create a Client Identifier','CLIENTIDENTIFIER','CREATE'),
|
||||
(132,'portfolio','READ_CLIENTIDENTIFIER','Read Client Identifiers','Read Client Identifiers','CLIENTIDENTIFIER','READ'),(133,'portfolio','UPDATE_CLIENTIDENTIFIER','Update a Client Identifier','Update a Client Identifier','CLIENTIDENTIFIER','UPDATE'),(134,'portfolio','DELETE_CLIENTIDENTIFIER','Delete a Client Identifier','Delete a Client Identifier','CLIENTIDENTIFIER','DELETE'),(135,'configuration','CREATE_CODE','Create a Code','Create a Code','CODE','CREATE'),(136,'configuration','READ_CODE','Read Codes','Read Codes','CODE','READ'),(137,'configuration','UPDATE_CODE','Update a Code','Update a Code','CODE','UPDATE'),(138,'configuration','DELETE_CODE','Delete a Code','Delete a Code','CODE','DELETE'),(139,'configuration','READ_CURRENCY','Read Currencies','Read Currencies','CURRENCY','READ'),(140,'configuration','UPDATE_CURRENCY','Update Currencies','Update Currencies','CURRENCY','UPDATE'),(141,'portfolio','CREATE_DOCUMENT','Create and Upload a Document','Create and Upload a Document','DOCUMENT','CREATE'),(142,'portfolio','READ_DOCUMENT','Read Documents','Read Documents','DOCUMENT','READ'),(143,'portfolio','UPDATE_DOCUMENT','Update and Upload a Document','Update and Upload a Document','DOCUMENT','UPDATE'),(144,'portfolio','DELETE_DOCUMENT','Delete a Document','Delete a Document','DOCUMENT','DELETE'),(145,'organisation','CREATE_FUND','Create a Fund','Create a Fund','FUND','CREATE'),(146,'organisation','READ_FUND','Read Funds','Read Funds','FUND','READ'),(147,'organisation','UPDATE_FUND','Update a Fund','Update a Fund','FUND','UPDATE'),(148,'organisation','DELETE_FUND','Delete Fund','Delete Fund','FUND','DELETE'),(149,'portfolio','CREATE_GROUP','Create a Group','Create a Group','GROUP','CREATE'),
|
||||
(150,'portfolio','READ_GROUP','Read Groups','Read Groups','GROUP','READ'),(151,'portfolio','UPDATE_GROUP','Update a Group','Update a Group','GROUP','UPDATE'),(152,'portfolio','DELETE_GROUP','Delete a Group','Delete a Group','GROUP','DELETE'),(153,'organisation','CREATE_LOANPRODUCT','Create a Loan Product','Create a Loan Product','LOANPRODUCT','CREATE'),(154,'organisation','READ_LOANPRODUCT','Read Loan Products','Read Loan Products','LOANPRODUCT','READ'),(155,'organisation','UPDATE_LOANPRODUCT','Update a Loan Product','Update a Loan Product','LOANPRODUCT','UPDATE'),(156,'organisation','DELETE_LOANPRODUCT','Delete a Loan Product','Delete a Loan Product','LOANPRODUCT','DELETE'),(157,'portfolio','READ_LOAN','Read Loans','Read Loans','LOAN','READ'),(158,'portfolio','UPDATE_LOAN','Update a Loan','Update a Loan','LOAN','UPDATE'),(159,'portfolio','UPDATEHISTORIC_LOAN','Update a Loan that was Created Historically','Update a Loan that was Created Historically','LOAN','UPDATEHISTORIC'),(160,'portfolio','CREATE_LOANCHARGE','Create a Loan Charge','Create a Loan Charge','LOANCHARGE','CREATE'),(161,'portfolio','UPDATE_LOANCHARGE','Update a Loan Charge','Update a Loan Charge','LOANCHARGE','UPDATE'),(162,'portfolio','DELETE_LOANCHARGE','Delete a Loan Charge','Delete a Loan Charge','LOANCHARGE','DELETE'),(163,'portfolio','WAIVE_LOANCHARGE','Waive a Loan Charge','Waive a Loan Charge','LOANCHARGE','WAIVE'),(164,'transaction_loan','BULKREASSIGN_LOAN','Bulk Reassign Loans','Bulk Reassign Loans','LOAN','BULKREASSIGN'),(165,'transaction_loan','ADJUST_LOAN','Adjust a Loan Transaction','Adjust a Loan Transaction','LOAN','ADJUST'),(166,'transaction_loan','WAIVEINTERESTPORTION_LOAN','Waive Portion of Loan Interest','Waive Portion of Loan Interest','LOAN','WAIVEINTERESTPORTION'),
|
||||
(167,'transaction_loan','WRITEOFF_LOAN','Write-Off a Loan','Write-Off a Loan','LOAN','WRITEOFF'),(168,'transaction_loan','CLOSE_LOAN','Close a Loan','Close a Loan','LOAN','CLOSE'),(169,'transaction_loan','CLOSEASRESCHEDULED_LOAN','Close a Loan (having been Rescheduled (Mifos Legacy Need)','Close a Loan (having been Rescheduled (Mifos Legacy Need)','LOAN','CLOSEASRESCHEDULED'),(170,'organisation','READ_MAKERCHECKER','Read Maker-Checker Entries','Read Maker-Checker Entries','MAKERCHECKER','READ'),(171,'organisation','CREATE_OFFICE','Create an Office','Create an Office','OFFICE','CREATE'),(172,'organisation','READ_OFFICE','Read Offices','Read Offices','OFFICE','READ'),(173,'organisation','UPDATE_OFFICE','Update an Office','Update an Office','OFFICE','UPDATE'),(174,'organisation','DELETE_OFFICE','Delete an Office','Delete an Office','OFFICE','DELETE'),(175,'organisation','READ_OFFICETRANSACTION','Read Office Transactions','Read Office Transactions','OFFICETRANSACTION','READ'),(176,'organisation','CREATE_OFFICETRANSACTION','Create an Office Transaction','Create an Office Transaction','OFFICETRANSACTION','CREATE'),(177,'authorisation','READ_PERMISSION','Read Permissions','Read Permissions','PERMISSION','READ'),(178,'authorisation','CREATE_ROLE','Create a Role','Create a Role','ROLE','CREATE'),(179,'authorisation','READ_ROLE','Read Roles','Read Roles','ROLE','READ'),(180,'authorisation','UPDATE_ROLE','Update a Role','Update a Role','ROLE','UPDATE'),(181,'authorisation','DELETE_ROLE','Delete a Role','Delete a Role','ROLE','DELETE'),(182,'authorisation','CREATE_USER','Create a User','Create a User','USER','CREATE'),(183,'authorisation','READ_USER','Read Users','Read Users','USER','READ'),(184,'authorisation','UPDATE_USER','Update a User','Update a User','USER','UPDATE'),
|
||||
(185,'authorisation','DELETE_USER','Create a User','Create a User','USER','DELETE'),(186,'organisation','CREATE_STAFF','Create a Staff Member','Create a Staff Member','STAFF','CREATE'),(187,'organisation','READ_STAFF','Read Staff','Read Staff','STAFF','READ'),(188,'organisation','UPDATE_STAFF','Update a Staff Member','Update a Staff Member','STAFF','UPDATE'),(189,'organisation','DELETE_STAFF','Delete a Staff Member','Delete a Staff Member','STAFF','DELETE'),(190,'organisation','CREATE_SAVINGSPRODUCT','Create a Savings Product','Create a Savings Product','SAVINGSPRODUCT','CREATE'),(191,'organisation','READ_SAVINGSPRODUCT','Read Savings Products','Read Savings Products','SAVINGSPRODUCT','READ'),(192,'organisation','UPDATE_SAVINGSPRODUCT','Update a Savings Product','Update a Savings Product','SAVINGSPRODUCT','UPDATE'),(193,'organisation','DELETE_SAVINGSPRODUCT','Delete a Savings Product','Delete a Savings Product','SAVINGSPRODUCT','DELETE'),(194,'organisation','CREATE_DEPOSITPRODUCT','Create a Deposit Product','Create a Deposit Product','DEPOSITPRODUCT','CREATE'),(195,'organisation','READ_DEPOSITPRODUCT','Read Deposit Products','Read Deposit Products','DEPOSITPRODUCT','READ'),(196,'organisation','UPDATE_DEPOSITPRODUCT','Update a Deposit Product','Update a Deposit Product','DEPOSITPRODUCT','UPDATE'),(197,'organisation','DELETE_DEPOSITPRODUCT','Delete a Deposit Product','Delete a Deposit Product','DEPOSITPRODUCT','DELETE'),(198,'portfolio','CREATE_DEPOSITACCOUNT','Create a Deposit Account','Create a Deposit Account','DEPOSITACCOUNT','CREATE'),(199,'portfolio','READ_DEPOSITACCOUNT','Read Deposit Accounts','Read Deposit Accounts','DEPOSITACCOUNT','READ'),(200,'portfolio','UPDATE_DEPOSITACCOUNT','Update a Deposit Account','Update a Deposit Account','DEPOSITACCOUNT','UPDATE'),
|
||||
(201,'portfolio','DELETE_DEPOSITACCOUNT','Delete a Deposit Account','Delete a Deposit Account','DEPOSITACCOUNT','DELETE'),(202,'transaction_deposit','APPROVE_DEPOSITACCOUNT','Approve a Deposit Account','Approve a Deposit Account','DEPOSITACCOUNT','APPROVE'),(203,'transaction_deposit','REJECT_DEPOSITACCOUNT','Reject Deposit Account','Reject Deposit Account','DEPOSITACCOUNT','REJECT'),(204,'transaction_deposit','WITHDRAW_DEPOSITACCOUNT','Withdraw Deposit Account','Withdraw Deposit Account','DEPOSITACCOUNT','WITHDRAW'),(205,'transaction_deposit','APPROVALUNDO_DEPOSITACCOUNT','Undo Approval of Deposit Account','Undo Approval of Deposit Account','DEPOSITACCOUNT','APPROVALUNDO'),(206,'transaction_deposit','WITHDRAWAL_DEPOSITACCOUNT','Make a Withdrawal From Deposit Account','Make a Withdrawal From Deposit Account','DEPOSITACCOUNT','WITHDRAWAL'),(207,'transaction_deposit','INTEREST_DEPOSITACCOUNT','Apply Interest to Deposit Accounts','Apply Interest to Deposit Accounts','DEPOSITACCOUNT','INTEREST'),(208,'transaction_deposit','RENEW_DEPOSITACCOUNT','Renew Deposit Account','Renew Deposit Account','DEPOSITACCOUNT','RENEW'),(209,'portfolio','CREATE_SAVINGSACCOUNT','Create a Savings Account','Create a Savings Account','SAVINGSACCOUNT','CREATE'),(210,'portfolio','READ_SAVINGSACCOUNT','Read Savings Accounts','Read Savings Accounts','SAVINGSACCOUNT','READ'),(211,'portfolio','UPDATE_SAVINGSACCOUNT','Update a Savings Account','Update a Savings Account','SAVINGSACCOUNT','UPDATE'),(212,'portfolio','DELETE_SAVINGSACCOUNT','Delete a Savings Account','Delete a Savings Account','SAVINGSACCOUNT','DELETE'),(213,'authorisation','PERMISSIONS_ROLE','Manage Permissions for a Role','Manage Permissions for a Role','ROLE','PERMISSIONS');
|
||||
|
||||
/* role 1 is super user, give it ALL_FUNCTIONS */
|
||||
INSERT INTO m_role_permission(role_id, permission_id)
|
||||
select 1, id
|
||||
from m_permission
|
||||
where code = 'ALL_FUNCTIONS';
|
||||
|
||||
/* add a read permission for each defined report */
|
||||
insert into m_permission(grouping, `code`, default_description, default_name, entity_name, action_name)
|
||||
select 'report', concat('READ_', sr.report_name), concat('READ_', sr.report_name), concat('READ_', sr.report_name), sr.report_name, 'READ'
|
||||
from stretchy_report sr;
|
||||
|
||||
/* add a create, read, update and delete permission for each registered datatable */
|
||||
insert into m_permission(grouping, `code`, default_description, default_name, entity_name, action_name)
|
||||
select 'datatable', concat('CREATE_', r.registered_table_name), concat('CREATE_', r.registered_table_name), concat('CREATE_', r.registered_table_name), r.registered_table_name, 'CREATE'
|
||||
from x_registered_table r;
|
||||
|
||||
insert into m_permission(grouping, `code`, default_description, default_name, entity_name, action_name)
|
||||
select 'datatable', concat('READ_', r.registered_table_name), concat('READ_', r.registered_table_name), concat('READ_', r.registered_table_name), r.registered_table_name, 'READ'
|
||||
from x_registered_table r;
|
||||
|
||||
insert into m_permission(grouping, `code`, default_description, default_name, entity_name, action_name)
|
||||
select 'datatable', concat('UPDATE_', r.registered_table_name), concat('UPDATE_', r.registered_table_name), concat('UPDATE_', r.registered_table_name), r.registered_table_name, 'UPDATE'
|
||||
from x_registered_table r;
|
||||
|
||||
insert into m_permission(grouping, `code`, default_description, default_name, entity_name, action_name)
|
||||
select 'datatable', concat('DELETE_', r.registered_table_name), concat('DELETE_', r.registered_table_name), concat('DELETE_', r.registered_table_name), r.registered_table_name, 'DELETE'
|
||||
from x_registered_table r;
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE m_code
|
||||
ADD COLUMN `is_system_defined` TINYINT(1) NOT NULL DEFAULT '0' AFTER `code_name` ;
|
||||
|
||||
update m_code
|
||||
set is_system_defined = true
|
||||
where code_name = 'Customer Identifier';
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `m_portfolio_command_source` CHANGE COLUMN `command_as_json` `command_as_json` VARCHAR(5000) NOT NULL;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
ALTER TABLE `m_permission`
|
||||
DROP COLUMN `default_name` ,
|
||||
DROP COLUMN `default_description` ,
|
||||
ADD COLUMN `is_maker_checker` TINYINT(1) NOT NULL AFTER `action_name` ;
|
||||
|
||||
update m_permission
|
||||
set is_maker_checker = false;
|
||||
|
||||
update m_permission
|
||||
set is_maker_checker = true
|
||||
where grouping not in ('special', 'report')
|
||||
and action_name != 'READ';
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `m_loan` CHANGE COLUMN `arrearstolerance_amount` `arrearstolerance_amount` DECIMAL(19,6) NULL;
|
||||
@@ -0,0 +1,9 @@
|
||||
SET foreign_key_checks = 0;
|
||||
drop table IF EXISTS `stretchydata_dataset_fields`;
|
||||
drop table IF EXISTS `stretchydata_datasettype`;
|
||||
drop table IF EXISTS `stretchydata_dataset`;
|
||||
|
||||
drop table IF EXISTS `m_client_xadditional information`;
|
||||
drop table IF EXISTS `m_client_xhighly improbable info`;
|
||||
drop table IF EXISTS `m_loan_xadditional information`;
|
||||
SET foreign_key_checks = 1;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
|
||||
ALTER TABLE m_permission
|
||||
CHANGE COLUMN `is_maker_checker` `can_maker_checker` TINYINT(1) NOT NULL DEFAULT '1' ;
|
||||
|
||||
/*
|
||||
add all checker permissions
|
||||
*/
|
||||
insert into m_permission(grouping, code, entity_name, action_name, can_maker_checker)
|
||||
select grouping, concat(code, '_CHECKER'), entity_name, action_name, false
|
||||
from m_permission
|
||||
where code not like 'READ_%'
|
||||
and grouping != 'special';
|
||||
|
||||
|
||||
/* 5k not enough for command json */
|
||||
ALTER TABLE m_portfolio_command_source
|
||||
CHANGE COLUMN `command_as_json` `command_as_json` TEXT NOT NULL ;
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
DROP TABLE IF EXISTS `m_acc_coa`;
|
||||
|
||||
DROP TABLE IF EXISTS `acc_gl_account`;
|
||||
CREATE TABLE `acc_gl_account` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(45) NOT NULL,
|
||||
`parent_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`gl_code` VARCHAR(45) NOT NULL,
|
||||
`disabled` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`manual_journal_entries_allowed` TINYINT(1) NOT NULL DEFAULT '1',
|
||||
`header_account` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`classification` VARCHAR(45) NOT NULL,
|
||||
`description` VARCHAR(500) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `acc_gl_code` (`gl_code`),
|
||||
INDEX `FK_ACC_0000000001` (`parent_id`),
|
||||
CONSTRAINT `FK_ACC_0000000001` FOREIGN KEY (`parent_id`) REFERENCES `acc_gl_account` (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `acc_gl_closure`;
|
||||
CREATE TABLE `acc_gl_closure` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`office_id` BIGINT(20) NOT NULL,
|
||||
`closing_date` DATE NOT NULL,
|
||||
`is_deleted` INT(20) NOT NULL DEFAULT '0',
|
||||
`createdby_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`lastmodifiedby_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`created_date` DATETIME NULL DEFAULT NULL,
|
||||
`lastmodified_date` DATETIME NULL DEFAULT NULL,
|
||||
`comments` VARCHAR(500) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FK_acc_gl_closure_m_office` (`office_id`),
|
||||
INDEX `FK_acc_gl_closure_m_appuser` (`createdby_id`),
|
||||
INDEX `FK_acc_gl_closure_m_appuser_2` (`lastmodifiedby_id`),
|
||||
UNIQUE INDEX `office_id_closing_date` (`office_id`, `closing_date`),
|
||||
CONSTRAINT `FK_acc_gl_closure_m_appuser` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_closure_m_appuser_2` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_closure_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
DROP TABLE IF EXISTS `m_saving_schedule`;
|
||||
CREATE TABLE `m_saving_schedule` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`saving_account_id` bigint(20) NOT NULL,
|
||||
`duedate` date NOT NULL,
|
||||
`installment` smallint(5) NOT NULL,
|
||||
`deposit` decimal(21,4) NOT NULL,
|
||||
`payment_date` date DEFAULT NULL,
|
||||
`deposit_paid` decimal(21,4) DEFAULT NULL,
|
||||
`completed_derived` bit(1) NOT NULL,
|
||||
`createdby_id` bigint(20) DEFAULT NULL,
|
||||
`created_date` datetime DEFAULT NULL,
|
||||
`lastmodified_date` datetime DEFAULT NULL,
|
||||
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKSS00000000001` (`saving_account_id`),
|
||||
CONSTRAINT `FKSS00000000001` FOREIGN KEY (`saving_account_id`) REFERENCES `m_saving_account` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/* some addition permissions and alterations */
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'UPDATE_PERMISSION', 'PERMISSION', 'UPDATE', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'UPDATE_PERMISSION_CHECKER', 'PERMISSION', 'UPDATE', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'READ_DATATABLE', 'DATATABLE', 'READ', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'REGISTER_DATATABLE', 'DATATABLE', 'REGISTER', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'REGISTER_DATATABLE_CHECKER', 'DATATABLE', 'REGISTER', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'DEREGISTER_DATATABLE', 'DATATABLE', 'DEREGISTER', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'DEREGISTER_DATATABLE_CHECKER', 'DATATABLE', 'DEREGISTER', '0');
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `can_maker_checker`)
|
||||
VALUES ('special', 'CHECKER_SUPER_USER', '0');
|
||||
|
||||
|
||||
update m_permission
|
||||
set grouping = 'configuration'
|
||||
where code like '%permission%';
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
update m_permission
|
||||
|
||||
set grouping = "authorisation"
|
||||
where code like 'PERMISSIONS_ROLE%';
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `m_portfolio_command_source` CHANGE COLUMN `api_resource` `api_resource` VARCHAR(100) NOT NULL;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE `m_deposit_account`
|
||||
ADD COLUMN `available_interest` decimal(19,6) DEFAULT '0.000000' AFTER `is_interest_withdrawable`,
|
||||
ADD COLUMN `interest_posted_amount` decimal(19,6) DEFAULT '0.000000' AFTER `available_interest`,
|
||||
ADD COLUMN `last_interest_posted_date` date DEFAULT NULL AFTER `interest_posted_amount`,
|
||||
ADD COLUMN `next_interest_posting_date` date DEFAULT NULL AFTER `last_interest_posted_date`;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `m_client`
|
||||
CHANGE COLUMN `joining_date` `joined_date` DATE NULL DEFAULT NULL;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
drop table if exists extra_client_details;
|
||||
|
||||
CREATE TABLE `extra_client_details` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`client_id` bigint(20) NOT NULL,
|
||||
`client_dob` date DEFAULT NULL,
|
||||
`client_address` varchar(60) DEFAULT NULL,
|
||||
`father_name` varchar(40) DEFAULT NULL,
|
||||
`nominee` varchar(40) DEFAULT NULL,
|
||||
`nominee_relationship` varchar(40) DEFAULT NULL,
|
||||
`nominee_address` varchar(60) DEFAULT NULL,
|
||||
`crime_no` varchar(40) DEFAULT NULL,
|
||||
`police_station` varchar(40) DEFAULT NULL,
|
||||
`other_notes` text,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `client_id` (`client_id`),
|
||||
KEY `FK_extra_client_details_1` (`client_id`),
|
||||
CONSTRAINT `FK_extra_client_details` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
INSERT INTO m_permission (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES ('configuration', 'READ_AUDIT', 'AUDIT', 'READ', '0');
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
drop table if exists `m_portfolio_command_source`;
|
||||
CREATE TABLE `m_portfolio_command_source` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`permission_code` varchar(50) NOT NULL,
|
||||
`api_operation` varchar(30) NOT NULL,
|
||||
`api_resource` varchar(100) NOT NULL,
|
||||
`resource_id` bigint(20) DEFAULT NULL,
|
||||
`api_subresource` varchar(100) DEFAULT NULL,
|
||||
`subresource_id` bigint(20) DEFAULT NULL,
|
||||
`command_as_json` text NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` datetime NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
drop table if exists `m_portfolio_command_source`;
|
||||
CREATE TABLE `m_portfolio_command_source` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`action_name` varchar(50) NOT NULL,
|
||||
`entity_name` varchar(50) NOT NULL,
|
||||
`api_operation` varchar(30) NOT NULL,
|
||||
`api_resource` varchar(100) NOT NULL,
|
||||
`resource_id` bigint(20) DEFAULT NULL,
|
||||
`api_subresource` varchar(100) DEFAULT NULL,
|
||||
`subresource_id` bigint(20) DEFAULT NULL,
|
||||
`command_as_json` text NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` datetime NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` datetime DEFAULT NULL,
|
||||
`processing_result_enum` smallint(5) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -0,0 +1,40 @@
|
||||
DROP TABLE IF EXISTS `acc_gl_journal_entry`;
|
||||
|
||||
CREATE TABLE `acc_gl_journal_entry` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`account_id` BIGINT(20) NOT NULL,
|
||||
`office_id` BIGINT(20) NOT NULL,
|
||||
`reversal_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`transaction_id` VARCHAR(50) NOT NULL,
|
||||
`reversed` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`portfolio_generated` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`entry_date` DATE NOT NULL,
|
||||
`type` VARCHAR(50) NOT NULL,
|
||||
`amount` DECIMAL(19,6) NOT NULL,
|
||||
`description` VARCHAR(500) NULL DEFAULT NULL,
|
||||
`entity_type` VARCHAR(50) NULL DEFAULT NULL,
|
||||
`entity_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`createdby_id` BIGINT(20) NOT NULL,
|
||||
`lastmodifiedby_id` BIGINT(20) NOT NULL,
|
||||
`created_date` DATETIME NOT NULL,
|
||||
`lastmodified_date` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FK_acc_gl_journal_entry_m_office` (`office_id`),
|
||||
INDEX `FK_acc_gl_journal_entry_m_appuser` (`createdby_id`),
|
||||
INDEX `FK_acc_gl_journal_entry_m_appuser_2` (`lastmodifiedby_id`),
|
||||
INDEX `FK_acc_gl_journal_entry_acc_gl_journal_entry` (`reversal_id`),
|
||||
INDEX `FK_acc_gl_journal_entry_acc_gl_account` (`account_id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_acc_gl_account` FOREIGN KEY (`account_id`) REFERENCES `acc_gl_account` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_acc_gl_journal_entry` FOREIGN KEY (`reversal_id`) REFERENCES `acc_gl_journal_entry` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_m_appuser` FOREIGN KEY (`createdby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_m_appuser_2` FOREIGN KEY (`lastmodifiedby_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_acc_gl_journal_entry_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `acc_gl_account`
|
||||
ALTER `description` DROP DEFAULT;
|
||||
ALTER TABLE `acc_gl_account`
|
||||
CHANGE COLUMN `description` `description` VARCHAR(500) NULL AFTER `classification`;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**Balance sheet report**/
|
||||
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Balance Sheet', 'Pentaho', NULL, 'Accounting', NULL, 'Balance Sheet', 1, 1);
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 5, 'branch');
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 81, 'date');
|
||||
|
||||
/**Income statement report**/
|
||||
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Income Statement', 'Pentaho', NULL, 'Accounting', NULL, 'Profilt and Loss Statement', 1, 1);
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 5, 'branch');
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 80, 'fromDate');
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 81, 'toDate');
|
||||
|
||||
/**Trial Balance report**/
|
||||
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Trial Balance', 'Pentaho', NULL, 'Accounting', NULL, 'Trial Balance Report', 1, 1);
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 5, 'branch');
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 80, 'fromDate');
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select max(report_id) from stretchy_report), 81, 'toDate');
|
||||
|
||||
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '0', 'invalid', 'Invalid');
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '1', 'processed', 'Processed');
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '2', 'awaiting.approval', 'Awaiting Approval');
|
||||
INSERT INTO r_enum_value(`enum_name`, `enum_id`, `enum_message_property`, `enum_value`) VALUES ('processing_result_enum', '3', 'rejected', 'Rejected');
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE m_product_savings
|
||||
ADD COLUMN `deposit_every` bigint(20) DEFAULT NULL AFTER `tenure_type`;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE m_saving_account
|
||||
ADD COLUMN `deposit_every` bigint(20) DEFAULT NULL AFTER `tenure_type`;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
DELETE FROM m_role_permission
|
||||
where exists
|
||||
(select 'f' from m_permission p
|
||||
where p.id = m_role_permission.permission_id
|
||||
and p.code in ("ORGANISATION_ADMINISTRATION_SUPER_USER", "PORTFOLIO_MANAGEMENT_SUPER_USER", "USER_ADMINISTRATION_SUPER_USER"));
|
||||
|
||||
|
||||
DELETE from m_permission
|
||||
where code in ("ORGANISATION_ADMINISTRATION_SUPER_USER", "PORTFOLIO_MANAGEMENT_SUPER_USER", "USER_ADMINISTRATION_SUPER_USER");
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
INSERT INTO `m_permission`
|
||||
(`grouping`,
|
||||
`code`,
|
||||
`entity_name`,
|
||||
`action_name`,
|
||||
`can_maker_checker`)
|
||||
VALUES
|
||||
('transaction_loan', 'UPDATELOANOFFICER_LOAN', 'LOAN', 'UPDATELOANOFFICER', 1),
|
||||
('transaction_loan', 'UPDATELOANOFFICER_LOAN_CHECKER', 'LOAN', 'UPDATELOANOFFICER', 0);
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
ALTER TABLE m_portfolio_command_source
|
||||
ADD INDEX `action_name` (`action_name` ASC)
|
||||
, ADD INDEX `entity_name` (`entity_name` ASC, `resource_id` ASC)
|
||||
, ADD INDEX `made_on_date` (`made_on_date` ASC)
|
||||
, ADD INDEX `checked_on_date` (`checked_on_date` ASC)
|
||||
, ADD INDEX `processing_result_enum` (`processing_result_enum` ASC)
|
||||
, ADD INDEX `api_operation` (`api_operation` ASC)
|
||||
, ADD INDEX `api_resource` (`api_resource` ASC, `resource_id` ASC) ;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
|
||||
VALUES ('loan_status_id', '601', 'Closed - Written Off', 'Closed - Written Off');
|
||||
|
||||
INSERT INTO `mifostenant-creocore`.`r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
|
||||
VALUES ('loan_status_id', '602', 'Closed - Reschedule Outstanding Amount', 'Closed - Reschedule Outstanding Amount');
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `account_no` VARCHAR(20) NOT NULL AFTER `id`;
|
||||
|
||||
UPDATE `m_client`
|
||||
SET
|
||||
`account_no` = `id`
|
||||
WHERE `id` > 0;
|
||||
|
||||
ALTER TABLE `m_client` ADD UNIQUE INDEX `account_no_UNIQUE` (`account_no` ASC);
|
||||
|
||||
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
DROP TABLE IF EXISTS `m_portfolio_command_source`;
|
||||
CREATE TABLE `m_portfolio_command_source` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`action_name` varchar(50) NOT NULL,
|
||||
`entity_name` varchar(50) NOT NULL,
|
||||
`office_id` bigint(20) DEFAULT NULL,
|
||||
`group_id` bigint(20) DEFAULT NULL,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`loan_id` bigint(20) DEFAULT NULL,
|
||||
`api_get_url` varchar(100) NOT NULL,
|
||||
`resource_id` bigint(20) DEFAULT NULL,
|
||||
`command_as_json` text NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` datetime NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` datetime DEFAULT NULL,
|
||||
`processing_result_enum` smallint(5) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
KEY `action_name` (`action_name`),
|
||||
KEY `entity_name` (`entity_name`,`resource_id`),
|
||||
KEY `made_on_date` (`made_on_date`),
|
||||
KEY `checked_on_date` (`checked_on_date`),
|
||||
KEY `processing_result_enum` (`processing_result_enum`),
|
||||
KEY `office_id` (`office_id`),
|
||||
KEY `group_id` (`office_id`),
|
||||
KEY `client_id` (`office_id`),
|
||||
KEY `loan_id` (`office_id`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
DROP TABLE IF EXISTS `c_configuration`;
|
||||
CREATE TABLE `c_configuration` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
`enabled` tinyint(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `c_configuration`
|
||||
(`name`, `enabled`)
|
||||
VALUES
|
||||
('maker-checker', 0);
|
||||
|
||||
INSERT INTO `m_permission`
|
||||
(
|
||||
`grouping`,
|
||||
`code`,
|
||||
`entity_name`,
|
||||
`action_name`,
|
||||
`can_maker_checker`)
|
||||
VALUES
|
||||
('configuration','UPDATE_CONFIGURATION',
|
||||
'CONFIGURATION','UPDATE',1),
|
||||
('configuration','READ_CONFIGURATION',
|
||||
'CONFIGURATION','READ',1);
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
ALTER TABLE `m_product_loan`
|
||||
ADD COLUMN `accounting_type` SMALLINT(5) NOT NULL AFTER `amortization_method_enum`;
|
||||
|
||||
update m_product_loan set accounting_type=1;
|
||||
|
||||
DROP TABLE if exists `acc_product_mapping`;
|
||||
|
||||
CREATE TABLE `acc_product_mapping` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`gl_account_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`product_id` BIGINT(20) NULL DEFAULT NULL,
|
||||
`product_type` SMALLINT(5) NULL DEFAULT NULL,
|
||||
`financial_account_type` SMALLINT(5) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `middlename` VARCHAR(50) DEFAULT NULL AFTER `firstname`;
|
||||
|
||||
ALTER TABLE `m_client`
|
||||
ADD COLUMN `fullname` VARCHAR(100) DEFAULT NULL AFTER `lastname`;
|
||||
|
||||
UPDATE `m_client`
|
||||
SET
|
||||
`fullname` = `lastname`
|
||||
WHERE `firstname` is NULL;
|
||||
|
||||
UPDATE `m_client`
|
||||
SET
|
||||
`lastname` = null
|
||||
WHERE `fullname` is not NULL;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
ALTER TABLE `m_loan`
|
||||
ADD COLUMN `account_no` VARCHAR(20) NOT NULL AFTER `id`;
|
||||
|
||||
UPDATE `m_loan`
|
||||
SET
|
||||
`account_no` = `id`
|
||||
WHERE `id` > 0;
|
||||
|
||||
ALTER TABLE `m_loan` ADD UNIQUE INDEX `loan_account_no_UNIQUE` (`account_no` ASC);
|
||||
|
||||
|
||||
ALTER TABLE `m_loan` DROP INDEX `org_id`;
|
||||
ALTER TABLE `m_loan` ADD UNIQUE INDEX `loan_externalid_UNIQUE` (`external_id` ASC);
|
||||
@@ -1,3 +1,18 @@
|
||||
apply plugin: 'rebel'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
mavenRepo(name: 'zt-public-snapshots',
|
||||
url: 'http://repos.zeroturnaround.com/nexus/content/groups/zt-public/')
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath group: 'org.zeroturnaround', name: 'gradle-jrebel-plugin', version: '1.0.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
|
||||
@@ -7,43 +22,40 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'bmuschko:gradle-tomcat-plugin:0.9.3'
|
||||
classpath 'bmuschko:gradle-tomcat-plugin:0.9.5'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'tomcat'
|
||||
apply plugin: 'project-report'
|
||||
|
||||
project.ext.springVersion = '3.1.1.RELEASE'
|
||||
project.ext.springSecurityVersion = '3.1.0.RELEASE'
|
||||
project.ext.hibernateValidatorVersion = '4.3.0.Final'
|
||||
project.ext.hibernateCoreVersion = '4.1.3.Final'
|
||||
project.ext.jerseyVersion = '1.13'
|
||||
project.ext.springDataJpaVersion = '1.0.3.RELEASE'
|
||||
/* define the valid syntax level for source files */
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
/* define binary compatiblity version */
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
|
||||
project.ext.springVersion = '3.2.0.RELEASE'
|
||||
project.ext.springSecurityVersion = '3.1.3.RELEASE'
|
||||
project.ext.hibernateValidatorVersion = '4.3.1.Final'
|
||||
project.ext.hibernateCoreVersion = '4.1.8.Final'
|
||||
project.ext.jerseyVersion = '1.16'
|
||||
project.ext.springDataJpaVersion = '1.1.2.RELEASE'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven {
|
||||
url "http://maven.springframework.org/milestone"
|
||||
}
|
||||
maven {
|
||||
url "http://maven.springframework.org/release"
|
||||
}
|
||||
maven {
|
||||
url "http://maven.springframework.org/snapshot"
|
||||
}
|
||||
maven {
|
||||
url "http://download.java.net/maven/2"
|
||||
}
|
||||
maven {
|
||||
url "http://repository.pentaho.org/artifactory/pentaho/"
|
||||
}
|
||||
flatDir {
|
||||
dirs '../repos'
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -54,7 +66,7 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def tomcatVersion = '7.0.29'
|
||||
def tomcatVersion = '7.0.34'
|
||||
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
|
||||
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
|
||||
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
|
||||
@@ -73,7 +85,7 @@ dependencies {
|
||||
[group: 'org.springframework.security', name: 'spring-security-core', version: springSecurityVersion],
|
||||
[group: 'org.springframework.security', name: 'spring-security-web', version: springSecurityVersion],
|
||||
[group: 'org.springframework.security', name: 'spring-security-config', version: springSecurityVersion],
|
||||
[group: 'org.aspectj', name: 'aspectjrt', version: '1.6.12.RELEASE'],
|
||||
[group: 'org.aspectj', name: 'aspectjrt', version: '1.7.0.RELEASE'],
|
||||
|
||||
[group: 'org.hibernate', name: 'hibernate-core', version: hibernateCoreVersion],
|
||||
[group: 'org.hibernate', name: 'hibernate-entitymanager', version: hibernateCoreVersion],
|
||||
@@ -96,14 +108,14 @@ dependencies {
|
||||
[group: 'org.apache.commons', name: 'commons-email', version: '1.2'],
|
||||
[group: 'commons-lang', name: 'commons-lang', version: '2.4'],
|
||||
|
||||
[group: 'org.slf4j', name: 'slf4j-api', version: '1.6.6'],
|
||||
[group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.6.6'],
|
||||
[group: 'org.slf4j', name: 'slf4j-api', version: '1.7.2'],
|
||||
[group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.2'],
|
||||
|
||||
[group: 'ch.qos.logback', name: 'logback-core', version: '1.0.6'],
|
||||
[group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.6'],
|
||||
[group: 'ch.qos.logback', name: 'logback-core', version: '1.0.9'],
|
||||
[group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.9'],
|
||||
|
||||
[group: 'mysql', name: 'mysql-connector-java', version: '5.1.21'],
|
||||
[group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.29'],
|
||||
[group: 'mysql', name: 'mysql-connector-java', version: '5.1.22'],
|
||||
[group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.34'],
|
||||
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-core', version: '3.8.3-GA'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions', version: '3.8.3-GA'],
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.data.ApiParameterError;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
public class DataValidatorBuilder {
|
||||
|
||||
private final List<ApiParameterError> dataValidationErrors;
|
||||
private String resource;
|
||||
private String parameter;
|
||||
private Object value;
|
||||
private boolean ignoreNullValue = false;
|
||||
|
||||
public DataValidatorBuilder(List<ApiParameterError> dataValidationErrors) {
|
||||
this.dataValidationErrors = dataValidationErrors;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder reset() {
|
||||
return new DataValidatorBuilder(dataValidationErrors).resource(resource);
|
||||
}
|
||||
|
||||
public DataValidatorBuilder resource(final String resource) {
|
||||
this.resource = resource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder parameter(final String parameter) {
|
||||
this.parameter = parameter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder value(Object value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder ignoreIfNull() {
|
||||
this.ignoreNullValue = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public DataValidatorBuilder andNotBlank(String linkedParameterName, String linkedValue) {
|
||||
if (value == null && linkedValue == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(linkedValue)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(linkedParameterName).append(".cannot.be.empty.when.").append(parameter).append(".is.populated");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" cannot be empty when ").append(parameter).append(" is populated.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), linkedParameterName, linkedValue, value);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder equalToParameter(String linkedParameterName, Object linkedValue) {
|
||||
if (value == null && linkedValue == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null && !value.equals(linkedValue)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(linkedParameterName).append(".not.equal.to.").append(parameter);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is not equal to ").append(parameter).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), linkedParameterName, linkedValue, value);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notSameAsParameter(String linkedParameterName, Object linkedValue) {
|
||||
if (value == null && linkedValue == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null && value.equals(linkedValue)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(linkedParameterName).append(".same.as.").append(parameter);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(linkedParameterName).append(" is same as ").append(parameter).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), linkedParameterName, linkedValue, value);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notNull() {
|
||||
if (value == null && !ignoreNullValue) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be blank.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notBlank() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value == null || StringUtils.isBlank(value.toString())) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.blank");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be blank.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder notExceedingLengthOf(Integer maxLength) {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null && value.toString().trim().length() > maxLength) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".exceeds.max.length");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" exceeds max length of ").append(maxLength).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, maxLength, value.toString());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder inMinMaxRange(Integer min, Integer max) {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (number < min || number > max) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".is.not.within.expected.range");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be between ").append(min).append(" and ").append(max).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, min, max);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder positiveAmount() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (number.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.greater.than.zero");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder zeroOrPositiveAmount() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
BigDecimal number = BigDecimal.valueOf(Double.valueOf(value.toString()));
|
||||
if (number.compareTo(BigDecimal.ZERO) < 0) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.zero.or.greater");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than or equal to 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder integerGreaterThanZero() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
Integer number = Integer.valueOf(value.toString());
|
||||
if (number < 1) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".not.greater.than.zero");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" must be greater than 0.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, number, 0);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder arrayNotEmpty() {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
Object[] array = (Object[]) value;
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.be.empty");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot be empty. You must select at least one.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder anyOfNotNull(Object... object) {
|
||||
boolean hasData = false;
|
||||
for (Object obj : object) {
|
||||
if (obj != null) {
|
||||
hasData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasData) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".no.parameters.for.update");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("No parameters passed for update.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), "id");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder inValidValue(String parameterValueCode, Object invalidValue) {
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".invalid.").append(parameterValueCode);
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" has an invalid value.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, invalidValue);
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder mustBeBlankWhenParameterProvided(String parameterName, Object parameterValue) {
|
||||
if (value == null && ignoreNullValue) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value == null && parameterValue != null) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (value != null && StringUtils.isBlank(value.toString()) && parameterValue != null && StringUtils.isNotBlank(parameterValue.toString())) {
|
||||
return this;
|
||||
}
|
||||
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".").append(parameter).append(".cannot.also.be.provided.when.").append(parameterName).append(".is.populated");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(parameter).append(" cannot also be provided when ").append(parameterName).append(" is populated.");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, value, parameterName, parameterValue);
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder comapareMinimumAndMaximumAmounts(BigDecimal minimumBalance,BigDecimal maximumBalance){
|
||||
if(minimumBalance!=null&&maximumBalance!=null)
|
||||
if(maximumBalance.compareTo(minimumBalance)==-1){
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".minimum.amount.should.lessthan.maximun.amount");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(" minimum amount ").append(minimumBalance).append(" should less than maximum amount ").append(maximumBalance).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, minimumBalance, maximumBalance);
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(BigDecimal min,BigDecimal max){
|
||||
if(min!=null&&max!=null)
|
||||
if(max.compareTo(min)==-1){
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".min.number.should.lessthan.max.number");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min).append(" should less than max number ").append(max).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, min, max);
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InvalidSqlException extends RuntimeException {
|
||||
|
||||
private final String sql;
|
||||
|
||||
public InvalidSqlException(SQLException e, String sql) {
|
||||
super(e);
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
|
||||
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
|
||||
public interface ReadExtraDataAndReportingService {
|
||||
|
||||
StreamingOutput retrieveReportCSV(String name, String type,
|
||||
Map<String, String> extractedQueryParams);
|
||||
|
||||
// @PreAuthorize(value = "hasAnyRole('REPORTING_SUPER_USER_ROLE')")
|
||||
GenericResultsetData retrieveGenericResultset(String name, String type,
|
||||
Map<String, String> extractedQueryParams);
|
||||
|
||||
List<AdditionalFieldsSetData> retrieveExtraDatasetNames(String type);
|
||||
|
||||
GenericResultsetData retrieveExtraData(String type, String set, Long id);
|
||||
|
||||
void updateExtraData(String type, String set, Long id,
|
||||
Map<String, String> queryParams);
|
||||
|
||||
Response processPentahoRequest(String reportName, String outputType,
|
||||
Map<String, String> queryParams);
|
||||
|
||||
String getReportType(String reportName);
|
||||
}
|
||||
-845
@@ -1,845 +0,0 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.data.ResultsetColumnHeader;
|
||||
import org.mifosng.platform.api.data.ResultsetDataRow;
|
||||
import org.mifosng.platform.exceptions.AdditionalFieldsNotFoundException;
|
||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||
import org.mifosng.platform.exceptions.ReportNotFoundException;
|
||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||
import org.pentaho.reporting.engine.classic.core.ClassicEngineBoot;
|
||||
import org.pentaho.reporting.engine.classic.core.MasterReport;
|
||||
import org.pentaho.reporting.engine.classic.core.ReportProcessingException;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.table.csv.CSVReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.table.xls.ExcelReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.parameters.ParameterDefinitionEntry;
|
||||
import org.pentaho.reporting.engine.classic.core.parameters.ReportParameterDefinition;
|
||||
import org.pentaho.reporting.engine.classic.core.util.ReportParameterValues;
|
||||
import org.pentaho.reporting.libraries.resourceloader.Resource;
|
||||
import org.pentaho.reporting.libraries.resourceloader.ResourceException;
|
||||
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ReadExtraDataAndReportingServiceImpl implements
|
||||
ReadExtraDataAndReportingService {
|
||||
|
||||
private final static Logger logger = LoggerFactory
|
||||
.getLogger(ReadExtraDataAndReportingServiceImpl.class);
|
||||
|
||||
private final DataSource dataSource;
|
||||
private Boolean noPentaho = false;
|
||||
|
||||
@Autowired
|
||||
public ReadExtraDataAndReportingServiceImpl(
|
||||
final TenantAwareRoutingDataSource dataSource) {
|
||||
// kick off pentaho reports server
|
||||
ClassicEngineBoot.getInstance().start();
|
||||
noPentaho = false;
|
||||
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamingOutput retrieveReportCSV(final String name,
|
||||
final String type, final Map<String, String> queryParams) {
|
||||
|
||||
return new StreamingOutput() {
|
||||
|
||||
@Override
|
||||
public void write(OutputStream out) {
|
||||
try {
|
||||
|
||||
GenericResultsetData result = retrieveGenericResultset(
|
||||
name, type, queryParams);
|
||||
StringBuffer sb = generateCsvFileBuffer(result);
|
||||
|
||||
InputStream in = new ByteArrayInputStream(sb.toString()
|
||||
.getBytes("UTF-8"));
|
||||
|
||||
byte[] outputByte = new byte[4096];
|
||||
Integer readLen = in.read(outputByte, 0, 4096);
|
||||
|
||||
while (readLen != -1) {
|
||||
out.write(outputByte, 0, readLen);
|
||||
readLen = in.read(outputByte, 0, 4096);
|
||||
}
|
||||
// in.close();
|
||||
// out.flush();
|
||||
// out.close();
|
||||
} catch (Exception e) {
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.exception.error", e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private static StringBuffer generateCsvFileBuffer(
|
||||
GenericResultsetData result) {
|
||||
StringBuffer writer = new StringBuffer();
|
||||
|
||||
List<ResultsetColumnHeader> columnHeaders = result.getColumnHeaders();
|
||||
logger.info("NO. of Columns: " + columnHeaders.size());
|
||||
Integer chSize = columnHeaders.size();
|
||||
for (int i = 0; i < chSize; i++) {
|
||||
writer.append('"' + columnHeaders.get(i).getColumnName() + '"');
|
||||
if (i < (chSize - 1))
|
||||
writer.append(",");
|
||||
}
|
||||
writer.append('\n');
|
||||
|
||||
List<ResultsetDataRow> data = result.getData();
|
||||
List<String> row;
|
||||
Integer rSize;
|
||||
// String currCol;
|
||||
String currColType;
|
||||
String currVal;
|
||||
logger.info("NO. of Rows: " + data.size());
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
row = data.get(i).getRow();
|
||||
rSize = row.size();
|
||||
for (int j = 0; j < rSize; j++) {
|
||||
// currCol = columnHeaders.get(j).getColumnName();
|
||||
currColType = columnHeaders.get(j).getColumnType();
|
||||
currVal = row.get(j);
|
||||
if (currVal != null) {
|
||||
if (currColType.equals("DECIMAL")
|
||||
|| currColType.equals("DOUBLE")
|
||||
|| currColType.equals("BIGINT")
|
||||
|| currColType.equals("SMALLINT")
|
||||
|| currColType.equals("INT"))
|
||||
writer.append(currVal);
|
||||
else
|
||||
writer.append('"' + currVal + '"');
|
||||
}
|
||||
if (j < (rSize - 1))
|
||||
writer.append(",");
|
||||
}
|
||||
writer.append('\n');
|
||||
}
|
||||
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericResultsetData retrieveGenericResultset(final String name,
|
||||
final String type, final Map<String, String> queryParams) {
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
logger.info("STARTING REPORT: " + name + " Type: " + type);
|
||||
|
||||
// AppUser currentUser = extractAuthenticatedUser();
|
||||
// Collection<GrantedAuthority> permissions =
|
||||
// currentUser.getAuthorities();
|
||||
/*
|
||||
* AppUser currentUser = extractAuthenticatedUser(); Boolean validUser =
|
||||
* verifyUserDetails(currentUser);
|
||||
*
|
||||
* if (!validUser) { return null; }
|
||||
*
|
||||
* String orgId = currentUser.getOrganisation().getId().toString(); put
|
||||
* back in later
|
||||
*/
|
||||
|
||||
String sql;
|
||||
if (name.equals(".")) {
|
||||
sql = "select r.report_id, r.report_name, r.report_type, r.report_subtype, r.report_category,"
|
||||
+ " rp.parameter_id, rp.report_parameter_name, p.parameter_name"
|
||||
+ " from stretchy_report r"
|
||||
+ " left join stretchy_report_parameter rp on rp.report_id = r.report_id"
|
||||
+ " left join stretchy_parameter p on p.parameter_id = rp.parameter_id"
|
||||
+ " order by r.report_name, rp.parameter_id";
|
||||
} else {
|
||||
sql = getSQLtoRun(name, type, queryParams);
|
||||
}
|
||||
|
||||
GenericResultsetData result = fillReportingGenericResultSet(sql);
|
||||
|
||||
long elapsed = System.currentTimeMillis() - startTime;
|
||||
logger.info("FINISHING Report/Request Name: " + name + " - " + type
|
||||
+ " Elapsed Time: " + elapsed);
|
||||
return result;
|
||||
}
|
||||
|
||||
private GenericResultsetData fillReportingGenericResultSet(final String sql) {
|
||||
|
||||
GenericResultsetData result = new GenericResultsetData();
|
||||
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
ResultSet rs = db_statement.executeQuery(sql);
|
||||
|
||||
ResultSetMetaData rsmd = rs.getMetaData();
|
||||
String columnName = null;
|
||||
String columnValue = null;
|
||||
List<ResultsetColumnHeader> columnHeaders = new ArrayList<ResultsetColumnHeader>();
|
||||
for (int i = 0; i < rsmd.getColumnCount(); i++) {
|
||||
ResultsetColumnHeader rsch = new ResultsetColumnHeader();
|
||||
rsch.setColumnName(rsmd.getColumnName(i + 1));
|
||||
rsch.setColumnType(rsmd.getColumnTypeName(i + 1));
|
||||
columnHeaders.add(rsch);
|
||||
}
|
||||
result.setColumnHeaders(columnHeaders);
|
||||
|
||||
List<ResultsetDataRow> resultsetDataRows = new ArrayList<ResultsetDataRow>();
|
||||
ResultsetDataRow resultsetDataRow;
|
||||
while (rs.next()) {
|
||||
resultsetDataRow = new ResultsetDataRow();
|
||||
List<String> columnValues = new ArrayList<String>();
|
||||
for (int i = 0; i < rsmd.getColumnCount(); i++) {
|
||||
columnName = rsmd.getColumnName(i + 1);
|
||||
columnValue = rs.getString(columnName);
|
||||
columnValues.add(columnValue);
|
||||
}
|
||||
resultsetDataRow.setRow(columnValues);
|
||||
resultsetDataRows.add(resultsetDataRow);
|
||||
}
|
||||
result.setData(resultsetDataRows);
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Sql: " + sql);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private String getSQLtoRun(final String name, final String type,
|
||||
final Map<String, String> queryParams) {
|
||||
String sql = null;
|
||||
|
||||
if (type.equals("report")) {
|
||||
sql = getReportSql(name);
|
||||
} else {
|
||||
sql = getParameterSql(name);
|
||||
}
|
||||
|
||||
Set<String> keys = queryParams.keySet();
|
||||
for (String key : keys) {
|
||||
String pValue = queryParams.get(key);
|
||||
// logger.info("(" + key + " : " + pValue + ")");
|
||||
sql = replace(sql, key, pValue);
|
||||
}
|
||||
|
||||
// wrap sql to prevent JDBC sql errors and also prevent malicious sql
|
||||
sql = "select x.* from (" + sql + ") x";
|
||||
|
||||
return sql;
|
||||
|
||||
}
|
||||
|
||||
// private Boolean verifyUserDetails(AppUser usr) {
|
||||
//
|
||||
// // some logs to be taken out after testing
|
||||
// String idDetails = usr.getId() + ", " + usr.getLastname() + ", "
|
||||
// + usr.getFirstname();
|
||||
// logger.info("Id: " + idDetails + " Organisation: "
|
||||
// + usr.getOrganisation().getId() + " Office: "
|
||||
// + usr.getOffice().getId() + " Role Names: "
|
||||
// + usr.getRoleNames());
|
||||
// String otherDetails = "Head Officer User? " + usr.isHeadOfficeUser()
|
||||
// + " Enabled: " + usr.isEnabled();
|
||||
// logger.info(otherDetails);
|
||||
// if (usr.getAuthorities() != null) {
|
||||
// // for (GrantedAuthority grantedAuthority : usr.getAuthorities()) {
|
||||
// // logger.info("Granted Authority: " +
|
||||
// // grantedAuthority.getAuthority());
|
||||
// // }
|
||||
// }
|
||||
// logger.info("");
|
||||
//
|
||||
// // some checks
|
||||
// if (usr.getOrganisation().getId() == null) {
|
||||
// logger.info("Organisation ID not Found");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private String getReportSql(String reportName) {
|
||||
String sql = "select report_sql as the_sql from stretchy_report where report_name = '"
|
||||
+ reportName + "'";
|
||||
return getSql(sql);
|
||||
}
|
||||
|
||||
private String getParameterSql(String parameterName) {
|
||||
String sql = "select parameter_sql as the_sql from stretchy_parameter where parameter_name = '"
|
||||
+ parameterName + "'";
|
||||
return getSql(sql);
|
||||
}
|
||||
|
||||
private String getSql(String inputSql) {
|
||||
|
||||
String sql = null;
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
ResultSet rs = db_statement.executeQuery(inputSql);
|
||||
|
||||
if (rs.next()) {
|
||||
sql = rs.getString("the_sql");
|
||||
} else {
|
||||
throw new ReportNotFoundException(inputSql);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Input Sql: " + inputSql);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdditionalFieldsSetData> retrieveExtraDatasetNames(String type) {
|
||||
|
||||
List<AdditionalFieldsSetData> additionalFieldsSets = new ArrayList<AdditionalFieldsSetData>();
|
||||
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
|
||||
String whereClause;
|
||||
if (type == null) {
|
||||
whereClause = "";
|
||||
} else {
|
||||
whereClause = "where t.`name` = '" + type + "'";
|
||||
}
|
||||
String sql = "select d.id, d.`name` as 'set', t.`name` as 'type' from stretchydata_dataset d join stretchydata_datasettype t on t.id = d.datasettype_id "
|
||||
+ whereClause + " order by d.`name`";
|
||||
|
||||
ResultSet rs = db_statement.executeQuery(sql);
|
||||
|
||||
while (rs.next()) {
|
||||
additionalFieldsSets.add(new AdditionalFieldsSetData(rs
|
||||
.getInt("id"), rs.getString("set"), rs
|
||||
.getString("type")));
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Additional Fields Type: " + type);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
|
||||
return additionalFieldsSets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericResultsetData retrieveExtraData(String type, String set,
|
||||
Long id) {
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
GenericResultsetData result = fillExtraDataGenericResultSet(type, set,
|
||||
id);
|
||||
long elapsed = System.currentTimeMillis() - startTime;
|
||||
logger.info("FINISHING SET: " + set + " Elapsed Time: " + elapsed);
|
||||
return result;
|
||||
}
|
||||
|
||||
private GenericResultsetData fillExtraDataGenericResultSet(String type,
|
||||
String set, Long id) {
|
||||
|
||||
GenericResultsetData result = new GenericResultsetData();
|
||||
|
||||
Connection db_connection = null;
|
||||
Statement db_statement1 = null;
|
||||
Statement db_statement2 = null;
|
||||
Statement db_statement3 = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement1 = db_connection.createStatement();
|
||||
String sql = "select f.`name`, f.data_type, f.data_length, f.display_type, f.allowed_list_id from stretchydata_datasettype t join stretchydata_dataset d on d.datasettype_id = t.id join stretchydata_dataset_fields f on f.dataset_id = d.id where d.`name` = '"
|
||||
+ set + "' and t.`name` = '" + type + "' order by f.id";
|
||||
|
||||
ResultSet rsmd = db_statement1.executeQuery(sql);
|
||||
|
||||
if (rsmd.next()) {
|
||||
|
||||
String fullDatasetName = getFullDatasetName(type, set);
|
||||
db_statement2 = db_connection.createStatement();
|
||||
List<ResultsetColumnHeader> columnHeaders = new ArrayList<ResultsetColumnHeader>();
|
||||
Boolean firstColumn = true;
|
||||
Integer allowedListId;
|
||||
String selectFieldList = "";
|
||||
String selectFieldSeparator = "";
|
||||
do {
|
||||
ResultsetColumnHeader rsch = new ResultsetColumnHeader();
|
||||
rsch.setColumnName(rsmd.getString("name"));
|
||||
|
||||
if (firstColumn) {
|
||||
selectFieldSeparator = " ";
|
||||
firstColumn = false;
|
||||
} else {
|
||||
selectFieldSeparator = ", ";
|
||||
}
|
||||
selectFieldList += selectFieldSeparator + "s.`"
|
||||
+ rsch.getColumnName() + "`";
|
||||
|
||||
rsch.setColumnType(rsmd.getString("data_type"));
|
||||
if (rsmd.getInt("data_length") > 0)
|
||||
rsch.setColumnLength(rsmd.getInt("data_length"));
|
||||
rsch.setColumnDisplayType(rsmd.getString("display_type"));
|
||||
allowedListId = rsmd.getInt("allowed_list_id");
|
||||
if (allowedListId > 0) {
|
||||
|
||||
// logger.info("allowedListId != null: Column: " +
|
||||
// rsch.getColumnName());
|
||||
sql = "select v.`name` from stretchydata_allowed_value v where allowed_list_id = "
|
||||
+ allowedListId + " order by id";
|
||||
ResultSet rsValues = db_statement2.executeQuery(sql);
|
||||
while (rsValues.next()) {
|
||||
rsch.getColumnValues().add(
|
||||
rsValues.getString("name"));
|
||||
}
|
||||
}
|
||||
columnHeaders.add(rsch);
|
||||
} while (rsmd.next());
|
||||
result.setColumnHeaders(columnHeaders);
|
||||
|
||||
sql = "select " + selectFieldList + " from `" + type
|
||||
+ "` t left join `" + fullDatasetName
|
||||
+ "` s on s.id = t.id " + " where t.id = " + id;
|
||||
|
||||
db_statement3 = db_connection.createStatement();
|
||||
ResultSet rs = db_statement3.executeQuery(sql);
|
||||
|
||||
if (rs.next()) {
|
||||
String columnName = null;
|
||||
String columnValue = null;
|
||||
List<ResultsetDataRow> resultsetDataRows = new ArrayList<ResultsetDataRow>();
|
||||
ResultsetDataRow resultsetDataRow;
|
||||
do {
|
||||
resultsetDataRow = new ResultsetDataRow();
|
||||
List<String> columnValues = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < columnHeaders.size(); i++) {
|
||||
columnName = columnHeaders.get(i).getColumnName();
|
||||
columnValue = rs.getString(columnName);
|
||||
columnValues.add(columnValue);
|
||||
}
|
||||
resultsetDataRow.setRow(columnValues);
|
||||
resultsetDataRows.add(resultsetDataRow);
|
||||
} while (rs.next());
|
||||
result.setData(resultsetDataRows);
|
||||
} else {
|
||||
throw new AdditionalFieldsNotFoundException(type, id);
|
||||
}
|
||||
} else {
|
||||
throw new AdditionalFieldsNotFoundException(type, set);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Additional Fields Type: " + type
|
||||
+ " Set: " + set + " Id: " + id);
|
||||
} finally {
|
||||
dbClose(db_statement2, null);
|
||||
dbClose(db_statement3, null);
|
||||
dbClose(db_statement1, db_connection);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private String getFullDatasetName(final String type, final String set) {
|
||||
return type + "_extra_" + set;
|
||||
}
|
||||
|
||||
private static String replace(String str, String pattern, String replace) {
|
||||
int s = 0;
|
||||
int e = 0;
|
||||
StringBuffer result = new StringBuffer();
|
||||
|
||||
while ((e = str.indexOf(pattern, s)) >= 0) {
|
||||
result.append(str.substring(s, e));
|
||||
result.append(replace);
|
||||
s = e + pattern.length();
|
||||
}
|
||||
result.append(str.substring(s));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(String type, String set, Long id,
|
||||
Map<String, String> queryParams) {
|
||||
logger.info("updateExtraData - type: " + type + " set: " + set
|
||||
+ " id: " + id);
|
||||
|
||||
checkResourceTypeThere(type, set);
|
||||
String fullDatasetName = getFullDatasetName(type, set);
|
||||
String transType = getTransType(type, fullDatasetName, id);
|
||||
|
||||
String saveSql = getSaveSql(fullDatasetName, id, transType, queryParams);
|
||||
|
||||
logger.info("saveSQL: " + saveSql);
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
db_statement.executeUpdate(saveSql);
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Additional Fields Type: " + type
|
||||
+ " Set: " + set + " Id: " + id);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkResourceTypeThere(String type, String set) {
|
||||
String sql = "select 'f' from stretchydata_datasettype t join stretchydata_dataset d on d.datasettype_id = t.id where d.`name` = '"
|
||||
+ set + "' and t.`name` = '" + type + "'";
|
||||
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
ResultSet rs = db_statement.executeQuery(sql);
|
||||
|
||||
if (!(rs.next())) {
|
||||
throw new AdditionalFieldsNotFoundException(type, set);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Additional Fields Type: " + type
|
||||
+ " Set: " + set + " Sql: " + sql);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getTransType(String type, String fullDatasetName, Long id) {
|
||||
String transType = null;
|
||||
|
||||
String sql = "select s.id from `" + type + "` t left join `"
|
||||
+ fullDatasetName + "` s on s.id = t.id where t.id = " + id;
|
||||
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
ResultSet rs = db_statement.executeQuery(sql);
|
||||
|
||||
if (rs.next()) {
|
||||
String idValue = rs.getString("id");
|
||||
if (idValue != null) {
|
||||
transType = "E";
|
||||
} else {
|
||||
transType = "A";
|
||||
}
|
||||
} else {
|
||||
throw new AdditionalFieldsNotFoundException(type, id);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Additional Fields Type: " + type
|
||||
+ " Full Set Name: " + fullDatasetName
|
||||
+ " Sql: " + sql);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
|
||||
return transType;
|
||||
}
|
||||
|
||||
private String getSaveSql(String fullSetName, Long id, String transType,
|
||||
Map<String, String> queryParams) {
|
||||
|
||||
String pValue = "";
|
||||
String pValueWrite = "";
|
||||
String saveSql = "";
|
||||
String singleQuote = "'";
|
||||
String underscore = "_";
|
||||
String space = " ";
|
||||
Set<String> keys = queryParams.keySet();
|
||||
|
||||
if (transType.equals("E")) {
|
||||
boolean firstColumn = true;
|
||||
saveSql = "update `" + fullSetName + "` ";
|
||||
|
||||
for (String key : keys) {
|
||||
if (!(key.equalsIgnoreCase("id"))) {
|
||||
if (firstColumn) {
|
||||
saveSql += " set ";
|
||||
firstColumn = false;
|
||||
} else {
|
||||
saveSql += ", ";
|
||||
}
|
||||
|
||||
pValue = queryParams.get(key);
|
||||
if (pValue == null || pValue.equals("")) {
|
||||
pValueWrite = "null";
|
||||
} else {
|
||||
pValueWrite = singleQuote
|
||||
+ replace(pValue, singleQuote, singleQuote
|
||||
+ singleQuote) + singleQuote;
|
||||
}
|
||||
saveSql += "`" + replace(key, underscore, space) + "` = "
|
||||
+ pValueWrite;
|
||||
}
|
||||
}
|
||||
|
||||
saveSql += " where id = " + id;
|
||||
} else {
|
||||
String insertColumns = "";
|
||||
String selectColumns = "";
|
||||
String columnName = "";
|
||||
for (String key : keys) {
|
||||
pValue = queryParams.get(key);
|
||||
if (!(key.equalsIgnoreCase("id"))) {
|
||||
|
||||
pValue = queryParams.get(key);
|
||||
if (pValue == null || pValue.equals("")) {
|
||||
pValueWrite = "null";
|
||||
} else {
|
||||
pValueWrite = singleQuote
|
||||
+ replace(pValue, singleQuote, singleQuote
|
||||
+ singleQuote) + singleQuote;
|
||||
}
|
||||
columnName = "`" + replace(key, underscore, space) + "`";
|
||||
insertColumns += ", " + columnName;
|
||||
selectColumns += "," + pValueWrite + " as " + columnName;
|
||||
}
|
||||
}
|
||||
|
||||
saveSql = "insert into `" + fullSetName + "` (id" + insertColumns
|
||||
+ ")" + " select " + id + " as id" + selectColumns;
|
||||
}
|
||||
return saveSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReportType(String reportName) {
|
||||
String sql = "SELECT ifnull(report_type,'') as report_type FROM `stretchy_report` where report_name = '"
|
||||
+ reportName + "'";
|
||||
String reportType = "";
|
||||
logger.info("get reportType: " + sql);
|
||||
|
||||
Connection db_connection = null;
|
||||
Statement db_statement = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
db_connection = dataSource.getConnection();
|
||||
db_statement = db_connection.createStatement();
|
||||
rs = db_statement.executeQuery(sql);
|
||||
|
||||
if (rs.next()) {
|
||||
reportType = rs.getString("report_type");
|
||||
} else {
|
||||
throw new ReportNotFoundException(sql);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Report Name: " + reportName + " Sql: "
|
||||
+ sql);
|
||||
} finally {
|
||||
dbClose(db_statement, db_connection);
|
||||
}
|
||||
|
||||
return reportType;
|
||||
}
|
||||
|
||||
private void dbClose(Statement db_statement, Connection db_connection) {
|
||||
logger.info("dbClose");
|
||||
try {
|
||||
if (db_statement != null) {
|
||||
db_statement.close();
|
||||
db_statement = null;
|
||||
}
|
||||
if (db_connection != null) {
|
||||
db_connection.close();
|
||||
db_connection = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new PlatformDataIntegrityException("error.msg.sql.error",
|
||||
e.getMessage(), "Error closing database connection");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response processPentahoRequest(String reportName,
|
||||
String outputTypeParam, Map<String, String> queryParams) {
|
||||
|
||||
String outputType = "HTML";
|
||||
if (StringUtils.isNotBlank(outputTypeParam))
|
||||
outputType = outputTypeParam;
|
||||
|
||||
if (!(outputType.equalsIgnoreCase("HTML")
|
||||
|| outputType.equalsIgnoreCase("PDF")
|
||||
|| outputType.equalsIgnoreCase("XLS") || outputType
|
||||
.equalsIgnoreCase("CSV")))
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.outputType", "No matching Output Type: "
|
||||
+ outputType);
|
||||
|
||||
if (noPentaho)
|
||||
throw new PlatformDataIntegrityException("error.msg.no.pentaho",
|
||||
"Pentaho is not enabled", "Pentaho is not enabled");
|
||||
|
||||
// TODO - use pentaho location finder like Pawel does in Mifos
|
||||
// String reportPath =
|
||||
// "C:\\dev\\apache-tomcat-7.0.25\\webapps\\ROOT\\PentahoReports\\"
|
||||
// + reportName + ".prpt";
|
||||
String reportPath = "/var/lib/tomcat7/webapps/ROOT/PentahoReports/"
|
||||
+ reportName + ".prpt";
|
||||
logger.info("Report path: " + reportPath);
|
||||
|
||||
// load report definition
|
||||
ResourceManager manager = new ResourceManager();
|
||||
manager.registerDefaults();
|
||||
Resource res;
|
||||
|
||||
logger.info("outputType: " + outputType);
|
||||
try {
|
||||
res = manager.createDirectly(reportPath, MasterReport.class);
|
||||
MasterReport masterReport = (MasterReport) res.getResource();
|
||||
|
||||
addParametersToReport(masterReport, queryParams);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
if ("PDF".equalsIgnoreCase(outputType)) {
|
||||
PdfReportUtil.createPDF(masterReport, baos);
|
||||
return Response.ok().entity(baos.toByteArray())
|
||||
.type("application/pdf").build();
|
||||
}
|
||||
|
||||
if ("XLS".equalsIgnoreCase(outputType)) {
|
||||
ExcelReportUtil.createXLS(masterReport, baos);
|
||||
return Response
|
||||
.ok()
|
||||
.entity(baos.toByteArray())
|
||||
.type("application/vnd.ms-excel")
|
||||
.header("Content-Disposition",
|
||||
"attachment;filename="
|
||||
+ reportName.replaceAll(" ", "")
|
||||
+ ".xls").build();
|
||||
}
|
||||
|
||||
if ("CSV".equalsIgnoreCase(outputType)) {
|
||||
CSVReportUtil.createCSV(masterReport, baos, "UTF-8");
|
||||
return Response
|
||||
.ok()
|
||||
.entity(baos.toByteArray())
|
||||
.type("application/x-msdownload")
|
||||
.header("Content-Disposition",
|
||||
"attachment;filename="
|
||||
+ reportName.replaceAll(" ", "")
|
||||
+ ".csv").build();
|
||||
}
|
||||
|
||||
if ("HTML".equalsIgnoreCase(outputType)) {
|
||||
HtmlReportUtil.createStreamHTML(masterReport, baos);
|
||||
return Response.ok().entity(baos.toByteArray())
|
||||
.type("text/html").build();
|
||||
}
|
||||
} catch (ResourceException e) {
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.reporting.error", e.getMessage());
|
||||
} catch (ReportProcessingException e) {
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.reporting.error", e.getMessage());
|
||||
} catch (IOException e) {
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.reporting.error", e.getMessage());
|
||||
}
|
||||
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.outputType", "No matching Output Type: "
|
||||
+ outputType);
|
||||
|
||||
}
|
||||
|
||||
private void addParametersToReport(MasterReport report,
|
||||
Map<String, String> queryParams) {
|
||||
|
||||
try {
|
||||
ReportParameterValues rptParamValues = report.getParameterValues();
|
||||
ReportParameterDefinition paramsDefinition = report
|
||||
.getParameterDefinition();
|
||||
|
||||
/*
|
||||
* only allow integer and string parameter types and assume all
|
||||
* mandatory - could go more detailed like Pawel did in Mifos later
|
||||
* and could match incoming and pentaho parameters better...
|
||||
* currently assuming they come in ok... and if not an error
|
||||
*/
|
||||
for (ParameterDefinitionEntry paramDefEntry : paramsDefinition
|
||||
.getParameterDefinitions()) {
|
||||
String paramName = paramDefEntry.getName();
|
||||
String pValue = queryParams.get(paramName);
|
||||
if (StringUtils.isBlank(pValue))
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.reporting.error", "Pentaho Parameter: "
|
||||
+ paramName + " - not Provided");
|
||||
|
||||
Class<?> clazz = paramDefEntry.getValueType();
|
||||
logger.info("addParametersToReport(" + paramName + " : "
|
||||
+ pValue + " : " + clazz.getCanonicalName() + ")");
|
||||
|
||||
if (clazz.getCanonicalName().equalsIgnoreCase(
|
||||
"java.lang.Integer"))
|
||||
rptParamValues.put(paramName, Integer.parseInt(pValue));
|
||||
else if (clazz.getCanonicalName().equalsIgnoreCase(
|
||||
"java.sql.Date"))
|
||||
rptParamValues.put(paramName, Date.valueOf(pValue));
|
||||
else
|
||||
rptParamValues.put(paramName, pValue);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.reporting.error", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.loan.domain.Loan;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
public final class Specifications {
|
||||
|
||||
public static Specification<Loan> loansThatMatch(final Client client) {
|
||||
return new Specification<Loan>() {
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(final Root<Loan> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
||||
return cb.equal(root.get("client"), client);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
-142
@@ -1,142 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.mifosng.platform.InvalidSqlException;
|
||||
import org.mifosng.platform.ReadExtraDataAndReportingService;
|
||||
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
||||
import org.mifosng.platform.api.data.ApiParameterError;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/additionalfields")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class AdditionalFieldsApiResource {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(AdditionalFieldsApiResource.class);
|
||||
|
||||
@Autowired
|
||||
private ReadExtraDataAndReportingService readExtraDataAndReportingService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String datasets(@QueryParam("type") final String type, @Context final UriInfo uriInfo) {
|
||||
|
||||
List<AdditionalFieldsSetData> result = this.readExtraDataAndReportingService.retrieveExtraDatasetNames(type);
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
return this.apiDataConversionService.convertAdditionalFieldsSetDataToJson(prettyPrint, result.toArray(new AdditionalFieldsSetData[result.size()]));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{type}/{set}/{id}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String extraData(@PathParam("type") final String type,
|
||||
@PathParam("set") final String set, @PathParam("id") final Long id,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
try {
|
||||
GenericResultsetData result = this.readExtraDataAndReportingService.retrieveExtraData(type, set, id);
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
return this.apiDataConversionService.convertGenericResultsetDataToJson(prettyPrint, result);
|
||||
} catch (InvalidSqlException e) {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
ApiParameterError error = ApiParameterError.parameterError(
|
||||
"extradata.invalid.sql", "The sql is invalid.", "sql",
|
||||
e.getSql());
|
||||
dataValidationErrors.add(error);
|
||||
throw new PlatformApiDataValidationException(
|
||||
"validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{type}/{set}/{id}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response saveExtraData(@PathParam("type") final String type,
|
||||
@PathParam("set") final String set, @PathParam("id") final Long id,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
try {
|
||||
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
String pValue = "";
|
||||
String pName;
|
||||
try {
|
||||
JSONObject jsonObj = new JSONObject(jsonRequestBody);
|
||||
JSONArray jsonArr = jsonObj.names();
|
||||
if (jsonArr != null) {
|
||||
for (int i = 0; i < jsonArr.length(); i++) {
|
||||
pName = (String) jsonArr.get(i);
|
||||
pValue = jsonObj.getString(pName);
|
||||
logger.info(pName + " - " + pValue);
|
||||
queryParams.put(pName, pValue);
|
||||
}
|
||||
} else {
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST)
|
||||
.entity("JSON body empty").build());
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST)
|
||||
.entity("JSON body is wrong").build());
|
||||
}
|
||||
|
||||
this.readExtraDataAndReportingService.updateExtraData(type, set,
|
||||
id, queryParams);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||
Long.valueOf(id));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
} catch (InvalidSqlException e) {
|
||||
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
ApiParameterError error = ApiParameterError.parameterError(
|
||||
"extradata.invalid.sql", "The sql is invalid.", "sql",
|
||||
e.getSql());
|
||||
dataValidationErrors.add(error);
|
||||
throw new PlatformApiDataValidationException(
|
||||
"validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.user.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sun.jersey.core.util.Base64;
|
||||
|
||||
@Path("/authentication")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class AuthenticationApiResource {
|
||||
|
||||
@Qualifier("customAuthenticationProvider")
|
||||
@Autowired
|
||||
private DaoAuthenticationProvider customAuthenticationProvider;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String authenticate(@QueryParam("username") final String username, @QueryParam("password") final String password) {
|
||||
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(username, password);
|
||||
Authentication authenticationCheck = customAuthenticationProvider.authenticate(authentication);
|
||||
|
||||
Collection<String> permissions = new ArrayList<String>();
|
||||
AuthenticatedUserData authenticatedUserData = new AuthenticatedUserData(permissions);
|
||||
authenticatedUserData.setUsername(username);
|
||||
|
||||
if (authenticationCheck.isAuthenticated()) {
|
||||
Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(authenticationCheck.getAuthorities());
|
||||
for (GrantedAuthority grantedAuthority : authorities) {
|
||||
permissions.add(grantedAuthority.getAuthority());
|
||||
}
|
||||
authenticatedUserData.setPermissions(permissions);
|
||||
authenticatedUserData.setAuthenticated(true);
|
||||
AppUser principal = (AppUser) authenticationCheck.getPrincipal();
|
||||
authenticatedUserData.setUserId(principal.getId());
|
||||
byte[] base64EncodedAuthenticationKey = Base64.encode(username + ":" + password);
|
||||
authenticatedUserData.setBase64EncodedAuthenticationKey(new String(base64EncodedAuthenticationKey));
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertAuthenticatedUserDataToJson(false, authenticatedUserData);
|
||||
}
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.NoteData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.client.service.ClientWritePlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/clients")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ClientsApiResource {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ClientsApiResource.class);
|
||||
|
||||
@Autowired
|
||||
private ClientReadPlatformService clientReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ClientWritePlatformService clientWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService officeReadPlatformService;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllIndividualClients(@Context final UriInfo uriInfo,
|
||||
@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("officeId") final Integer officeId,
|
||||
@QueryParam("externalId") final String externalId,
|
||||
@QueryParam("displayName") final String displayName,
|
||||
@QueryParam("firstName") final String firstName,
|
||||
@QueryParam("lastName") final String lastName) {
|
||||
|
||||
final String extraCriteria = getClientCriteria(sqlSearch, officeId, externalId, displayName, firstName, lastName);
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "officeId", "officeName", "externalId", "firstname", "lastname", "joinedDate", "displayName")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<ClientData> clients = this.clientReadPlatformService.retrieveAllIndividualClients(extraCriteria);
|
||||
|
||||
return this.apiDataConversionService.convertClientDataToJson(prettyPrint, responseParameters, clients.toArray(new ClientData[clients.size()]));
|
||||
}
|
||||
|
||||
private String getClientCriteria(String sqlSearch, Integer officeId,
|
||||
String externalId, String displayName, String firstName,
|
||||
String lastName) {
|
||||
|
||||
String extraCriteria = "";
|
||||
|
||||
if (sqlSearch != null)
|
||||
extraCriteria = " and (" + sqlSearch + ")";
|
||||
|
||||
if (officeId != null)
|
||||
extraCriteria += " and office_id = " + officeId;
|
||||
if (externalId != null)
|
||||
extraCriteria += " and external_id like "
|
||||
+ sqlEncodeString(externalId);
|
||||
if (displayName != null)
|
||||
extraCriteria += " and concat(ifnull(firstname, ''), if(firstname > '',' ', '') , ifnull(lastname, '')) like "
|
||||
+ sqlEncodeString(displayName);
|
||||
if (firstName != null)
|
||||
extraCriteria += " and firstname like "
|
||||
+ sqlEncodeString(firstName);
|
||||
if (lastName != null)
|
||||
extraCriteria += " and lastname like " + sqlEncodeString(lastName);
|
||||
|
||||
if (StringUtils.isNotBlank(extraCriteria))
|
||||
extraCriteria = extraCriteria.substring(4);
|
||||
|
||||
logger.info("extraCriteria; " + extraCriteria);
|
||||
|
||||
return extraCriteria;
|
||||
}
|
||||
|
||||
private String sqlEncodeString(String str) {
|
||||
String singleQuote = "'";
|
||||
String twoSingleQuotes = "''";
|
||||
return singleQuote
|
||||
+ StringUtils.replace(str, singleQuote, twoSingleQuotes, -1)
|
||||
+ singleQuote;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveClientData(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "officeId", "officeName", "externalId", "firstname", "lastname", "joinedDate", "displayName")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService.retrieveIndividualClient(clientId);
|
||||
if (template) {
|
||||
clientData.setAllowedOffices(new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup()));
|
||||
responseParameters.add("allowedOffices");
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertClientDataToJson(prettyPrint, responseParameters, clientData);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String newClientDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "officeId", "officeName", "externalId", "firstname", "lastname", "joinedDate", "displayName", "allowedOffices")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService.retrieveNewClientDetails();
|
||||
|
||||
return this.apiDataConversionService.convertClientDataToJson(prettyPrint, responseParameters, clientData);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response enrollClient(final String jsonRequestBody) {
|
||||
|
||||
ClientCommand command = this.apiDataConversionService.convertJsonToClientCommand(null, jsonRequestBody);
|
||||
|
||||
Long clientId = this.clientWritePlatformService.enrollClient(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(clientId)).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{clientId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateClient(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
|
||||
ClientCommand command = this.apiDataConversionService.convertJsonToClientCommand(clientId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.clientWritePlatformService.updateClientDetails(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{clientId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response deleteClient(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
this.clientWritePlatformService.deleteClient(clientId);
|
||||
|
||||
return Response.ok(new EntityIdentifier(clientId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/loans")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveClientAccount(@PathParam("clientId") final Long clientId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
||||
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
ClientLoanAccountSummaryCollectionData clientAccount = this.clientReadPlatformService.retrieveClientAccountDetails(clientId);
|
||||
|
||||
return this.apiDataConversionService.convertClientLoanAccountSummaryCollectionDataToJson(prettyPrint, responseParameters, clientAccount);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllClientNotes(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "clientId", "loanId", "loanTransactionId", "noteType", "note", "createdById", "createdByUsername",
|
||||
"createdOn", "updatedById", "updatedByUsername", "updatedOn")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<NoteData> notes = this.clientReadPlatformService.retrieveAllClientNotes(clientId);
|
||||
|
||||
return this.apiDataConversionService.convertNoteDataToJson(prettyPrint, responseParameters, notes.toArray(new NoteData[notes.size()]));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response addNewClientNote(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
|
||||
NoteCommand command = this.apiDataConversionService.convertJsonToNoteCommand(null, clientId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.clientWritePlatformService.addClientNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveClientNote(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
@PathParam("noteId") final Long noteId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "clientId", "loanId", "loanTransactionId", "noteType", "note", "createdById", "createdByUsername",
|
||||
"createdOn", "updatedById", "updatedByUsername", "updatedOn")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
NoteData note = this.clientReadPlatformService.retrieveClientNote(clientId, noteId);
|
||||
|
||||
return this.apiDataConversionService.convertNoteDataToJson(prettyPrint, responseParameters, note);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateClientNote(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
@PathParam("noteId") final Long noteId, final String jsonRequestBody) {
|
||||
|
||||
NoteCommand command = this.apiDataConversionService.convertJsonToNoteCommand(noteId, clientId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.clientWritePlatformService.updateNote(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.data.ConfigurationData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.configuration.service.ConfigurationReadPlatformService;
|
||||
import org.mifosng.platform.configuration.service.ConfigurationWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/configurations")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ConfigurationApiResource {
|
||||
|
||||
@Autowired
|
||||
private ConfigurationReadPlatformService configurationReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationWritePlatformService configurationWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Path("currency")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveCurrencyDataForConfiguration(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("selectedCurrencyOptions", "currencyOptions"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
ConfigurationData configurationData = this.configurationReadPlatformService.retrieveCurrencyConfiguration();
|
||||
|
||||
return this.apiDataConversionService.convertConfigurationDataToJson(prettyPrint, responseParameters, configurationData);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("currency")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateAllowedCurrenciesForOrganisation(final String jsonRequestBody) {
|
||||
|
||||
OrganisationCurrencyCommand command = this.apiDataConversionService.convertJsonToOrganisationCurrencyCommand(jsonRequestBody);
|
||||
|
||||
this.configurationWritePlatformService.updateOrganisationCurrencies(command);
|
||||
|
||||
return Response.ok().entity(command).build();
|
||||
}
|
||||
}
|
||||
-164
@@ -1,164 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.DepositAccountCommand;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.DepositAccountData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.DepositAccountReadPlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.DepositAccountWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/depositaccounts")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class DepositAccountsApiResource {
|
||||
|
||||
@Autowired
|
||||
private DepositAccountReadPlatformService depositAccountReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private CurrencyReadPlatformService currencyReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private DepositAccountWritePlatformService depositAccountWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createDepositAccount(final String jsonRequestBody){
|
||||
|
||||
final DepositAccountCommand command = this.apiDataConversionService.convertJsonToDepositAccountCommand(null, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.depositAccountWritePlatformService.createDepositAccount(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{accountId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateSavingProduct(@PathParam("accountId") final Long accountId, final String jsonRequestBody){
|
||||
|
||||
final DepositAccountCommand command = this.apiDataConversionService.convertJsonToDepositAccountCommand(accountId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.depositAccountWritePlatformService.updateDepositAccount(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllDepositAccounts(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("createdOn", "lastModifedOn",
|
||||
"id", "clientId", "clientName", "productId", "productName",
|
||||
"currency", "deposit", "maturityInterestRate")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<DepositAccountData> accounts = this.depositAccountReadPlatformService.retrieveAllDepositAccounts();
|
||||
|
||||
return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, accounts.toArray(new DepositAccountData[accounts.size()]));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{accountId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveDepositAccount(@PathParam("accountId") final Long accountId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("createdOn", "lastModifedOn",
|
||||
"id", "clientId", "clientName", "productId", "productName",
|
||||
"currency", "deposit", "maturityInterestRate")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
DepositAccountData account = this.depositAccountReadPlatformService.retrieveDepositAccount(accountId);
|
||||
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
if (template) {
|
||||
responseParameters.addAll(Arrays.asList("currencyOptions"));
|
||||
List<CurrencyData> allowedCurrencies = this.currencyReadPlatformService.retrieveAllowedCurrencies();
|
||||
account = new DepositAccountData(account, allowedCurrencies);
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, account);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewDepositAccountDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("createdOn", "lastModifedOn",
|
||||
"id", "clientId", "clientName", "productId", "productName",
|
||||
"currency", "deposit", "maturityInterestRate", "currencyOptions")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
DepositAccountData account = this.depositAccountReadPlatformService.retrieveNewDepositAccountDetails();
|
||||
List<CurrencyData> allowedCurrencies = this.currencyReadPlatformService.retrieveAllowedCurrencies();
|
||||
account = new DepositAccountData(account, allowedCurrencies);
|
||||
|
||||
return this.apiDataConversionService.convertDepositAccountDataToJson(prettyPrint, responseParameters, account);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{accountId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response deleteProduct(@PathParam("accountId") final Long accountId) {
|
||||
|
||||
this.depositAccountWritePlatformService.deleteDepositAccount(accountId);
|
||||
|
||||
return Response.ok(new EntityIdentifier(accountId)).build();
|
||||
}
|
||||
}
|
||||
-142
@@ -1,142 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.depositproduct.service.DepositProductReadPlatformService;
|
||||
import org.mifosng.platform.depositproduct.service.DepositProductWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/depositproducts")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class DepositProductsApiResource {
|
||||
|
||||
@Autowired
|
||||
private DepositProductReadPlatformService depositProductReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private DepositProductWritePlatformService depositProductWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createDepositProduct(final String jsonRequestBody){
|
||||
|
||||
final DepositProductCommand command=this.apiDataConversionService.convertJsonToDepositProductCommand(null, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier=this.depositProductWritePlatformService.createDepositProduct(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateDepositProduct(@PathParam("productId") final Long productId, final String jsonRequestBody){
|
||||
|
||||
final DepositProductCommand command=this.apiDataConversionService.convertJsonToDepositProductCommand(productId, jsonRequestBody);
|
||||
EntityIdentifier entityIdentifier=this.depositProductWritePlatformService.updateDepositProduct(command);
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response deleteDepositProduct(@PathParam("productId") final Long productId) {
|
||||
|
||||
this.depositProductWritePlatformService.deleteDepositProduct(productId);
|
||||
|
||||
return Response.ok(new EntityIdentifier(productId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllDepositProducts(@Context final UriInfo uriInfo){
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
|
||||
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<DepositProductData> products=this.depositProductReadPlatformService.retrieveAllDepositProducts();
|
||||
return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, products.toArray(new DepositProductData[products.size()]));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveDepositProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo){
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
|
||||
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
if (template) {
|
||||
responseParameters.addAll(Arrays.asList("currencyOptions"));
|
||||
}
|
||||
DepositProductData productData = this.depositProductReadPlatformService.retrieveDepositProductData(productId);
|
||||
return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, productData);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewDepositProductDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
DepositProductData depositProduct = this.depositProductReadPlatformService.retrieveNewDepositProductDetails();
|
||||
|
||||
return this.apiDataConversionService.convertDepositProductDataToJson(prettyPrint, responseParameters, depositProduct);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.fund.service.FundReadPlatformService;
|
||||
import org.mifosng.platform.fund.service.FundWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/funds")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class FundsApiResource {
|
||||
|
||||
@Autowired
|
||||
private FundReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private FundWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveFunds(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<FundData> funds = this.readPlatformService.retrieveAllFunds();
|
||||
|
||||
return this.apiDataConversionService.convertFundDataToJson(prettyPrint, responseParameters, funds.toArray(new FundData[funds.size()]));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createFund(final String jsonRequestBody) {
|
||||
|
||||
FundCommand command = this.apiDataConversionService.convertJsonToFundCommand(null, jsonRequestBody);
|
||||
|
||||
Long fundId = this.writePlatformService.createFund(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(fundId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{fundId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retreiveOffice(@PathParam("fundId") final Long fundId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
FundData fund = this.readPlatformService.retrieveFund(fundId);
|
||||
|
||||
return this.apiDataConversionService.convertFundDataToJson(prettyPrint, responseParameters, fund);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{fundId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateFund(@PathParam("fundId") final Long fundId, final String jsonRequestBody) {
|
||||
|
||||
FundCommand command = this.apiDataConversionService.convertJsonToFundCommand(fundId, jsonRequestBody);
|
||||
|
||||
Long entityId = this.writePlatformService.updateFund(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.GroupCommand;
|
||||
import org.mifosng.platform.api.data.ClientMemberData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.group.service.GroupReadPlatformService;
|
||||
import org.mifosng.platform.group.service.GroupWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/groups")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class GroupsApiResource {
|
||||
|
||||
@Autowired
|
||||
private GroupReadPlatformService groupReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private GroupWritePlatformService groupWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllGroups(@Context final UriInfo uriInfo){
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "externalId", "clientMembers")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<GroupData> groups = this.groupReadPlatformService.retrieveAllGroups();
|
||||
|
||||
for (GroupData group : groups){
|
||||
group.setClientMembers(this.groupReadPlatformService.retrieveClientMembers(group.getId()));
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertGroupDataToJson(prettyPrint, responseParameters, groups.toArray(new GroupData[groups.size()]));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{groupId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveGroupData(@PathParam("groupId") final Long groupId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "externalId", "clientMembers"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo
|
||||
.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
GroupData group = this.groupReadPlatformService.retrieveGroup(groupId);
|
||||
|
||||
Collection<ClientMemberData> clientMembers = this.groupReadPlatformService.retrieveClientMembers(groupId);
|
||||
group.setClientMembers(clientMembers);
|
||||
|
||||
return this.apiDataConversionService.convertGroupDataToJson(prettyPrint, responseParameters, group);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response createGroup(final String jsonRequestBody) {
|
||||
|
||||
final GroupCommand command = this.apiDataConversionService.convertJsonToGroupCommand(null, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.groupWritePlatformService.createGroup(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{groupId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateGroup(@PathParam("groupId") final Long groupId, final String jsonRequestBody) {
|
||||
|
||||
final GroupCommand command = this.apiDataConversionService.convertJsonToGroupCommand(groupId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.groupWritePlatformService.updateGroup(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{groupId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteGroup(@PathParam("groupId") final Long groupId){
|
||||
|
||||
EntityIdentifier entityIdentifier = this.groupWritePlatformService.deleteGroup(groupId);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.LoanProductCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.mifosng.platform.loanproduct.service.LoanProductWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/loanproducts")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class LoanProductsApiResource {
|
||||
|
||||
@Autowired
|
||||
private LoanProductReadPlatformService loanProductReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private LoanProductWritePlatformService loanProductWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createLoanProduct(final String jsonRequestBody) {
|
||||
|
||||
final LoanProductCommand command = this.apiDataConversionService.convertJsonToLoanProductCommand(null, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.loanProductWritePlatformService.createLoanProduct(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllLoanProducts(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description", "fundId", "fundName", "principal", "inArrearsTolerance", "numberOfRepayments",
|
||||
"repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"createdOn", "lastModifedOn")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<LoanProductData> products = this.loanProductReadPlatformService.retrieveAllLoanProducts();
|
||||
|
||||
return this.apiDataConversionService.convertLoanProductDataToJson(prettyPrint, responseParameters, products.toArray(new LoanProductData[products.size()]));
|
||||
}
|
||||
|
||||
/*
|
||||
* see
|
||||
* http://stackoverflow.com/questions/5250074/what-uri-can-be-used-to-request
|
||||
* -a-default-resource
|
||||
*/
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewLoanProductDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
// TODO - KW - every addition of a parameter here requires same additon in supported params used in 'apiDataConversionService' method.
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description", "fundId", "fundName", "transactionProcessingStrategyId", "transactionProcessingStrategyName",
|
||||
"principal", "inArrearsTolerance", "numberOfRepayments",
|
||||
"repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"createdOn", "lastModifedOn","currencyOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
||||
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveNewLoanProductDetails();
|
||||
|
||||
return this.apiDataConversionService.convertLoanProductDataToJson(prettyPrint, responseParameters, loanProduct);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveLoanProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description", "fundId", "fundName",
|
||||
"transactionProcessingStrategyId", "transactionProcessingStrategyName",
|
||||
"principal", "inArrearsTolerance", "numberOfRepayments",
|
||||
"repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"createdOn", "lastModifedOn")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
if (template) {
|
||||
responseParameters.addAll(Arrays.asList("currencyOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
|
||||
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "fundOptions", "transactionProcessingStrategyOptions"));
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertLoanProductDataToJson(prettyPrint, responseParameters, loanProduct);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{productId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateLoanProduct(@PathParam("productId") final Long productId, final String jsonRequestBody) {
|
||||
|
||||
LoanProductCommand command = this.apiDataConversionService.convertJsonToLoanProductCommand(productId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.loanProductWritePlatformService.updateLoanProduct(command);
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
}
|
||||
@@ -1,338 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.LoanAccountData;
|
||||
import org.mifosng.platform.api.data.LoanAccountSummaryData;
|
||||
import org.mifosng.platform.api.data.LoanBasicDetailsData;
|
||||
import org.mifosng.platform.api.data.LoanPermissionData;
|
||||
import org.mifosng.platform.api.data.LoanRepaymentPeriodData;
|
||||
import org.mifosng.platform.api.data.LoanRepaymentTransactionData;
|
||||
import org.mifosng.platform.api.data.LoanSchedule;
|
||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||
import org.mifosng.platform.api.data.NewLoanData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.exceptions.UnrecognizedQueryParamException;
|
||||
import org.mifosng.platform.loan.service.CalculationPlatformService;
|
||||
import org.mifosng.platform.loan.service.LoanReadPlatformService;
|
||||
import org.mifosng.platform.loan.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/loans")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class LoansApiResource {
|
||||
|
||||
@Autowired
|
||||
private LoanReadPlatformService loanReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private LoanWritePlatformService loanWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private CalculationPlatformService calculationPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveDetailsForNewLoanApplicationStepOne(
|
||||
@QueryParam("clientId") final Long clientId,
|
||||
@QueryParam("productId") final Long productId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("clientId", "clientName", "productId", "productName",
|
||||
"selectedProduct", "expectedDisbursementDate", "allowedProducts"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
NewLoanData workflowData = this.loanReadPlatformService.retrieveClientAndProductDetails(clientId, productId);
|
||||
|
||||
return this.apiDataConversionService.convertNewLoanDataToJson(prettyPrint, responseParameters, workflowData);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{loanId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveLoanAccountDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "externalId", "fundId", "fundName", "loanProductId", "loanProductName", "principal", "inArrearsTolerance", "numberOfRepayments",
|
||||
"repaymentEvery", "interestRatePerPeriod", "annualInterestRate",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
|
||||
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
|
||||
"lifeCycleStatusId", "lifeCycleStatusText", "lifeCycleStatusDate")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||
|
||||
Collection<LoanRepaymentTransactionData> loanRepayments = null;
|
||||
Collection<LoanRepaymentPeriodData> repaymentSchedule = null;
|
||||
LoanAccountSummaryData summary = null;
|
||||
LoanPermissionData permissions = null;
|
||||
|
||||
Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (!associationParameters.isEmpty()) {
|
||||
if (associationParameters.contains("all")) {
|
||||
responseParameters.addAll(Arrays.asList("summary", "repaymentSchedule", "loanRepayments", "permissions", "convenienceData"));
|
||||
} else {
|
||||
responseParameters.addAll(associationParameters);
|
||||
}
|
||||
|
||||
loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId);
|
||||
repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId);
|
||||
|
||||
summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule, loanRepayments);
|
||||
|
||||
boolean isWaiveAllowed = summary.isWaiveAllowed(loanBasicDetails.getInArrearsTolerance());
|
||||
permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepayments.size());
|
||||
}
|
||||
|
||||
LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, summary, repaymentSchedule, loanRepayments, permissions);
|
||||
|
||||
return this.apiDataConversionService.convertLoanAccountDataToJson(prettyPrint, responseParameters, loanAccount);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response calculateLoanScheduleOrSubmitLoanApplication(
|
||||
@QueryParam("command") final String commandParam,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
SubmitLoanApplicationCommand command = this.apiDataConversionService
|
||||
.convertJsonToSubmitLoanApplicationCommand(jsonRequestBody);
|
||||
|
||||
CalculateLoanScheduleCommand calculateLoanScheduleCommand = command.toCalculateLoanScheduleCommand();
|
||||
LoanSchedule loanSchedule = this.calculationPlatformService.calculateLoanSchedule(calculateLoanScheduleCommand);
|
||||
|
||||
// for now just auto generating the loan schedule and setting support
|
||||
// for 'manual' loan schedule creation later.
|
||||
command.setLoanSchedule(loanSchedule);
|
||||
|
||||
if (is(commandParam, "calculateLoanSchedule")) {
|
||||
return Response.ok().entity(loanSchedule).build();
|
||||
}
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.submitLoanApplication(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{loanId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteLoanApplication(@PathParam("loanId") final Long loanId) {
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.deleteLoan(loanId);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{loanId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response stateTransitions(@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("command") final String commandParam,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
LoanStateTransitionCommand command = this.apiDataConversionService
|
||||
.convertJsonToLoanStateTransitionCommand(loanId,
|
||||
jsonRequestBody);
|
||||
|
||||
Response response = null;
|
||||
|
||||
if (is(commandParam, "reject")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.rejectLoan(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "withdrewbyclient")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.withdrawLoan(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "approve")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.approveLoanApplication(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "disburse")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.disburseLoan(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(
|
||||
loanId, command.getNote());
|
||||
|
||||
if (is(commandParam, "undoapproval")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.undoLoanApproval(undoCommand);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "undodisbursal")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.undoLoanDisbursal(undoCommand);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private boolean is(final String commandParam, final String commandValue) {
|
||||
return StringUtils.isNotBlank(commandParam)
|
||||
&& commandParam.trim().equalsIgnoreCase(commandValue);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{loanId}/transactions")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response executeLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("command") final String commandParam,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
final LoanTransactionCommand command = this.apiDataConversionService
|
||||
.convertJsonToLoanTransactionCommand(loanId, jsonRequestBody);
|
||||
|
||||
Response response = null;
|
||||
|
||||
if (is(commandParam, "repayment")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.makeLoanRepayment(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.waiveLoanAmount(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/transactions/template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveNewRepaymentDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("command") final String commandParam,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "transactionType", "date", "principal", "interest", "total", "totalWaived", "overpaid")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
LoanTransactionData transactionData = null;
|
||||
if (is(commandParam, "repayment")) {
|
||||
transactionData = this.loanReadPlatformService.retrieveNewLoanRepaymentDetails(loanId);
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
transactionData = this.loanReadPlatformService.retrieveNewLoanWaiverDetails(loanId);
|
||||
} else {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertLoanTransactionDataToJson(prettyPrint, responseParameters, transactionData);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveTransaction(@PathParam("loanId") final Long loanId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "transactionType", "date", "principal", "interest", "total", "totalWaived", "overpaid")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
LoanTransactionData transactionData = this.loanReadPlatformService.retrieveLoanTransactionDetails(loanId, transactionId);
|
||||
|
||||
return this.apiDataConversionService.convertLoanTransactionDataToJson(prettyPrint, responseParameters, transactionData);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response adjustLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
final AdjustLoanTransactionCommand command = this.apiDataConversionService
|
||||
.convertJsonToAdjustLoanTransactionCommand(loanId,
|
||||
transactionId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.adjustLoanTransaction(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.OfficeTransactionData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/officetransactions")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class OfficeTransactionsApiResource {
|
||||
|
||||
@Autowired
|
||||
private OfficeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("transactionDate", "allowedOffices", "currencyOptions"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
OfficeTransactionData officeTransactionData = this.readPlatformService.retrieveNewOfficeTransactionDetails();
|
||||
|
||||
return this.apiDataConversionService.convertOfficeTransactionDataToJson(prettyPrint, responseParameters, officeTransactionData);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response transferMoneyFrom(final String jsonRequestBody) {
|
||||
|
||||
BranchMoneyTransferCommand command = this.apiDataConversionService.convertJsonToBranchMoneyTransferCommand(jsonRequestBody);
|
||||
|
||||
Long id = this.writePlatformService.externalBranchMoneyTransfer(command);
|
||||
return Response.ok().entity(new EntityIdentifier(id)).build();
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.OfficeData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/offices")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class OfficesApiResource {
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private OfficeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveOffices(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||
"hierarchy", "parentId", "parentName"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<OfficeData> offices = this.readPlatformService.retrieveAllOffices();
|
||||
|
||||
return this.apiDataConversionService.convertOfficeDataToJson(prettyPrint, responseParameters, offices.toArray(new OfficeData[offices.size()]));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveOfficeTemplate(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||
"hierarchy", "parentId", "parentName", "allowedParents"));
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
OfficeData officeData = this.readPlatformService.retrieveNewOfficeTemplate();
|
||||
|
||||
return this.apiDataConversionService.convertOfficeDataToJson(prettyPrint, typicalResponseParameters, officeData);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createOffice(final String jsonRequestBody) {
|
||||
|
||||
OfficeCommand command = this.apiDataConversionService.convertJsonToOfficeCommand(null, jsonRequestBody);
|
||||
|
||||
Long officeId = this.writePlatformService.createOffice(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(officeId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{officeId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retreiveOffice(@PathParam("officeId") final Long officeId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||
"hierarchy", "parentId", "parentName"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
|
||||
OfficeData office = this.readPlatformService.retrieveOffice(officeId);
|
||||
if (template) {
|
||||
office.setAllowedParents(this.readPlatformService.retrieveAllowedParents(officeId));
|
||||
responseParameters.add("allowedParents");
|
||||
}
|
||||
|
||||
return this.apiDataConversionService.convertOfficeDataToJson(prettyPrint, responseParameters, office);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{officeId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateOffice(@PathParam("officeId") final Long officeId, final String jsonRequestBody) {
|
||||
|
||||
OfficeCommand command = this.apiDataConversionService.convertJsonToOfficeCommand(officeId, jsonRequestBody);
|
||||
|
||||
Long entityId = this.writePlatformService.updateOffice(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.data.PermissionData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.mifosng.platform.user.service.PermissionReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/permissions")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class PermissionsApiResource {
|
||||
|
||||
@Autowired
|
||||
private PermissionReadPlatformService permissionReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllPermissions(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<PermissionData> permissions = this.permissionReadPlatformService.retrieveAllPermissions();
|
||||
|
||||
return this.apiDataConversionService.convertPermissionDataToJson(prettyPrint, responseParameters, permissions.toArray(new PermissionData[permissions.size()]));
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.ReadExtraDataAndReportingService;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/reports")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ReportsApiResource {
|
||||
|
||||
@Autowired
|
||||
private ReadExtraDataAndReportingService readExtraDataAndReportingService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON, "application/x-msdownload" })
|
||||
public Response retrieveReportList(@Context final UriInfo uriInfo) {
|
||||
|
||||
Map<String, String> extractedQueryParams = new HashMap<String, String>();
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean exportCsv = ApiParameterHelper.exportCsv(uriInfo.getQueryParameters());
|
||||
|
||||
if (!exportCsv) {
|
||||
GenericResultsetData result = this.readExtraDataAndReportingService.retrieveGenericResultset(".", ".", extractedQueryParams);
|
||||
|
||||
final String json = this.apiDataConversionService.convertGenericResultsetDataToJson(prettyPrint, result);
|
||||
|
||||
return Response.ok().entity(json).build();
|
||||
}
|
||||
|
||||
StreamingOutput result = this.readExtraDataAndReportingService.retrieveReportCSV(".", ".", extractedQueryParams);
|
||||
|
||||
return Response
|
||||
.ok()
|
||||
.entity(result)
|
||||
.header("Content-Disposition",
|
||||
"attachment;filename=ReportList.csv").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{reportName}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON, "application/x-msdownload","application/vnd.ms-excel", "application/pdf", "text/html" })
|
||||
public Response retrieveReport(
|
||||
@PathParam("reportName") final String reportName,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean exportCsv = ApiParameterHelper.exportCsv(uriInfo.getQueryParameters());
|
||||
boolean parameterType = ApiParameterHelper.parameterType(uriInfo.getQueryParameters());
|
||||
|
||||
String parameterTypeValue = null;
|
||||
if (!parameterType) {
|
||||
parameterTypeValue = "report";
|
||||
if (this.readExtraDataAndReportingService.getReportType(reportName).equalsIgnoreCase("Pentaho")) {
|
||||
Map<String, String> reportParams = getReportParams(queryParams, true);
|
||||
return this.readExtraDataAndReportingService.processPentahoRequest(reportName, queryParams.getFirst("output-type"), reportParams);
|
||||
}
|
||||
} else {
|
||||
parameterTypeValue = "parameter";
|
||||
}
|
||||
|
||||
if (!exportCsv) {
|
||||
|
||||
Map<String, String> reportParams = getReportParams(queryParams, false);
|
||||
|
||||
GenericResultsetData result = this.readExtraDataAndReportingService.retrieveGenericResultset(reportName, parameterTypeValue, reportParams);
|
||||
|
||||
final String json = this.apiDataConversionService.convertGenericResultsetDataToJson(prettyPrint, result);
|
||||
|
||||
return Response.ok().entity(json).type(MediaType.APPLICATION_JSON).build();
|
||||
}
|
||||
|
||||
// CSV Export
|
||||
Map<String, String> reportParams = getReportParams(queryParams, false);
|
||||
StreamingOutput result = this.readExtraDataAndReportingService.retrieveReportCSV(reportName, parameterTypeValue, reportParams);
|
||||
|
||||
return Response
|
||||
.ok()
|
||||
.entity(result)
|
||||
.type("application/x-msdownload")
|
||||
.header("Content-Disposition",
|
||||
"attachment;filename=" + reportName.replaceAll(" ", "")
|
||||
+ ".csv").build();
|
||||
}
|
||||
|
||||
private Map<String, String> getReportParams(final MultivaluedMap<String, String> queryParams, final Boolean isPentaho) {
|
||||
|
||||
Map<String, String> reportParams = new HashMap<String, String>();
|
||||
Set<String> keys = queryParams.keySet();
|
||||
String pKey;
|
||||
String pValue;
|
||||
for (String k : keys) {
|
||||
|
||||
if (k.startsWith("R_")) {
|
||||
if (isPentaho) pKey = k.substring(2);
|
||||
else pKey = "${" + k.substring(2) + "}";
|
||||
|
||||
pValue = queryParams.get(k).get(0);
|
||||
reportParams.put(pKey, pValue);
|
||||
}
|
||||
}
|
||||
return reportParams;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user