212 Commits

Author SHA1 Message Date
b993700ae4 Merge pull request 'feature/employee_login_defaults' (#124) from feature/employee_login_defaults into master
Reviewed-on: #124
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 19:00:36 +02:00
5d506a1526 Merge pull request 'Fix display order in various locations. closes #120' (#121) from feateure/display_order_intern into master
Reviewed-on: #121
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 18:59:14 +02:00
e87d0d8cdd Merge pull request 'feature/optimize_create_order_whbookings' (#117) from feature/optimize_create_order_whbookings into master
Reviewed-on: #117
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 18:57:45 +02:00
fb222c9213 Merge branch 'master' into feature/employee_login_defaults 2020-06-24 18:57:05 +02:00
cf9ab66e68 Hide /intern/ link if non employee. closes #76 2020-06-24 18:40:57 +02:00
cdc372d574 Redirect to intern if employee. 2020-06-24 18:40:22 +02:00
2290f01a8f Merge pull request 'feature/fix_delivery_api' (#116) from feature/fix_delivery_api into master
Reviewed-on: #116
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 18:38:03 +02:00
3bc0996c73 Merge pull request 'Add & generate tracking information to (Supplier-)OrderConfirmation. Fixes #110' (#114) from feature/supplier_tracking into master
Reviewed-on: #114
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 18:37:15 +02:00
758c6810ab Merge pull request 'Clean Shopping Cart on Logout' (#123) from feature/clean_shopping_on_logout into master
Reviewed-on: #123
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 18:27:24 +02:00
577a4f72f0 Clean Shopping Cart on Logout for real 2020-06-24 18:25:42 +02:00
a2aca7a8ca Clean Shopping Cart on Logout 2020-06-24 18:23:01 +02:00
3b7317a831 Fix typo 7 2020-06-24 18:19:14 +02:00
32921a3f87 Merge pull request 'Remove WarehouseBookingReason it was not used.' (#115) from feature/remove_unused_warehouse_booking_reason into master
Reviewed-on: #115
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 15:03:47 +02:00
63e9bc2336 Merge pull request 'Fix in stock calculation. closes #118' (#119) from feature/display_article_shop_in_stock into master
Reviewed-on: #119
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 15:03:04 +02:00
31bff55a20 Merge pull request 'Show advertisements distinct.' (#122) from feature/show_ads_distinct into master
Reviewed-on: #122
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-24 14:59:50 +02:00
5861b61565 Merge branch 'master' into feature/supplier_tracking 2020-06-24 10:44:38 +02:00
f0c9823e45 Clearify Inventory view with text. 2020-06-24 09:53:19 +02:00
6fbb16fea2 Show advertisements distinct. 2020-06-24 02:20:24 +02:00
0d547c8903 Fix display order in various locations. closes #120 2020-06-24 02:15:31 +02:00
5162e3fc19 Fix in stock calculation. closes #118 2020-06-24 02:05:25 +02:00
8bfe8b37f5 Maybe Fix warehouse booking repo 2020-06-24 02:00:37 +02:00
2e07d03908 Fix warehouse bookings on CreateOrderAction 2020-06-24 01:48:33 +02:00
b9e87f5bd4 Add additional infos for order history in /user/... fixes #109 2020-06-24 01:19:37 +02:00
cd641d6cc4 Fix #113 by fixing initialization of RestServiceForDelivery. 2020-06-24 01:18:16 +02:00
4e9f7800be Remove WarehouseBookingReason it was not used. 2020-06-24 00:42:55 +02:00
8d27c486d5 Add & generate tracking information to (Supplier-)OrderConfirmation. Fixes #110 2020-06-24 00:37:58 +02:00
714ac4f1de Fix issues with class loading in Cronjobs 2020-06-24 00:35:18 +02:00
186db31b17 Merge pull request 'Fix showing CustomerOrder all CustomerOrders in my orders. fix displaying orders in random order' (#108) from feature/fix_show_orders into master
reviewed by Lukas
2020-06-21 22:22:53 +02:00
fb53c68be3 Merge pull request 'implement Config for Supplier and Delivery Service' (#107) from feature/reading_config into master
reviewed by Lukas
2020-06-21 22:22:43 +02:00
19cf6ccfc5 Merge pull request 'Implement Supplier AutoSupplierPayment. closes #100' (#105) from feature/supplier_auto_payment into master 2020-06-21 22:13:41 +02:00
7fafd14715 Fix variable name 2020-06-21 19:01:25 +02:00
d5181f149a Fix showing CustomerOrder all CustomerOrders in my orders. fix displaying orders in random order 2020-06-21 18:58:15 +02:00
a950ecb2b9 Make delivery/gradlew executable 2020-06-21 18:42:33 +02:00
f42a50d24d fix CustomerOrder find by order 2020-06-21 18:32:04 +02:00
33118ddb2f Mark lost delivery as delivered. #spaghetticode 2020-06-21 18:25:33 +02:00
a6a2adc7db implement Config for Supplier and Delivery Service 2020-06-21 16:49:35 +02:00
62df2346c3 fix template crashing when defaultAddr == null 2020-06-21 16:28:00 +02:00
c1a0ecdcf3 fix delivery server crashing when tracking id not found 2020-06-21 16:13:48 +02:00
a1abbf5329 Implement Supplier AutoSupplierPayment. closes #100 2020-06-21 15:50:27 +02:00
deaf283a98 remove db blob 2020-06-21 01:08:58 +02:00
ffe9af0633 Prevent duplicate Articles from ArticleOffer 2020-06-21 01:07:04 +02:00
2989b54593 Merge pull request 'fix_change_user_name' (#104) from fix_change_user_name into master 2020-06-21 00:15:57 +02:00
b846b919b7 code clean up 2020-06-21 00:14:00 +02:00
1f83a82f17 removed user.name and use user.defaultDeliveryAddress.name instead 2020-06-21 00:13:10 +02:00
cd1a8568e6 show only one entry per article suggestions fix #96 2020-06-21 00:06:15 +02:00
53cdb20091 Merge pull request 'Fix the warehouse diagrams on the dashboard' (#103) from fix/dashboard_warehouse_statistics into master 2020-06-21 00:02:50 +02:00
9389675b5c Do not show dupliactes in category search. fixes #85 2020-06-21 00:01:28 +02:00
97a7f3a8ad Fix the warehouse diagrams on the dashboard
- Show the correct utilization
- Display values as correct percentages

Closes #99
2020-06-20 23:54:33 +02:00
aa2f42a10a Add password restrictions fixes #91 2020-06-20 23:47:53 +02:00
f128a8b9ed Make reason for manuel booking required. fixes #90 2020-06-20 23:35:56 +02:00
ffea25c082 Merge pull request 'Fix bad query for article slot sum' (#102) from feature/89_fix_lagerstand into master 2020-06-20 23:30:12 +02:00
d77b8c046a Fix bad query for article slot sum 2020-06-20 23:24:06 +02:00
8fdfe9cc69 Catch failing delivery server 2020-06-20 22:51:18 +02:00
e5332a3348 Fix String -> UUIDs -> String in method causing crash 2020-06-20 22:25:52 +02:00
c3eaf5ac11 Remove unused db fields 2020-06-20 22:10:53 +02:00
fa75beb9c4 Fix 6284a4d7bf altering template 2020-06-20 22:09:25 +02:00
4bef17dc0a Merge pull request 'feature/dashboard' (#83) from feature/dashboard into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-19 14:12:44 +02:00
79e4986880 delete blank line 2020-06-19 14:11:32 +02:00
181a09e16b Merge pull request 'feature/config' (#78) from feature/config into master
Reviewed-by: CodeSteak <codesteak@shellf.art>
2020-06-18 14:09:46 +02:00
f4aae9c581 ignore config.yml 2020-06-18 14:07:59 +02:00
ea0c8c45d6 rename eCommerce_config.yml to config.yml
* if no config file is present, create a default config file
2020-06-18 14:04:54 +02:00
8416783e0a merged 2020-06-18 01:13:03 +02:00
bcbebe8e8d master merged into feature/customer_orders 2020-06-18 01:11:11 +02:00
a570696795 feature/customer_orders merged into master 2020-06-18 01:07:11 +02:00
187656814e String Error -> Enum ErrorHandling Logic removed from model class 2020-06-18 00:50:43 +02:00
8c0652b26b exit if the settings file has not been found
* use a final variable for the settings file name
2020-06-17 22:32:48 +02:00
ef07447abc fix json-file 2020-06-17 20:42:08 +02:00
bb7b35dc28 Increase the amount of commits 2020-06-17 19:00:49 +02:00
93cfbb4a27 Merge remote-tracking branch 'origin/master' 2020-06-17 18:59:10 +02:00
68cc35cec3 Fix typo 6 2020-06-17 18:57:42 +02:00
b2ee048f25 Fix typo 5 2020-06-17 18:57:23 +02:00
020a30474e Fix typo 4 2020-06-17 18:56:32 +02:00
4bfc8a2cc6 Fix typo 3 2020-06-17 18:56:02 +02:00
0ff873baaa Fix typo 2 2020-06-17 18:55:50 +02:00
1812c89994 Fix typo 2020-06-17 18:55:29 +02:00
2442a477c8 add missing "|" 2020-06-17 18:43:06 +02:00
ebb3c8c235 removes unused Imports and fomattet 2020-06-17 17:23:29 +02:00
e6c068e71a Secretly fix number 0 showing on 'Warenkorb' 2020-06-17 00:23:05 +02:00
86e3ced19b Secretly fix searchbar not showing term when searching 2020-06-17 00:17:50 +02:00
44df9e4b4f Secretly add Favicon 2020-06-17 00:11:55 +02:00
18cbfbf148 Fix template strings with a starting "/" 2020-06-17 00:02:46 +02:00
e037b75f7c Merge pull request 'fix creditcard num not being set leading to crash' (#82) from feature/80_fix_creditcardnum_null_usersettings into master 2020-06-16 23:51:25 +02:00
486f237135 fix creditcard num not being set leading to crash 2020-06-16 23:50:10 +02:00
396d3fda14 Merge pull request 'Fix not creating directory when uploading file' (#80) from feature/fix_uploading_images into master 2020-06-16 23:40:12 +02:00
3b1d378968 Fix not creating directory when uploading file 2020-06-16 23:38:35 +02:00
5a0b303601 Merge branch 'master' into feature/config 2020-06-16 20:44:10 +02:00
d5825ba7a0 use @Autowired to get AppSettings Object 2020-06-16 20:42:40 +02:00
8199bd8a23 Merge pull request 'Allow employees to trigger cronjobs manually' (#74) from feature/manual_cronjobs into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-16 19:29:38 +02:00
774e62f892 add suppliers to YAMLData, store data in AppSettings() 2020-06-16 19:19:58 +02:00
e1c00eca8f fix ApplicationSettings.readConfig() 2020-06-16 18:52:33 +02:00
e904eba7a4 Merge remote-tracking branch 'origin/feature/manual_cronjobs' into feature/dashboard
Butfixes
2020-06-15 21:41:54 +02:00
6284a4d7bf Dashboard working 2020-06-15 17:47:55 +02:00
3b364ae815 Allow employees to trigger cronjobs manually 2020-06-15 16:23:42 +02:00
2ba4968556 Merge pull request 'feature/create_admin' (#73) from feature/create_admin into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-15 11:18:59 +02:00
18f35c43e7 remove spaces 2020-06-15 10:46:04 +02:00
709c80fa37 add fist admin user after start 2020-06-15 10:43:16 +02:00
87bade71b4 Dateien hochladen nach „supplier/config“ 2020-06-15 10:20:40 +02:00
b6eb66e348 Dateien hochladen nach „supplier/config“ 2020-06-15 10:19:16 +02:00
0a7722d612 removed register user type and ad 2020-06-15 09:40:32 +02:00
d121532fba Merge remote-tracking branch 'origin/master' into feature/config 2020-06-14 21:15:37 +02:00
985169117d fix nullpointer in settings 2020-06-14 18:19:59 +02:00
fa610cae3b if no orders show hint 2020-06-14 17:56:09 +02:00
3bb3c5b513 [HOTFIX] of HOTFIX: Use CanonicalPath for check 2020-06-14 16:51:59 +02:00
15616e05f3 [HOTFIX] Prevent path directory traversal attack for deploy 2020-06-14 15:54:56 +02:00
0ab185f143 impl trackingID for the UserController 2020-06-13 21:59:18 +02:00
1dd4b5cfa5 del update query and impl error for trackigID 2020-06-13 20:05:22 +02:00
266bba095a merged feature/customer_orders with master 2020-06-13 19:58:30 +02:00
fa7bdf2f7e impl error handling 2020-06-13 19:37:34 +02:00
76550be9e7 Merge pull request 'Allow partial discount on supplier orders' (#68) from fix/discount_calculation_in_supplier_service into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-13 12:21:26 +02:00
ef8aa826a3 Merge pull request 'Fix the cash booking sum on customer order' (#67) from fix/wrong_bookings_on_customer_order into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-13 12:19:18 +02:00
114453b5b9 Merge pull request 'Implement Arrival of Supplier Order.' (#62) from feature/supplier_order_arrived_button into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-13 11:59:17 +02:00
7397698929 fix check for missing article 2020-06-13 11:54:25 +02:00
9fa2c1f3a7 Allow partial discount on supplier orders
Closes #46
2020-06-13 11:46:16 +02:00
327ba182f5 Fix the cash booking sum on customer order
Closes #57
2020-06-13 11:10:20 +02:00
30226c5c19 Merge pull request 'fixes_ui' (#66) from fixes_ui into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-13 11:03:20 +02:00
e0e853a575 fixes from PR review 2020-06-13 10:41:59 +02:00
d2b98f083b Merge pull request 'fix missing cells in TODO-Warehouse. fixes #63' (#64) from feature/63_fix_todo_ui into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-13 10:26:36 +02:00
a41889b2cb login in extern loginController, RequestController cleanup, login right after register 2020-06-12 23:48:28 +02:00
0f7d248d40 add radio BTNs to register 2020-06-12 23:31:57 +02:00
11ade7b8f9 fix missing cells in TODO-Warehouse. fixes #63 2020-06-12 19:57:50 +02:00
a664b42853 Allow reuse of empty warehouse slots. Also fixes #59 2020-06-12 19:48:21 +02:00
56f4ec0dda Implement Arrival of Supplier Order. 2020-06-12 19:22:36 +02:00
1590821f64 delete bonuspoints and notifications html 2020-06-12 11:15:05 +02:00
16803d2b12 Merge pull request 'feature/customers' (#58) from feature/customers into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-12 00:52:53 +02:00
938d16301d fix stuff 2020-06-10 20:10:12 +02:00
5a59ac11b0 code cleanup 2020-06-10 19:28:12 +02:00
c194f44308 implement customers detail bookings 2020-06-10 19:28:12 +02:00
fc68e231d3 Allow the user to create manual bookings 2020-06-10 19:28:07 +02:00
6d8a36b7ac implement customers detail part 2 2020-06-10 19:27:38 +02:00
49e26039a3 implement customers detail part 1 2020-06-10 19:27:38 +02:00
28834431ce Display financial bookings in the ui 2020-06-10 19:27:38 +02:00
5691f0eeec implement customers index 2020-06-10 19:27:16 +02:00
7f643987f3 fix wrong closing tags in customerOrder/id.html 2020-06-10 19:12:34 +02:00
6b8bf25e0e Merge pull request 'feature/cash_bookings' (#55) from feature/cash_bookings into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-10 19:04:45 +02:00
ebeba72278 impl tracking ID 2020-06-10 17:03:59 +02:00
f671baf7f0 Error with package path 2020-06-10 14:51:12 +02:00
691916894f Apply some changes according to comments on the pullrequest 2020-06-10 11:48:38 +02:00
e7e2017825 Merge pull request 'Show a hyphen in supplier column if an article is not offered by anyone' (#56) from fix/null_pointer_deref_in_SupplierOfferController into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-09 14:06:51 +02:00
03d557d67b Show a hyphen in supplier column if an article is not offered by anyone
Closes #54
2020-06-08 18:56:35 +02:00
8fff0e2dca Merge remote-tracking branch 'origin/master' into feature/cash_bookings 2020-06-08 18:15:34 +02:00
6317780dfa Merge pull request 'Implement Warehouse....' (#47) from feature/intern_warehouse into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-08 13:40:10 +02:00
78a7ad053a Merge branch 'master' into feature/intern_warehouse 2020-06-08 09:22:06 +02:00
f6554629d7 Merge branch 'master' into feature/intern_warehouse 2020-06-08 09:14:50 +02:00
eb82d05f4f Use Spring model for template attributes 2020-06-08 09:14:11 +02:00
41320473d9 Merge pull request 'feature/supplier_page' (#52) from feature/supplier_page into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-07 15:00:56 +02:00
bd6be54149 removed space in SupplierOrderRepo 2020-06-07 11:45:53 +02:00
99612165f5 fixed review requests 2020-06-07 11:44:50 +02:00
9dff6adb3d rebase to master 2020-06-05 21:25:38 +02:00
445b504188 code cleanup 2020-06-05 21:20:54 +02:00
bd8b3db7f3 added post form for marking order as delivered 2020-06-05 21:18:04 +02:00
8a4ff4cfa5 added supplier bookings table 2020-06-05 21:18:04 +02:00
2245309198 added supplier balance label 2020-06-05 21:18:04 +02:00
d078c44027 finished supplier orders 2020-06-05 21:18:04 +02:00
bd8b07990b finished show orders based on supplier 2020-06-05 21:18:04 +02:00
2f4c45ed71 show orders based on supplier 2020-06-05 21:18:04 +02:00
b600040bf3 basic detail page for supplier 2020-06-05 21:18:04 +02:00
4f5e1fe185 list suppliers page 2020-06-05 21:18:04 +02:00
f348d33c94 Show the balances of the main and vat account in the dashboard 2020-06-05 19:17:44 +02:00
6f90b9c941 Fix a bug where bookings were invisible if they affected only one account 2020-06-05 18:58:16 +02:00
e53c1e0872 Allow the user to create manual bookings 2020-06-05 18:45:25 +02:00
e138476d76 code cleanup 2020-06-05 18:05:10 +02:00
c1b9588189 added post form for marking order as delivered 2020-06-05 17:37:19 +02:00
5e05100d21 added supplier bookings table 2020-06-05 15:43:46 +02:00
93a5863fbe added supplier balance label 2020-06-05 13:10:16 +02:00
7f652e38f0 fix nullpointer in category search 2020-06-05 12:32:34 +02:00
0061d25082 Display financial bookings in the ui 2020-06-05 07:49:11 +02:00
d4ddd8a9a3 Merge pull request 'feature/user' (#38) from feature/user into master
Reviewed-by: Jannik Seiler <seil0@mosad.xyz>
2020-06-03 18:36:06 +02:00
a192f0ac51 Set Tracing Id in Warehouse/finish not in Checkout. This was wrong. 2020-06-03 16:55:36 +02:00
9660e52f34 Merge pull request 'feature/31_js_magic_article_edit' (#50) from feature/31_js_magic_article_edit into master 2020-06-02 07:47:28 +02:00
fc239983a7 Fix article links. 2020-06-01 21:15:27 +02:00
5e1170839e Update Gross Price in Article Edit View. Fixes #31 2020-06-01 21:11:15 +02:00
f4ba79a4cd add id's to form inputs 2020-06-01 20:27:19 +02:00
976e2d1949 Implement Warehouse....
Sry, only one commit. No time to make history ;D
2020-06-01 20:25:51 +02:00
b7134a60da rename CustomerOrderRepo in Cronjob 2020-06-01 20:25:31 +02:00
ff4c984f54 fix error message 2020-06-01 20:24:45 +02:00
21502a0b1c Merge branch 'master' into feature/user 2020-06-01 19:03:42 +02:00
3775f96f3f implement getCustomerOrderDetail 2020-06-01 11:53:29 +02:00
2394157be8 implement getCustomerOrder 2020-06-01 11:31:12 +02:00
dfa528484c Merge branch 'master' into feature/user 2020-06-01 10:57:55 +02:00
1cb52a20d4 finished supplier orders 2020-05-30 23:32:01 +02:00
67c101ebea finished show orders based on supplier 2020-05-30 21:13:25 +02:00
657d315850 show orders based on supplier 2020-05-30 20:16:27 +02:00
5d7ecbdfb7 basic detail page for supplier 2020-05-30 16:43:07 +02:00
c8d3ab3ff0 list suppliers page 2020-05-30 16:16:14 +02:00
8a2eff1fe9 code cleanup 2020-05-27 19:03:18 +02:00
e4d6642d61 order orders by newest first 2020-05-27 15:52:51 +02:00
9406bbc4ac fix nullpointer again 2020-05-27 15:10:12 +02:00
e5b28250c2 fix payment method null pointer 2020-05-27 14:56:15 +02:00
db1d3d31b2 fix register 2020-05-27 14:55:51 +02:00
819cca7f2a Merge remote-tracking branch 'origin/feature/user' into feature/user 2020-05-27 13:41:04 +02:00
846e448f01 code cleanup 2020-05-27 13:40:44 +02:00
614a929592 code cleanup 2020-05-27 13:40:44 +02:00
60699ed847 fix error handling 2020-05-27 13:40:44 +02:00
83ad1f3999 remove advertisementflag 2020-05-27 13:40:44 +02:00
5b4c0be1c8 add Errorhandling to UpdateSettingsAction 2020-05-27 13:40:44 +02:00
0256c19e8f implement change User Settings 2020-05-27 13:40:44 +02:00
adcd840154 remove notification center 2020-05-27 13:40:44 +02:00
b5495bda3d show all Orders 2020-05-27 13:40:44 +02:00
106b00a907 show usersettings from db 2020-05-27 13:40:44 +02:00
7c73f69865 remove bonuspoints 2020-05-27 13:40:44 +02:00
86a2e5d8c2 code cleanup 2020-05-25 12:17:09 +02:00
8d65998ac2 code cleanup 2020-05-25 10:21:36 +02:00
178f98d664 fix error handling 2020-05-25 10:10:42 +02:00
33ff754b9d remove advertisementflag 2020-05-25 09:36:40 +02:00
8ede86fdce add Errorhandling to UpdateSettingsAction 2020-05-20 12:08:57 +02:00
39eefbdd3e implement change User Settings 2020-05-19 15:18:48 +02:00
6e3d1cbcf5 remove notification center 2020-05-19 14:17:38 +02:00
1ce9a971ba show all Orders 2020-05-19 11:52:41 +02:00
4711527971 show usersettings from db 2020-05-18 14:41:33 +02:00
b7b5c7a6b3 remove bonuspoints 2020-05-18 12:49:37 +02:00
bba4173269 fixed inputstream once more 2020-05-10 22:19:58 +02:00
e1d7becc2e added yaml dump&parse class 2020-05-10 21:23:44 +02:00
125 changed files with 4716 additions and 2023 deletions

0
delivery/gradlew vendored Normal file → Executable file
View File

View File

@ -4,9 +4,9 @@ package org.hso.ecommerce.supplier;
import org.hso.ecommerce.supplier.data.Delivery;
import org.hso.ecommerce.supplier.data.DeliveryManager;
import org.hso.ecommerce.supplier.data.ReturnStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -19,13 +19,18 @@ public class RequestController {
public String supplier(HttpServletResponse response, HttpServletRequest request, @RequestBody Delivery delivery) {
DeliveryManager.getInstance().add(delivery);
return delivery.getUuid().toString();
return delivery.getUuid();
}
@GetMapping("/status")
@GetMapping(value = "/status", produces = MediaType.APPLICATION_JSON_VALUE)
public ReturnStatus searchArticles(@RequestParam(value = "trackingID") String trackingID, HttpServletRequest request, HttpServletResponse response) {
Delivery delivery = DeliveryManager.getInstance().getDeliveryByeID(trackingID);
Delivery delivery = DeliveryManager.getInstance().getDeliveryByID(trackingID);
if (delivery == null) {
Delivery lostDelivery = Delivery.lostDelivery(trackingID);
DeliveryManager.getInstance().add(lostDelivery);
delivery = lostDelivery;
}
return new ReturnStatus(delivery.getStatus(), delivery.getEstimatedArrival());
}

View File

@ -13,28 +13,38 @@ public class Delivery {
private String name;
private String address;
private String estimatedArrival;
private Date creationTime;
private UUID uuid;
public Delivery(String name, String address)
{
// Why is this a string and creationTime a Date?!
private String estimatedArrival;
private Date creationTime;
private String uuid;
public Delivery(String name, String address) {
this.name = name;
this.address = address;
this.uuid = UUID.randomUUID();
this.uuid = UUID.randomUUID().toString();
this.creationTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
this.estimatedArrival = formatter.format(addDays((Date) this.creationTime.clone(), 1));
}
public static Delivery lostDelivery(String uuid) {
Delivery delivery = new Delivery("", "");
delivery.uuid = uuid;
delivery.creationTime = addDays(new Date(), -1);
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
delivery.estimatedArrival = formatter.format(addDays((Date) delivery.creationTime.clone(), 1));
return delivery;
}
public String getStatus()
{
public String getStatus() {
Date now = new Date();
Long timeNow = now.getTime();
Long creationTime = this.creationTime.getTime();
long timeNow = now.getTime();
long creationTime = this.creationTime.getTime();
Long diff = timeNow - creationTime;
// Wow, that's how calculate date diffs.
long diff = timeNow - creationTime;
double hour = (((diff / 1000.0) / 3600.0));
for (int i = 0; i < timeBorder.length; i++) {
@ -51,15 +61,14 @@ public class Delivery {
return estimatedArrival;
}
private Date addDays(Date date, int days)
{
private static Date addDays(Date date, int days) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, days);
return cal.getTime();
}
public UUID getUuid() {
public String getUuid() {
return uuid;
}

View File

@ -1,17 +1,15 @@
package org.hso.ecommerce.supplier.data;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.HashMap;
public class DeliveryManager {
private List<Delivery> deliveryList;
private HashMap<String, Delivery> deliveryList;
private static DeliveryManager deliveryManager;
private DeliveryManager()
{
deliveryList = new ArrayList<>();
deliveryList = new HashMap<>();
}
public static DeliveryManager getInstance() {
@ -22,13 +20,11 @@ public class DeliveryManager {
return DeliveryManager.deliveryManager;
}
public boolean add(Delivery delivery)
{
return deliveryList.add(delivery);
public void add(Delivery delivery) {
deliveryList.put(delivery.getUuid(), delivery);
}
public Delivery getDeliveryByeID(String uuid)
{
return deliveryList.parallelStream().filter(d -> d.getUuid().equals(UUID.fromString(uuid))).findAny().get();
public Delivery getDeliveryByID(String uuid) {
return deliveryList.getOrDefault(uuid, null);
}
}

View File

@ -5,3 +5,5 @@ e-commerce.db
./e-commerce.iml
./e-commerce.ipr
./e-commerce.iws
config.yml

View File

@ -28,6 +28,7 @@ dependencies {
implementation 'com.github.gwenn:sqlite-dialect:0.1.0'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation 'org.xerial:sqlite-jdbc:3.31.1'
implementation 'org.yaml:snakeyaml:1.26'
testCompile("org.springframework.boot:spring-boot-starter-test")
}

0
prototype/gradlew vendored Normal file → Executable file
View File

View File

@ -0,0 +1,3 @@
INSERT INTO supplier_orders ("created", "delivered", "number_of_units", "price_per_unit_net_cent", "total_price_net", "ordered_id", "supplier_id")
VALUES ('0', '0', '42', '42', '42', '1', '1');

View File

@ -10,6 +10,7 @@ public class CreateBookingAction {
public CreateBookingAction(BookingAccountEntry source, BookingAccountEntry destination, BookingReason reason, int amountCent) {
booking = new Booking();
booking.created = new java.sql.Timestamp(System.currentTimeMillis());
booking.reason = reason;
booking.amountCent = amountCent;

View File

@ -1,8 +1,5 @@
package org.hso.ecommerce.action.cronjob;
import java.sql.Timestamp;
import java.util.HashMap;
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.ArticleIdentifier;
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.Offer;
import org.hso.ecommerce.api.SupplierService;
@ -14,6 +11,9 @@ import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Timestamp;
import java.util.HashMap;
public class ReorderAction {
private static final Logger log = LoggerFactory.getLogger(ReorderAction.class);
@ -102,6 +102,10 @@ public class ReorderAction {
createdOrder.numberOfUnits = confirm.quantity;
createdOrder.pricePerUnitNetCent = confirm.pricePerUnitNetCent;
createdOrder.totalPriceNet = confirm.totalPriceNetCharged;
createdOrder.carrier = confirm.carrier;
createdOrder.trackingId = confirm.trackingId;
createdOrder.estimatedArrival = Timestamp.valueOf(confirm.estimatedArrival);
return createdOrder;
}
}

View File

@ -13,6 +13,7 @@ import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@ -74,9 +75,15 @@ public class CreateOrderAction {
CustomerPayment payment = createPayment();
List<Booking> bookingList = new ArrayList<>();
bookingList.add(new CreateBookingAction(latestUserBooking, latestMainBooking, new BookingReason(order), order.totalGrossCent).finish());
bookingList.add(new CreateBookingAction(null, latestUserBooking, new BookingReason(payment), order.totalGrossCent).finish());
bookingList.add(new CreateBookingAction(latestMainBooking, latestVatBooking, new BookingReason(order), order.totalVatCent).finish());
Booking purchaseBooking = new CreateBookingAction(
latestUserBooking, latestMainBooking, new BookingReason(order), order.totalGrossCent).finish();
Booking paymentBooking = new CreateBookingAction(
null, purchaseBooking.source /* userAccount */, new BookingReason(payment), order.totalGrossCent).finish();
Booking vatBooking = new CreateBookingAction(
purchaseBooking.destination /* mainAccount */, latestVatBooking, new BookingReason(order), order.totalVatCent).finish();
bookingList.add(purchaseBooking);
bookingList.add(paymentBooking);
bookingList.add(vatBooking);
WarehouseBooking warehouseBooking = createWarehouseBooking(order);
@ -95,7 +102,14 @@ public class CreateOrderAction {
for (OrderItem item : orderItems) {
int needed = item.quantity;
// Sort for most empty slot first;
item.availableSlots.sort(Comparator.comparingInt(a -> a.newSumSlot));
for (WarehouseBookingPositionSlotEntry slot : item.availableSlots) {
if (slot.newSumSlot == 0) {
continue;
}
int remove = Math.min(slot.newSumSlot, needed);
needed -= remove;
@ -103,7 +117,7 @@ public class CreateOrderAction {
bookingPosition.article = item.article;
bookingPosition.amount = -remove;
bookingPosition.slotEntry = slot.copyAddAmount(-remove);
bookingPosition.slotEntry = slot.copyAddAmount(-remove, item.article);
bookingPosition.booking = booking;
booking.positions.add(bookingPosition);

View File

@ -1,11 +1,16 @@
package org.hso.ecommerce.action.shop;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.springframework.web.client.ResourceAccessException;
import java.sql.Timestamp;
import java.util.Date;
public class EnableTrackingAction {
public static void addTrackingInfo(CustomerOrder customerOrder) {
// TODO:
customerOrder.trackingId = "555-NASE";
public static void addTrackingInfo(RestServiceForDelivery deliveryService, CustomerOrder customerOrder) throws ResourceAccessException {
customerOrder.inDeliverySince = new Timestamp(new Date().getTime());
customerOrder.trackingId = deliveryService.getDeliveryID(customerOrder);
}
}

View File

@ -0,0 +1,48 @@
package org.hso.ecommerce.action.user;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.uimodel.DeliveryData;
import org.hso.ecommerce.uimodel.DeliveryDataEnum;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class CreateDeliveryData {
public static DeliveryData getDeliveryDataFromCustomerOrder(CustomerOrder customerOrder, CustomerOrderRepository customerOrderRepository, RestServiceForDelivery restServiceForDelivery)
{
if(customerOrder.trackingId == null)
return new DeliveryData("", "", DeliveryDataEnum.NO_TRACKING_ID);
if(customerOrder.deliveredAt == null)
{
DeliveryData deliveryData = restServiceForDelivery.getDeliveryData(customerOrder.trackingId);
if(deliveryData.isDelivered())
{
Calendar calendar = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
try {
calendar.setTime(simpleDateFormat.parse(deliveryData.getEstimatedArrival()));
} catch (ParseException e) {
e.printStackTrace();
}
customerOrder.deliveredAt = new Timestamp(calendar.getTimeInMillis());
customerOrderRepository.save(customerOrder);
}
return deliveryData;
}
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
return new DeliveryData("Lieferung erfolgreich", formatter.format(customerOrder.deliveredAt), DeliveryDataEnum.OK);
}
}

View File

@ -0,0 +1,83 @@
package org.hso.ecommerce.action.user;
import org.hso.ecommerce.entities.booking.PaymentMethod;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository;
public class UpdateUserSettingsAction {
private User user;
private UserRepository repository;
public UpdateUserSettingsAction(User user, UserRepository repository) {
this.user = user;
this.repository = repository;
}
public UpdateResult updateEmail(String newMail) {
UpdateResult result = new UpdateResult(false);
if (!newMail.contains("@")) {
result.errorString = "Ändern der Email-Addresse nicht möglich. Bitte versuchen Sie es erneut.";
} else {
this.user.email = newMail;
this.repository.save(this.user);
result.updated = true;
}
return result;
}
public UpdateResult updatePassword(String oldPassword, String password1, String password2) {
UpdateResult result = new UpdateResult(false);
if (this.user.validatePassword(oldPassword)) {
if (password1.equals(password2)) {
if (!password1.equals(oldPassword)) {
this.user.setPassword(password1);
this.repository.save(this.user);
result.updated = true;
} else {
result.errorString = "Das neue Passwort entspricht dem alten Passwort.";
}
} else {
result.errorString = "Die beiden neuen Passwörter stimmen nicht überein. Bitte versuchen Sie es erneut.";
}
} else {
result.errorString = "Das eingegebene alte Passwort stimmt nicht mit dem momentan gespeicherten Passwort überein. Bitte versuchen Sie es erneut.";
}
return result;
}
public UpdateResult updateShippingInfo(String salutation, String name, String address) {
this.user.salutation = salutation;
this.user.defaultDeliveryAddress.name = name;
this.user.defaultDeliveryAddress.addressString = address;
this.repository.save(this.user);
return new UpdateResult(true);
}
public UpdateResult updatePaymentInfo(String creditCardNumber) {
UpdateResult result = new UpdateResult(false);
if (creditCardNumber.matches("[0-9]+")) {
this.user.defaultPayment = PaymentMethod.fromCreditCardNumber(creditCardNumber);
this.repository.save(this.user);
result.updated = true;
} else {
result.errorString = "Kreditkartennummer darf nur Zahlen enthalten. Bitte versuchen Sie es erneut.";
}
return result;
}
public class UpdateResult {
public boolean updated; //if true worked, if false not worked
public String errorString;
public UpdateResult(boolean updated, String errorString) {
this.updated = updated;
this.errorString = errorString;
}
public UpdateResult(boolean updated) {
this.updated = updated;
this.errorString = "";
}
}
}

View File

@ -0,0 +1,73 @@
package org.hso.ecommerce.action.warehouse;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import java.util.HashSet;
import java.util.List;
public class CalculateWarehouseStatsAction {
private List<WarehouseBookingPositionSlotEntry> entryList;
public CalculateWarehouseStatsAction(List<WarehouseBookingPositionSlotEntry> everyCurrentEntry) {
this.entryList = everyCurrentEntry;
}
public WarehouseStats finish() {
int numArticles = calculateNumArticles();
double efficiency = calculateEfficiency();
double ratioUsedSlots = calculateRatioSlotsUsed();
return new WarehouseStats(numArticles, efficiency, ratioUsedSlots);
}
private double calculateRatioSlotsUsed() {
int used = 0;
for (WarehouseBookingPositionSlotEntry entry : entryList) {
if (entry.newSumSlot > 0) {
used++;
}
}
return ((double) used) / entryList.size();
}
private double calculateEfficiency() {
double e = 0;
for (WarehouseBookingPositionSlotEntry entry : entryList) {
if (entry.newSumSlot > 0) {
e += entry.newSumSlot / (double) entry.article.warehouseUnitsPerSlot;
} else {
e += 0;
}
}
return e / entryList.size();
}
private int calculateNumArticles() {
HashSet<Long> articleIds = new HashSet<>();
for (WarehouseBookingPositionSlotEntry entry : entryList) {
if (entry.newSumSlot > 0) {
articleIds.add(entry.article.id);
}
}
return articleIds.size();
}
public static class WarehouseStats {
public int numArticles;
public double efficiency;
public double ratioUsedSlots;
WarehouseStats(int numArticles, double efficiency, double ratioUsedSlots) {
this.numArticles = numArticles;
this.efficiency = efficiency;
this.ratioUsedSlots = ratioUsedSlots;
}
}
}

View File

@ -0,0 +1,92 @@
package org.hso.ecommerce.action.warehouse;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.warehouse.WarehouseBooking;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPosition;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Optional;
public class CreateManuelBookingAction {
private Article article;
private int amount;
private Optional<WarehouseBookingPositionSlotEntry> source;
private Optional<WarehouseBookingPositionSlotEntry> destination;
private String reason;
public CreateManuelBookingAction(Article article, int amount, Optional<WarehouseBookingPositionSlotEntry> source, Optional<WarehouseBookingPositionSlotEntry> destination, String reason) {
this.article = article;
this.amount = amount;
this.source = source;
this.destination = destination;
this.reason = reason;
}
public WarehouseBooking finish() throws ArticleSlotConstraintFailedException {
WarehouseBooking booking = new WarehouseBooking();
booking.created = new Timestamp(new Date().getTime());
booking.reason = new BookingReason(reason);
if (source.isPresent()) {
if (source.get().article.id != article.id) {
throw new ArticleSlotConstraintArticleTypeFailedException();
}
WarehouseBookingPosition bookingPosition = new WarehouseBookingPosition();
bookingPosition.booking = booking;
bookingPosition.article = article;
bookingPosition.amount = -amount;
bookingPosition.slotEntry = source.get().copyAddAmount(-amount, article);
if (bookingPosition.slotEntry.newSumSlot < 0 || bookingPosition.slotEntry.newSumSlot > article.warehouseUnitsPerSlot) {
throw new ArticleSlotConstraintFailedException("The quantity of article can only be set in bounds.");
}
booking.positions.add(bookingPosition);
}
if (destination.isPresent()) {
if (destination.get().article.id != article.id && destination.get().newSumSlot > 0) {
throw new ArticleSlotConstraintArticleTypeFailedException();
}
WarehouseBookingPosition bookingPosition = new WarehouseBookingPosition();
bookingPosition.booking = booking;
bookingPosition.article = article;
bookingPosition.amount = amount;
bookingPosition.slotEntry = destination.get().copyAddAmount(amount, article);
if (bookingPosition.slotEntry.newSumSlot < 0 || bookingPosition.slotEntry.newSumSlot > article.warehouseUnitsPerSlot) {
throw new ArticleSlotConstraintFailedException("The quantity of article can only be set in bounds.");
}
booking.positions.add(bookingPosition);
}
return booking;
}
public static class ArticleSlotConstraintFailedException extends Exception {
public ArticleSlotConstraintFailedException(String s) {
super(s);
}
public ArticleSlotConstraintFailedException() {
super("The quantity of article can only be set in bounds.");
}
}
public static class ArticleSlotConstraintArticleTypeFailedException extends ArticleSlotConstraintFailedException {
public ArticleSlotConstraintArticleTypeFailedException() {
super("The Article in the slot entry does not match.");
}
}
}

View File

@ -0,0 +1,103 @@
package org.hso.ecommerce.action.warehouse;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.hso.ecommerce.entities.warehouse.WarehouseBooking;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPosition;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class SupplierOrderArrivedAction {
private final Article article;
private final ArrayList<WarehouseBookingPositionSlotEntry> warehouseCandidates;
private final SupplierOrder order;
public SupplierOrderArrivedAction(List<WarehouseBookingPositionSlotEntry> warehouseCandidates, SupplierOrder order, Article article) {
this.warehouseCandidates = new ArrayList<>(warehouseCandidates);
this.order = order;
this.article = article;
}
public Result finish() throws NoSpaceInWarehouseException {
// Sort for most filled slot first;
warehouseCandidates.sort((b, a) -> Integer.compare(a.newSumSlot, b.newSumSlot));
int needed = order.numberOfUnits;
WarehouseBooking booking = new WarehouseBooking();
booking.created = new Timestamp(new Date().getTime());
booking.reason = new BookingReason(order);
for (WarehouseBookingPositionSlotEntry entry : warehouseCandidates) {
int canBeAdded = article.warehouseUnitsPerSlot - entry.newSumSlot;
if (canBeAdded == 0) {
// this slot is full, skip
continue;
}
int willBeAdded = Math.min(canBeAdded, needed);
needed -= willBeAdded;
WarehouseBookingPosition bookingPosition = new WarehouseBookingPosition();
bookingPosition.article = article;
bookingPosition.amount = willBeAdded;
bookingPosition.slotEntry = entry.copyAddAmount(willBeAdded, article);
bookingPosition.booking = booking;
booking.positions.add(bookingPosition);
if (needed == 0) {
break;
}
}
if (needed > 0) {
throw new NoSpaceInWarehouseException(article);
}
order.delivered = new Timestamp(new Date().getTime());
return new Result(order, booking);
}
public static class Result extends Exception {
private final SupplierOrder order;
private final WarehouseBooking booking;
public Result(SupplierOrder order, WarehouseBooking booking) {
this.order = order;
this.booking = booking;
}
public SupplierOrder getOrder() {
return order;
}
public WarehouseBooking getBooking() {
return booking;
}
}
public static class NoSpaceInWarehouseException extends Exception {
private Article article;
public NoSpaceInWarehouseException(Article article) {
super("The quantity of article '" + article.title + "' does not fit in warehouse.");
this.article = article;
}
public Article getArticle() {
return article;
}
}
}

View File

@ -0,0 +1,83 @@
package org.hso.ecommerce.api;
import org.hso.ecommerce.app.config.AppSettings;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.uimodel.DeliveryData;
import org.hso.ecommerce.uimodel.DeliveryDataEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import java.util.HashMap;
import java.util.Map;
@Service
public class RestServiceForDelivery {
@Autowired
private final RestTemplateBuilder restTemplateBuilder = null;
@Autowired
private final AppSettings settings = null;
private String getDeliveryEndpoint() {
return settings.getParcelServiceApiURL();
}
public String getDeliveryID(CustomerOrder customerOrder) throws ResourceAccessException {
String url = getDeliveryEndpoint() + "/newDelivery";
RestTemplate restTemplate = restTemplateBuilder.build();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Map<String, String> requestBody = new HashMap<>();
requestBody.put("name", customerOrder.destination.name);
requestBody.put("address", customerOrder.destination.addressString);
HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestBody, headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
if (response.getStatusCode() == HttpStatus.OK) {
return response.getBody();
} else {
throw new ResourceAccessException("Http Status wrong");
}
}
public DeliveryData getDeliveryData(String trackingID) {
String url = getDeliveryEndpoint() + "/status";
RestTemplate restTemplate = restTemplateBuilder.build();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url).queryParam("trackingID", trackingID);
HttpEntity<?> entity = new HttpEntity<>(headers);
ResponseEntity<DeliveryData> response;
try {
response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, DeliveryData.class);
if (response.getStatusCode() == HttpStatus.OK) {
return response.getBody();
} else {
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
}
} catch (Exception e) {
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
}
}
}

View File

@ -1,5 +1,7 @@
package org.hso.ecommerce.api.data;
import java.time.LocalDateTime;
public class OrderConfirmation {
public String manufacturer;
public String articleNumber;
@ -9,4 +11,8 @@ public class OrderConfirmation {
public int pricePerUnitNetCent;
public int discountNetCent;
public int totalPriceNetCharged;
public String carrier;
public String trackingId;
public LocalDateTime estimatedArrival;
}

View File

@ -13,6 +13,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

View File

@ -1,186 +0,0 @@
package org.hso.ecommerce.app;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Optional;
/**
* TODO clean up this class
*/
@Controller
public class RequestController {
@Autowired
private final UserRepository userRepository = null;
static int notSoRandom = 0;
@GetMapping("/login")
public String login() {
return "login";
}
@PostMapping("/login")
public String loginPost(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("username") String username,
@RequestParam("password") String password,
HttpSession session
) {
String gto = (String) session.getAttribute("afterLogin");
Optional<User> user = userRepository.findByEmail(username);
if (!user.isPresent()) {
request.setAttribute("error", "Email Adresse falsch.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "login";
}
if (!user.get().validatePassword(password)) {
request.setAttribute("error", "Passwort falsch.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "login";
}
if (!user.get().isActive) {
request.setAttribute("error", "User ist deaktiviert.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "login";
}
session.setAttribute("userId", user.get().getId());
if (gto != null && gto.startsWith("/")) {
return "redirect:" + gto;
} else {
return "redirect:/";
}
}
@PostMapping("/logout")
public String logoutPost(HttpServletResponse response,
HttpSession session
) {
session.removeAttribute("userId");
return "redirect:/";
}
@GetMapping("/intern/")
public String intern() {
return "intern/index";
}
@GetMapping("/intern/customers/")
public String internCustomers() {
return "intern/customers/index";
}
@GetMapping("/intern/customers/{id}")
public String internCustomersId() {
return "intern/customers/id";
}
@GetMapping("/intern/customerOrders/")
public String internCustomerOrder() {
return "intern/customerOrders/index";
}
@GetMapping("/intern/customerOrders/{id}")
public String internCustomerOrdersId() {
return "intern/customerOrders/id";
}
@GetMapping("/intern/suppliers/")
public String internSuppliers() {
return "intern/suppliers/index";
}
@GetMapping("/intern/suppliers/{id}")
public String internSuppliersId() {
return "intern/suppliers/id";
}
@GetMapping("/intern/supplierOrders/")
public String internSupplierOrders() {
return "intern/supplierOrders/index";
}
@GetMapping("/intern/supplierOrders/{id}")
public String internSupplierOrdersId() {
return "intern/supplierOrders/id";
}
/*
@GetMapping("/intern/suppliersOffers")
public String internSuppliersOffers() {
return "intern/offeredArticles/index";
}
*/
@GetMapping("/intern/accounting/")
public String accounting() {
return "intern/accounting/index";
}
@GetMapping("/intern/accounting/vat")
public String accountingVat() {
return "intern/accounting/vat";
}
@GetMapping("/intern/accounting/main")
public String accountingIntern() {
return "intern/accounting/main";
}
@GetMapping("/intern/accounting/addManual")
public String accountingAddManual() {
return "intern/accounting/addManual";
}
@GetMapping("/intern/warehouse/")
public String accountingWarehouse() {
return "intern/warehouse/index";
}
@GetMapping("/intern/warehouse/todo")
public String accountingWarehouseTodo() {
return "intern/warehouse/todo";
}
@GetMapping("/intern/warehouse/addManual")
public String accountingWarehouseAddManual() {
return "intern/warehouse/addManual";
}
@PostMapping("/intern/warehouse/progress/{id}")
public String accountingWarehouseProgressIdPost(HttpServletResponse response) {
if ((notSoRandom++) % 2 == 1) {
return "redirect:/intern/warehouse/progress/450";
} else {
response.setStatus(409);
return "intern/warehouse/error_progress_failed";
}
}
@GetMapping("/intern/warehouse/progress/{id}")
public String accountingWarehouseProgressId() {
return "intern/warehouse/id_progress";
}
@GetMapping("/intern/warehouse/slots/")
public String accountingWarehouseSlots() {
return "intern/warehouse/slots/index";
}
}

View File

@ -1,36 +0,0 @@
package org.hso.ecommerce.app;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("user")
public class UserRequestController {
@GetMapping("/")
public String user() {
return "redirect:/user/settings";
}
@GetMapping("/settings")
public String userSettings() {
return "user/settings";
}
@GetMapping("/orders/")
public String userOrdeers() {
return "user/orders/index";
}
@GetMapping("/bonuspoints")
public String userBonuspoints() {
return "user/bonuspoints";
}
@GetMapping("/notifications/")
public String userNotifications() {
return "user/notifications/index";
}
}

View File

@ -0,0 +1,161 @@
package org.hso.ecommerce.app.config;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import org.hso.ecommerce.app.config.YAMLData.Address;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import javax.annotation.PostConstruct;
@Component("appSettings")
public class AppSettings {
private YAMLData data;
private final String configFile = "config.yml";
private String installationName;
private String companyName;
private Address companyAddress;
private int numberOfStorageSpaces;
private List<YAMLData.Supplier> suppliers;
private String parcelServiceName;
private String parcelServiceApiURL;
/**
* on initialization read the config and store the data in static objects
*/
@PostConstruct
public void init() {
data = readConfig();
installationName = data.getInstallationName();
companyName = data.getCompanyName();
companyAddress = data.getCompanyAddress();
numberOfStorageSpaces = data.getNumberOfStorageSpaces();
suppliers = data.getSuppliers();
parcelServiceName = data.getParcelServiceName();
parcelServiceApiURL = data.getParcelServiceApiURL();
System.out.println("Initialised Settings!");
}
/**
* write the default config file
*/
public void writeDefaultConfig() {
YAMLData data = new YAMLData();
data.setInstallationName("eCommerce");
data.setCompanyName("eCommerce Shop UG");
data.setCompanyAddress(new Address(
"Musterstraße",
"1",
"12345",
"Musterstadt",
"Germany"
));
data.setNumberOfStorageSpaces(128);
List<YAMLData.Supplier> suppliers = new ArrayList<>();
suppliers.add(new YAMLData.Supplier(
"Bank of Chees",
"d41d8cd98f00b204e9800998ecf8427e",
"http://[::1]:8081/bank/",
4,
new Address(
"Musterstraße",
"2",
"12345",
"Musterstadt",
"Germany"
)
));
suppliers.add(new YAMLData.Supplier(
"MDA",
"18a17da5bac1cf00551b08c3e98720f5",
"http://[::1]:8081/mda/",
5,
new Address(
"Musterstraße",
"3",
"12345",
"Musterstadt",
"Germany"
)
));
data.setSuppliers(suppliers);
data.setParcelServiceName("Parcel Service");
data.setParcelServiceApiURL("http://[::1]:8082/");
try (FileWriter writer = new FileWriter("./" + configFile)) {
Yaml yaml = new Yaml();
yaml.dump(data, writer);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* read a config file named "eCommerce_config.yml" from the applications root directory
* @return the settings as YAMLData object
*/
public YAMLData readConfig() {
YAMLData data = new YAMLData();
File file = new File("./" + configFile);
if (!file.exists()) {
writeDefaultConfig();
}
try (InputStream inputStream = new FileInputStream("./" + configFile)) {
Yaml yaml = new Yaml(new Constructor(YAMLData.class));
data = yaml.load(inputStream);
} catch (FileNotFoundException e) {
System.err.println("The file \"" + configFile + "\" has not been found, please create a valid Configuration file.");
e.printStackTrace();
System.exit(1);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
return data;
}
public YAMLData getData() {
return data;
}
public String getInstallationName() {
return installationName;
}
public String getCompanyName() {
return companyName;
}
public Address getCompanyAddress() {
return companyAddress;
}
public int getNumberOfStorageSpaces() {
return numberOfStorageSpaces;
}
public List<YAMLData.Supplier> getSuppliers() {
return suppliers;
}
public String getParcelServiceName() {
return parcelServiceName;
}
public String getParcelServiceApiURL() {
return parcelServiceApiURL;
}
}

View File

@ -0,0 +1,183 @@
package org.hso.ecommerce.app.config;
import java.util.List;
public class YAMLData {
private String installationName;
private String companyName;
private Address companyAddress;
private int numberOfStorageSpaces;
private List<Supplier> suppliers;
private String parcelServiceName;
private String parcelServiceApiURL;
public String getInstallationName() {
return installationName;
}
public void setInstallationName(String installationName) {
this.installationName = installationName;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public Address getCompanyAddress() {
return companyAddress;
}
public void setCompanyAddress(Address companyAddress) {
this.companyAddress = companyAddress;
}
public int getNumberOfStorageSpaces() {
return numberOfStorageSpaces;
}
public void setNumberOfStorageSpaces(int numberOfStorageSpaces) {
this.numberOfStorageSpaces = numberOfStorageSpaces;
}
public List<Supplier> getSuppliers() {
return suppliers;
}
public void setSuppliers(List<Supplier> suppliers) {
this.suppliers = suppliers;
}
public String getParcelServiceName() {
return parcelServiceName;
}
public void setParcelServiceName(String parcelServiceName) {
this.parcelServiceName = parcelServiceName;
}
public String getParcelServiceApiURL() {
return parcelServiceApiURL;
}
public void setParcelServiceApiURL(String parcelServiceApiURL) {
this.parcelServiceApiURL = parcelServiceApiURL;
}
public static class Address {
public String streetName;
public String houseNumber;
public String zipCode;
public String cityName;
public String countryName;
public Address() {
// needed by snakeyaml
}
public Address(String streetName, String houseNumber, String zipCode, String cityName, String countryName) {
this.streetName = streetName;
this.houseNumber = houseNumber;
this.zipCode = zipCode;
this.cityName = cityName;
this.countryName = countryName;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public String getHouseNumber() {
return houseNumber;
}
public void setHouseNumber(String houseNumber) {
this.houseNumber = houseNumber;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
}
public static class Supplier {
public String name;
public String id;
public String apiURL;
public int deliveryTime;
public Address companyAddress;
public Supplier() {
// needed by snakeyaml
}
public Supplier(String name, String id, String apiURL, int deliveryTime, Address companyAddress) {
this.name = name;
this.id = id;
this.apiURL = apiURL;
this.deliveryTime = deliveryTime;
this.companyAddress = companyAddress;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getApiURL() {
return apiURL;
}
public void setApiURL(String apiURL) {
this.apiURL = apiURL;
}
public int getDeliveryTime() {
return deliveryTime;
}
public void setDeliveryTime(int deliveryTime) {
this.deliveryTime = deliveryTime;
}
public Address getCompanyAddress() {
return companyAddress;
}
public void setCompanyAddress(Address companyAddress) {
this.companyAddress = companyAddress;
}
}
}

View File

@ -0,0 +1,38 @@
package org.hso.ecommerce.components;
import org.hso.ecommerce.entities.booking.PaymentMethod;
import org.hso.ecommerce.entities.shop.Address;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.sql.Timestamp;
import java.util.Optional;
@Component
public class AdminInitializer {
@Autowired
private final UserRepository userRepository = null;
@PostConstruct
public void init() {
Optional<Integer> numberOfEmployees = userRepository.numberOfEmployees();
if (numberOfEmployees.orElse(0) == 0) {
// create first admin user
User firstAdmin = new User();
firstAdmin.created = new Timestamp(System.currentTimeMillis());
firstAdmin.defaultDeliveryAddress = new Address();
firstAdmin.defaultDeliveryAddress.name = "admin";
firstAdmin.defaultPayment = new PaymentMethod();
firstAdmin.defaultPayment.creditCardNumber = ""; //set empty number
firstAdmin.email = "admin";
firstAdmin.isActive = true;
firstAdmin.isEmployee = true;
firstAdmin.setPassword("admin");
userRepository.save(firstAdmin); //save to DB
}
}
}

View File

@ -1,5 +1,6 @@
package org.hso.ecommerce.components;
import org.hso.ecommerce.app.config.AppSettings;
import org.hso.ecommerce.entities.warehouse.Slot;
import org.hso.ecommerce.repos.warehouse.SlotRepository;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,11 +14,13 @@ public class SlotInitializer {
@Autowired
private final SlotRepository slotRepository = null;
// TODO: use values form cfg.
private final int NUM_SLOTS = 50;
@Autowired
private final AppSettings appSettings = null;
@PostConstruct
public void init() {
int NUM_SLOTS = appSettings.getNumberOfStorageSpaces();
for (int i = 1; i <= NUM_SLOTS; i++) {
if (!slotRepository.findBySlotNum(i).isPresent()) {
Slot slotAdded = new Slot();

View File

@ -0,0 +1,42 @@
package org.hso.ecommerce.components;
import org.hso.ecommerce.app.config.AppSettings;
import org.hso.ecommerce.app.config.YAMLData;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.repos.supplier.SupplierRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Optional;
@Component
public class SupplierInitializer {
@Autowired
private final SupplierRepository supplierRepository = null;
@Autowired
private final AppSettings appSettings = null;
@PostConstruct
public void init() {
for (YAMLData.Supplier cfg : appSettings.getSuppliers()) {
Optional<Supplier> sup = supplierRepository.findByUuid(cfg.id);
Supplier supplier;
if (sup.isPresent()) {
supplier = sup.get();
supplier.name = cfg.name;
supplier.apiUrl = cfg.apiURL;
} else {
supplier = new Supplier();
supplier.uuid = cfg.id;
supplier.apiUrl = cfg.apiURL;
supplier.name = cfg.name;
}
supplierRepository.save(supplier);
}
}
}

View File

@ -1,8 +0,0 @@
package org.hso.ecommerce.controller;
import org.springframework.stereotype.Controller;
@Controller
//@RequestMapping("...")
public class BookingController {
}

View File

@ -1,8 +1,70 @@
package org.hso.ecommerce.controller;
import org.hso.ecommerce.entities.shop.ShoppingCart;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Optional;
@Controller
//@RequestMapping("...")
@RequestMapping("/")
public class LoginController {
@Autowired
private final UserRepository userRepository = null;
@GetMapping("login")
public String login() {
return "login";
}
@PostMapping("login")
public String loginPost(HttpServletRequest request, HttpServletResponse response,
@RequestParam("username") String username, @RequestParam("password") String password, HttpSession session) {
String gto = (String) session.getAttribute("afterLogin");
Optional<User> user = userRepository.findByEmail(username);
if (!user.isPresent()) {
request.setAttribute("error", "Die Email Adresse falsch.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "login";
}
if (!user.get().validatePassword(password)) {
request.setAttribute("error", "Das Passwort ist falsch.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "login";
}
if (!user.get().isActive) {
request.setAttribute("error", "Dieses Konto ist deaktiviert..");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "login";
}
session.setAttribute("userId", user.get().getId());
if (gto != null && gto.startsWith("/")) {
return "redirect:" + gto;
} else if (user.get().isEmployee) {
return "redirect:/intern/";
} else {
return "redirect:/";
}
}
@PostMapping("logout")
public String logoutPost(@RequestAttribute(value = "shoppingCart") ShoppingCart shoppingCart, HttpSession session) {
session.removeAttribute("userId");
shoppingCart.clear();
return "redirect:/";
}
}

View File

@ -1,5 +1,6 @@
package org.hso.ecommerce.controller;
import org.hso.ecommerce.entities.booking.PaymentMethod;
import org.hso.ecommerce.entities.shop.Address;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository;
@ -21,29 +22,20 @@ public class RegisterController {
private final UserRepository userRepository = null;
@PostMapping("/register")
public String registerPost(
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("username") String username,
@RequestParam("password") String password,
@RequestParam("password2") String password2,
@RequestParam("salutation") String salutation,
@RequestParam("name") String name,
@RequestParam("address") String address,
@RequestParam("type") String type,
@RequestParam("ad") String ad,
HttpSession session
)
{
public String registerPost(HttpServletRequest request, HttpServletResponse response,
@RequestParam("username") String username, @RequestParam("password") String password,
@RequestParam("password2") String password2, @RequestParam("salutation") String salutation,
@RequestParam("name") String name, @RequestParam("address") String address,
HttpSession session) {
Optional<User> user = userRepository.findByEmail(username);
if (user.isPresent()) {
request.setAttribute("error", "Email Adresse existiert bereits!");
request.setAttribute("error", "Die Email Adresse existiert bereits.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "register";
}
if (!password.equals(password2)) {
request.setAttribute("error", "Passwörter sind nicht gleich");
request.setAttribute("error", "Die Passwörter stimmen nicht überein.");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return "register";
}
@ -54,7 +46,8 @@ public class RegisterController {
newUser.setPassword(password);
newUser.email = username;
newUser.isEmployee = false;
//TODO for salutation, type, ad are no attributes/fields in the class/database. Add when they are there.
newUser.salutation = salutation;
newUser.defaultPayment = PaymentMethod.fromCreditCardNumber("");
newUser.isActive = true;
newUser.created = new java.sql.Timestamp(System.currentTimeMillis());
@ -69,9 +62,17 @@ public class RegisterController {
user = userRepository.findByEmail(username);
session.setAttribute("userId", user.get().getId());
String gto = (String) session.getAttribute("afterLogin");
//login after register
if (gto != null && gto.startsWith("/")) {
return "redirect:" + gto;
} else {
return "redirect:/";
}
}
@GetMapping("/register")
public String register() {
return "register";

View File

@ -1,8 +1,159 @@
package org.hso.ecommerce.controller;
import org.hso.ecommerce.action.user.CreateDeliveryData;
import org.hso.ecommerce.action.user.UpdateUserSettingsAction;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.app.config.AppSettings;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.repos.user.UserRepository;
import org.hso.ecommerce.uimodel.DeliveryData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.stream.Collectors;
@Controller
//@RequestMapping("...")
@RequestMapping("/user")
public class UserController {
@Autowired
private final UserRepository userRepository = null;
@Autowired
private final CustomerOrderRepository customerOrderRepository = null;
@Autowired
private final RestServiceForDelivery restServiceForDelivery = null;
@Autowired
private final AppSettings appSettings = null;
@GetMapping("/")
public String user() {
return "redirect:/user/settings";
}
@GetMapping("/settings")
public String userSettings(Model model,
@RequestAttribute("user") User user
) {
model.addAttribute("user", user);
return "user/settings";
}
@GetMapping("/orders/")
public String userOrders(
@RequestAttribute("user") User user,
Model model
) {
List<CustomerOrder> orders = customerOrderRepository.getOrdersByUserId(user.id);
List<CustomerOrderDelivery> customerOrderDeliveryDataMap = orders
.stream()
.map(o -> new CustomerOrderDelivery(o, CreateDeliveryData.getDeliveryDataFromCustomerOrder(o, customerOrderRepository, restServiceForDelivery)))
.collect(Collectors.toList());
model.addAttribute("orderDeliveryDataMap", customerOrderDeliveryDataMap);
model.addAttribute("deliveryService", appSettings.getParcelServiceName());
return "user/orders/index";
}
static class CustomerOrderDelivery {
private CustomerOrder customerOrder;
private DeliveryData deliveryData;
public CustomerOrderDelivery(CustomerOrder customerOrder, DeliveryData deliveryData) {
this.customerOrder = customerOrder;
this.deliveryData = deliveryData;
}
public CustomerOrder getCustomerOrder() {
return customerOrder;
}
public DeliveryData getDeliveryData() {
return deliveryData;
}
}
@PostMapping("/settings/changeMail")
public String changeMail(HttpSession session,
@RequestParam("email") String email,
HttpServletRequest request
) {
User user = userRepository.findById((long) session.getAttribute("userId")).get();
UpdateUserSettingsAction cusa = new UpdateUserSettingsAction(user, userRepository);
UpdateUserSettingsAction.UpdateResult result = cusa.updateEmail(email);
if (result.updated == false) {
request.setAttribute("error", result.errorString);
return "user/settings";
}
return "redirect:/user/settings";
}
@PostMapping("/settings/changePwd")
public String changePwd(HttpSession session,
@RequestParam("old-password") String oldPassword,
@RequestParam("password1") String password1,
@RequestParam("password2") String password2,
HttpServletRequest request
) {
User user = userRepository.findById((long) session.getAttribute("userId")).get();
UpdateUserSettingsAction cusa = new UpdateUserSettingsAction(user, userRepository);
UpdateUserSettingsAction.UpdateResult result = cusa.updatePassword(oldPassword, password1, password2);
if (result.updated == false) {
request.setAttribute("error", result.errorString);
return "user/settings";
}
return "redirect:/user/settings";
}
@PostMapping("/settings/changeAddress")
public String changeAddress(HttpSession session,
@RequestParam("salutation") String salutation,
@RequestParam("name") String name,
@RequestParam("address") String address,
HttpServletRequest request
) {
User user = userRepository.findById((long) session.getAttribute("userId")).get();
UpdateUserSettingsAction cusa = new UpdateUserSettingsAction(user, userRepository);
UpdateUserSettingsAction.UpdateResult result = cusa.updateShippingInfo(salutation, name, address);
if (result.updated == false) {
request.setAttribute("error", result.errorString);
return "user/settings";
}
return "redirect:/user/settings";
}
@PostMapping("/settings/changePaymentInfo")
public String changePaymentInfo(HttpSession session,
@RequestParam("creditCardNumber") String creditCardNumber,
HttpServletRequest request
) {
User user = userRepository.findById((long) session.getAttribute("userId")).get();
UpdateUserSettingsAction cusa = new UpdateUserSettingsAction(user, userRepository);
UpdateUserSettingsAction.UpdateResult result = cusa.updatePaymentInfo(creditCardNumber);
if (result.updated == false) {
request.setAttribute("error", result.errorString);
return "user/settings";
}
return "redirect:/user/settings";
}
}

View File

@ -0,0 +1,77 @@
package org.hso.ecommerce.controller.cronjob;
import org.hso.ecommerce.action.booking.CreateBookingAction;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.hso.ecommerce.repos.supplier.SupplierRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Calendar;
@Component
public class AutoSupplierPayment implements ICronjob {
@Autowired
private SupplierRepository supplierRepository = null;
@Autowired
private BookingAccountEntryRepository bookingAccountEntryRepository = null;
@Autowired
private BookingRepository bookingRepository = null;
@Override
public Calendar nextExecution(Calendar reference) {
if (reference.get(Calendar.HOUR_OF_DAY) >= 10) {
reference.add(Calendar.DAY_OF_MONTH, 1);
}
reference.set(Calendar.HOUR_OF_DAY, 10);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
@Override
public Calendar previousExecution(Calendar reference) {
if (reference.get(Calendar.HOUR_OF_DAY) < 10) {
reference.add(Calendar.DAY_OF_MONTH, -1);
}
reference.set(Calendar.HOUR_OF_DAY, 10);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
@Override
public void executeAt(Calendar time, CronjobController controller) {
for (Supplier supplier : supplierRepository.findAll()) {
int debts = bookingAccountEntryRepository
.getBySupplier(supplier.id)
.map(entry -> entry.newSumCent).orElse(0);
if (debts > 0) {
Booking booking = new CreateBookingAction(
bookingAccountEntryRepository.getBySupplier(supplier.id).orElseGet(() -> BookingAccountEntry.newSupplier(supplier)),
null,
new BookingReason(supplier),
debts
).finish();
bookingRepository.save(booking);
}
}
}
@Override
public String getDisplayName() {
return "Supplier Auto Payment";
}
}

View File

@ -1,34 +1,12 @@
package org.hso.ecommerce.controller.cronjob;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import org.hso.ecommerce.action.booking.CreateBookingAction;
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction;
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.ArticleIdentifier;
import org.hso.ecommerce.action.cronjob.ReorderAction;
import org.hso.ecommerce.action.cronjob.UpdateOffersAction;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.entities.cron.BackgroundJob;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.supplier.ArticleOffer;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.hso.ecommerce.repos.cronjob.BackgroundJobRepository;
import org.hso.ecommerce.repos.dashboard.DashboardSummaryRepository;
import org.hso.ecommerce.repos.shop.ArticleRepository;
import org.hso.ecommerce.repos.shop.CustomerOderRepository;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.repos.supplier.ArticleOfferRepository;
import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
import org.hso.ecommerce.repos.supplier.SupplierRepository;
@ -37,188 +15,23 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
interface ICronjob {
/**
* Calculate the earliest cronjob execution time that happens after the given reference time.
*
* @param reference Position in time to start searching. The implementor is allowed to modify the reference time.
* @return A new Calendar instance (or the same) containing the time for next execution.
*/
Calendar nextExecution(Calendar reference);
/**
* Calculate the latest cronjob execution time that happens before or exactly at the given refernce time.
*
* @param reference Position in time to start searching. The implementor is allowed to modify the reference time.
* @return A new Calendar instance (or the same) containing the time of the last execution.
*/
Calendar previousExecution(Calendar reference);
/**
* Execute this cronjob.
*
* @param time The point in time this execution was scheduled. In case of a missed cronjob, the actual time of
* this call might be much later.
* @param controller Back-reference that allows to use repositories.
*/
void executeAt(Calendar time, CronjobController controller);
}
@Component
class Reorder implements ICronjob {
@Override
public Calendar nextExecution(Calendar reference) {
if (reference.get(Calendar.HOUR_OF_DAY) >= 8) {
reference.add(Calendar.DAY_OF_MONTH, 1);
}
reference.set(Calendar.HOUR_OF_DAY, 8);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
@Override
public Calendar previousExecution(Calendar reference) {
if (reference.get(Calendar.HOUR_OF_DAY) < 8) {
reference.add(Calendar.DAY_OF_MONTH, -1);
}
reference.set(Calendar.HOUR_OF_DAY, 8);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
/**
* Calculates the amount of ordered articles by customers for the given article type in the time between begin and
* end.
*
* @param article The article to search orders for.
* @param begin The start time for the search (included)
* @param end The end time for the search (excluded)
* @return The number of articles that were ordered by customers in the given range.
*/
private Integer getOrderedAmounts(Article article, Calendar begin, Calendar end, CronjobController controller) {
return controller.customerOrderRepository.countOrdersOfArticleInTimespan(
article.id,
new Timestamp(begin.getTimeInMillis()), new Timestamp(end.getTimeInMillis()));
}
/**
* Calculates the amount of ordered articles by customers for the given article type in the three days before the
* given reference time. The return-array contains 3 fields: Index 0: Orders 72 to 48 hours ago; Index 1: Orders 48
* to 24 hours ago; Index 2: Orders 24 to 0 hours ago.
*
* @param article The article for which the customer orders are checked.
* @param time The reference time to use for calculation of the last orders.
* @return A 3-element array containing the orders of the last three days.
*/
private Integer[] getOrderedAmounts(Article article, Calendar time, CronjobController controller) {
Calendar oneDayBefore = (Calendar) time.clone();
oneDayBefore.add(Calendar.DAY_OF_MONTH, -1);
Calendar twoDaysBefore = (Calendar) time.clone();
twoDaysBefore.add(Calendar.DAY_OF_MONTH, -2);
Calendar threeDaysBefore = (Calendar) time.clone();
threeDaysBefore.add(Calendar.DAY_OF_MONTH, -3);
return new Integer[] { //
getOrderedAmounts(article, threeDaysBefore, twoDaysBefore, controller), //
getOrderedAmounts(article, twoDaysBefore, oneDayBefore, controller), //
getOrderedAmounts(article, oneDayBefore, time, controller), //
};
}
private HashMap<ArticleIdentifier, ArticleOffer> mapArticleOffers(List<ArticleOffer> articleOffers) {
HashMap<ArticleIdentifier, ArticleOffer> map = new HashMap<>();
for (ArticleOffer articleOffer : articleOffers) {
ArticleIdentifier identifier = new ArticleIdentifier(articleOffer.manufacturer, articleOffer.articleNumber);
map.put(identifier, articleOffer);
}
return map;
}
@Override
public void executeAt(Calendar time, CronjobController controller) {
List<Supplier> suppliers = controller.supplierRepository.findAll();
ReadSupplierDataAction.Result supplierData = new ReadSupplierDataAction(suppliers).finish();
// Save the new offers in the database
List<ArticleOffer> allOffers = controller.articleOfferRepository.findAll();
allOffers = new UpdateOffersAction(allOffers, supplierData.cheapestOffer).finish();
controller.articleOfferRepository.saveAll(allOffers);
HashMap<ArticleIdentifier, ArticleOffer> mappedOffers = mapArticleOffers(allOffers);
// Reorder
List<Article> allArticles = controller.articleRepository.findAll();
for (Article article : allArticles) {
Integer[] orderedAmounts = getOrderedAmounts(article, time, controller);
Integer undeliveredReorders = controller.supplierOrderRepository
.countUndeliveredReorders(article.related.articleNumber);
int amountInStock = controller.warehouseBookingPositionSlotEntryRepository.getArticleStock(article.id)
.orElse(0);
ReorderAction action = new ReorderAction(article, orderedAmounts,
undeliveredReorders,
amountInStock,
supplierData.cheapestOffer, mappedOffers);
SupplierOrder order = action.finish();
if (order != null) {
controller.supplierOrderRepository.save(order);
// Create bookings for this order
int netPrice = order.totalPriceNet;
int vatPercent = order.ordered.vatPercent;
int vatAmount = netPrice * vatPercent / 100;
int grossPrice = netPrice + vatAmount;
// Obligation towards the supplier
BookingAccountEntry mainAccount = controller.bookingAccountEntryRepository.getByMain()
.orElseGet(BookingAccountEntry::newMain);
BookingAccountEntry supplierAccount = controller.bookingAccountEntryRepository
.getBySupplier(order.supplier.id)
.orElseGet(() -> BookingAccountEntry.newSupplier(order.supplier));
BookingReason obligationReason = new BookingReason(order);
Booking obligationBooking = new CreateBookingAction(mainAccount,
supplierAccount,
obligationReason,
grossPrice).finish();
controller.bookingRepository.save(obligationBooking);
// Input Tax
BookingAccountEntry vatAccount = controller.bookingAccountEntryRepository.getByVat()
.orElseGet(BookingAccountEntry::newVat);
mainAccount = controller.bookingAccountEntryRepository.getByMain().get();
BookingReason inputTaxReason = new BookingReason(order);
Booking inputTaxBooking = new CreateBookingAction(vatAccount, mainAccount, inputTaxReason, vatAmount)
.finish();
controller.bookingRepository.save(inputTaxBooking);
}
}
}
}
class ScheduledCronjob {
public final Calendar executionTime;
public final ICronjob cronjob;
public final BackgroundJob model;
public ScheduledCronjob(Calendar executionTime, ICronjob cronjob, BackgroundJob model) {
this.executionTime = executionTime;
this.cronjob = cronjob;
this.model = model;
}
}
import javax.annotation.PostConstruct;
import java.sql.Timestamp;
import java.util.*;
import java.util.Map.Entry;
@Component
@RequestMapping("intern/cronjobs")
class CronjobController {
private static final Logger log = LoggerFactory.getLogger(CronjobController.class);
private static final Map<String, ICronjob> cronjobs = getCronjobs();
private Map<String, ICronjob> cronjobs;
@Autowired
private final BackgroundJobRepository cronjobRepository = null;
@ -230,7 +43,7 @@ class CronjobController {
final ArticleOfferRepository articleOfferRepository = null;
@Autowired
final CustomerOderRepository customerOrderRepository = null;
final CustomerOrderRepository customerOrderRepository = null;
@Autowired
final BookingRepository bookingRepository = null;
@ -241,17 +54,36 @@ class CronjobController {
@Autowired
final WarehouseBookingPositionSlotEntryRepository warehouseBookingPositionSlotEntryRepository = null;
@Autowired
final DashboardSummaryRepository dashboardSummaryRepository = null;
@Autowired
final SupplierRepository supplierRepository = null;
@Autowired
final SupplierOrderRepository supplierOrderRepository = null;
private static Map<String, ICronjob> getCronjobs() {
@Autowired
final Reorder reorderJob = null;
@Autowired
final DashboardCronjob dashboardCronjob = null;
@Autowired
final AutoSupplierPayment autoSupplierPaymentJob = null;
@PostConstruct
public void init() {
cronjobs = getCronjobs();
}
private Map<String, ICronjob> getCronjobs() {
HashMap<String, ICronjob> map = new HashMap<>();
// Register all existing cronjobs
map.put(BackgroundJob.JOB_REORDER, new Reorder());
map.put(BackgroundJob.JOB_REORDER, reorderJob);
map.put(BackgroundJob.JOB_DASHBOARD, dashboardCronjob);
map.put(BackgroundJob.JOB_SUPPLIER_AUTO_PAYMENT, autoSupplierPaymentJob);
return Collections.unmodifiableMap(map);
}
@ -328,4 +160,42 @@ class CronjobController {
public void onPostConstruct() {
new Thread(this::runCronjobExecutionLoop).start();
}
class ManualCronjob {
public final String identifier;
public final String visibleName;
public ManualCronjob(String identifier, String visibleName) {
this.identifier = identifier;
this.visibleName = visibleName;
}
}
private List<ManualCronjob> listAllCronjobs() {
ArrayList<ManualCronjob> entries = new ArrayList<>();
for (Entry<String, ICronjob> job : cronjobs.entrySet()) {
entries.add(new ManualCronjob(job.getKey(), job.getValue().getDisplayName()));
}
return entries;
}
@GetMapping("/")
public String cronjobOverview(Model model) {
model.addAttribute("jobs", listAllCronjobs());
return "intern/cronjobs/index";
}
@PostMapping("/run/{identifier}")
public String runCronjob(Model model, @PathVariable("identifier") String identifier) {
ICronjob jobToExecute = cronjobs.get(identifier);
if (jobToExecute != null) {
jobToExecute.executeAt(new GregorianCalendar(), this);
model.addAttribute("info",
String.format("Der Cronjob \"%s\" wurde ausgeführt.", jobToExecute.getDisplayName()));
} else {
model.addAttribute("error", "Der Cronjob konnte nicht gefunden werden.");
}
model.addAttribute("jobs", listAllCronjobs());
return "intern/cronjobs/index";
}
}

View File

@ -0,0 +1,100 @@
package org.hso.ecommerce.controller.cronjob;
import org.hso.ecommerce.action.warehouse.CalculateWarehouseStatsAction;
import org.hso.ecommerce.entities.dashboard.DashboardSummary;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.repos.user.UserRepository;
import org.hso.ecommerce.repos.warehouse.SlotRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class DashboardCronjob implements ICronjob {
@Autowired
private SlotRepository slotRepository = null;
@Autowired
private UserRepository userRepository = null;
@Autowired
private WarehouseBookingPositionSlotEntryRepository warehouseBookingPositionSlotEntryRepository = null;
@Autowired
private CustomerOrderRepository customerOrderRepository = null;
@Override
public Calendar nextExecution(Calendar reference) {
reference.add(Calendar.DAY_OF_MONTH, 1);
reference.set(Calendar.HOUR_OF_DAY, 0);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
@Override
public Calendar previousExecution(Calendar reference) {
reference.set(Calendar.HOUR_OF_DAY, 0);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
@Override
public void executeAt(Calendar time, CronjobController controller) {
Calendar oneDayBefore = (Calendar) time.clone();
oneDayBefore.add(Calendar.DAY_OF_MONTH, -1);
DashboardSummary dashboardSummary = new DashboardSummary();
List<WarehouseBookingPositionSlotEntry> entries = slotRepository.findAll().stream().map(
s -> warehouseBookingPositionSlotEntryRepository
.getBySlotNum(s.slotNum)
.orElseGet(() -> WarehouseBookingPositionSlotEntry.empty(null, s))
).collect(Collectors.toList());
CalculateWarehouseStatsAction.WarehouseStats warehouseStats = new CalculateWarehouseStatsAction(entries).finish();
dashboardSummary.created = new java.sql.Date(time.getTimeInMillis());
dashboardSummary.todaysCustomersOrders = nullToZero(getSales(oneDayBefore, time));
dashboardSummary.todaysNewCustomers = nullToZero(getNewUsers(oneDayBefore, time));
dashboardSummary.todaysWarehouseCapacity = warehouseStats.efficiency;
dashboardSummary.currentWarehouseCapacity = warehouseStats.ratioUsedSlots;
dashboardSummary.todaysSalesCent = nullToZero(getTurnover(oneDayBefore, time));
controller.dashboardSummaryRepository.save(dashboardSummary);
}
@Override
public String getDisplayName() {
return "Dashboard refresh";
}
private Integer getSales(Calendar begin, Calendar end) {
return customerOrderRepository.countOrdersInTimespan(
new Timestamp(begin.getTimeInMillis()), new Timestamp(end.getTimeInMillis()));
}
private Integer getTurnover(Calendar begin, Calendar end) {
return customerOrderRepository.countTurnoverInTimespan(
new Timestamp(begin.getTimeInMillis()), new Timestamp(end.getTimeInMillis()));
}
private Integer getNewUsers(Calendar begin, Calendar end) {
return userRepository.countUsersInTimespan(
new Timestamp(begin.getTimeInMillis()), new Timestamp(end.getTimeInMillis()));
}
private int nullToZero(Integer input) {
return input == null ? 0 : input;
}
}

View File

@ -0,0 +1,38 @@
package org.hso.ecommerce.controller.cronjob;
import java.util.Calendar;
interface ICronjob {
/**
* Calculate the earliest cronjob execution time that happens after the given reference time.
*
* @param reference Position in time to start searching. The implementor is allowed to modify the reference time.
* @return A new Calendar instance (or the same) containing the time for next execution.
*/
Calendar nextExecution(Calendar reference);
/**
* Calculate the latest cronjob execution time that happens before or exactly at the given refernce time.
*
* @param reference Position in time to start searching. The implementor is allowed to modify the reference time.
* @return A new Calendar instance (or the same) containing the time of the last execution.
*/
Calendar previousExecution(Calendar reference);
/**
* Execute this cronjob.
*
* @param time The point in time this execution was scheduled. In case of a missed cronjob, the actual time of
* this call might be much later.
* @param controller Back-reference that allows to use repositories.
*/
void executeAt(Calendar time, CronjobController controller);
/**
* Get a name for this cronjob, that can be presented to the user in the frontend.
*
* @return A german name of this cronjob.
*/
String getDisplayName();
}

View File

@ -0,0 +1,164 @@
package org.hso.ecommerce.controller.cronjob;
import org.hso.ecommerce.action.booking.CreateBookingAction;
import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction;
import org.hso.ecommerce.action.cronjob.ReorderAction;
import org.hso.ecommerce.action.cronjob.UpdateOffersAction;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.supplier.ArticleOffer;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.springframework.stereotype.Component;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
@Component
class Reorder implements ICronjob {
@Override
public String getDisplayName() {
return "Nachbestellung";
}
@Override
public Calendar nextExecution(Calendar reference) {
if (reference.get(Calendar.HOUR_OF_DAY) >= 8) {
reference.add(Calendar.DAY_OF_MONTH, 1);
}
reference.set(Calendar.HOUR_OF_DAY, 8);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
@Override
public Calendar previousExecution(Calendar reference) {
if (reference.get(Calendar.HOUR_OF_DAY) < 8) {
reference.add(Calendar.DAY_OF_MONTH, -1);
}
reference.set(Calendar.HOUR_OF_DAY, 8);
reference.set(Calendar.MINUTE, 0);
reference.set(Calendar.SECOND, 0);
reference.set(Calendar.MILLISECOND, 0);
return reference;
}
/**
* Calculates the amount of ordered articles by customers for the given article type in the time between begin and
* end.
*
* @param article The article to search orders for.
* @param begin The start time for the search (included)
* @param end The end time for the search (excluded)
* @return The number of articles that were ordered by customers in the given range.
*/
private Integer getOrderedAmounts(Article article, Calendar begin, Calendar end, CronjobController controller) {
return controller.customerOrderRepository.countOrdersOfArticleInTimespan(
article.id,
new Timestamp(begin.getTimeInMillis()), new Timestamp(end.getTimeInMillis()));
}
/**
* Calculates the amount of ordered articles by customers for the given article type in the three days before the
* given reference time. The return-array contains 3 fields: Index 0: Orders 72 to 48 hours ago; Index 1: Orders 48
* to 24 hours ago; Index 2: Orders 24 to 0 hours ago.
*
* @param article The article for which the customer orders are checked.
* @param time The reference time to use for calculation of the last orders.
* @return A 3-element array containing the orders of the last three days.
*/
private Integer[] getOrderedAmounts(Article article, Calendar time, CronjobController controller) {
Calendar oneDayBefore = (Calendar) time.clone();
oneDayBefore.add(Calendar.DAY_OF_MONTH, -1);
Calendar twoDaysBefore = (Calendar) time.clone();
twoDaysBefore.add(Calendar.DAY_OF_MONTH, -2);
Calendar threeDaysBefore = (Calendar) time.clone();
threeDaysBefore.add(Calendar.DAY_OF_MONTH, -3);
return new Integer[]{ //
getOrderedAmounts(article, threeDaysBefore, twoDaysBefore, controller), //
getOrderedAmounts(article, twoDaysBefore, oneDayBefore, controller), //
getOrderedAmounts(article, oneDayBefore, time, controller), //
};
}
private HashMap<ReadSupplierDataAction.ArticleIdentifier, ArticleOffer> mapArticleOffers(List<ArticleOffer> articleOffers) {
HashMap<ReadSupplierDataAction.ArticleIdentifier, ArticleOffer> map = new HashMap<>();
for (ArticleOffer articleOffer : articleOffers) {
ReadSupplierDataAction.ArticleIdentifier identifier = new ReadSupplierDataAction.ArticleIdentifier(articleOffer.manufacturer, articleOffer.articleNumber);
map.put(identifier, articleOffer);
}
return map;
}
@Override
public void executeAt(Calendar time, CronjobController controller) {
List<Supplier> suppliers = controller.supplierRepository.findAll();
ReadSupplierDataAction.Result supplierData = new ReadSupplierDataAction(suppliers).finish();
// Save the new offers in the database
List<ArticleOffer> allOffers = controller.articleOfferRepository.findAll();
allOffers = new UpdateOffersAction(allOffers, supplierData.cheapestOffer).finish();
controller.articleOfferRepository.saveAll(allOffers);
HashMap<ReadSupplierDataAction.ArticleIdentifier, ArticleOffer> mappedOffers = mapArticleOffers(allOffers);
// Reorder
List<Article> allArticles = controller.articleRepository.findAll();
for (Article article : allArticles) {
Integer[] orderedAmounts = getOrderedAmounts(article, time, controller);
Integer undeliveredReorders = controller.supplierOrderRepository
.countUndeliveredReorders(article.related.articleNumber);
int amountInStock = controller.warehouseBookingPositionSlotEntryRepository
.getByArticle(article.id)
.stream()
.mapToInt(e -> e.newSumSlot)
.sum();
ReorderAction action = new ReorderAction(article, orderedAmounts,
undeliveredReorders,
amountInStock,
supplierData.cheapestOffer, mappedOffers);
SupplierOrder order = action.finish();
if (order != null) {
controller.supplierOrderRepository.save(order);
// Create bookings for this order
int netPrice = order.totalPriceNet;
int vatPercent = order.ordered.vatPercent;
int vatAmount = netPrice * vatPercent / 100;
int grossPrice = netPrice + vatAmount;
// Obligation towards the supplier
BookingAccountEntry mainAccount = controller.bookingAccountEntryRepository.getByMain()
.orElseGet(BookingAccountEntry::newMain);
BookingAccountEntry supplierAccount = controller.bookingAccountEntryRepository
.getBySupplier(order.supplier.id)
.orElseGet(() -> BookingAccountEntry.newSupplier(order.supplier));
BookingReason obligationReason = new BookingReason(order);
Booking obligationBooking = new CreateBookingAction(mainAccount,
supplierAccount,
obligationReason,
grossPrice).finish();
controller.bookingRepository.save(obligationBooking);
// Input Tax
BookingAccountEntry vatAccount = controller.bookingAccountEntryRepository.getByVat()
.orElseGet(BookingAccountEntry::newVat);
mainAccount = controller.bookingAccountEntryRepository.getByMain().get();
BookingReason inputTaxReason = new BookingReason(order);
Booking inputTaxBooking = new CreateBookingAction(vatAccount, mainAccount, inputTaxReason, vatAmount)
.finish();
controller.bookingRepository.save(inputTaxBooking);
}
}
}
}

View File

@ -0,0 +1,17 @@
package org.hso.ecommerce.controller.cronjob;
import org.hso.ecommerce.entities.cron.BackgroundJob;
import java.util.Calendar;
class ScheduledCronjob {
public final Calendar executionTime;
public final ICronjob cronjob;
public final BackgroundJob model;
public ScheduledCronjob(Calendar executionTime, ICronjob cronjob, BackgroundJob model) {
this.executionTime = executionTime;
this.cronjob = cronjob;
this.model = model;
}
}

View File

@ -0,0 +1,25 @@
package org.hso.ecommerce.controller.intern;
import org.hso.ecommerce.entities.dashboard.DashboardSummary;
import org.hso.ecommerce.repos.dashboard.DashboardSummaryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class DashboardController {
@Autowired
private DashboardSummaryRepository dashboardSummaryRepository;
@GetMapping("/intern/dashboardsummary")
public List<DashboardSummary> getDashboardEntries()
{
List<DashboardSummary> inTimespan = dashboardSummaryRepository.findInTimespan(PageRequest.of(0, 7) );
return inTimespan;
}
}

View File

@ -22,6 +22,7 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@ -52,7 +53,11 @@ public class InternArticleController {
for (Article article : articleRepository.findAll()) {
UImodelArticles tmp = new UImodelArticles();
tmp.addListedArticle(article, warehouseEntryRepository.getArticleStock(article.id).orElse(0));
tmp.addListedArticle(article, warehouseEntryRepository
.getByArticle(article.id)
.stream()
.mapToInt(e -> e.newSumSlot)
.sum());
totals.add(tmp);
}
@ -62,16 +67,16 @@ public class InternArticleController {
@GetMapping("/{id}")
public String internListedArticlesId(Model model, @PathVariable String id) {
int articleid = Integer.parseInt(id);
long articleId = Long.parseLong(id);
UImodelArticle total = new UImodelArticle();
total.addArticle(articleRepository.findArticleById(articleid),
warehouseEntryRepository.getArticleStock(articleid).orElse(0));
total.addArticle(
articleRepository.findById(articleId).get(),
warehouseEntryRepository.getByArticle(articleId)
.stream()
.mapToInt(e -> e.newSumSlot)
.sum());
model.addAttribute("ArticleID", total);
return "intern/listedArticles/id";
}
@ -80,7 +85,7 @@ public class InternArticleController {
@RequestParam(value = "title", required = true) String title,
@RequestParam(value = "description", required = true) String description,
@RequestParam(value = "units-per-slot", required = true) String warehouseUnitsPerSlot,
@RequestParam(value = "price_netto", required = true) String pricenetto,
@RequestParam(value = "priceNet", required = true) String pricenetto,
@RequestParam(value = "reorderMaxPrice", required = true) String reorderMaxPrice,
@RequestParam(value = "autobuy", required = true) Boolean shouldReorder,
@RequestParam(value = "categorie", required = true) String categories,
@ -115,11 +120,17 @@ public class InternArticleController {
@PostMapping("/addArticle/{id}")
public RedirectView addArticle(@PathVariable(required = true) String id) {
// article is not already listed, create new one
int offeredArticleID = Integer.parseInt(id);
long offeredArticleID = Long.parseLong(id);
Article tmpArticle = new Article();
ArticleOffer offeredArticle = offersRepository.findOfferedArticleById(offeredArticleID);
ArticleOffer offeredArticle = offersRepository.findById(offeredArticleID).get();
// Check for duplicates
Optional<Article> related = articleRepository.findArticleByArticleOffer(offeredArticle);
if (related.isPresent()) {
return new RedirectView("../" + related.get().id);
}
// set default values
tmpArticle.description = "";
@ -175,15 +186,22 @@ public class InternArticleController {
if (imageID.isPresent()) {
article.image = imageRepository.findImageById(imageID.get()); // add existing img to article
} else {
Path targetPath = Paths.get("./data/img/");
if (Files.notExists(targetPath)) {
Files.createDirectories(targetPath);
}
// write new img file to disk
Files.newOutputStream(Paths.get("./data/img/", fileName)).write(imgFile.getBytes());
Files.newOutputStream(Paths.get(targetPath.toString(), fileName)).write(imgFile.getBytes());
// create new img
Image newImage = new Image();
newImage.path = "./data/img/" + fileName; // set new file to new img
imageRepository.save(newImage); // save new img
article.image = newImage; // set new img to article
}
} catch (Exception e) {
} catch (IOException e) {
e.printStackTrace();
setDefaultImage(article); // if upload failed, reset to default img
}
}
@ -192,19 +210,12 @@ public class InternArticleController {
public static class UImodelArticles {
public String imgPath;
public String title;
public String price;
public String price_netto;
public String priceNet;
public String categorie;
public int stock;
public long offer_id;
public long offerID;
public long id;
void addListedArticle(Article article, int stock) {
@ -213,7 +224,7 @@ public class InternArticleController {
this.imgPath = article.image.path;
}
this.title = article.title;
this.price_netto = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
this.priceNet = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
this.price = String.format("%.2f", ((float) article.getPriceGross() / 100));
StringBuilder result = new StringBuilder();
@ -224,7 +235,7 @@ public class InternArticleController {
this.categorie = result.toString();
this.stock = stock;
this.offer_id = article.related.id;
this.offerID = article.related.id;
this.id = article.id;
}
}
@ -234,123 +245,31 @@ public class InternArticleController {
public String imgPath;
public String title;
public String price;
public String price_netto;
public String priceNet;
public String reorderMaxPrice;
public String categorie;
public int stock;
public long offer_id;
public long offerID;
public long id;
public boolean shouldReorder;
public String warehouseUnitsPerSlot;
public String description;
public int vatPercent;
public String getImgPath() {
return imgPath;
}
public void setImgPath(String imgPath) {
this.imgPath = imgPath;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public int getVatPercent() {
return vatPercent;
}
public String getPrice_netto() {
return price_netto;
}
public void setPrice_netto(String price_netto) {
this.price_netto = price_netto;
}
public String getReorderMaxPrice() {
return reorderMaxPrice;
}
public void setReorderMaxPrice(String reorderMaxPrice) {
this.reorderMaxPrice = reorderMaxPrice;
}
public String getCategorie() {
return categorie;
}
public void setCategorie(String categorie) {
this.categorie = categorie;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public long getOffer_id() {
return offer_id;
}
public void setOffer_id(long offer_id) {
this.offer_id = offer_id;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public boolean isShouldReorder() {
return shouldReorder;
}
public void setShouldReorder(boolean shouldReorder) {
this.shouldReorder = shouldReorder;
}
public String getWarehouseUnitsPerSlot() {
return warehouseUnitsPerSlot;
}
public void setWarehouseUnitsPerSlot(String warehouseUnitsPerSlot) {
this.warehouseUnitsPerSlot = warehouseUnitsPerSlot;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
void addArticle(Article article, int stock) {
if (article.image != null) {
this.imgPath = article.image.path;
}
this.title = article.title;
this.price_netto = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
this.priceNet = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
this.price = String.format("%.2f", ((float) article.getPriceGross() / 100));
StringBuilder result = new StringBuilder();
@ -362,7 +281,7 @@ public class InternArticleController {
this.categorie = result.toString();
this.stock = stock;
this.offer_id = article.related.id;
this.offerID = article.related.id;
this.id = article.id;
this.reorderMaxPrice = String.format("%.2f", ((float) article.reorderMaxPrice / 100));
this.shouldReorder = article.shouldReorder;

View File

@ -1,8 +1,34 @@
package org.hso.ecommerce.controller.intern;
import java.util.Optional;
import org.hso.ecommerce.controller.intern.accounting.AccountingController;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
//@RequestMapping("...")
@RequestMapping("/intern")
public class InternIndexController {
@Autowired
private final BookingAccountEntryRepository bookingAccountEntryRepository = null;
@GetMapping("/")
public String intern(Model model) {
Optional<BookingAccountEntry> mainAccount = bookingAccountEntryRepository.getByMain();
int mainAccountBalance = mainAccount.map(entry -> entry.newSumCent).orElse(0);
Optional<BookingAccountEntry> vatAccount = bookingAccountEntryRepository.getByVat();
int vatAccountBalance = vatAccount.map(entry -> entry.newSumCent).orElse(0);
model.addAttribute("mainAccountBalance", AccountingController.fmtEuro(mainAccountBalance));
model.addAttribute("vatAccountBalance", AccountingController.fmtEuro(vatAccountBalance));
return "intern/index";
}
}

View File

@ -1,8 +1,27 @@
package org.hso.ecommerce.controller.intern;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
@Controller
//@RequestMapping("...")
@RequestMapping("/intern/warehouse/")
public class WarehouseController {
@Autowired
private final WarehouseBookingRepository warehouseBookingRepository = null;
@GetMapping("/")
public String accountingWarehouse(
Model model,
HttpServletRequest request
) {
model.addAttribute("bookings", warehouseBookingRepository.findAllDesc());
return "intern/warehouse/index";
}
}

View File

@ -0,0 +1,229 @@
package org.hso.ecommerce.controller.intern.accounting;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@Controller
public class AccountingController {
@Autowired
private BookingRepository bookingRepository = null;
/**
* A description used to render the html template for the overview of all bookings
*/
static class TemplateBooking {
public String datetime;
public String amount;
public String source;
public String sourceAddr;
public String sourceBalance;
public String destination;
public String destinationAddr;
public String destinationBalance;
public String reason;
public String reference;
public String referenceAddr;
}
/**
* A description used to render the html template for bookings on a specific account
*/
public static class ShortTemplateBooking {
public String datetime;
public String amount;
public String source;
public String sourceAddr;
public String balance;
public String reason;
public String reference;
public String referenceAddr;
}
public static class ShortTemplateBookingResult {
public final String balance;
public final List<ShortTemplateBooking> bookings;
public ShortTemplateBookingResult(String balance, List<ShortTemplateBooking> bookings) {
this.balance = balance;
this.bookings = bookings;
}
}
/**
* Used to check which side of the booking (source or destination) is the account we are currently looking at.
*/
public interface AccountFilter {
boolean matches(BookingAccountEntry account);
}
/**
* Renders template information for the bookings of one specific account.
*
* @param bookings The (already fetched) booking entities to display
* @param currentAccount A filter matching the account that is to be displayed
* @return A collection result containing the final balance and all booking entries.
*/
public ShortTemplateBookingResult buildShortTemplate(List<Booking> bookings, AccountFilter currentAccount) {
List<ShortTemplateBooking> templateBookings = new ArrayList<>();
for (Booking booking : bookings) {
ShortTemplateBooking tb = new ShortTemplateBooking();
tb.datetime = new SimpleDateFormat("dd.MM.yyyy HH:mm").format(booking.created);
tb.reason = booking.reason.comment;
tb.reference = describeReference(booking.reason);
tb.referenceAddr = linkToReference(booking.reason);
if (booking.destination != null && currentAccount.matches(booking.destination)) {
// Money was transferred onto the account we are looking at.
tb.amount = fmtEuro(booking.amountCent);
if (booking.source != null) {
tb.source = describeAccount(booking.source);
tb.sourceAddr = linkAddrOfAccount(booking.source);
} else {
tb.source = "-";
tb.sourceAddr = null;
}
tb.balance = fmtEuro(booking.destination.newSumCent);
} else if (booking.source != null && currentAccount.matches(booking.source)) {
// Money was transferred away from the account we are looking at.
tb.amount = fmtEuro(-booking.amountCent); // Negative because of the transfer away
if (booking.destination != null) {
tb.source = describeAccount(booking.destination); // 'source' means 'the other account' in this case
tb.sourceAddr = linkAddrOfAccount(booking.destination);
} else {
tb.source = "-";
tb.sourceAddr = null;
}
tb.balance = fmtEuro(booking.source.newSumCent);
} else {
throw new RuntimeException(
"This booking should not appear in this list, because neither source nor destination is the account we are looking at.");
}
templateBookings.add(tb);
}
String balance = templateBookings.isEmpty() ? fmtEuro(0) : templateBookings.get(0).balance;
return new ShortTemplateBookingResult(balance, templateBookings);
}
public static String fmtEuro(long amountCent) {
return String.format("%.2f EUR", amountCent / 100.0);
}
private String describeAccount(BookingAccountEntry account) {
if (account.isMainAccount) {
return "Hauptkonto";
} else if (account.isVATAccount) {
return "Mehrwertsteuer";
} else if (account.supplierAccount != null) {
return "Lieferant " + account.supplierAccount.id;
} else if (account.userAccount != null) {
return "Kunde " + account.userAccount.id;
} else {
return "- unbekannt -";
}
}
private String linkAddrOfAccount(BookingAccountEntry account) {
if (account.isMainAccount) {
return "/intern/accounting/main";
} else if (account.isVATAccount) {
return "/intern/accounting/vat";
} else if (account.supplierAccount != null) {
return "/intern/suppliers/" + account.supplierAccount.id;
} else if (account.userAccount != null) {
return "/intern/customers/" + account.userAccount.id;
} else {
return null;
}
}
private String describeReference(BookingReason reason) {
if (reason.customerOrder != null) {
return reason.customerOrder.id + "";
} else if (reason.customerPayment != null) {
return "Bezahlung mit Kreditkarte " + reason.customerPayment.payment.creditCardNumber;
} else if (reason.supplierOrder != null) {
return "Lieferanten-Bestellung " + reason.supplierOrder.supplier.name;
} else if (reason.supplierPayment != null) {
return "Lieferanten-Zahlung " + reason.supplierPayment.name;
} else {
return "-";
}
}
private String linkToReference(BookingReason reason) {
if (reason.customerOrder != null) {
return "/intern/customerOrders/" + reason.customerOrder.id;
} else if (reason.supplierPayment != null) {
return "/intern/suppliers/#q=" + reason.supplierPayment.id;
} else if (reason.supplierOrder != null) {
return "/intern/supplierOrders/#q=" + reason.supplierOrder.id;
} else {
return null;
}
}
@GetMapping("/intern/accounting/")
public String accounting(Model model) {
List<Booking> bookings = bookingRepository.allBookingsReverseChronologically();
List<TemplateBooking> templateBookings = new ArrayList<>();
for (Booking booking : bookings) {
TemplateBooking tb = new TemplateBooking();
tb.datetime = new SimpleDateFormat("dd.MM.yyyy HH:mm").format(booking.created);
tb.amount = fmtEuro(booking.amountCent);
if (booking.source != null) {
tb.source = describeAccount(booking.source);
tb.sourceAddr = linkAddrOfAccount(booking.source);
tb.sourceBalance = fmtEuro(booking.source.newSumCent);
} else {
tb.source = "-";
tb.sourceAddr = null;
tb.sourceBalance = "-";
}
if (booking.destination != null) {
tb.destination = describeAccount(booking.destination);
tb.destinationAddr = linkAddrOfAccount(booking.destination);
tb.destinationBalance = fmtEuro(booking.destination.newSumCent);
} else {
tb.destination = "-";
tb.destinationAddr = null;
tb.destinationBalance = "-";
}
tb.reason = booking.reason.comment;
tb.reference = describeReference(booking.reason);
tb.referenceAddr = linkToReference(booking.reason);
templateBookings.add(tb);
}
model.addAttribute("bookings", templateBookings);
return "intern/accounting/index";
}
@GetMapping("/intern/accounting/vat")
public String accountingVat(Model model) {
List<Booking> bookings = bookingRepository.vatBookingsReverseChronologically();
ShortTemplateBookingResult result = buildShortTemplate(bookings, account -> account.isVATAccount);
model.addAttribute("balance", result.balance);
model.addAttribute("bookings", result.bookings);
return "intern/accounting/vat";
}
@GetMapping("/intern/accounting/main")
public String accountingIntern(Model model) {
List<Booking> bookings = bookingRepository.mainBookingsReverseChronologically();
ShortTemplateBookingResult result = buildShortTemplate(bookings, account -> account.isMainAccount);
model.addAttribute("balance", result.balance);
model.addAttribute("bookings", result.bookings);
return "intern/accounting/main";
}
}

View File

@ -0,0 +1,270 @@
package org.hso.ecommerce.controller.intern.accounting;
import java.util.Optional;
import org.hso.ecommerce.action.booking.CreateBookingAction;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.entities.booking.BookingReason;
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.hso.ecommerce.repos.supplier.SupplierRepository;
import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class ManualAccountingController {
@Autowired
final BookingRepository bookingRepository = null;
@Autowired
final BookingAccountEntryRepository bookingAccountEntryRepository = null;
@Autowired
final UserRepository userRepository = null;
@Autowired
final SupplierRepository supplierRepository = null;
/**
* Collection for the form values used to create a manual booking
*/
public static class ManualAccounting {
String amount;
String source;
String sourceCustomer;
String sourceSupplier;
String destination;
String destinationCustomer;
String destinationSupplier;
String reason;
String reasonText;
/**
* Default constructor with default values for the form
*/
public ManualAccounting() {
amount = "0.00";
reason = "Manual";
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getSourceCustomer() {
return sourceCustomer;
}
public void setSourceCustomer(String sourceCustomer) {
this.sourceCustomer = sourceCustomer;
}
public String getSourceSupplier() {
return sourceSupplier;
}
public void setSourceSupplier(String sourceSupplier) {
this.sourceSupplier = sourceSupplier;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public String getDestinationCustomer() {
return destinationCustomer;
}
public void setDestinationCustomer(String destinationCustomer) {
this.destinationCustomer = destinationCustomer;
}
public String getDestinationSupplier() {
return destinationSupplier;
}
public void setDestinationSupplier(String destinationSupplier) {
this.destinationSupplier = destinationSupplier;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getReasonText() {
return reasonText;
}
public void setReasonText(String reasonText) {
this.reasonText = reasonText;
}
}
/**
* An exception to represent errors that can be shown to the user
*/
public static class InvalidFormDataException extends Exception {
public InvalidFormDataException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
}
private boolean sameAccountBothSides(ManualAccounting formData) {
// No need to check for NumberFormatException because the numbers were already parsed before.
if (!formData.getSource().equals(formData.getDestination())) {
return false;
} else if (formData.getSource().equals("Cust")
&& Long.parseLong(formData.getSourceCustomer()) != Long.parseLong(formData.getDestinationCustomer())) {
return false;
} else if (formData.getSource().equals("Sup")
&& Long.parseLong(formData.getSourceSupplier()) != Long.parseLong(formData.getDestinationSupplier())) {
return false;
} else {
return true;
}
}
public Booking createBooking(ManualAccounting formData) throws InvalidFormDataException {
if (formData.getSource() == null) {
throw new InvalidFormDataException("Bitte wählen Sie ein Quellkonto aus.");
} else if (formData.getDestination() == null) {
throw new InvalidFormDataException("Bitte wählen Sie ein Zielkonto aus.");
}
BookingAccountEntry source = getAccountFromFormData(formData.getSource(), formData.getSourceCustomer(),
formData.getSourceSupplier());
BookingAccountEntry destination = getAccountFromFormData(formData.getDestination(),
formData.getDestinationCustomer(), formData.getDestinationSupplier());
if (sameAccountBothSides(formData)) {
throw new InvalidFormDataException("Quell- und Zielkonto dürfen nicht das selbe sein.");
}
double doubleAmount;
try {
doubleAmount = Double.parseDouble(formData.amount);
} catch (NumberFormatException e) {
throw new InvalidFormDataException("Der angegebene Betrag ist ungültig.");
}
int amountCent = (int) Math.round(doubleAmount * 100);
BookingReason reason = new BookingReason();
if (formData.getReason().equals("Start")) {
reason.isStartBooking = true;
} else if (formData.getReason().equals("Manual")) {
reason.isManuel = true;
} else {
throw new RuntimeException("Invalid form value for the booking reason: " + formData.getReason());
}
reason.comment = formData.reasonText;
CreateBookingAction action = new CreateBookingAction(source, destination, reason, amountCent);
return action.finish();
}
/**
* Retrieve the corresponding account based on user-input
*
* @param account The chosen value on the radio buttons
* @param customer The given customer id from the corresponding text field
* @param supplier the given supplier id from the corresponding text field
* @return The account entry that can be used to create the new booking
* @throws InvalidFormDataException If the user provided incorrect data in any way
*/
private BookingAccountEntry getAccountFromFormData(String account, String customer, String supplier)
throws InvalidFormDataException {
if (account.equals("None")) {
return null;
} else if (account.equals("Main")) {
return bookingAccountEntryRepository.getByMain().orElseGet(BookingAccountEntry::newMain);
} else if (account.equals("Vat")) {
return bookingAccountEntryRepository.getByVat().orElseGet(BookingAccountEntry::newVat);
} else if (account.equals("Cust")) {
long userId;
try {
userId = Long.parseLong(customer);
} catch (NumberFormatException e) {
throw new InvalidFormDataException("Die angegebene Kunden-Nr. ist ungültig.");
}
Optional<BookingAccountEntry> bookingAccount = bookingAccountEntryRepository.getByUser(userId);
if (!bookingAccount.isPresent()) {
bookingAccount = userRepository.findById(userId).map((user) -> BookingAccountEntry.newUser(user));
}
if (bookingAccount.isPresent()) {
return bookingAccount.get();
} else {
throw new InvalidFormDataException("Der Kunde Nr. " + userId + " konnte nicht gefunden werden.");
}
} else if (account.equals("Sup")) {
long supplierId;
try {
supplierId = Long.parseLong(supplier);
} catch (NumberFormatException e) {
throw new InvalidFormDataException("Die angegebene Lieferanten-Nr. ist ungültig.");
}
Optional<BookingAccountEntry> bookingAccount = bookingAccountEntryRepository.getBySupplier(supplierId);
if (!bookingAccount.isPresent()) {
bookingAccount = supplierRepository.findById(supplierId)
.map((sup) -> BookingAccountEntry.newSupplier(sup));
}
if (bookingAccount.isPresent()) {
return bookingAccount.get();
} else {
throw new InvalidFormDataException(
"Der Lieferant Nr. " + supplierId + " konnte nicht gefunden werden.");
}
} else {
throw new RuntimeException("Invalid form value for an account: " + account);
}
}
@GetMapping("/intern/accounting/addManual")
public String accountingAddManual(Model model) {
model.addAttribute("form_vals", new ManualAccounting());
return "intern/accounting/addManual";
}
@PostMapping("/intern/accounting/addManual")
public String accountingAddManualSubmit(Model model, @ModelAttribute ManualAccounting formData) {
Booking booking;
try {
booking = createBooking(formData);
bookingRepository.save(booking);
model.addAttribute("info", "Die Buchung wurde erfolgreich erstellt.");
model.addAttribute("form_vals", new ManualAccounting()); // Reply with empty form on success
} catch (InvalidFormDataException e) {
model.addAttribute("error", e.getMessage());
model.addAttribute("form_vals", formData);
}
return "intern/accounting/addManual";
}
}

View File

@ -1,8 +1,71 @@
package org.hso.ecommerce.controller.intern.customers;
import org.hso.ecommerce.action.user.CreateDeliveryData;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.uimodel.DeliveryData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import java.util.stream.Collectors;
@Controller
//@RequestMapping("...")
@RequestMapping("intern/customerOrders")
public class CustomerOrderController {
@Autowired
private final CustomerOrderRepository customerOrderRepository = null;
@Autowired
private final RestServiceForDelivery restServiceForDelivery = null;
@GetMapping("")
public String internCustomerOrder(Model model) {
List<CustomerOrder> orders = customerOrderRepository.getAllOrders();
List<CustomerOrderDelivery> customerOrderDeliveryDataMap = orders
.stream()
.map(o -> new CustomerOrderDelivery(o, CreateDeliveryData.getDeliveryDataFromCustomerOrder(o, customerOrderRepository, restServiceForDelivery)))
.collect(Collectors.toList());
model.addAttribute("orderDeliveryDataMap", customerOrderDeliveryDataMap);
return "intern/customerOrders/index";
}
static class CustomerOrderDelivery {
private CustomerOrder customerOrder;
private DeliveryData deliveryData;
public CustomerOrderDelivery(CustomerOrder customerOrder, DeliveryData deliveryData) {
this.customerOrder = customerOrder;
this.deliveryData = deliveryData;
}
public CustomerOrder getCustomerOrder() {
return customerOrder;
}
public DeliveryData getDeliveryData() {
return deliveryData;
}
}
@GetMapping("/{id}")
public String internCustomerOrdersId(Model model,
@PathVariable("id") String id
) {
CustomerOrder order = customerOrderRepository.findById(Long.parseLong(id)).get();
DeliveryData deliveryData = CreateDeliveryData.getDeliveryDataFromCustomerOrder(order, customerOrderRepository, restServiceForDelivery);
model.addAttribute("order", order);
model.addAttribute("deliveryData", deliveryData);
return "intern/customerOrders/id";
}
}

View File

@ -1,8 +1,118 @@
package org.hso.ecommerce.controller.intern.customers;
import org.hso.ecommerce.controller.intern.accounting.AccountingController;
import org.hso.ecommerce.controller.intern.accounting.AccountingController.ShortTemplateBookingResult;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Optional;
@Controller
//@RequestMapping("...")
@RequestMapping("/intern/customers")
public class CustomersIndexController {
@Autowired
private BookingRepository bookingRepository = null;
@Autowired
private final CustomerOrderRepository customerOrderRepository = null;
@Autowired
private final UserRepository userRepository = null;
@Autowired
private AccountingController accountingController = null;
@GetMapping("")
public String internCustomers(Model model) {
List<User> users = userRepository.findAll();
model.addAttribute("users", users);
return "intern/customers/index";
}
@GetMapping("/{id}")
public String internCustomersId(Model model,
@PathVariable("id") Long id,
HttpServletResponse response,
HttpServletRequest request
) {
Optional<User> optUser = userRepository.findById(id);
if (!optUser.isPresent()) {
request.setAttribute("error", "Der User wurde nicht gefunden.");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return "error/404";
}
User user = optUser.get();
model.addAttribute("user", user);
List<CustomerOrder> orders = customerOrderRepository.getOrdersByUserId(id);
model.addAttribute("orders", orders);
List<Booking> bookings = bookingRepository.customerBookingsReverseChronologically(id);
ShortTemplateBookingResult result = accountingController.buildShortTemplate(
bookings,
account -> account.userAccount != null && account.userAccount.id == id);
model.addAttribute("balance", result.balance);
model.addAttribute("bookings", result.bookings);
return "intern/customers/id";
}
@PostMapping("/{id}/changeState")
public String changeState(@PathVariable("id") Long id,
@RequestParam(value = "active", required = false) String active,
@RequestParam(value = "ma", required = false) String ma
) {
User user = userRepository.findById(id).get();
if (active == null)
user.isActive = false;
else
user.isActive = true;
if (ma == null)
user.isEmployee = false;
else
user.isEmployee = true;
userRepository.save(user);
return "redirect:/intern/customers/" + id.toString();
}
@PostMapping("/{id}/resetPassword")
public String resetPassword(@PathVariable("id") Long id,
@RequestParam("password") String password,
@RequestParam("password2") String password2,
HttpServletRequest request
) {
if (!password.equals(password2)) {
request.setAttribute("error", "Passwörter stimmen nicht überein!");
return "intern/customers/id";
}
User user = userRepository.findById(id).get();
if (!user.validatePassword(password)) {
request.setAttribute("error", "Die Passwörter stimmen nicht mit dem Original überein!");
return "intern/customers/id";
}
user.setPassword("12345");
userRepository.save(user);
request.setAttribute("info", "Passwort wurde auf 12345 geändert!");
return "intern/customers/id";
}
}

View File

@ -1,8 +1,157 @@
package org.hso.ecommerce.controller.intern.suppliers;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hso.ecommerce.controller.intern.accounting.AccountingController;
import org.hso.ecommerce.controller.intern.accounting.AccountingController.ShortTemplateBooking;
import org.hso.ecommerce.controller.intern.accounting.AccountingController.ShortTemplateBookingResult;
import org.hso.ecommerce.entities.booking.Booking;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
import org.hso.ecommerce.repos.supplier.SupplierRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
//@RequestMapping("...")
@RequestMapping("/intern/")
public class SupplierIndexController {
@Autowired
private final SupplierRepository supplierRepository = null;
@Autowired
private final SupplierOrderRepository supplierOrderRepository = null;
@Autowired
private final BookingRepository bookingRepository = null;
@Autowired
private final AccountingController accountingController = null;
@GetMapping("suppliers")
public String listSuppliers(Model model) {
List<UImodelSuppliers> totals = new ArrayList<UImodelSuppliers>();
for (Supplier supplier : supplierRepository.findAll()) {
UImodelSuppliers tmp = new UImodelSuppliers(supplier.id, supplier.name);
totals.add(tmp);
}
model.addAttribute("suppliers", totals);
return "intern/suppliers/index";
}
@GetMapping("/suppliers/{id}")
public String supplierDetail(Model model, @PathVariable String id) {
long supplierId = Long.parseLong(id);
// add orders from supplier to UImodel
List<UImodelSupplierDetailOrders> orders = new ArrayList<UImodelSupplierDetailOrders>();
for (SupplierOrder supplierOrder : supplierOrderRepository.findOrderBySupplierID(supplierId)) {
orders.add(new UImodelSupplierDetailOrders(supplierOrder));
}
// Table of bookings
List<Booking> bookings = bookingRepository.supplierBookingsReverseChronologically(supplierId);
ShortTemplateBookingResult bookingResult = accountingController.buildShortTemplate(bookings,
account -> account.supplierAccount != null && account.supplierAccount.id == supplierId);
UImodelSupplierDetail total = new UImodelSupplierDetail(supplierRepository.findSupplierById(supplierId).name,
bookingResult.balance, orders, bookingResult.bookings);
model.addAttribute("SupplierDetail", total);
return "intern/suppliers/id";
}
public class UImodelSuppliers {
public long id;
public String name;
public UImodelSuppliers(long id, String name) {
this.id = id;
this.name = name;
}
}
public class UImodelSupplierDetail {
public String name;
public String balance;
public List<UImodelSupplierDetailOrders> orders;
public List<ShortTemplateBooking> bookings;
public UImodelSupplierDetail(String name, String balance, List<UImodelSupplierDetailOrders> orders,
List<ShortTemplateBooking> bookings
) {
this.name = name;
this.balance = balance;
this.orders = orders;
this.bookings = bookings;
}
}
public class UImodelSupplierDetailOrders {
public long id;
public String dateOrder;
public String articleName;
public long articleId;
public String priceNet;
public String quantity;
public String priceTotal;
public boolean arrived;
public UImodelSupplierDetailOrders(SupplierOrder order) {
this.id = order.id;
this.articleName = order.ordered.title;
this.articleId = order.ordered.id;
this.priceNet = String.format("%.2f", ((float) order.pricePerUnitNetCent / 100));
this.quantity = String.valueOf(order.numberOfUnits);
this.priceTotal = String.format("%.2f", ((float) order.totalPriceNet / 100));
Date date = new Date();
date.setTime(order.created.getTime());
this.dateOrder = new SimpleDateFormat("dd.MM.yyyy").format(date);
if (order.delivered != null) {
arrived = true;
} else {
arrived = false;
}
}
}
public class UImodelSupplierDetailBookings {
public String dateBooking;
public String price;
public String srcName;
public String balance;
public String reason;
public long orderID;
public UImodelSupplierDetailBookings(Booking booking) {
Date date = new Date();
date.setTime(booking.reason.supplierOrder.created.getTime());
this.dateBooking = new SimpleDateFormat("dd.MM.yyyy").format(date);
this.price = String.format("%.2f", ((float) booking.amountCent / 100));
this.srcName = ((booking.source.isMainAccount) ? "Hauptkonto" : booking.source.supplierAccount.name);
this.balance = String.format("%.2f", ((float) booking.destination.newSumCent / 100));
this.reason = booking.reason.comment;
this.orderID = booking.reason.supplierOrder.id;
}
}
}

View File

@ -29,8 +29,8 @@ public class SupplierOfferController {
List<UImodelOfferedArticle> totals = new ArrayList<>();
for (ArticleOffer article : offersRepository.findAll()) {
UImodelOfferedArticle tmp = new UImodelOfferedArticle();
tmp.addData(article, articleRepository.findArticleIDByRelatedID(article.id));
UImodelOfferedArticle tmp = new UImodelOfferedArticle(article,
articleRepository.findArticleIDByRelatedID(article.id));
totals.add(tmp);
}
@ -40,95 +40,27 @@ public class SupplierOfferController {
public class UImodelOfferedArticle {
long offer_id;
String title;
String manufacturer;
String articlenumber;
String supplierName;
String price;
String ads;
int listedArticleId;
boolean offerIsListed; // true --> offered article is listed
public long offerId;
public String title;
public String manufacturer;
public String articleNumber;
public String supplierName;
public String price;
public String ads;
public int listedArticleId;
public boolean offerIsListed; // true --> offered article is listed
public long getOffer_id() {
return offer_id;
}
public UImodelOfferedArticle(ArticleOffer article, Optional<Integer> listedArticleId) {
public void setOffer_id(long offer_id) {
this.offer_id = offer_id;
}
public boolean isOfferIsListed() {
return offerIsListed;
}
public void setOfferIsListed(boolean offerIsListed) {
this.offerIsListed = offerIsListed;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getArticlenumber() {
return articlenumber;
}
public void setArticlenumber(String articlenumber) {
this.articlenumber = articlenumber;
}
public String getSupplierName() {
return supplierName;
}
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getAds() {
return ads;
}
public void setAds(String ads) {
this.ads = ads;
}
public int getListedArticleId() {
return listedArticleId;
}
public void setListedArticleId(int listedArticleId) {
this.listedArticleId = listedArticleId;
}
public void addData(ArticleOffer article, Optional<Integer> listedArticleId) {
this.offer_id = article.id;
this.offerId = article.id;
this.title = article.title;
this.manufacturer = article.manufacturer;
this.articlenumber = article.articleNumber;
this.articleNumber = article.articleNumber;
if (article.cheapestSupplier != null) {
this.supplierName = article.cheapestSupplier.name;
} else {
this.supplierName = "-";
}
this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100));
this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein";

View File

@ -1,8 +1,142 @@
package org.hso.ecommerce.controller.intern.suppliers;
import org.hso.ecommerce.action.warehouse.SupplierOrderArrivedAction;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import org.hso.ecommerce.repos.shop.ArticleRepository;
import org.hso.ecommerce.repos.supplier.SupplierOrderRepository;
import org.hso.ecommerce.repos.warehouse.SlotRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Controller
//@RequestMapping("...")
@RequestMapping("/intern/")
public class SupplierOrderController {
@Autowired
private final SupplierOrderRepository supplierOrderRepository = null;
@Autowired
private final ArticleRepository articleRepository = null;
@Autowired
private final WarehouseBookingPositionSlotEntryRepository warehouseBookingPositionSlotEntryRepository = null;
@Autowired
private final WarehouseBookingRepository warehouseBookingRepository = null;
@Autowired
private final SlotRepository slotRepository = null;
@GetMapping("supplierOrders")
public String listSuppliers(Model model) {
List<UImodelSupplierOrder> totals = new ArrayList<UImodelSupplierOrder>();
for (SupplierOrder order : supplierOrderRepository.findAllDesc()) {
final Article article = articleRepository.findArticleByArticleOffer(order.ordered).orElse(null);
totals.add(new UImodelSupplierOrder(order, article));
}
model.addAttribute("orders", totals);
return "intern/supplierOrders/index";
}
@PostMapping("/supplierOrders/store/{id}")
public String storeOrder(@PathVariable("id") Long supplierOrderID, Model model, HttpServletResponse response) {
SupplierOrder order = supplierOrderRepository.findById(supplierOrderID).orElse(null);
if (order == null) {
model.addAttribute("error", "Die ausgewählte Lieferung konnte nicht gefunden werden.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return listSuppliers(model);
}
if (order.wasDelivered()) {
model.addAttribute("error", "Die ausgewählte Lieferung wurde schon zugestellt.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return listSuppliers(model);
}
final Article article = articleRepository.findArticleByArticleOffer(order.ordered).orElse(null);
if (article == null) {
model.addAttribute("error", "Der bestellte Artikel wurde nicht angelegt, er hätte nicht bestellt werden dürfen.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return listSuppliers(model);
}
// Hard to do efficiently, this should be fine.
List<WarehouseBookingPositionSlotEntry> candidates = slotRepository
.findAll()
.stream()
.map(slot ->
warehouseBookingPositionSlotEntryRepository.getBySlotNum(slot.slotNum).orElseGet(() ->
WarehouseBookingPositionSlotEntry.empty(article, slot)
)
)
.filter(entry -> entry.article.id == article.id || entry.newSumSlot == 0)
.collect(Collectors.toList());
SupplierOrderArrivedAction action = new SupplierOrderArrivedAction(candidates, order, article);
try {
SupplierOrderArrivedAction.Result result = action.finish();
supplierOrderRepository.save(result.getOrder());
warehouseBookingRepository.save(result.getBooking());
} catch (SupplierOrderArrivedAction.NoSpaceInWarehouseException e) {
e.printStackTrace();
}
return "redirect:/intern/warehouse/todo";
}
public class UImodelSupplierOrder {
public long id;
public String dateOrder;
public String supplierName;
public String articleName;
public long articleId;
public String priceNet;
public String quantity;
public String priceTotal;
public boolean arrived;
public String carrier;
public String trackingId;
public String estimatedArrival;
public UImodelSupplierOrder(SupplierOrder order, Article article) {
this.id = order.id;
this.supplierName = order.supplier.name;
this.articleName = article != null ? article.title : "error";
this.articleId = article != null ? article.id : 0;
this.priceNet = String.format("%.2f", ((float) order.pricePerUnitNetCent / 100));
this.quantity = String.valueOf(order.numberOfUnits);
this.priceTotal = String.format("%.2f", ((float) order.totalPriceNet / 100));
this.carrier = order.carrier != null ? order.carrier : " - ";
this.trackingId = order.trackingId != null ? order.trackingId : " - ";
this.estimatedArrival = order.estimatedArrival != null
? new SimpleDateFormat("yyyy.MM.dd HH:00").format(order.estimatedArrival) + " Uhr"
: " - ";
this.dateOrder = new SimpleDateFormat("yyyy.MM.dd").format(order.created);
arrived = order.delivered != null;
}
}
}

View File

@ -0,0 +1,140 @@
package org.hso.ecommerce.controller.intern.warehouse;
import org.hso.ecommerce.action.warehouse.CreateManuelBookingAction;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.warehouse.Slot;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import org.hso.ecommerce.repos.shop.ArticleRepository;
import org.hso.ecommerce.repos.warehouse.SlotRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Optional;
@Controller
@RequestMapping("/intern/warehouse/")
public class ManuelBookingController {
@Autowired
private final ArticleRepository articleRepository = null;
@Autowired
private final SlotRepository slotRepository = null;
@Autowired
private final WarehouseBookingPositionSlotEntryRepository warehouseBookingPositionSlotEntryRepository = null;
@Autowired
private final WarehouseBookingRepository warehouseBookingRepository = null;
@GetMapping("addManual")
public String warehouseAddManual(
Model model
) {
model.addAttribute("articles", articleRepository.findAll());
model.addAttribute("slots", slotRepository.findAll());
return "intern/warehouse/addManual";
}
@PostMapping("addManual")
public String warehouseAddMaualPost(
Model model,
HttpServletRequest request,
HttpServletResponse response,
@RequestParam("articleId") String articleIdText,
@RequestParam("amount") Integer amount,
@RequestParam("reason") String reason,
@RequestParam("sourceIsSlot") Boolean sourceIsSlot,
@RequestParam("sourceSlot") Integer sourceSlotNum,
@RequestParam("destinationIsSlot") Boolean destinationIsSlot,
@RequestParam("destinationSlot") Integer destinationSlotNum
) {
// The suggestions for articleId in the UI show articles names, seperated by a " - ".
// The Number must be extracted first.
long articleId = -1;
try {
articleId = Long.parseLong(articleIdText.split(" - ", 2)[0].trim());
} catch (NumberFormatException e) {
model.addAttribute("error", "Die Artikel Id konnte nicht erkannt werden.");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return "intern/warehouse/addManual";
}
Optional<Article> optionalArticle = articleRepository.findById(articleId);
Article article = null;
if (!optionalArticle.isPresent()) {
model.addAttribute("error", "Der Artikel konnte nicht gefunden werden.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
} else {
article = optionalArticle.get();
}
if (amount <= 0) {
model.addAttribute("error", "Eine Anzahl <= 0 kann nicht verbucht werden.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
}
if (sourceIsSlot == false && destinationIsSlot == false) {
model.addAttribute("error", "Jede Buchung benötigt ein Ziel oder eine Quelle.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
}
Optional<WarehouseBookingPositionSlotEntry> sourceSlot = Optional.empty();
if (sourceIsSlot == true) {
sourceSlot = warehouseBookingPositionSlotEntryRepository.getBySlotNum(sourceSlotNum);
if (!sourceSlot.isPresent()) {
request.setAttribute("error", "Quelllagerplatz wurde nicht gefunden oder ist leer.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
}
}
Optional<WarehouseBookingPositionSlotEntry> destinationSlot = Optional.empty();
if (destinationIsSlot == true) {
Optional<Slot> slot = slotRepository.findBySlotNum(destinationSlotNum);
if (!slot.isPresent()) {
request.setAttribute("error", "Ziellagerplatz wurde nicht gefunden.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
}
Article finalArticle = article;
destinationSlot = Optional.of(warehouseBookingPositionSlotEntryRepository.getBySlotNum(destinationSlotNum).orElseGet(
() -> WarehouseBookingPositionSlotEntry.empty(finalArticle, slot.get())
));
}
try {
warehouseBookingRepository.save(
new CreateManuelBookingAction(article, amount, sourceSlot, destinationSlot, reason).finish()
);
} catch (CreateManuelBookingAction.ArticleSlotConstraintArticleTypeFailedException e) {
model.addAttribute("error", "Es befindet sich der falsche Artikeltyp in Quell- oder Ziellagerplatz. ");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
} catch (CreateManuelBookingAction.ArticleSlotConstraintFailedException e) {
model.addAttribute("error", "Die maximale Anzahl an lagerbaren Artikeln im Ziellagerplatz wurde überschritten.");
response.setStatus(HttpServletResponse.SC_EXPECTATION_FAILED);
return "intern/warehouse/addManual";
}
return "redirect:/intern/warehouse/todo";
}
}

View File

@ -0,0 +1,46 @@
package org.hso.ecommerce.controller.intern.warehouse;
import org.hso.ecommerce.action.warehouse.CalculateWarehouseStatsAction;
import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry;
import org.hso.ecommerce.repos.warehouse.SlotRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;
@Controller
@RequestMapping("/intern/warehouse/")
public class SlotsController {
@Autowired
private final WarehouseBookingPositionSlotEntryRepository warehouseBookingPositionSlotEntryRepository = null;
@Autowired
private final SlotRepository slotRepository = null;
@GetMapping("slots/")
public String accountingWarehouseSlots(
Model model,
HttpServletRequest request
) {
// Doing this in a single would be hard and error prone.
// Writing native queries should be minimized.
// Therefore this method was prefered
List<WarehouseBookingPositionSlotEntry> entries = slotRepository.findAll().stream().map(
s -> warehouseBookingPositionSlotEntryRepository
.getBySlotNum(s.slotNum)
.orElseGet(() -> WarehouseBookingPositionSlotEntry.empty(null, s))
).collect(Collectors.toList());
model.addAttribute("entries", entries);
model.addAttribute("stats", new CalculateWarehouseStatsAction(entries).finish());
return "intern/warehouse/slots/index";
}
}

View File

@ -0,0 +1,124 @@
package org.hso.ecommerce.controller.intern.warehouse;
import org.hso.ecommerce.action.shop.EnableTrackingAction;
import org.hso.ecommerce.api.RestServiceForDelivery;
import org.hso.ecommerce.entities.warehouse.WarehouseBooking;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.ResourceAccessException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Optional;
@Controller
@RequestMapping("/intern/warehouse/")
public class TodoController {
@Autowired
private final WarehouseBookingRepository warehouseBookingRepository = null;
@Autowired
private final RestServiceForDelivery deliveryService = null;
@GetMapping("todo")
public String accountingWarehouseTodo(
Model model
) {
model.addAttribute("bookings", warehouseBookingRepository.findNotDone());
return "intern/warehouse/todo";
}
@PostMapping("progress/{id}")
public String postProgressId(
Model model,
HttpServletRequest request,
HttpServletResponse response,
@PathVariable("id") Long id
) {
Optional<WarehouseBooking> booking = warehouseBookingRepository.findById(id);
if (!booking.isPresent()) {
model.addAttribute("error", "Die Buchung wurde nicht gefunden.");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return "error/404";
}
if (booking.get().isInProgress) {
response.setStatus(409);
return "intern/warehouse/error_progress_failed";
}
booking.get().isInProgress = true;
warehouseBookingRepository.save(booking.get());
return "redirect:/intern/warehouse/progress/" + id;
}
@PostMapping("progress/{id}/finish")
public String postProgressIdFinish(
Model model,
HttpServletRequest request,
HttpServletResponse response,
@PathVariable("id") Long id
) {
Optional<WarehouseBooking> booking = warehouseBookingRepository.findById(id);
if (!booking.isPresent()) {
model.addAttribute("error", "Die Buchung wurde nicht gefunden.");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return "error/404";
}
booking.get().isInProgress = true;
booking.get().isDone = true;
// Update Delivery Date
if (booking.get().reason.customerOrder != null) {
try{
EnableTrackingAction.addTrackingInfo(deliveryService, booking.get().reason.customerOrder);
}
catch(ResourceAccessException e)
{
return "error/500";
}
}
warehouseBookingRepository.save(booking.get());
return "redirect:/intern/warehouse/todo";
}
@GetMapping("progress/{id}")
public String getProgressId(Model model,
HttpServletRequest request,
HttpServletResponse response,
@PathVariable("id") Long id) {
Optional<WarehouseBooking> booking = warehouseBookingRepository.findById(id);
if (!booking.isPresent()) {
model.addAttribute("error", "Die Buchung wurde nicht gefunden.");
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
return "error/404";
}
if (booking.get().isDone) {
model.addAttribute("info", "Die Buchung wurde schon abgeschlossen.");
}
if (!booking.get().isInProgress) {
// Only reachable if path is manipulated.
model.addAttribute("error", "Die Buchung wurde noch nicht zugewiesen!");
}
model.addAttribute("booking", booking.get());
return "intern/warehouse/id_progress";
}
}

View File

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -51,7 +52,11 @@ public class ShopArticleController {
}
model.addAttribute("article", article);
if (warehouseBookingPositionSlotEntryRepository.getByArticle(id).get(0).newSumSlot > 0) { //check if in Stock
if (warehouseBookingPositionSlotEntryRepository
.getByArticle(id)
.stream()
.mapToInt(e -> e.newSumSlot)
.sum() > 0) { //check if in Stock
model.addAttribute("inStock", true);
} else {
model.addAttribute("inStock", false);
@ -102,9 +107,16 @@ public class ShopArticleController {
Article article = articleRepository.findArticleById(id);
if(article.image != null) {
InputStream in = new FileInputStream(article.image.path);
File file = new File(article.image.path);
File allowedPath = new File("./data/img/");
if (file.getCanonicalPath().startsWith(allowedPath.getCanonicalPath())) {
InputStream in = new FileInputStream(file);
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
IOUtils.copy(in, response.getOutputStream());
} else {
throw new RuntimeException("Got illegal file path. DB was modified.");
}
}
}
}

View File

@ -1,7 +1,6 @@
package org.hso.ecommerce.controller.shop;
import org.hso.ecommerce.action.shop.CreateOrderAction;
import org.hso.ecommerce.action.shop.EnableTrackingAction;
import org.hso.ecommerce.entities.booking.BookingAccountEntry;
import org.hso.ecommerce.entities.booking.PaymentMethod;
import org.hso.ecommerce.entities.shop.Address;
@ -11,7 +10,7 @@ import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository;
import org.hso.ecommerce.repos.booking.BookingRepository;
import org.hso.ecommerce.repos.shop.ArticleRepository;
import org.hso.ecommerce.repos.shop.CustomerOderRepository;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
import org.hso.ecommerce.repos.user.UserRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository;
@ -45,7 +44,7 @@ public class ShopCheckoutController {
private final WarehouseBookingRepository warehouseBookingRepository = null;
@Autowired
private final CustomerOderRepository customerOderRepository = null;
private final CustomerOrderRepository customerOderRepository = null;
@Autowired
private final WarehouseBookingPositionSlotEntryRepository wbeseRepo = null;
@ -110,7 +109,7 @@ public class ShopCheckoutController {
) {
if (shoppingCart.getRevision() != cartRevision) {
request.setAttribute("error", "Der Warenkorb wurde zwischenzeitlich bearbeitet. Daher die Kaufvorgang nicht abgeschlossen werden. Bitte versuchen Sie es erneut.");
request.setAttribute("error", "Der Warenkorb wurde zwischenzeitlich bearbeitet. Daher konnte der Kaufvorgang nicht abgeschlossen werden. Bitte versuchen Sie es erneut.");
response.setStatus(HttpServletResponse.SC_CONFLICT);
return "shop/checkout";
}
@ -122,7 +121,7 @@ public class ShopCheckoutController {
user,
expectedPrice,
Address.fromString(address),
PaymentMethod.fromCreditCarNumber(cardnumber),
PaymentMethod.fromCreditCardNumber(cardnumber),
bookingEntryRepository.getByUser(user.id).orElse(BookingAccountEntry.newUser(user)),
bookingEntryRepository.getByVat().orElse(BookingAccountEntry.newVat()),
bookingEntryRepository.getByMain().orElse(BookingAccountEntry.newMain())
@ -136,7 +135,6 @@ public class ShopCheckoutController {
CreateOrderAction.Result result = null;
try {
result = action.finish();
EnableTrackingAction.addTrackingInfo(result.customerOrder);
customerOderRepository.save(result.customerOrder);
bookingRepository.saveAll(result.bookings);

View File

@ -7,7 +7,9 @@ import org.hso.ecommerce.repos.shop.CategoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -32,9 +34,8 @@ public class ShopSearchController {
) {
model.addAttribute("categories", categoryRepository.getCategories()); //for sidebar
term = term.trim();
if (term != null) { //if search by Term
term = term.trim();
List<Article> articles = SearchByTermAction.searchByTerm(term, articleRepository);
model.addAttribute("articles", articles);
} else if (category != null) { //if search by Category
@ -46,6 +47,9 @@ public class ShopSearchController {
return "error/404";
}
return "/shop/search";
// Show term in search box
model.addAttribute("searchterm", term != null ? term : "");
return "shop/search";
}
}

View File

@ -1,6 +1,7 @@
package org.hso.ecommerce.entities.booking;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Entity
@Table(name = "bookings")
@ -14,6 +15,9 @@ public class Booking {
// always >= 0
public int amountCent;
@NotNull
public java.sql.Timestamp created;
@ManyToOne(optional = true, cascade = CascadeType.ALL)
public BookingAccountEntry source;

View File

@ -1,6 +1,7 @@
package org.hso.ecommerce.entities.booking;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import javax.persistence.*;
@ -28,6 +29,9 @@ public class BookingReason {
@ManyToOne(optional = true)
public SupplierOrder supplierOrder;
@ManyToOne(optional = true)
public Supplier supplierPayment;
// Default Constructor is needed for construction by ORM
public BookingReason() {
}
@ -40,7 +44,16 @@ public class BookingReason {
this.customerPayment = customerPayment;
}
public BookingReason(Supplier supplierPayment) {
this.supplierPayment = supplierPayment;
}
public BookingReason(SupplierOrder supplierOrder) {
this.supplierOrder = supplierOrder;
}
public BookingReason(String comment) {
this.isManuel = true;
this.comment = comment;
}
}

View File

@ -7,7 +7,7 @@ public class PaymentMethod {
public String creditCardNumber;
public static PaymentMethod fromCreditCarNumber(String cardnumber) {
public static PaymentMethod fromCreditCardNumber(String cardnumber) {
PaymentMethod m = new PaymentMethod();
m.creditCardNumber = cardnumber;

View File

@ -9,6 +9,7 @@ public class BackgroundJob {
public static final String JOB_DASHBOARD = "Dashboard";
public static final String JOB_REORDER = "SupplierOrder";
public static final String JOB_SUPPLIER_AUTO_PAYMENT = "SupplierAutoPayment";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@ -15,11 +15,18 @@ public class DashboardSummary {
@NotNull
public java.sql.Date created;
public int todaysCustomers;
public int todaysCustomersOrders;
public int todaysSuppliersOrders;
public int todaysItemsSold;
public int todaysSalesCent;
public int totalWarehouseCapacity;
public int currentWarehouseCapacity;
@NotNull
public Integer todaysNewCustomers;
@NotNull
public Integer todaysCustomersOrders;
@NotNull
public Integer todaysSalesCent;
@NotNull
public Double currentWarehouseCapacity;
@NotNull
public Double todaysWarehouseCapacity;
}

View File

@ -16,7 +16,7 @@ public class Article {
@Basic
public long id;
@ManyToOne(optional = false)
@OneToOne(optional = false)
public ArticleOffer related;
public int shopPricePerUnitNetCent;

View File

@ -4,6 +4,7 @@ import org.hso.ecommerce.entities.user.User;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@ -31,7 +32,7 @@ public class CustomerOrder {
@NotNull
public java.sql.Timestamp created;
@NotNull
@Column(nullable = true)
public String trackingId;
@Column(nullable = true)
@ -43,4 +44,16 @@ public class CustomerOrder {
public int totalNetCent;
public int totalGrossCent;
public int totalVatCent;
public String formatInDeliverySince(){
return new SimpleDateFormat("dd.MM.yyyy HH:mm").format(inDeliverySince);
}
public String formatCreated(){
return new SimpleDateFormat("dd.MM.yyyy HH:mm").format(created);
}
public String formatDeliveredAt(){
return new SimpleDateFormat("dd.MM.yyyy HH:mm").format(deliveredAt);
}
}

View File

@ -19,4 +19,8 @@ public class CustomerOrderPosition {
public int pricePerUnit;
public int quantity;
public int getSumPrice(){
return article.getPriceGross() * quantity;
}
}

View File

@ -28,6 +28,15 @@ public class SupplierOrder {
// Includes discounts
public int totalPriceNet;
@Column(nullable = true)
public String carrier;
@Column(nullable = true)
public String trackingId;
@Column(nullable = true)
public Timestamp estimatedArrival;
@Column(nullable = true)
public Timestamp delivered;

View File

@ -24,6 +24,8 @@ public class User {
@Column(unique = true)
public String email;
public String salutation;
public String passwordHash;
public boolean isActive;

View File

@ -25,7 +25,12 @@ public class WarehouseBookingPositionSlotEntry {
@ManyToOne
public Slot slot;
public WarehouseBookingPositionSlotEntry copyAddAmount(int amount) {
public WarehouseBookingPositionSlotEntry copyAddAmount(int amount, Article article) {
// Article can be changed if newSumSlot == 0.
if (this.newSumSlot != 0 && this.article.id != article.id) {
throw new IllegalArgumentException("Article does not match.");
}
WarehouseBookingPositionSlotEntry e = new WarehouseBookingPositionSlotEntry();
e.article = article;
@ -38,4 +43,14 @@ public class WarehouseBookingPositionSlotEntry {
return e;
}
public static WarehouseBookingPositionSlotEntry empty(Article article, Slot slot) {
WarehouseBookingPositionSlotEntry e = new WarehouseBookingPositionSlotEntry();
e.article = article;
e.slot = slot;
e.newSumSlot = 0;
return e;
}
}

View File

@ -1,34 +0,0 @@
package org.hso.ecommerce.entities.warehouse;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import javax.persistence.*;
@Entity
@Table(name = "warehouse_booking_reasons")
public class WarehouseBookingReason {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic
public long id;
public String comment;
@ManyToOne(optional = true)
public SupplierOrder causeSupplierOrder;
@ManyToOne(optional = true)
public CustomerOrder customerOrder;
public boolean isManuel;
// Default Constructor is needed for construction by ORM
public WarehouseBookingReason() {
}
public WarehouseBookingReason(CustomerOrder order) {
this.customerOrder = order;
}
}

View File

@ -1,12 +1,28 @@
package org.hso.ecommerce.repos.booking;
import java.util.List;
import org.hso.ecommerce.entities.booking.Booking;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface BookingRepository extends JpaRepository<Booking, Long> {
@Query("SELECT b FROM Booking b ORDER BY b.id DESC")
List<Booking> allBookingsReverseChronologically();
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.isMainAccount = 1 OR d.isMainAccount = 1 ORDER BY b.id DESC")
List<Booking> mainBookingsReverseChronologically();
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.isVATAccount = 1 OR d.isVATAccount = 1 ORDER BY b.id DESC")
List<Booking> vatBookingsReverseChronologically();
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.userAccount.id = :customerId OR d.userAccount.id = :customerId ORDER BY b.id DESC")
List<Booking> customerBookingsReverseChronologically(long customerId);
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.supplierAccount.id = :supplierId OR d.supplierAccount.id = :supplierId ORDER BY b.id DESC")
List<Booking> supplierBookingsReverseChronologically(long supplierId);
}

View File

@ -0,0 +1,20 @@
package org.hso.ecommerce.repos.dashboard;
import org.hso.ecommerce.entities.dashboard.DashboardSummary;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface DashboardSummaryRepository extends JpaRepository<DashboardSummary, Long> {
@Query("SELECT ds FROM DashboardSummary ds ORDER BY ds.id DESC")
List<DashboardSummary> findInTimespan(
Pageable pageable
);
}

View File

@ -1,6 +1,7 @@
package org.hso.ecommerce.repos.shop;
import org.hso.ecommerce.entities.shop.Article;
import org.hso.ecommerce.entities.supplier.ArticleOffer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
@ -12,30 +13,41 @@ import java.util.Optional;
@Repository
public interface ArticleRepository extends JpaRepository<Article, Long> {
/***
* use findById instead.
*/
@Deprecated
@Query("SELECT a FROM Article a WHERE a.id = :articleId")
Article findArticleById(@Param("articleId") long articleId);
@Query("SELECT a FROM Article a")
List<Article> findAll();
@Query(value = "Select a.* from articles as a, article_offers as ao, warehouse_booking_position_entries as wbpe where a.related_id = ao.id and wbpe.article_id = a.id and ao.should_be_advertised = true group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
@Query(value = "SELECT DISTINCT a.* from articles as a, article_offers as ao, warehouse_booking_position_entries as wbpe where a.related_id = ao.id and wbpe.article_id = a.id and ao.should_be_advertised = true group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
List<Article> getAdvertisedArticles();
@Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a ORDER BY co.id DESC")
List<Article> getOrderedArticles();
@Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a WHERE c.id = :customerId ORDER BY co.id DESC")
@Query("SELECT DISTINCT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a WHERE c.id = :customerId ORDER BY co.id DESC")
List<Article> getOrderedArticles(long customerId);
/***
* use type safe findArticleByArticleOffer instead.
*/
@Deprecated
@Query(value = "SELECT a.id FROM articles a WHERE a.related_id = :relatedId", nativeQuery = true)
Optional<Integer> findArticleIDByRelatedID(@Param("relatedId") long relatedId);
@Query(value = "SELECT a FROM Article a Where a.related = :related")
Optional<Article> findArticleByArticleOffer(ArticleOffer related);
@Query(value = "Select a.* from articles as a, warehouse_booking_position_entries as wbpe where wbpe.article_id = a.id and a.title LIKE %:term% group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
List<Article> getArticlesByTermInTitle(String term);
@Query(value = "Select a.* from articles as a, warehouse_booking_position_entries as wbpe where wbpe.article_id = a.id and a.description LIKE %:term% group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
List<Article> getArticlesByTermInDescription(String term);
@Query(value = "Select a.* from articles as a, categories as c, article_categories_bindings as acb, warehouse_booking_position_entries as wbpe where wbpe.article_id = a.id and acb.articles_id = a.id and acb.categories_id = c.id and c.name = :category group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
@Query(value = "Select distinct a.* from articles as a, categories as c, article_categories_bindings as acb, warehouse_booking_position_entries as wbpe where wbpe.article_id = a.id and acb.articles_id = a.id and acb.categories_id = c.id and c.name = :category group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
List<Article> getArticlesByCategory(String category);
}

View File

@ -1,17 +0,0 @@
package org.hso.ecommerce.repos.shop;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface CustomerOderRepository extends JpaRepository<CustomerOrder, Long> {
@Query("SELECT SUM(cop.quantity) FROM CustomerOrderPosition cop JOIN cop.order co WHERE cop.article.id = :articleId AND co.created >= :begin AND co.created < :end")
Integer countOrdersOfArticleInTimespan(
long articleId, java.sql.Timestamp begin, java.sql.Timestamp end
);
}

View File

@ -0,0 +1,34 @@
package org.hso.ecommerce.repos.shop;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Long> {
@Query("SELECT SUM(cop.quantity) FROM CustomerOrderPosition cop JOIN cop.order co WHERE cop.article.id = :articleId AND co.created >= :begin AND co.created < :end")
Integer countOrdersOfArticleInTimespan(
long articleId, java.sql.Timestamp begin, java.sql.Timestamp end
);
@Query("SELECT co FROM CustomerOrder co ORDER BY co.id DESC")
List<CustomerOrder> getAllOrders();
@Query("SELECT co FROM CustomerOrder co WHERE co.customer.id = :userId ORDER BY co.id DESC")
List<CustomerOrder> getOrdersByUserId(long userId);
@Query("SELECT COUNT(co.id) FROM CustomerOrder co WHERE co.created >= :begin AND co.created < :end")
Integer countOrdersInTimespan(
java.sql.Timestamp begin, java.sql.Timestamp end
);
@Query("SELECT SUM(co.totalGrossCent) FROM CustomerOrder co WHERE co.created >= :begin AND co.created < :end")
Integer countTurnoverInTimespan(
java.sql.Timestamp begin, java.sql.Timestamp end
);
}

View File

@ -3,12 +3,23 @@ package org.hso.ecommerce.repos.supplier;
import org.hso.ecommerce.entities.supplier.SupplierOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SupplierOrderRepository extends JpaRepository<SupplierOrder, Long> {
@Query("SELECT SUM(so.numberOfUnits) FROM SupplierOrder so JOIN so.ordered ao WHERE ao.articleNumber = :articleNumber AND so.delivered IS NULL")
Integer countUndeliveredReorders(String articleNumber);
@Query(value = "SELECT * FROM supplier_orders as a WHERE a.supplier_id = :supplierId ORDER BY a.id DESC", nativeQuery = true)
List<SupplierOrder> findOrderBySupplierID(@Param("supplierId") long supplierId);
@Query("SELECT a FROM SupplierOrder a")
List<SupplierOrder> findAll();
@Query("SELECT a FROM SupplierOrder a ORDER BY a.id DESC")
List<SupplierOrder> findAllDesc();
}

View File

@ -2,9 +2,22 @@ package org.hso.ecommerce.repos.supplier;
import org.hso.ecommerce.entities.supplier.Supplier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface SupplierRepository extends JpaRepository<Supplier, Long> {
@Query("SELECT a FROM Supplier a")
List<Supplier> findAll();
@Query("SELECT a FROM Supplier a WHERE a.id = :supplierId")
Supplier findSupplierById(@Param("supplierId") long supplierId);
@Query("SELECT a FROM Supplier a WHERE a.uuid = :uuid")
Optional<Supplier> findByUuid(@Param("uuid") String uuid);
}

View File

@ -13,6 +13,11 @@ public interface UserRepository extends JpaRepository<User, Long> {
@Query("SELECT c FROM User c WHERE c.email = :email")
Optional<User> findByEmail(String email);
@Query("SELECT COUNT(c.id) FROM User c WHERE c.created >= :begin AND c.created < :end AND c.isEmployee = false")
Integer countUsersInTimespan(
java.sql.Timestamp begin, java.sql.Timestamp end
);
@Query("SELECT count(*) FROM User WHERE isEmployee = true")
Optional<Integer> numberOfEmployees();
}

View File

@ -11,12 +11,11 @@ import java.util.Optional;
@Repository
public interface WarehouseBookingPositionSlotEntryRepository extends JpaRepository<WarehouseBookingPositionSlotEntry, Long> {
@Query(value = "Select e.id, e.article_id, e.new_sum_slot, e.slot_id from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND e.article_id = :article GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true)
@Query(value = "Select e.* from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND e.article_id = :article GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true)
List<WarehouseBookingPositionSlotEntry> getByArticle(long article);
@Query(value = "SELECT SUM(w.new_sum_slot) FROM warehouse_booking_position_entries as w WHERE w.article_id = :articleid", nativeQuery = true)
Optional<Integer> getArticleStock(long articleid);
@Query(value = "Select e.* from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND s.slot_num = :slotnum GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true)
Optional<WarehouseBookingPositionSlotEntry> getBySlotNum(long slotnum);
}

View File

@ -2,10 +2,19 @@ package org.hso.ecommerce.repos.warehouse;
import org.hso.ecommerce.entities.warehouse.WarehouseBooking;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface WarehouseBookingRepository extends JpaRepository<WarehouseBooking, Long> {
@Query("Select b FROM WarehouseBooking b WHERE b.isDone = 0")
List<WarehouseBooking> findNotDone();
@Query("Select b FROM WarehouseBooking b ORDER BY b.id DESC")
List<WarehouseBooking> findAllDesc();
}

View File

@ -0,0 +1,57 @@
package org.hso.ecommerce.uimodel;
import com.fasterxml.jackson.annotation.JsonCreator;
public class DeliveryData
{
private final String status;
private final DeliveryDataEnum deliveryDataEnum;
private final String estimatedArrival;
private boolean isDelivered;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public DeliveryData(String status, String estimatedArrival) {
this.status = status;
this.estimatedArrival = estimatedArrival;
this.deliveryDataEnum = DeliveryDataEnum.OK;
isDelivered = status.equals("Lieferung erfolgreich");
}
public DeliveryData(String status, String estimatedArrival, DeliveryDataEnum deliveryDataEnum) {
this.status = status;
this.estimatedArrival = estimatedArrival;
this.deliveryDataEnum = deliveryDataEnum;
isDelivered = status.equals("Lieferung erfolgreich");
}
public boolean isDelivered() {
return isDelivered;
}
public String getStatus() {
return status;
}
public String getEstimatedArrival() {
return estimatedArrival;
}
public boolean allOk() {
return deliveryDataEnum == DeliveryDataEnum.OK;
}
public boolean noTrackingID() {
return deliveryDataEnum == DeliveryDataEnum.NO_TRACKING_ID;
}
public boolean noData() {
return deliveryDataEnum == DeliveryDataEnum.NO_DATA;
}
}

View File

@ -0,0 +1,7 @@
package org.hso.ecommerce.uimodel;
public enum DeliveryDataEnum {
OK,
NO_TRACKING_ID,
NO_DATA
}

View File

@ -0,0 +1,35 @@
.alert {
display: block;
text-transform: uppercase;
background: #c0392b;
color: white;
animation: blinking 1s linear infinite;
overflow: hidden;
}
.alert > span {
display: inline-block;
padding-left: 100%;
animation: marquee 10s linear infinite;
white-space: nowrap;
}
@keyframes marquee {
0% { transform: translateX(0); }
100% { transform: translateX(-100%); }
}
@keyframes blinking {
60% {
color: white;
}
75% {
color: #c0392b;
}
85% {
color: #c0392b;
}
100% {
color: white;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,15 @@
document.addEventListener("DOMContentLoaded", function() {
let priceElm = document.getElementById("price");
let priceGrossElm = document.getElementById("priceGross");
let vatPercent = parseInt(document.getElementById("vatPercent").value);
let updateFn = () => {
let net = Math.floor(priceElm.value*100);
let vat = Math.floor((net * vatPercent) / 100);
let gross = net + vat;
priceGrossElm.innerText = (gross / 100.0).toFixed(2).replace("\\.", ",");
};
priceElm.onchange = updateFn;
});

View File

@ -12,8 +12,6 @@
<ul class="secondary">
<li><a th:href="@{/}"> &gt; Zur Startseite</a></li>
<li><a th:href="@{/user/settings}">Einstellungen</a></li>
<li><a th:href="@{/user/bonuspoints}">Bonuspunkte</a></li>
<li><a th:href="@{/user/notifications/}">Benachrichtigungen</a></li>
<li><a th:href="@{/user/orders/}">Bestellungen</a></li>
</ul>
</nav>

View File

@ -17,7 +17,7 @@
<li><a href="/login">Login</a></li>
<li><a href="/">Angebote</a></li>
<li><a href="/shop/search">Suche</a></li>
<li><a href="/intern/">Mitarbeiter Bereich</a></li>
<li><a href="/intern/" th:if="${user != null && user.isEmployee}">Mitarbeiter Bereich</a></li>
</ul>
</div>
<div>

View File

@ -11,14 +11,14 @@
<div class='content-width bar-flex'>
<a class="button no-padding" href="/"><img class="logo" th:src="@{/img/ecom-logo-base.svg}"></a>
<form class='spacer input-icon secondary' th:action="@{/shop/search}" method="GET">
<input type="text" name="term" placeholder="Nach Produkten suchen..."/>
<input type="text" name="term" placeholder="Nach Produkten suchen..."
th:value="${searchterm != null ? searchterm : ''}"/>
<button>Finden</button>
</form>
<a th:unless="${user}" class="button" th:href="@{/login}">Login</a>
<div th:if="${user}" class="dropdown">
<a class="dropdown-button button">Mein Konto</a>
<div class="dropdown-content">
<a class="black button" th:href="@{/user/notifications/}">Benachrichtigungen</a>
<a class="black button" th:href="@{/user/}">Einstellungen</a>
<a class="black button" th:href="@{/user/orders/}">Meine Bestellungen</a>
<form th:if="${user}" method="post" th:action="@{/logout}" class="no-margin">
@ -26,7 +26,10 @@
</form>
</div>
</div>
<a class="button" th:href="@{/shop/checkout}">Warenkorb (<span th:text="${shoppingCart.itemCount}"></span>)</a>
<a class="button" th:href="@{/shop/checkout}">Warenkorb
<th:block th:if="${shoppingCart.itemCount > 0}"> (<span th:text="${shoppingCart.itemCount}"></span>)
</th:block>
</a>
</div>
<div th:if="${error}" class="error" id="error-msg">
<div class="content-width bar-flex">

View File

@ -47,6 +47,8 @@
</ul>
</li>
<li><a th:href="@{/intern/cronjobs/}">Cronjobs</a></li>
</ul>
</ul>
</nav>

View File

@ -20,10 +20,10 @@
<main class="sidebar-layout content-width">
<nav th:replace="fragments/intern :: sidebar"></nav>
<div class="content-width">
<form class="detailgrid">
<form th:action="@{/intern/accounting/addManual}" th:object="${form_vals}" method="post" class="detailgrid">
<div class="s">
<label for="amount">Betrag</label>
<input type="number" step="0.01" name="amount" value="0.00"/>&nbsp;EUR
<input type="number" step="0.01" id="amount" th:field="*{amount}" />&nbsp;EUR
</div>
<div class="spacer"></div>
@ -31,26 +31,26 @@
<fieldset>
<label for="source">Von Konto:</label>
<fieldset>
<input type="radio" id="s-no" name="destination" value="None" required>
<input type="radio" id="s-no" th:field="*{source}" value="None" required>
<label for="s-no">Kein Konto</label>
</fieldset>
<fieldset>
<input type="radio" id="s-main" name="destination" value="Main" required>
<input type="radio" id="s-main" th:field="*{source}" value="Main" required>
<label for="s-main">Hauptkonto</label>
</fieldset>
<fieldset>
<input type="radio" id="s-vat" name="destination" value="Vat" required>
<input type="radio" id="s-vat" th:field="*{source}" value="Vat" required>
<label for="s-vat">Mehrwertsteuerkonto</label>
</fieldset>
<fieldset>
<input type="radio" id="s-cust" name="destination" value="Cust" required>
<input type="radio" id="s-cust" th:field="*{source}" value="Cust" required>
<label for="s-cust">Kundenkonto</label>
<input placeholder="Kunden Nr." type="text" name="destination-customer" value=""/>
<input placeholder="Kunden Nr." type="text" th:field="*{sourceCustomer}" value=""/>
</fieldset>
<fieldset>
<input type="radio" id="s-sup" name="destination" value="Sup" required>
<input type="radio" id="s-sup" th:field="*{source}" value="Sup" required>
<label for="s-sup">Lieferanten Konto</label>
<input placeholder="Lieferanten Nr." type="text" name="destination-sup" value=""/>
<input placeholder="Lieferanten Nr." type="text" th:field="*{sourceSupplier}" value=""/>
</fieldset>
</fieldset>
</div>
@ -59,26 +59,26 @@
<fieldset>
<label for="destination">Nach Konto:</label>
<fieldset>
<input type="radio" id="d-no" name="destination" value="None" required>
<input type="radio" id="d-no" th:field="*{destination}" value="None" required>
<label for="d-no">Kein Konto</label>
</fieldset>
<fieldset>
<input type="radio" id="d-main" name="destination" value="Main" required>
<input type="radio" id="d-main" th:field="*{destination}" value="Main" required>
<label for="d-main">Hauptkonto</label>
</fieldset>
<fieldset>
<input type="radio" id="d-vat" name="destination" value="Vat" required>
<input type="radio" id="d-vat" th:field="*{destination}" value="Vat" required>
<label for="d-vat">Mehrwertsteuerkonto</label>
</fieldset>
<fieldset>
<input type="radio" id="d-cust" name="destination" value="Cus" required>
<input type="radio" id="d-cust" th:field="*{destination}" value="Cust" required>
<label for="d-cust">Kundenkonto</label>
<input placeholder="Kunden Nr." type="text" name="destination-customer" value=""/>
<input placeholder="Kunden Nr." type="text" th:field="*{destinationCustomer}" value=""/>
</fieldset>
<fieldset>
<input type="radio" id="d-sup" name="destination" value="Sup" required>
<input type="radio" id="d-sup" th:field="*{destination}" value="Sup" required>
<label for="d-sup">Lieferanten Konto</label>
<input placeholder="Lieferanten Nr." type="text" name="destination-sup" value=""/>
<input placeholder="Lieferanten Nr." type="text" th:field="*{destinationSupplier}" value=""/>
</fieldset>
</fieldset>
</div>
@ -87,13 +87,14 @@
<fieldset>
<label for="reason">Buchungsgrund:</label>
<fieldset>
<input type="radio" name="reason" value="Start">
<label for="d-sup">Startbuchung</label>
<input type="radio" id="r-start" th:field="*{reason}" value="Start">
<label for="r-start">Startbuchung</label>
</fieldset>
<fieldset>
<input type="radio" name="reason" value="Manual" checked>
<label for="d-sup">Manuell</label>
<input placeholder="Grund" class="full-width" type="text" name="reason-man" value=""/>
<input type="radio" id="r-manual" th:field="*{reason}" value="Manual">
<label for="r-manual">Manuell</label>
<input placeholder="Grund" class="full-width" type="text" th:field="*{reasonText}" value=""
required="required"/>
</fieldset>
</fieldset>
</div>

View File

@ -49,48 +49,21 @@
<th>Referenz</th>
</tr>
<tr>
<td>10.09.2019 14:10</td>
<td>119,00&nbsp;EUR</td>
<td> -</td>
<td> -</td>
<td><a th:href="@{/intern/customers/5000}">Kunde 5080</a></td>
<td>0&nbsp;EUR</td>
<td>Kunden-Bezahlung</td>
<td>Bezahlung mit Kreditkarte XXXXX480</td>
</tr>
<tr th:each="booking: ${bookings}">
<td th:text="${booking.datetime}" />
<td th:text="${booking.amount}" />
<tr>
<td>10.09.2019 13:45</td>
<td>19,00&nbsp;EUR</td>
<td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
<td>331,00&nbsp;EUR</td>
<td><a th:href="@{/intern/accounting/vat}">Mehrwertsteuer</a></td>
<td>1510,95&nbsp;EUR</td>
<td>Kunden-Bestellung</td>
<td><a th:href="@{/intern/customerOrders/450}">2504</a></td>
</tr>
<td th:if="${booking.sourceAddr}"><a th:href="@{${booking.sourceAddr}}" th:text="${booking.source}" /></td>
<td th:unless="${booking.sourceAddr}" th:text="${booking.source}" />
<td th:text="${booking.sourceBalance}" />
<tr>
<td>10.09.2019 13:45</td>
<td>100,00&nbsp;EUR</td>
<td><a th:href="@{/intern/customers/5000}">Kunde 5080</a></td>
<td>-100,00&nbsp;EUR</td>
<td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
<td>350,00&nbsp;EUR</td>
<td>Kunden-Bestellung</td>
<td><a th:href="@{/intern/customerOrders/450}">2504</a></td>
</tr>
<td th:if="${booking.destinationAddr}"><a th:href="@{${booking.destinationAddr}}" th:text="${booking.destination}" /></td>
<td th:unless="${booking.destinationAddr}" th:text="${booking.destination}" />
<td th:text="${booking.destinationBalance}" />
<tr>
<td>19.08.2019 12:31</td>
<td>250,00&nbsp;EUR</td>
<td> -</td>
<td> -</td>
<td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
<td>250,00&nbsp;EUR</td>
<td>Startkapital</td>
<td> -</td>
<td th:text="${booking.reason}" />
<td th:if="${booking.referenceAddr}"><a th:href="@{${booking.referenceAddr}}" th:text="${booking.reference}" /></td>
<td th:unless="${booking.referenceAddr}" th:text="${booking.reference}" />
</tr>
</table>

View File

@ -25,7 +25,7 @@
<nav th:replace="fragments/intern :: sidebar"></nav>
<div class="content-width">
<h3> Kontostand </h3>
<h2> 331,00&nbsp;EUR </h2>
<h2 th:text="${balance}" />
<p>
<table id="main-table">
<tr>
@ -42,33 +42,18 @@
<th>Grund</th>
<th>Referenz</th>
</tr>
<tr>
<td>10.09.2019 13:45</td>
<td>-19,00&nbsp;EUR</td>
<tr th:each="booking: ${bookings}">
<td th:text="${booking.datetime}" />
<td th:text="${booking.amount}" />
<td><a th:href="@{/intern/accounting/vat}">Mehrwertsteuer</a></td>
<td>331,00&nbsp;EUR</td>
<td th:if="${booking.sourceAddr}"><a th:href="@{${booking.sourceAddr}}" th:text="${booking.source}" /></td>
<td th:unless="${booking.sourceAddr}" th:text="${booking.source}" />
<td>Kunden-Bestellung</td>
<td><a th:href="@{/intern/customerOrders/450}">2504</a></td>
</tr>
<td th:text="${booking.balance}" />
<tr>
<td>10.09.2019 13:45</td>
<td>100,00&nbsp;EUR</td>
<td><a th:href="@{/intern/customers/5000}">Kunde 5080</a></td>
<td>350,00&nbsp;EUR</td>
<td>Kunden-Bestellung</td>
<td><a th:href="@{/intern/customerOrders/450}">2504</a></td>
</tr>
<tr>
<td>19.08.2019 12:31</td>
<td>250,00&nbsp;EUR</td>
<td> -</td>
<td>250,00&nbsp;EUR</td>
<td>Startkapital</td>
<td> -</td>
<td th:text="${booking.reason}" />
<td th:if="${booking.referenceAddr}"><a th:href="@{${booking.referenceAddr}}" th:text="${booking.reference}" /></td>
<td th:unless="${booking.referenceAddr}" th:text="${booking.reference}" />
</tr>
</table>

View File

@ -26,7 +26,7 @@
<nav th:replace="fragments/intern :: sidebar"></nav>
<div class="content-width">
<h3> Kontostand </h3>
<h2> 1510.95&nbsp;EUR </h2>
<h2 th:text="${balance}" />
<p>
<table id="main-table">
<tr>
@ -43,13 +43,18 @@
<th>Grund</th>
<th>Referenz</th>
</tr>
<tr>
<td>10.09.2019 13:45</td>
<td>19,00&nbsp;EUR</td>
<td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
<td>1510,95&nbsp;EUR</td>
<td>Kunden-Bestellung</td>
<td><a th:href="@{/intern/customerOrders/450}">2504</a></td>
<tr th:each="booking: ${bookings}">
<td th:text="${booking.datetime}" />
<td th:text="${booking.amount}" />
<td th:if="${booking.sourceAddr}"><a th:href="@{${booking.sourceAddr}}" th:text="${booking.source}" /></td>
<td th:unless="${booking.sourceAddr}" th:text="${booking.source}" />
<td th:text="${booking.balance}" />
<td th:text="${booking.reason}" />
<td th:if="${booking.referenceAddr}"><a th:href="@{${booking.referenceAddr}}" th:text="${booking.reference}" /></td>
<td th:unless="${booking.referenceAddr}" th:text="${booking.reference}" />
</tr>
</table>

View File

@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
<title>Cronjobs</title>
<script th:src="@{/js/filterTable.js}"></script>
<link rel="stylesheet" th:href="@{/css/ecom.css}"/>
<link rel="stylesheet" th:href="@{/css/manual-cronjobs.css}"/>
</head>
<body>
<nav th:replace="fragments/header :: header">Header</nav>
<div class="sidebar-layout content-width">
<nav></nav>
<div>
<h1>Cronjobs</h1>
</div>
</div>
<main class="sidebar-layout content-width">
<nav th:replace="fragments/intern :: sidebar"></nav>
<div class="content-width">
<h3>Manuelle Ausführung von Cronjobs</h3>
<div class="alert"><span>
WARNUNG<br>
Manuelles Triggern von Cronjobs kann zu unerwartetem Verhalten führen!<br>
Diese Seite ist nur für Debugging-Zwecke gedacht.
</span></div>
<p>
<table id="main-table">
<tr>
<th colspan="7">
<input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width"
data-target-id="main-table"></input>
</th>
</tr>
<tr>
<th>Cronjob</th>
<th></th>
</tr>
<tr th:each="job: ${jobs}">
<td th:text="${job.visibleName}"></td>
<td>
<form th:action="@{/intern/cronjobs/run/{identifier}(identifier = ${job.identifier})}" method="post">
<input class="button smaller" type="submit" value="Ausführen" />
</form>
</td>
</tr>
</table>
</p>
</div>
</main>
<footer th:replace="fragments/footer :: footer"></footer>
</body>
</html>

View File

@ -15,7 +15,7 @@
<div class="sidebar-layout content-width">
<nav></nav>
<div>
<h1>Bestellung 1010</h1>
<h1 th:text="|Bestellung ${order.id}|"></h1>
<script th:src="@{/js/back.js}"></script>
<div class="back" data-group="intern" data-insert="true"></div>
@ -25,33 +25,32 @@
<nav th:replace="fragments/intern :: sidebar"></nav>
<div class="content-width">
<div>
<h2 id="20202701"> Bestellung vom 27.01.2020 </h2>
<h2 th:text="| Bestellung vom ${order.created.toString().substring(0,10)}|"></h2>
<div>
<table class="key-value">
<tr>
<th>Nutzer</th>
<td><a th:href="@{/intern/customers/498}">K-4850</a></td>
<td><a th:href="@{/intern/customers/{id}(id=${order.customer.id})}" th:text="${order.customer.id}"></a></td>
</tr>
<tr>
<th>Lieferstatus</th>
<td><b>Unterwegs</b> <br/> Vorraussichtliche Ankunft: 29.01.2020</td>
<td th:if="${deliveryData.allOk()}"><span th:text="${deliveryData.getStatus()}" /></td>
<td th:if="${deliveryData.noTrackingID()}">Bestellung wurde elektronisch angekündigt</td>
<td th:if="${deliveryData.noData()}">DHL-Server ist gerade nicht erreichbar</td>
</tr>
<tr>
<td></td>
<td th:if="${order.deliveredAt == null && order.trackingId!=null && !deliveryData.noData()}">Vorraussichtliche Ankunft: <span th:text="${deliveryData.getEstimatedArrival()}" /></td>
<td th:if="${order.deliveredAt == null && order.trackingId!=null && deliveryData.noData()}">Vorraussichtliche Ankunft: --:--:---- </td>
<td th:if="${order.deliveredAt != null && order.trackingId!=null}"><b>Angekommen</b> Ankunft: <span th:text="${deliveryData.getEstimatedArrival()}" /></td>
</tr>
<tr>
<th>Sendeverfolgungsnummer</th>
<td>XE51451436DE</td>
<td th:text="${order.trackingId!=null} ? ${order.trackingId} : 'Es wurde noch keine Sendungsnummer vergeben'"></td>
</tr>
<tr>
<th></th>
<td>
Hans Maier <br/>
Hauptstraße 12<br/>
74880 Musterstadt<br/>
Deutschland <br/>
</td>
</tr>
<tr>
<th>Eingelösste Bonuspunkte</th>
<td>10</td>
<td th:text="${order.destination.toString()}"></td>
</tr>
</table>
</div>
@ -62,18 +61,11 @@
<th>Menge</th>
<th>Preis (Brutto)</th>
</tr>
<tr>
<td><a th:href="@{/shop/articles/4151}"><img th:src="@{/img/product-1.jpg}" class="s"/><a></td>
<td><a th:href="@{/shop/articles/4151}">Kamera<a/></td>
<td> 1</td>
<td>100,50&nbsp;EUR</td>
</tr>
<tr>
<td><a th:href="@{/shop/articles/4151}"><img th:src="@{/img/product-2.jpg}" class="s"/><a/></td>
<td><a th:href="@{/shop/articles/4151}">Earbuds<a/></td>
<td> 3</td>
<td>63,95&nbsp;EUR</td>
</tr>
<tr th:each="position: ${order.positions}">
<td><a th:href="@{/shop/articles/{id}(id = ${position.article.id})}"><img th:src="@{/shop/articles/{id}/image.jpg(id=${position.article.id})}" class="s"/></a></td>
<td><a th:href="@{/shop/articles/{id}(id = ${position.article.id})}" th:text="${position.article.title}" class="s"></a></td>
<td th:text="${position.quantity}" />
<td th:text="${#numbers.formatDecimal(position.getSumPrice() * 0.01, 1, 'POINT', 2, 'COMMA')}" />
<tr>
<th></th>
<th></th>
@ -84,28 +76,22 @@
<td></td>
<td></td>
<td>Artikel (Netto)</td>
<td> 120,00&nbsp;EUR</td>
<td th:text="${#numbers.formatDecimal(order.totalNetCent * 0.01, 1, 'POINT', 2, 'COMMA')}" />
</tr>
<tr>
<td></td>
<td></td>
<td>Bonuspunkte</td>
<td> 5,00&nbsp;EUR</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Umsatzsteuer (19%)</td>
<td> 42,00&nbsp;EUR</td>
<td>Umsatzsteuer</td>
<td th:text="${#numbers.formatDecimal(order.totalVatCent * 0.01, 1, 'POINT', 2, 'COMMA')}" />
</tr>
<tr>
<td></td>
<td></td>
<td>
<h3>Gesammtpreis</h3>
<h3>Gesamtpreis</h3>
</td>
<td>
<h3>240,79&nbsp;EUR</h3>
<h3 th:text="${#numbers.formatDecimal(order.totalGrossCent * 0.01, 1, 'POINT', 2, 'COMMA')}"/>
</td>
</tr>
</table>

View File

@ -40,37 +40,17 @@
<th>Status</th>
<th></th>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">101</a></td>
<td>440</td>
<td>2019-12-54</td>
<td>10,13&nbsp;EUR</td>
<td>Zugestellt</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">102</a></td>
<td>241</td>
<td>2019-11-10</td>
<td>40,13&nbsp;EUR</td>
<td>In Zustellung</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">101</a></td>
<td>241</td>
<td>2019-11-10</td>
<td>10,13&nbsp;EUR</td>
<td>Erfasst</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td><a th:href="@{/intern/customers/48584}">755</a></td>
<td>544</td>
<td>2019-12-10</td>
<td>45,13&nbsp;EUR</td>
<td>Erfasst</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
<tr th:each="order: ${orderDeliveryDataMap}">
<td><a th:href="@{/intern/customers/{id}(id=${order.customerOrder.customer.id})}"
th:text="${order.customerOrder.customer.id}">101</a></td>
<td th:text="${order.customerOrder.id}"></td>
<td th:text="${order.customerOrder.created.toString().substring(0, 10)}"></td>
<td th:text="${#numbers.formatDecimal(order.customerOrder.totalGrossCent * 0.01, 1, 'POINT', 2, 'COMMA')}"></td>
<td th:if="${order.deliveryData.allOk()}"><span th:text="${order.deliveryData.getStatus()}"/></td>
<td th:if="${order.deliveryData.noTrackingID()}">Bestellung wurde elektronisch angekündigt</td>
<td th:if="${order.deliveryData.noData()}">DHL-Server ist gerade nicht erreichbar</td>
<td><a th:href="@{/intern/customerOrders/{id}(id=${order.customerOrder.id})}" class="button smaller">Details</a>
</td>
</tr>
</table>
</p>

View File

@ -23,7 +23,7 @@
<div class="sidebar-layout content-width">
<nav></nav>
<div>
<h1>Kunde 1510</h1>
<h1 th:text="|Kunde ${user.id}|"></h1>
<script th:src="@{/js/back.js}"></script>
<div class="back" data-group="intern" data-insert="true"></div>
@ -37,33 +37,26 @@
<table class="key-value">
<tr>
<th>Nutzer</th>
<td><a th:href="@{/intern/customers/498}">1510</a></td>
<td><a th:href="@{/intern/customers/{id}(id=${user.id})}" th:text="${user.id}"></a></td>
</tr>
<tr>
<th>Bonuspunktestand</th>
<td>50</td>
</tr>
<tr>
<th>Name</th>
<td>Hans Maier</td>
<td th:text="${user.defaultDeliveryAddress != null ? user.defaultDeliveryAddress.name : '-'}"></td>
</tr>
<tr>
<th>E-Mail</th>
<td>hans.maier@example.com</td>
<td th:text="${user.email}"></td>
</tr>
<tr>
<th>Status</th>
<td>Geschäftskunde, Aktiv</td>
<td>
<span th:text="${user.isActive} ? 'Aktiv,' : 'Inaktiv,'"></span>
<span th:text="${user.isEmployee} ? 'Mitarbeiter' : 'Kunde'"></span>
</td>
</tr>
<tr>
<th>Adresse</th>
<td>
Hans Maier <br/>
Hauptstraße 12<br/>
74880 Musterstadt<br/>
Deutschland <br/>
</td>
<td th:Text="${user.defaultDeliveryAddress != null ? user.defaultDeliveryAddress : ''}"></td>
</tr>
</table>
</p>
@ -74,15 +67,15 @@
<div id="add-actions" class="invisible info-box secondary hero">
<h2>Status bearbeiten</h2>
<p>
<form>
<form method="POST" th:action="@{/intern/customers/{id}/changeState(id=${user.id})}">
<fieldset>
<input type="checkbox" name="activ" id="activ" checked>
<label for="activ">Aktiv</label> <br/>
<input type="checkbox" name="active" id="active" th:checked="${user.isActive}">
<label for="active">Aktiv</label> <br/>
</fieldset>
<fieldset>
<input type="checkbox" name="ma" id="ma">
<input type="checkbox" name="ma" id="ma" th:checked="${user.isEmployee}">
<label for="ma">Mitarbeiter-Status</label> <br/>
</fieldset>
@ -94,11 +87,14 @@
</p>
<h2>Passwort zurücksetzen</h2>
<p>
<form>
<form method="POST" th:action="@{/intern/customers/{id}/resetPassword(id=${user.id})}">
<div>
<label for="password">Passwort</label>
<input class="full-width" type="password" name="password" placeholder="Passwort" id="password"
pattern="(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,}"
required>
<small>Das Passwort muss mindestens 8 Zeichen enthalten. Es muss aus mindestens einem
Großbuchstaben, einem Kleinbuchstaben und einer Zahl bestehen.</small>
</div>
<div>
@ -113,10 +109,8 @@
</button>
</form>
</p>
</div>
<h2>Bestellungen</h2>
<p>
<table id="main-table">
@ -127,26 +121,20 @@
<th>Status</th>
<th></th>
</tr>
<tr>
<td>440</td>
<td>2019-12-54</td>
<td>10,13&nbsp;EUR</td>
<td>Zugestellt</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>241</td>
<td>2019-11-10</td>
<td>40,13&nbsp;EUR</td>
<td>In Zustellung</td>
<td><a th:href="@{/intern/customerOrders/48584}" class="button smaller">Details</a></td>
<tr th:each="order: ${orders}">
<td th:text="${order.id}"></td>
<td th:text="${order.formatCreated()}"></td>
<td th:text="${#numbers.formatDecimal(order.totalGrossCent * 0.01, 1, 'POINT', 2, 'COMMA')}"></td>
<td th:if="${order.deliveredAt == null}">In Zustellung</td>
<td th:if="${order.deliveredAt != null}">Zugestellt</td>
</tr>
</table>
</p>
<h2>Buchungen</h2>
<div>
<h4> Kontostand </h4>
<h3> 0,00&nbsp;EUR </h3>
<h3 th:text="${balance}" />
</div>
<p>
<table id="main-table">
@ -164,21 +152,18 @@
<th>Grund</th>
<th>Referenz</th>
</tr>
<tr>
<td>10.09.2019 14:10</td>
<td>119,00&nbsp;EUR</td>
<td> -</td>
<td>0&nbsp;EUR</td>
<td>Kunden-Bezahlung</td>
<td>Bezahlung mit Kreditkarte XXXXXXXX480</td>
</tr>
<tr>
<td>10.09.2019 13:45</td>
<td>-100,00&nbsp;EUR</td>
<td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
<td>-100,00&nbsp;EUR</td>
<td>Kunden-Bestellung</td>
<td><a th:href="@{/intern/customerOrders/450}">2504</a></td>
<tr th:each="booking: ${bookings}">
<td th:text="${booking.datetime}" />
<td th:text="${booking.amount}" />
<td th:if="${booking.sourceAddr}"><a th:href="@{${booking.sourceAddr}}" th:text="${booking.source}" /></td>
<td th:unless="${booking.sourceAddr}" th:text="${booking.source}" />
<td th:text="${booking.balance}" />
<td th:text="${booking.reason}" />
<td th:if="${booking.referenceAddr}"><a th:href="@{${booking.referenceAddr}}" th:text="${booking.reference}" /></td>
<td th:unless="${booking.referenceAddr}" th:text="${booking.reference}" />
</tr>
</table>
</p>

View File

@ -39,85 +39,16 @@
<th>Status</th>
<th></th>
</tr>
<tr>
<td>1209</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td>Geschäftskunde</td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1208</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td>Inaktiv, Geschäftskunde</td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1207</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td></td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1206</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td></td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1205</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td></td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1204</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td></td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1203</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td></td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1202</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td></td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1201</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>hans.maier@example.com</td>
<td>Inaktiv, Mitarbeiter</td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
</tr>
<tr>
<td>1214</td>
<td>2019-11-10</td>
<td>Hans Maier</td>
<td>admin@example.com</td>
<td>Mitarbeiter</td>
<td><a th:href="@{/intern/customers/4884}" class="button smaller">Details</a></td>
<tr th:each="user: ${users}">
<td th:text="${user.id}"></td>
<td th:text="${user.created.toString().substring(0, 10)}"></td>
<td th:text="${user.defaultDeliveryAddress != null ? user.defaultDeliveryAddress.name : ''}"></td>
<td th:text="${user.email}"></td>
<td>
<span th:text="${user.isActive} ? 'Aktiv,' : 'Inaktiv,'"></span>
<span th:text="${user.isEmployee} ? 'Mitarbeiter' : 'Kunde'"></span>
</td>
<td><a th:href="@{/intern/customers/{id}(id = ${user.id})}" class="button smaller">Details</a></td>
</tr>
</table>
</p>

View File

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
<script src="/js/chart.js"></script>
<script>
function chart(id, name, data, unit) {
document.addEventListener("DOMContentLoaded", function() {
function chart(id, name, data, unit, dates) {
let elm = document.getElementById(id);
let cs = getComputedStyle(elm)
let ctx = elm.getContext('2d');
@ -20,7 +20,7 @@
// The data for our dataset
data: {
labels: ['Freitag', 'Donnerstag', 'Mittwoch', 'Dienstag', 'Montag'],
labels: dates,
datasets: [{
label: name,
backgroundColor: cs.getPropertyValue('--c-primary'),
@ -61,7 +61,6 @@
}
}
});
});
}
</script>
@ -88,12 +87,12 @@
<div class="grid xl">
<section class="primary hero">
<h3>Hauptkonto</h3>
<h2>4080,00&nbsp;EUR</h2>
<h2 th:text="${mainAccountBalance}" />
</section>
<section class="primary hero">
<h3>Umsatzsteuerkonto</h3>
<h2>-505,00&nbsp;EUR</h2>
<h2 th:text="${vatAccountBalance}" />
</section>
<section class="spacer"></section>
@ -107,7 +106,12 @@
<h3>Verkäufe (Anzahl)</h3>
<canvas id="sales"></canvas>
<script>
chart('sales', 'Verkäufe/Tag', [15, 12, 14, 8, 7])
fetch('./dashboardsummary')
.then(response => response.json())
.then(data => {
chart('sales', 'Verkäufe/Tag', data.map(d => d.todaysCustomersOrders),
"", data.map(g => " "+g.created));
});
</script>
</section>
@ -116,7 +120,12 @@
<h3>Verkäufe (Umsatz)</h3>
<canvas id="umsatz"></canvas>
<script>
chart('umsatz', 'Umsatz/Tag', [1512.45, 1225.15, 1452.54, 814.54, 746.00], "EUR")
fetch('./dashboardsummary')
.then(response => response.json())
.then(data => {
chart('umsatz', 'Umsatz/Tag', data.map(d => d.todaysSalesCent / 100),
"€", data.map(g => " "+g.created));
});
</script>
</section>
@ -125,7 +134,12 @@
<h3>Neukunden</h3>
<canvas id="Neukunden"></canvas>
<script>
chart('Neukunden', 'Neukunden', [1, 1, 0, 5, 0], "")
fetch('./dashboardsummary')
.then(response => response.json())
.then(data => {
chart('Neukunden', 'Neukunden', data.map(d => d.todaysNewCustomers),
"", data.map(g => " "+g.created));
});
</script>
</section>
@ -139,7 +153,12 @@
<h2>Lagerauslastung</h2>
<canvas id="warehouse"></canvas>
<script>
chart('warehouse', 'Lagerauslastung', [50, 30, 20, 80, 60], "%")
fetch('./dashboardsummary')
.then(response => response.json())
.then(data => {
chart('warehouse', 'Lagerauslastung', data.map(d => d.currentWarehouseCapacity * 100),
"%", data.map(g => g.created));
});
</script>
</section>
@ -148,7 +167,12 @@
<h2>Lagereffizienz</h2>
<canvas id="warehouse-ef"></canvas>
<script>
chart('warehouse-ef', 'Lagereffizienz', [80, 70, 60, 75, 54], "%")
fetch('./dashboardsummary')
.then(response => response.json())
.then(data => {
chart('warehouse-ef', 'Lagereffizienz', data.map(d => d.todaysWarehouseCapacity * 100),
"%", data.map(g => g.created));
});
</script>
</section>

View File

@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
<title>Bearbeiten: Artikel</title>
<script th:src="@{/js/filterTable.js}"></script>
<script th:src="@{/js/editViewUpdateTax.js}"></script>
<link rel="stylesheet" th:href="@{/css/ecom.css}"/>
</head>
<body>
@ -27,17 +28,17 @@
<input class=" full-width" type="text" id="title" name="title" required="required" pattern=".+" th:value="${ArticleID.title}"/>
</p>
<p class="s">
<label for="ref_disabled">Refernzierter Artikel</label>
<input class="" type="text" id="ref_disabled" th:value="${ArticleID.offer_id}" disabled/>
<label for="ref_disabled">Referenzierter Artikel</label>
<input class="" type="text" id="ref_disabled" th:value="${ArticleID.offerID}" disabled/>
<input type="hidden" id="ref_hidden" th:value="${ArticleID.offer_id}" name="ref-article" />
<input type="hidden" id="ref_hidden" th:value="${ArticleID.offerID}" name="ref-article" />
<a th:href="${'/intern/supplierOffers/#q=' + ArticleID.id}">Details</a>
</p>
<div class="spacer"></div>
<div class="m">
<p>
<label for="img">Bild Hochladen</label>
<label for="img">Bild hochladen</label>
<input class="full-width" type="file" id="img" name="img"/>
</p>
<p>
@ -47,11 +48,13 @@
<div class="s">
<p>
<label for="price">Preis (Netto)</label>
<input class="" type="number" id="price" step="0.01" name="price_netto" required
th:value="${ArticleID.price_netto}"/>&nbsp;EUR <br/>
<input class="" type="number" id="price" step="0.01" name="priceNet" required
th:value="${ArticleID.priceNet}"/>&nbsp;EUR <br/>
(<span th:text="${ArticleID.vatPercent}"></span>% Mwst.)
<input type="hidden" id="vatPercent" name="vatPercent" th:value="${ArticleID.vatPercent}"/>
<!-- Info von article ref--> <br/>
= <span th:text="${ArticleID.price}"></span>&nbsp;EUR Brutto
= <span id="priceGross" th:text="${ArticleID.price}"></span>&nbsp;EUR Brutto
</p>
<p>
<label for="reorderMaxPrice">Maximaler Einkaufspreis (Netto)</label>
@ -85,7 +88,7 @@
</p>
<p>
Der Wert wird nur für zukünftige Lagerbuchungen verwendet.
Bei Problemen kann können Einheiten aus- und wieder eingebucht werden.
Bei Problemen können Einheiten aus- und wieder eingebucht werden.
<!-- TODO: set link g-->
</p>
<p>

View File

@ -50,10 +50,10 @@
<td><img th:src="@{/shop/articles/{id}/image.jpg(id=${article.id})}" class="s"/></td>
<td><span th:text="${article.title}"></span></td>
<td><span th:text="${article.price}"></span></td>
<td><span th:text="${article.price_netto}"></span></td>
<td><span th:text="${article.priceNet}"></span></td>
<td><span th:text="${article.categorie}"></span></td>
<td><span th:text="${article.stock}"></span></td>
<td><a th:href="${'/intern/supplierOffers/#q=' + article.title}" th:text="${article.offer_id}"></a></td>
<td><a th:href="${'/intern/supplierOffers/#q=' + article.title}" th:text="${article.offerID}"></a></td>
<td><a th:href="@{/intern/articles/{id}(id = ${article.id})}" th:text="${article.id}"></a></td>
<td>
<form th:action="@{/intern/articles/{id}(id = ${article.id})}"><input class="button smaller" type="submit" value="Bearbeiten" /></form>

View File

@ -43,8 +43,9 @@
<tr th:each="article : ${OfferedArticles}">
<td><span th:text="${article.title}"></span></td>
<td><span th:text="${article.manufacturer}"></span></td>
<td><span th:text="${article.articlenumber}"></span></td>
<td><a th:href="${'/intern/suppliers/#q=' + article.supplierName}" th:text="${article.supplierName}"></a></td>
<td><span th:text="${article.articleNumber}"></span></td>
<td th:if="${article.supplierName} == '-'">-</td>
<td th:unless="${article.supplierName} == '-'"><a th:href="${'/intern/suppliers/#q=' + article.supplierName}" th:text="${article.supplierName}"></a></td>
<td><span th:text="${article.price}"></span></td>
<td><span th:text="${article.ads}"></span></td>
<td>
@ -53,7 +54,7 @@
</div>
<!-- ELSE -->
<div th:unless="${article.offerIsListed}">
<form class="detailgrid" action="#" th:action="@{/intern/articles/addArticle/{id}(id = ${article.offer_id})}" method="POST">
<form class="detailgrid" action="#" th:action="@{/intern/articles/addArticle/{id}(id = ${article.offerId})}" method="POST">
<input class="button smaller" type="submit" value="Hinzufügen" />
</form>
</div>

View File

@ -1,22 +1,18 @@
<!DOCTYPE html>
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
<title>Lieferanten Bestellungen</title>
<script th:src="@{/js/filterTable.js}"></script>
<link rel="stylesheet" th:href="@{/css/ecom.css}"/>
</head>
<body>
<nav th:replace="fragments/header :: header">Header</nav>
<div class="sidebar-layout content-width">
<nav></nav>
<div>
<h1>Lieferanten Bestellungen</h1>
<script th:src="@{/js/back.js}"></script>
<div class="back" data-group="intern" data-name="Zurück zu den Bestellungen bei Lieferanten."
data-insert="false"></div>
@ -30,9 +26,10 @@
<tr>
<th colspan="9">
<input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width"
data-target-id="main-table"></input>
data-target-id="main-table">
</th>
</tr>
<thead>
<tr>
<th>Bestellnummer</th>
<th>Datum</th>
@ -43,61 +40,39 @@
<th>Gesamtpreis (Netto)</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>4545</td>
<td>2019-18-10</td>
<td><a th:href="@{/intern/suppliers/45015}">Cheap AG</a></td>
<td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
<td>20,00&nbsp;EUR</td>
<td>10</td>
<td>200,00&nbsp;EUR</td>
<td>Unterwegs <br/><a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a></td>
</tr>
<tr>
<td>2455</td>
<td>2019-18-10</td>
<td><a th:href="@{/intern/suppliers/45015}">Cheap AG</a></td>
<td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
<td>20,00&nbsp;EUR</td>
<td>11</td>
<td>220,00&nbsp;EUR</td>
<td>Unterwegs <br/><a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a></td>
</tr>
<tr>
<td>1224</td>
<td>2019-18-10</td>
<td><a th:href="@{/intern/suppliers/45015}">Cheap AG</a></td>
<td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
<td>20,00&nbsp;EUR</td>
<td>11</td>
<td>220,00&nbsp;EUR</td>
<td>Angekommen</td>
</tr>
<tr>
<td>4520</td>
<td>2019-18-10</td>
<td><a th:href="@{/intern/suppliers/45015}">Cheap AG</a></td>
<td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
<td>20,00&nbsp;EUR</td>
<td>11</td>
<td>220,00&nbsp;EUR</td>
<td>Angekommen</td>
</tr>
<tr>
<td>4521</td>
<td>2019-18-10</td>
<td><a th:href="@{/intern/suppliers/45015}">Cheap AG</a></td>
<td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
<td>20,00&nbsp;EUR</td>
<td>11</td>
<td>220,00&nbsp;EUR</td>
<td>Angekommen</td>
<tr th:each="order : ${orders}">
<td><span th:text="${order.id}"></span></td>
<td><span th:text="${order.dateOrder}"></span></td>
<td><span th:text="${order.supplierName}"></span></td>
<td><a th:href="@{/intern/articles/{id}(id = ${order.articleId})}" class="smaller"
th:text="${order.articleName}"></a></td>
<td><span th:text="${order.priceNet}"></span></td>
<td><span th:text="${order.quantity}"></span></td>
<td><span th:text="${order.priceTotal}"></span></td>
<td>
<div th:if="${order.arrived}">
Angekommen
</div>
<!-- ELSE -->
<div th:unless="${order.arrived}">
Unterwegs: <span th:text="${order.carrier}"></span>, <span
th:text="${order.trackingId}"></span><br/>
<form class="detailgrid" action="#"
th:action="@{/intern/supplierOrders/store/{id}(id = ${order.id})}" method="POST">
<input class="button smaller" type="submit" value="Eingang verbuchen"/>
</form>
Geschätzte Ankunft: <span th:text="${order.estimatedArrival}"></span>.
</div>
</td>
</tr>
</tbody>
</table>
</p>
</div>
</main>
<footer th:replace="fragments/footer :: footer"></footer>
</body>
</html>

View File

@ -1,22 +1,18 @@
<!DOCTYPE html>
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.75, user-scalable=no">
<title>Lieferanten Details</title>
<script th:src="@{/js/filterTable.js}"></script>
<link rel="stylesheet" th:href="@{/css/ecom.css}"/>
</head>
<body>
<nav th:replace="fragments/header :: header">Header</nav>
<div class="sidebar-layout content-width">
<nav></nav>
<div>
<h1>Lierfant Cheap AG</h1>
<h1>Lieferant <span th:text="${SupplierDetail.name}"></span></h1>
<script th:src="@{/js/back.js}"></script>
<div class="back" data-group="intern" data-insert="true"></div>
</div>
@ -26,13 +22,14 @@
<div class="content-width">
<h2>Bestellungen</h2>
<p>
<table id="main-table">
<table id="order-table">
<tr>
<th colspan="9">
<input type="text" placeholder="Filtern" class="smaller jsFilterTable full-width"
data-target-id="main-table"></input>
data-target-id="main-table">
</th>
</tr>
<thead>
<tr>
<th>Bestellnummer</th>
<th>Datum</th>
@ -42,24 +39,39 @@
<th>Gesamtpreis (Netto)</th>
<th>Status</th>
</tr>
<tr>
<td>4545</td>
<td>2019-18-10</td>
<td><a th:href="@{/intern/listedArticles/45015}">Kamera</a></td>
<td>20,00&nbsp;EUR</td>
<td>10</td>
<td>200,00&nbsp;EUR</td>
<td>Unterwegs <br/><a th:href="@{/intern/warehouse/todo}" class="button smaller">Angekommen</a></td>
</thead>
<tbody>
<tr th:each="order : ${SupplierDetail.orders}">
<td><span th:text="${order.id}"></span></td>
<td><span th:text="${order.dateOrder}"></span></td>
<td><a th:href="@{/intern/articles/{id}(id = ${order.articleId})}" class="button smaller" th:text="${order.articleName}"></a></td>
<td><span th:text="${order.priceNet}"></span></td>
<td><span th:text="${order.quantity}"></span></td>
<td><span th:text="${order.priceTotal}"></span></td>
<td>
<div th:if="${order.arrived}">
Angekommen
</div>
<!-- ELSE -->
<div th:unless="${order.arrived}">
Unterwegs <br>
<form class="detailgrid" action="#" th:action="@{/intern/supplierOrders/store/{id}(id = ${order.id})}" method="POST">
<input class="button smaller" type="submit" value="Eingang verbuchen" />
</form>
</div>
</td>
</tr>
</tbody>
</table>
</p>
<h2>Buchungen</h2>
<div>
<h4> Kontostand </h4>
<h3> -100,00&nbsp;EUR </h3>
<h3 th:text="${SupplierDetail.balance}" />
</div>
<p>
<table id="main-table">
<table id="booking-table">
<thead>
<tr>
<th>Zeitpunkt</th>
<th>Betrag</th>
@ -68,19 +80,27 @@
<th>Grund</th>
<th>Referenz</th>
</tr>
</thead>
<tbody>
<tr>
<td>10.09.2019 13:45</td>
<td>100,00&nbsp;EUR</td>
<td><a th:href="@{/intern/accounting/main}">Hauptkonto</a></td>
<td>-100,00&nbsp;EUR</td>
<td>Lieferanten-Bestellung</td>
<td><a th:href="@{/intern/supplierOrders/#q=4520}">2504</a></td>
<tr th:each="booking : ${SupplierDetail.bookings}">
<td th:text="${booking.datetime}" />
<td th:text="${booking.amount}" />
<td th:if="${booking.sourceAddr}"><a th:href="@{${booking.sourceAddr}}" th:text="${booking.source}" /></td>
<td th:unless="${booking.sourceAddr}" th:text="${booking.source}" />
<td th:text="${booking.balance}" />
<td th:text="${booking.reason}" />
<td th:if="${booking.referenceAddr}"><a th:href="@{${booking.referenceAddr}}" th:text="${booking.reference}" /></td>
<td th:unless="${booking.referenceAddr}" th:text="${booking.reference}" />
</tr>
</tbody>
</table>
</p>
</div>
</main>
<footer th:replace="fragments/footer :: footer"></footer>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More