Compare commits

...

343 Commits

Author SHA1 Message Date
ea3ea5ca83 Bump version to 1.0.0.0
All checks were successful
Deploy / Build and Deploy (push) Successful in 2m29s
2025-07-30 17:37:25 +02:00
93e920f61a Add GNU GPLv3 as license 2025-07-29 23:53:53 +02:00
9b48242f0e Setup: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 2m32s
2025-07-29 23:43:42 +02:00
7153bfab6f Tests: Update dependencies 2025-07-29 23:43:27 +02:00
4b27ebf81b Elwig: Update dependencies 2025-07-29 23:43:17 +02:00
c26e4a2dbd [#61] Windows: Use more red and green color to indicate type of WineVariety
All checks were successful
Test / Run tests (push) Successful in 2m27s
2025-07-28 20:38:20 +02:00
fad1e28c06 Documents: Add Bio-KSt. to footer
All checks were successful
Test / Run tests (push) Successful in 2m24s
2025-07-23 17:07:10 +02:00
c61c2e3fcd [#64] AreaComAdminWindow: Add dialog for modifying/deleting
All checks were successful
Test / Run tests (push) Successful in 2m21s
2025-07-09 18:14:27 +02:00
267aa3d47c Dialogs: Rename AreaComDialog to AreaComTransferDialog
Some checks failed
Test / Run tests (push) Has been cancelled
2025-07-09 16:56:08 +02:00
7e9a27c75d Services: Move App.HintContextChange() to Windows
Some checks failed
Test / Run tests (push) Has been cancelled
2025-07-09 16:07:47 +02:00
53d82604a1 AreaComAdminWindow: Enhance visual appearance
All checks were successful
Test / Run tests (push) Successful in 1m53s
2025-07-09 00:39:01 +02:00
bb65a1f20e [#62] CreditNote: Add longer custom text to bottom
All checks were successful
Test / Run tests (push) Successful in 1m53s
2025-07-08 16:06:12 +02:00
c6748055fd [#61] Windows: Use red and green color to indicate type of WineVariety
All checks were successful
Test / Run tests (push) Successful in 2m17s
2025-07-08 15:27:13 +02:00
e6746f76b1 Windows: Small fixes 2025-07-08 15:27:13 +02:00
e9f389b885 DeliveryService: Fix spacing in tooltip 2025-07-08 15:27:13 +02:00
919ab3356d [#57] MailWindow: Use Task.Run() 2025-07-08 15:27:13 +02:00
39060f6a1e [#57] PaymentAdjustmentWindow: Use Task.Run() 2025-07-08 15:26:57 +02:00
070dda1bde [#57] ChartWindow: Use Task.Run() 2025-07-07 23:53:08 +02:00
b6bfc60ab8 [#57] DeliveryScheduleAdminWindow: Use Task.Run() 2025-07-07 23:39:55 +02:00
8aaa22fcb4 [#57] DeliveryAncmtAdminWindow: Use Task.Run() 2025-07-07 23:36:08 +02:00
64832e9a53 [#57] PaymentVariantsWindow: Use Task.Run()
All checks were successful
Test / Run tests (push) Successful in 1m49s
2025-07-07 23:31:03 +02:00
7c9844e277 [#57] MainWindow: Use Task.Run()
All checks were successful
Test / Run tests (push) Successful in 1m40s
2025-07-07 22:45:28 +02:00
19d2208fc3 [#57] AreaComAdminWindow: Use Task.Run() 2025-07-07 22:45:28 +02:00
38d0ff969d BaseDataWindow: Use Cursors.Wait instead of Cursors.AppStarting 2025-07-07 22:45:28 +02:00
fb2b998d1b [#57] DeliveryAdminWindow: Use Task.Run() 2025-07-07 22:45:28 +02:00
10d5f49f63 [#57] MemberAdminWinodw: Use Task.Run() 2025-07-07 22:45:28 +02:00
41811925be PaymentVariantsWindow: Add ViewModel and Service
All checks were successful
Test / Run tests (push) Successful in 1m58s
2025-07-07 22:44:30 +02:00
97300b6e30 [#65] MailLogWindow: Fix initial loading
All checks were successful
Test / Run tests (push) Successful in 1m49s
2025-07-03 13:03:01 +02:00
c6c8fd9b68 ChartWindow: Automatically calculate variant when saved 2025-07-03 13:03:01 +02:00
913129f155 PaymentVariantsWindow: Add estimates for uncommited variants 2025-07-03 13:02:57 +02:00
953532cae4 MemberService: Filter area commitments by CurrentLastSeason instead of CurrentYear
All checks were successful
Test / Run tests (push) Successful in 2m15s
2025-06-24 13:31:58 +02:00
267797b55d AreaComDialog: Fix property name (MaintainYearFrom) 2025-06-24 13:30:04 +02:00
4234c7f994 Elwig: Add ITime/XTime to entities and allow to export/import CTime/MTime
All checks were successful
Test / Run tests (push) Successful in 2m30s
2025-06-17 18:06:05 +02:00
3493ff6df1 Tests: Add UnitTests folder
All checks were successful
Test / Run tests (push) Successful in 2m24s
2025-06-03 20:57:53 +02:00
623f55f5b0 App: Rename ExePath to InstallPath
All checks were successful
Test / Run tests (push) Successful in 2m13s
2025-05-27 11:43:34 +02:00
b580e1bf79 App: Use environment variables for paths
All checks were successful
Test / Run tests (push) Successful in 1m42s
2025-05-26 15:18:32 +02:00
b08ca63bed [#59] Documents: Move Documents install folder from ProgramData to Program Files
All checks were successful
Test / Run tests (push) Successful in 2m19s
2025-05-26 15:12:49 +02:00
6a5f4cefa9 [#58] PaymentVariantSummary: Add 'attributlos gebunden' columns 2025-05-23 15:43:39 +02:00
0f3ce39f35 Elwig: Use 'Menge' instead of 'Gewicht' where applicable
All checks were successful
Test / Run tests (push) Successful in 1m59s
2025-05-20 15:55:11 +02:00
336aef5c70 CreditNoteDeliveryData: Include WeighingModifier only if delivery modifiers are considered 2025-05-20 13:09:29 +02:00
0dff3986b7 PaymentVariantsWindow: Add note, that modifiers include Rebelzuschlag
All checks were successful
Test / Run tests (push) Successful in 2m30s
2025-05-20 12:07:28 +02:00
318fb5dc7b Bump version to 0.13.9
All checks were successful
Test / Run tests (push) Successful in 2m7s
Deploy / Build and Deploy (push) Successful in 1m55s
2025-05-05 10:41:18 +02:00
41c5288fc5 Elwig: Update dependencies
Some checks failed
Test / Run tests (push) Failing after 14s
2025-05-05 10:36:30 +02:00
e50e7337e6 Helpers/Utils: Automatically change URL to sync.elwig.at when applicable 2025-05-05 10:36:30 +02:00
ffe85d471c README: Add text 2025-04-24 16:05:41 +02:00
d1c07ee92a Installer/Setup: Update to WiX 6
All checks were successful
Test / Run tests (push) Successful in 2m43s
2025-04-24 14:35:40 +02:00
4af2fa256e Tests: Update dependencies 2025-04-24 14:31:36 +02:00
bf0db37872 Elwig: Update dependencies 2025-04-24 14:31:27 +02:00
3161351a30 Bump version to 0.13.8
All checks were successful
Test / Run tests (push) Successful in 2m19s
Deploy / Build and Deploy (push) Successful in 2m1s
2025-02-21 12:05:34 +01:00
aa98909c0a DeliveryAdminWindow: Fix Handlese/Gerebelt Gewogen input behaviour
All checks were successful
Test / Run tests (push) Successful in 1m51s
2025-02-20 17:06:40 +01:00
775bb08e95 Elwig: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 2m29s
2025-02-20 16:08:52 +01:00
fe0a7dab2a Tests: Update dependencies 2025-02-20 16:08:42 +01:00
138dae715e DeliveryAdminWindow: Allow Gr.Inzersdorf to select LesewagenInput 2025-02-20 15:56:26 +01:00
28af7f8dd3 CHANGELOG: Fix unser anchor names 2025-01-22 16:19:24 +01:00
7cc2f75e7c Bump version to 0.13.7
All checks were successful
Test / Run tests (push) Successful in 2m15s
Deploy / Build and Deploy (push) Successful in 2m23s
2025-01-21 11:59:54 +01:00
c7a2f2241d Billing: Handle negative credit amount in following credits
Some checks failed
Test / Run tests (push) Has been cancelled
2025-01-21 11:58:08 +01:00
bd4ebb8c35 PaymentVariantsWindow: Allow user to change date
All checks were successful
Test / Run tests (push) Successful in 2m35s
2025-01-21 11:03:54 +01:00
6d88c5645c PaymentVariantsWindow: Warn user about negative credit exports 2025-01-21 11:01:56 +01:00
5d017cc8ea MailLogWindow: Fix crash when opening
All checks were successful
Test / Run tests (push) Successful in 2m52s
2025-01-19 17:00:31 +01:00
0b8a1b321f BillingData: Fix collapsing tested with permutations
All checks were successful
Test / Run tests (push) Successful in 3m7s
2025-01-18 12:19:33 +01:00
95927c3f1a ChartWindow: Remove old commented-out code
All checks were successful
Test / Run tests (push) Successful in 2m42s
2025-01-16 09:09:28 +01:00
f7297d313a Bump version to 0.13.6
All checks were successful
Deploy / Build and Deploy (push) Successful in 2m20s
2025-01-14 23:43:20 +01:00
80fec4473a Elwig: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 2m3s
2025-01-14 22:43:53 +01:00
95ccb2627c Tests: Update dependencies 2025-01-14 22:43:04 +01:00
20e3e2a76b BillingData: Fix collapsing with cultivations/defaults
All checks were successful
Test / Run tests (push) Successful in 1m58s
2025-01-14 22:05:48 +01:00
b83df45e8f Bump version to 0.13.5
All checks were successful
Test / Run tests (push) Successful in 2m9s
Deploy / Build and Deploy (push) Successful in 2m22s
2025-01-02 17:41:51 +01:00
c24b1ca2b9 DeliveryAdminWindow: Add WineLocalityStatistics
All checks were successful
Test / Run tests (push) Successful in 2m10s
2025-01-02 17:25:46 +01:00
5e53d864b1 MemberAdminWindow: Add filters for active and non-active members
All checks were successful
Test / Run tests (push) Successful in 2m20s
2025-01-02 14:08:46 +01:00
633b560a67 Tests: Update dependencies 2025-01-02 14:04:50 +01:00
c9e483ba9d Elwig: Update dependencies 2025-01-02 14:04:40 +01:00
c484d27520 Bump version to 0.13.4
All checks were successful
Test / Run tests (push) Successful in 1m54s
Deploy / Build and Deploy (push) Successful in 2m10s
2024-11-25 19:23:20 +01:00
6c7f10cb26 Tests: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 1m55s
2024-11-25 19:19:31 +01:00
4a10e94d71 Elwig: Update dependencies 2024-11-25 19:19:28 +01:00
338f9fe092 AreaComUnderDeliveryData: Also include inactive members with active area commitments
All checks were successful
Test / Run tests (push) Successful in 2m9s
2024-11-25 12:38:04 +01:00
3b97c2243a AreaComUnderDeliveryData: Fix file name 2024-11-25 12:34:43 +01:00
6ba2aa7143 OverUnderDeliveryData: Fix absence of non-deliverers in list
Bug was introduced by commit 9930e6173c
and shipped with v0.10.6 (2024-08-30)
2024-11-25 12:17:23 +01:00
a99a23fd08 Tests: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 2m52s
2024-11-17 16:58:09 +01:00
70e01849be Setup: Update dependencies 2024-11-17 16:57:53 +01:00
c3a2f983d5 Elwig: Update dependencies 2024-11-17 16:57:40 +01:00
ebf0c20a90 Bump version to 0.13.3
All checks were successful
Test / Run tests (push) Successful in 2m26s
Deploy / Build and Deploy (push) Successful in 2m21s
2024-11-13 23:35:29 +01:00
2ee0d56dcc Windows: Add MailLogWindow
All checks were successful
Test / Run tests (push) Successful in 1m54s
2024-11-13 18:37:50 +01:00
0a9731af09 MailWindow: Fix small bugs and persist all settings
All checks were successful
Test / Run tests (push) Successful in 1m54s
2024-11-13 18:07:03 +01:00
6718ad4c8d AreaComAdminWindow: Add filters for season
All checks were successful
Test / Run tests (push) Successful in 2m26s
2024-11-10 16:35:44 +01:00
a1d84dd988 MemberAdminWindow: Add more filters for AreaComs 2024-11-10 16:35:03 +01:00
f4fa549130 Windows: Add icons on Buttons and MenuItems
All checks were successful
Test / Run tests (push) Successful in 2m15s
2024-11-10 10:58:44 +01:00
c5453c2fe6 MainWindow: Add 'Flächenbindungen' and 'Liefermenge/Ertrag' button 2024-11-10 10:58:35 +01:00
54deccf021 MainWindow: Add statistics table in Leseabschluss 2024-11-09 09:49:19 +01:00
f5d3a04cb1 Bump version to 0.13.2
All checks were successful
Test / Run tests (push) Successful in 1m50s
Deploy / Build and Deploy (push) Successful in 2m6s
2024-10-13 19:08:20 +02:00
0675c45617 Elwig: Use ExecuteSql/FromSql instead of ExecuteSqlRaw/FromSqlRaw where possible
All checks were successful
Test / Run tests (push) Successful in 1m42s
2024-10-13 18:24:40 +02:00
d1f67dc57d BaseDataWindow: Fix WineAttr/WineCult Id updates in payment variant data
All checks were successful
Test / Run tests (push) Successful in 2m10s
2024-10-13 18:18:31 +02:00
3cbffdbf27 Documents: Add DeliveryDepreciationList
All checks were successful
Test / Run tests (push) Successful in 1m55s
2024-10-13 11:54:18 +02:00
e247925472 Controls: Fix blurry borders when system scaling is enabled
All checks were successful
Test / Run tests (push) Successful in 2m21s
2024-10-12 14:25:24 +02:00
a1b3cff624 [#11] Tests: Add DeliveryServiceTest
All checks were successful
Test / Run tests (push) Successful in 1m56s
2024-10-07 23:43:22 +02:00
65498dd18f App: Fix BranchLocation shortening
All checks were successful
Test / Run tests (push) Successful in 1m46s
2024-10-05 19:31:59 +02:00
27dc4f648f [#11] Tests: Add MemberServiceTest 2024-10-05 19:31:51 +02:00
86f7f693a0 Export/Bki: Format house nr that excel interprets it correctly
All checks were successful
Test / Run tests (push) Successful in 2m10s
2024-10-02 11:08:14 +02:00
8680e51052 Weighing: Fix scale L320 for Baden 2024-10-02 10:45:04 +02:00
1d97f3c422 Bump version to 0.13.1
All checks were successful
Test / Run tests (push) Successful in 1m38s
Deploy / Build and Deploy (push) Successful in 2m12s
2024-09-29 22:25:39 +02:00
b6ae1f5675 Elwig: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 1m37s
2024-09-29 22:24:31 +02:00
c185437b9a DeliveryService: Do not delete own delivery in SplitDeliveryToLsNr()
All checks were successful
Test / Run tests (push) Successful in 2m8s
2024-09-29 22:12:19 +02:00
a2315e84bd Windows: Ask user if they really want to send an email
All checks were successful
Test / Run tests (push) Successful in 1m46s
2024-09-29 09:43:17 +02:00
6ba1973087 MemberAdminWindow: Fix 'Save as PDF' option for DeliveryConfirmation and CreditNote
All checks were successful
Test / Run tests (push) Successful in 2m5s
2024-09-29 09:16:39 +02:00
c62947dacd DeliveryAdminWindow: Add DeliverySplittingDialog
All checks were successful
Test / Run tests (push) Successful in 2m10s
2024-09-28 19:54:50 +02:00
f29a609d3b Bump version to 0.13.0
All checks were successful
Test / Run tests (push) Successful in 1m38s
Deploy / Build and Deploy (push) Successful in 1m58s
2024-09-25 22:56:48 +02:00
8a61747538 DeliveryAdminWindow: Fix extraction error
All checks were successful
Test / Run tests (push) Successful in 1m47s
2024-09-25 22:51:06 +02:00
4a7c95e250 MailWindow: Make more user safe
All checks were successful
Test / Run tests (push) Successful in 1m50s
2024-09-25 22:30:26 +02:00
4fa5b8f6d4 Billing: Include all deliveries when calculating under delivery for area commitments
All checks were successful
Test / Run tests (push) Successful in 1m43s
2024-09-25 15:32:26 +02:00
579ed53487 Windows: Prettify formatting for numbers
All checks were successful
Test / Run tests (push) Successful in 2m5s
2024-09-25 12:19:25 +02:00
1fc736ce16 Bump version to 0.12.0
All checks were successful
Test / Run tests (push) Successful in 1m54s
Deploy / Build and Deploy (push) Successful in 2m9s
2024-09-24 23:10:17 +02:00
ce39797d8b [#56] Windows: Fail gracefully while saving
All checks were successful
Test / Run tests (push) Successful in 2m11s
2024-09-24 20:10:26 +02:00
94a6dd5312 Printing: Replace PDFtoPrinter with PdfiumViewer 2024-09-24 20:10:26 +02:00
b67857ae22 [#56] AppDbContext: Turn off connection pooling 2024-09-24 20:10:26 +02:00
a48ea8e7e2 Printing/Pdf: Small fixes 2024-09-24 20:10:21 +02:00
0f87446906 Bump version to 0.11.4
All checks were successful
Test / Run tests (push) Successful in 1m47s
Deploy / Build and Deploy (push) Successful in 2m7s
2024-09-22 23:33:45 +02:00
e0fcaf1f53 Services: Fix spacing in tool tip grids
All checks were successful
Test / Run tests (push) Successful in 2m3s
2024-09-22 23:22:23 +02:00
26e549caa6 Bump version to 0.11.3
All checks were successful
Test / Run tests (push) Successful in 1m37s
Deploy / Build and Deploy (push) Successful in 2m28s
2024-09-22 21:05:42 +02:00
1d187c25f3 MemberAdminWindow: Revert caching of MembersDeliveries
All checks were successful
Test / Run tests (push) Successful in 1m46s
2024-09-22 21:01:48 +02:00
accbb9df08 Bump version to 0.11.2
All checks were successful
Test / Run tests (push) Successful in 1m36s
Deploy / Build and Deploy (push) Successful in 2m2s
2024-09-22 20:49:14 +02:00
7791d02979 Services: Extract GenerateToolTipData() from GenerateToolTip()
All checks were successful
Test / Run tests (push) Successful in 1m35s
2024-09-22 20:47:06 +02:00
dcec6f03fe DeliveryAdminWindow: Fix 'Collection was modified' error
All checks were successful
Test / Run tests (push) Successful in 2m1s
2024-09-22 12:35:37 +02:00
526e951029 Elwig: Add LogWindow
All checks were successful
Test / Run tests (push) Successful in 1m49s
2024-09-22 12:16:14 +02:00
3cde360aaa DeliveryAncmtAdminWindow: Replace 'Traubenanmeldung' with 'Anmeldung'
All checks were successful
Test / Run tests (push) Successful in 2m4s
2024-09-22 10:29:48 +02:00
66be5a3e2c MemberAdminWindow: Cache MembersDeliveries
All checks were successful
Test / Run tests (push) Successful in 1m46s
2024-09-21 23:29:10 +02:00
5c12dba125 DeliveryService: Fix duplicate LsNr error
All checks were successful
Test / Run tests (push) Successful in 1m49s
2024-09-21 23:04:30 +02:00
165770fa37 DeliveryAncmtList: Add DefaultKg of member 2024-09-21 23:04:30 +02:00
648c406ad2 Services: Make FillInputs synchronous 2024-09-21 23:04:26 +02:00
9fa9d9fbec DeliveryAdminWindow: Minor layout changes 2024-09-21 21:37:57 +02:00
5dc725620b Bump version to 0.11.1
All checks were successful
Test / Run tests (push) Successful in 2m2s
Deploy / Build and Deploy (push) Successful in 2m7s
2024-09-19 12:35:25 +02:00
27d8a5cfb6 DeliveryAncmtAdminWindow: Add more filters and tooltip for weight
All checks were successful
Test / Run tests (push) Successful in 1m47s
2024-09-19 11:56:45 +02:00
642fb3a625 DeliveryService: Small fixes 2024-09-19 11:54:57 +02:00
3f7cd2a6ff DeliveryAncmtAdminWindow: Focus MgNrInput when creating new ancmt
All checks were successful
Test / Run tests (push) Successful in 2m8s
2024-09-19 09:34:44 +02:00
21a1b11d68 AreaCom: Make YearFrom nullable
All checks were successful
Test / Run tests (push) Successful in 1m48s
2024-09-18 18:26:16 +02:00
d8beb03b96 Tests: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 1m53s
2024-09-17 23:18:51 +02:00
eee90c784b Elwig: Update dependencies 2024-09-17 23:18:41 +02:00
74200083ab DeliveryAncmtAdminWindow: Mark cancelled schedules with Strikethrough
All checks were successful
Test / Run tests (push) Successful in 1m38s
2024-09-17 23:08:22 +02:00
871bc299bd Utils: Fix SplitName() for double names
All checks were successful
Test / Run tests (push) Successful in 1m46s
2024-09-17 19:18:43 +02:00
a18b58f438 DeliveryAncmtAdminWindow: Make delivery schedule list bigger
All checks were successful
Test / Run tests (push) Successful in 2m10s
2024-09-17 19:07:59 +02:00
cadb5515ea Bump version to 0.11.0
All checks were successful
Deploy / Build and Deploy (push) Successful in 2m9s
2024-09-16 11:17:23 +02:00
d8a10152b3 DeliveryScheduleAdminWindow: Add Attribute, Cultivation and IsCancelled
All checks were successful
Test / Run tests (push) Successful in 1m37s
2024-09-16 10:10:31 +02:00
f09c43c1bd App: Make HintContextChange() synchronous by using MainDispatcher
All checks were successful
Test / Run tests (push) Successful in 2m37s
2024-09-12 11:40:32 +02:00
5c08f61963 MailWindow: Add feature to address members with ancmts on specific day
All checks were successful
Test / Run tests (push) Successful in 2m28s
2024-09-08 15:55:10 +02:00
7a15050575 Bump version to 0.10.8
All checks were successful
Test / Run tests (push) Successful in 2m9s
Deploy / Build and Deploy (push) Successful in 2m52s
2024-09-05 23:32:23 +02:00
8d9172f91e AppDbContext: Move all calls to App.HintContextChange() outside of any AppDbContext block
All checks were successful
Test / Run tests (push) Successful in 2m44s
2024-09-05 17:21:00 +02:00
7437187630 DeliveryAncmtAdminWindow: Add date column 2024-09-05 15:28:55 +02:00
a38cdaa8af DeliveryAdminWindow: Slightly increase default width
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-09-04 18:18:19 +02:00
a5638135a3 DeliveryAncmtAdminWindow: Add option to search in all delivery schedules and init mgnr with selected
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-09-04 18:11:56 +02:00
a04c7d538e MemberDataSheet: Add VAT to 'Buchführend'
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-09-04 17:32:34 +02:00
26235f8c0a BusinessDocument: Add ':' in aside block
All checks were successful
Test / Run tests (push) Successful in 2m6s
2024-09-04 17:23:22 +02:00
f43d9c020c DeliveryAncmtList: Center 'Anmldg.' column
All checks were successful
Test / Run tests (push) Successful in 2m54s
2024-09-04 17:18:36 +02:00
22514715c1 DeliveryService: Small text fix 2024-09-04 17:16:14 +02:00
5eda25ed14 Bump version to 0.10.7
All checks were successful
Test / Run tests (push) Successful in 2m2s
Deploy / Build and Deploy (push) Successful in 3m42s
2024-09-02 23:42:00 +02:00
543185d48e DeliveryAdminWindow: Add weight filter
All checks were successful
Test / Run tests (push) Successful in 2m58s
2024-09-02 23:28:55 +02:00
141086673f DeliveryAncmtList: Add status to indicate late ancmts 2024-09-02 23:10:37 +02:00
6627ab6d12 App: Try to fix auto context renewal 2
All checks were successful
Test / Run tests (push) Successful in 2m57s
2024-09-01 11:44:38 +02:00
7ef3faa39e Bump version to 0.10.6
All checks were successful
Deploy / Build and Deploy (push) Successful in 3m12s
2024-08-30 22:35:10 +02:00
8c8c0a8c2b App: Try to fix auto context renewal
All checks were successful
Test / Run tests (push) Successful in 2m23s
2024-08-30 22:26:49 +02:00
78a72c641f MemberAdminWindow: Fix checking and unchecking of ContactEmailInput
All checks were successful
Test / Run tests (push) Successful in 2m3s
2024-08-30 21:40:01 +02:00
e18bc58b6c DeliveryAncmtAdminWindow: Fix bug when pressing Enter in weight input
All checks were successful
Test / Run tests (push) Successful in 2m55s
2024-08-30 21:33:58 +02:00
21f68caf4c DeliveryAncmtAdminWindow: Increase window width 2024-08-30 21:33:16 +02:00
2ef10b4bb2 DeliveryAdminWindow: Scroll DeliveryPartList down when adding new delivery parts 2024-08-30 21:31:44 +02:00
5321be46c7 [#33] ChartWindow: Add CheckBox to indicate which graph (gebunden, normal) is currently selected
All checks were successful
Test / Run tests (push) Successful in 2m54s
2024-08-28 11:14:51 +02:00
0f24f9da08 [#33] ChartWindow: Fix scaling bug 2024-08-28 10:20:21 +02:00
8ce8492c74 MainWindow: Use 'Waage' instead of 'Waagen'
All checks were successful
Test / Run tests (push) Successful in 4m42s
2024-08-26 23:00:24 +02:00
ee1315929c AreaComAdminWindow: Fix window title
All checks were successful
Test / Run tests (push) Successful in 2m59s
2024-08-26 22:12:37 +02:00
9930e6173c Dtos: Rewrite SQL queries to be more efficient
All checks were successful
Test / Run tests (push) Successful in 2m28s
2024-08-24 16:37:41 +02:00
b5c1bfb08f Bump version to 0.10.5
All checks were successful
Test / Run tests (push) Successful in 2m4s
Deploy / Build and Deploy (push) Successful in 2m47s
2024-08-24 14:00:49 +02:00
cd2b482b5a Weighing: Add SetDateAndTime()
All checks were successful
Test / Run tests (push) Successful in 2m22s
2024-08-24 13:54:59 +02:00
bec1b165bf MemberAdminWindow: Allow user to keep AreaCom YearTo when transfering
All checks were successful
Test / Run tests (push) Successful in 2m49s
2024-08-24 13:35:14 +02:00
2ae2564647 DeliveryAncmtAdminWinodw: Do not show warning windows
All checks were successful
Test / Run tests (push) Successful in 2m31s
2024-08-23 14:49:05 +02:00
adbe418b7c DeliveryAncmtAdminWindow: Change status bar spacing
All checks were successful
Test / Run tests (push) Successful in 2m51s
2024-08-23 08:53:48 +02:00
94db0723c5 Bump version to 0.10.4
All checks were successful
Test / Run tests (push) Successful in 2m2s
Deploy / Build and Deploy (push) Successful in 2m48s
2024-08-22 13:36:38 +02:00
f54677d429 DeliveryAncmtAdminWindow: Display stats in status bar
All checks were successful
Test / Run tests (push) Successful in 2m27s
2024-08-22 13:32:08 +02:00
49e4b65c27 MemberAdminWindow: Display currently shown member count and business shares
All checks were successful
Test / Run tests (push) Successful in 2m25s
2024-08-22 12:29:41 +02:00
ada5085cae Validator: Add some syntax sugar
All checks were successful
Test / Run tests (push) Successful in 2m51s
2024-08-22 11:04:24 +02:00
85931e62e8 DeliveryAncmtAdminWindow: Show weekday also in ComboBox
All checks were successful
Test / Run tests (push) Successful in 11m7s
2024-08-21 16:57:21 +02:00
39956cbcbd Bump version to 0.10.3
All checks were successful
Test / Run tests (push) Successful in 2m25s
Deploy / Build and Deploy (push) Successful in 3m20s
2024-08-21 00:01:47 +02:00
84d8d0cecb DeliveryScheduleAdminWindow: Fix AncmtToDateInput input bug
All checks were successful
Test / Run tests (push) Successful in 2m3s
2024-08-20 23:39:08 +02:00
fe7f9d675b DeliveryAncmtAdminWindow: Add day of week to delivery schedule list
All checks were successful
Test / Run tests (push) Successful in 3m0s
2024-08-20 23:31:37 +02:00
9d1ee8638c Bump version to 0.10.2
All checks were successful
Test / Run tests (push) Successful in 1m59s
Deploy / Build and Deploy (push) Successful in 2m41s
2024-08-16 21:31:43 +02:00
cd40075702 ElwigData: Allow legacy field family_name to be used and other fixes
All checks were successful
Test / Run tests (push) Successful in 2m50s
2024-08-16 21:24:04 +02:00
204dfe8745 MemberService: Include area commitments when uploading export data 2024-08-16 21:23:32 +02:00
f97dfc3c72 Bump version to 0.10.1
All checks were successful
Test / Run tests (push) Successful in 2m7s
Deploy / Build and Deploy (push) Successful in 2m59s
2024-08-14 12:02:36 +02:00
d3839c288a MemberList: Allow filtering area commitments 2024-08-14 11:57:19 +02:00
2764a0ca21 Dtos: Fix error when given_name is null 2024-08-14 11:57:04 +02:00
48970de652 Billing: Fix error when no deliveries exist in season 2024-08-14 11:56:25 +02:00
367c3ac357 Bump version to 0.10.0
All checks were successful
Test / Run tests (push) Successful in 2m8s
Deploy / Build and Deploy (push) Successful in 2m37s
2024-08-13 15:23:58 +02:00
4d89a17e80 Billing: Allow users to add custom member modifiers before VAT
All checks were successful
Test / Run tests (push) Successful in 2m8s
2024-08-13 14:43:12 +02:00
f52c11b91e PaymentVariantSummary: Subtract member modifiers from sum
All checks were successful
Test / Run tests (push) Successful in 2m20s
2024-08-12 15:44:04 +02:00
f48c6a02cb [#54] Member: Add IsJuridicalPerson
All checks were successful
Test / Run tests (push) Successful in 2m49s
2024-08-12 15:18:34 +02:00
025ff08d84 [#14] Documents: Add DeliveryAncmtList
All checks were successful
Test / Run tests (push) Successful in 2m35s
2024-08-10 15:45:37 +02:00
b091bd0ec3 [#14] Windows: Add DeliveryAncmtWindow
All checks were successful
Test / Run tests (push) Successful in 2m5s
2024-08-09 22:11:47 +02:00
804a17911c [#14] Windows: Add DeliveryScheduleAdminWindow
All checks were successful
Test / Run tests (push) Successful in 2m58s
2024-08-09 17:45:14 +02:00
170cfda37e Windows: Minor cleanups 2024-08-09 17:44:48 +02:00
2d737e2780 [#14] Models: Add DeliveryAncmt 2024-08-09 17:44:21 +02:00
2333077aa5 Billing: Include predecessors in Treuebonus for WGM
All checks were successful
Test / Run tests (push) Successful in 2m29s
2024-08-08 19:09:38 +02:00
9127cd3f03 MemberAdminWindow: Fix area commitment transfer for new members
All checks were successful
Test / Run tests (push) Successful in 2m5s
2024-08-08 17:35:58 +02:00
036a0dc978 App: Use Version class
All checks were successful
Test / Run tests (push) Successful in 2m28s
2024-08-02 20:48:53 +02:00
7749f6ab45 Bump version to 0.9.3
All checks were successful
Test / Run tests (push) Successful in 2m29s
Deploy / Build and Deploy (push) Successful in 2m38s
2024-08-02 12:22:52 +02:00
cf05a0c658 DeliveryJournalData: Add delivery and member branch to excel export
All checks were successful
Test / Run tests (push) Successful in 2m52s
2024-08-02 11:42:27 +02:00
5567d9f25a Bump version to 0.9.2
All checks were successful
Test / Run tests (push) Successful in 2m7s
Deploy / Build and Deploy (push) Successful in 2m50s
2024-08-01 16:06:13 +02:00
4403754ada MemberAdminWindow: Fix error when saving telephone numbers
All checks were successful
Test / Run tests (push) Successful in 2m23s
2024-08-01 15:57:49 +02:00
8db6007264 MainWindow: Fix closing behaviour when other windows are open
All checks were successful
Test / Run tests (push) Successful in 2m24s
2024-08-01 13:49:04 +02:00
944270744a Bump version to 0.9.1
All checks were successful
Test / Run tests (push) Successful in 2m53s
Deploy / Build and Deploy (push) Successful in 2m36s
2024-08-01 09:12:33 +02:00
10ee1d6548 [#3] MemberService: Export area commitments with members 2024-07-30 17:00:29 +02:00
db4de5b5fe [#3] Windows: Add option to export selected member or delivery only
All checks were successful
Test / Run tests (push) Successful in 2m23s
2024-07-30 14:24:53 +02:00
f69d2809f3 MailWindow: Allow users to send emails without documents
All checks were successful
Test / Run tests (push) Successful in 2m14s
2024-07-30 12:57:07 +02:00
1c2e0baa68 [#3] Services: Use .elwig.zip as export extension everywhere 2024-07-30 12:57:04 +02:00
39f93da0ba SysTecITScale: Add error code 20 for negative weight
All checks were successful
Test / Run tests (push) Successful in 2m39s
2024-07-30 00:07:12 +02:00
91717f8efb Services: Add also messages for TaskCanceledException
All checks were successful
Test / Run tests (push) Successful in 2m21s
2024-07-29 23:35:03 +02:00
7786fb421a DeliveryAdminWindow: Fix scale button ordering
All checks were successful
Test / Run tests (push) Successful in 2m54s
2024-07-29 23:12:00 +02:00
12d2aeecaf Bump version to 0.9.0
All checks were successful
Test / Run tests (push) Successful in 2m50s
Deploy / Build and Deploy (push) Successful in 2m40s
2024-07-28 22:13:17 +02:00
1bc0d67d26 [#3] Services: Add 'Check internet connection' message
All checks were successful
Test / Run tests (push) Successful in 2m46s
2024-07-28 09:35:01 +02:00
38315cd928 [#3] Services: Update 'upload successful' message
All checks were successful
Test / Run tests (push) Successful in 2m24s
2024-07-28 00:27:21 +02:00
53d3affefe DeliveryConfirmation: Use checkboxes for 'gerebelt'
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-07-27 21:55:20 +02:00
4c3f0c40fa DeliveryAdminWindow: Handle members without default KG correctly
All checks were successful
Test / Run tests (push) Successful in 2m44s
2024-07-27 20:46:13 +02:00
662862090e [#3] ElwigData: Fix import error when no deliveries are present
All checks were successful
Test / Run tests (push) Successful in 2m31s
2024-07-27 19:44:22 +02:00
a5164e286f [#3] Services: Use .elwig.zip as export extension 2024-07-27 19:44:22 +02:00
ae1e985656 [#3] MainWindow: Add functionality to import data from files 2024-07-27 19:44:22 +02:00
36c1bd35a7 [#3] MemberAdminWindow: Add Export item in menu 2024-07-27 19:44:22 +02:00
4aa3362029 DeliveryConfirmation: Use 'gerebelt' instead of 'bto./nto.' 2024-07-27 19:44:15 +02:00
cc97004b30 [#3] ElwigData: Fix importing of duplicate data
All checks were successful
Test / Run tests (push) Successful in 2m52s
2024-07-27 16:57:23 +02:00
935b31f6e3 DeliveryAdminWindow: Force user to input gerebelt gewogen input
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-07-26 19:47:47 +02:00
f09753ccc2 Remove byte order marks
All checks were successful
Test / Run tests (push) Successful in 2m4s
2024-07-26 19:44:41 +02:00
53c7cb2ec0 Workflows: Check for byte order mark 2024-07-26 19:44:37 +02:00
80c3ec1b9c Windows: Use Indeterminate event in ThreeState CheckBoxes
All checks were successful
Test / Run tests (push) Successful in 2m19s
2024-07-26 16:15:51 +02:00
b49c9c65b1 [#3] Elwig: Add user-friendly sync method
All checks were successful
Test / Run tests (push) Successful in 2m57s
2024-07-26 14:58:15 +02:00
b6afb94246 MemberListData: Include contact information like phone numbers and email addresses
All checks were successful
Test / Run tests (push) Successful in 2m25s
2024-07-24 19:28:34 +02:00
8e9f2f4e90 WeighingTests: Add Haugsdorf and Sitzendorf
All checks were successful
Test / Run tests (push) Successful in 2m46s
2024-07-24 16:42:38 +02:00
d741ba92dc Printing/Pdf: Set CreateNoWindow to true
All checks were successful
Test / Run tests (push) Successful in 2m6s
2024-07-23 20:22:59 +02:00
84f772a32f MailWindow: Fix crash when no season is present 2024-07-23 20:22:59 +02:00
fd0ed97305 Weighing: Do not ignore gross and tare weight and show it on DeliveryNote 2024-07-23 20:22:59 +02:00
1141331608 MemberAdminWindow: Add filters for E-Mail, Tel.-Nr., and contact options 2024-07-23 20:22:59 +02:00
f235d5b380 DeliveryAdminWindow: Fix ModifierInput_SelectionChanged event 2024-07-23 20:22:59 +02:00
30116f7848 DeliveryAdminWindow: Improve status bar widths 2024-07-23 20:22:59 +02:00
abe7699a5b [#26] MemberAdminWindow: Rearrange status bar items 2024-07-23 20:22:59 +02:00
bb77a4e79a [#26] AreaComAdminWindow: Overhaul status bar and search filters 2024-07-23 20:22:59 +02:00
46ea0f29ff [#26] MemberAdminWindow: Add tooltip to area commitment status bar 2024-07-23 20:22:59 +02:00
4229fbbef6 [#26] AreaComService: Add GenerateToolTip() 2024-07-23 20:22:59 +02:00
8dde1cb3f4 [#10] ViewModels: Unify FilterMember property 2024-07-23 20:22:59 +02:00
c314321039 Utils: Change CurrentLastSeason to switch in july 2024-07-23 20:22:59 +02:00
cf1e975d8e [#10] MemberAdminWindow: Add tooltip for delivieries 2024-07-23 20:22:59 +02:00
60359935a4 [#10] DeliveryAdminWindow: Move generation of tooltips to DeliveryService 2024-07-23 20:22:59 +02:00
49e988f71a [#10] AreaComAdminWindow: Implement MVVM 2024-07-23 20:22:59 +02:00
2a8de18772 [#10] DeliveryAdminWindow: Implement MVVM 2024-07-23 20:22:59 +02:00
af80e827b7 [#10] MemberAdminWindow: Implement MVVM 2024-07-23 20:22:59 +02:00
9a2fa3ee3d Bump version to 0.8.9
All checks were successful
Deploy / Build and Deploy (push) Successful in 2m37s
2024-07-23 20:22:52 +02:00
ba9e1d7201 Export/Ods: Escape strings in XML 2024-07-23 20:13:04 +02:00
49f03c0a3c CheckComboBox: Fix SelectedItems property
All checks were successful
Test / Run tests (push) Successful in 2m12s
2024-07-23 11:08:42 +02:00
37adf92e80 Bump version to 0.8.8
All checks were successful
Test / Run tests (push) Successful in 2m37s
Deploy / Build and Deploy (push) Successful in 2m33s
2024-07-22 09:48:53 +02:00
4c75dbe4aa GassnerScale: Hot fix record parsing 2024-07-22 09:48:18 +02:00
5c31ad8851 Bump version to 0.8.7
All checks were successful
Deploy / Build and Deploy (push) Successful in 2m47s
2024-07-22 00:19:11 +02:00
3ac9536e76 App: Small changes in auto updater
All checks were successful
Test / Run tests (push) Successful in 2m41s
2024-07-21 15:52:57 +02:00
7246852181 E2ETests: Refactor to use .FindElement(By.Something())
All checks were successful
Test / Run tests (push) Successful in 2m12s
2024-07-19 14:34:12 +02:00
dd48a24c58 Setup: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 2m30s
2024-07-19 13:43:48 +02:00
ffef1fd6e4 Elwig: Update dependencies 2024-07-19 13:43:40 +02:00
01d658f51d Tests: Fix flaky tests when extracting table
All checks were successful
Test / Run tests (push) Successful in 2m10s
2024-07-19 10:49:21 +02:00
5a36e84b1f MemberAdminWindow: Make first email address required when contact via email is enabled
Some checks failed
Test / Run tests (push) Failing after 2m37s
2024-07-19 10:35:14 +02:00
5b2f617a68 Tests: Change IBAN and LfbisNr to be valid
All checks were successful
Test / Run tests (push) Successful in 2m14s
2024-07-19 00:41:49 +02:00
dd5049faae E2ETests: Add DeliveryAdminWindowReceiptTest
All checks were successful
Test / Run tests (push) Successful in 1m56s
2024-07-19 00:16:33 +02:00
ffe0ff5508 WeighingTests: Move all scale handlers into ScaleHandlers.cs 2024-07-18 23:46:05 +02:00
34178105a7 E2ETests: Use ElwigTestDB.sqlite3 instead of default
All checks were successful
Test / Run tests (push) Successful in 2m38s
2024-07-08 13:05:21 +02:00
6b48a1090c E2ETests: Refactor initial class structure
All checks were successful
Test / Run tests (push) Successful in 2m35s
2024-07-07 14:35:54 +02:00
ddd821e478 Tests: Add E2ETests
All checks were successful
Test / Run tests (push) Successful in 2m16s
2024-07-07 01:22:43 +02:00
658a1f4dc1 DeliveryAdminWindow: Only show active modifiers in receipt mode
All checks were successful
Test / Run tests (push) Successful in 1m53s
2024-07-06 18:50:02 +02:00
daf83c4bbc CheckComboBox: Add setter for SelectedItems
All checks were successful
Test / Run tests (push) Successful in 2m6s
2024-07-03 12:25:07 +02:00
26d75ea3cd Controls: Use nameof(Property) instead of string
All checks were successful
Test / Run tests (push) Successful in 1m43s
2024-07-02 11:02:07 +02:00
86937485e4 DocumentTests: Fix Test Date
All checks were successful
Test / Run tests (push) Successful in 1m47s
2024-07-02 01:19:12 +02:00
e9de54415a UpdateDialog: Fix cancellation and buttons
All checks were successful
Test / Run tests (push) Successful in 2m24s
2024-07-01 12:04:13 +02:00
62f63ef63d UpdateDialog: Add Link to Changelog
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-07-01 11:07:21 +02:00
44656e0022 Workflows: Only test on push on a branch 2024-07-01 10:03:15 +02:00
80df16999f Bump version to 0.8.6
All checks were successful
Deploy / Build and Deploy (push) Successful in 2m29s
Test / Run tests (push) Successful in 1m44s
2024-07-01 09:59:51 +02:00
d317ccc1e0 [#51] ChartWindow: Select 73 Oechsle per default 2024-06-30 22:04:01 +02:00
6195363335 PaymentVariantsWindow: Rearrange button grid
All checks were successful
Test / Run tests (push) Successful in 1m45s
2024-06-28 23:39:49 +02:00
6a92eb76a0 PaymentAdjustmentWindow: Minor layout changes
Some checks failed
Test / Run tests (push) Has been cancelled
2024-06-28 23:38:04 +02:00
f9d6da7bc8 [#49] PaymentVariantSummary: Add section heading
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-06-28 23:09:07 +02:00
9478f2a1ab [#49] PaymentVariantSummary: Add modifier statistics
All checks were successful
Test / Run tests (push) Successful in 2m18s
2024-06-28 21:07:55 +02:00
157d0b75a2 [#52] BaseDataWindow: Better group penalties in season tab
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-06-28 17:32:40 +02:00
255bcbe3ad CreditNote: Show business share penalty correctly
All checks were successful
Test / Run tests (push) Successful in 2m3s
2024-06-28 15:43:05 +02:00
bce2eea3ac MemberAdminWindow: Add menu item for generating CreditNotes per member
All checks were successful
Test / Run tests (push) Successful in 2m5s
2024-06-28 13:48:22 +02:00
91c60018f1 [#48] Dtos/CreditNoteData: Include custom member modifiers
All checks were successful
Test / Run tests (push) Successful in 2m28s
2024-06-28 13:05:08 +02:00
5037818997 [#48] Billing: Add custom modifiers for members
All checks were successful
Test / Run tests (push) Successful in 2m21s
2024-06-27 13:40:52 +02:00
5c76b8ec52 PaymentAdjustmentWindow: Improve DataGrid and add status bar
All checks were successful
Test / Run tests (push) Successful in 2m26s
2024-06-26 19:04:43 +02:00
9d9bb099e1 Workflows: Improve deploy and test workflow 2024-06-25 23:09:43 +02:00
f4172235be Changelog: Add v0.7.0, v0.7.1, and v0.7.2
All checks were successful
Test / Run tests (push) Successful in 1m44s
2024-06-25 12:10:11 +02:00
299c65ab1a Changelog: Reformat
All checks were successful
Test / Run tests (push) Successful in 2m29s
2024-06-25 10:43:47 +02:00
ba8034ad75 Changelog: Add v0.6.5, v0.6.6, v0.6.7, and v0.6.8
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-06-23 21:46:04 +02:00
7c63373a02 Changelog: Add v0.8.0
All checks were successful
Test / Run tests (push) Successful in 2m24s
2024-06-23 21:01:46 +02:00
750ae53428 Test: Fix flaky DocumentTests by using arrays
All checks were successful
Test / Run tests (push) Successful in 1m46s
2024-06-20 22:44:00 +02:00
1121c18dc5 Changelog: Add v0.8.2 and v0.8.1
Some checks failed
Test / Run tests (push) Failing after 2m0s
2024-06-20 11:38:43 +02:00
96a3168d49 Changelog: Add description for v0.8.3
All checks were successful
Test / Run tests (push) Successful in 2m1s
2024-06-19 19:11:54 +02:00
e627f13264 Add Changelog and Readme
All checks were successful
Test / Run tests (push) Successful in 1m47s
2024-06-19 17:27:20 +02:00
7ce8c3cabf MailWindow: Allow user to change document date
All checks were successful
Test / Run tests (push) Successful in 1m55s
2024-06-17 19:28:21 +02:00
763f0197ca CreditNote: Remove calc time and add Variant.Date
All checks were successful
Test / Run tests (push) Successful in 2m1s
2024-06-17 19:01:47 +02:00
43dddf2c07 PaymentAdjustmentWindow: Lock auto ajusting in old seasons 2024-06-17 18:58:39 +02:00
70129695ae Bump version to 0.8.5
All checks were successful
Test / Run tests (push) Successful in 1m41s
Deploy / Build and Deploy (push) Successful in 2m21s
2024-06-17 11:31:26 +02:00
51b9799b56 [#46] PaymentAdjustmentWindow: Persist parameters in ClientParameters
All checks were successful
Test / Run tests (push) Successful in 1m53s
2024-06-17 11:25:35 +02:00
c1903b1f36 [#46] PaymentAdjustmentWindow: Refine DataGrid
All checks were successful
Test / Run tests (push) Successful in 1m55s
2024-06-17 11:03:32 +02:00
66eb177fbf [#46] Billing: Only adjust business shares for active members 2024-06-17 10:51:48 +02:00
87467bbe75 Export/Ebics: Remove blank line for not shown <Ctry/> 2024-06-17 10:47:14 +02:00
abf465f821 OverUnderDeliveryData: Also show inactive members
All checks were successful
Test / Run tests (push) Successful in 1m42s
2024-06-17 10:24:58 +02:00
792c18365e MailWindow: Send DeliveryConfirmations and CreditNotes also to inactive members
All checks were successful
Test / Run tests (push) Successful in 2m16s
2024-06-17 10:17:28 +02:00
5c46a00752 [#46] Windows: Add PaymentAdjustmentWindow
All checks were successful
Test / Run tests (push) Successful in 2m13s
2024-06-17 01:41:32 +02:00
9d9f929843 [#46] MemberHistory: Add Type to PK 2024-06-17 01:19:25 +02:00
b76c5ea874 [#46] CreditNote: Show number of added business shares
All checks were successful
Test / Run tests (push) Successful in 1m57s
2024-06-16 23:54:53 +02:00
86e69e9ff8 [#48] PaymentVariantsWindow: Add checkbox for custom member modifiers
All checks were successful
Test / Run tests (push) Successful in 2m22s
2024-06-16 18:31:02 +02:00
050e4f5b6f ControlUtils: Allow RenewItemsSource for ListBox to reselect all items
All checks were successful
Test / Run tests (push) Successful in 2m21s
2024-06-14 17:02:25 +02:00
01f055ee17 Test: Fix DocumentTests again?
All checks were successful
Test / Run tests (push) Successful in 1m42s
2024-06-14 12:15:05 +02:00
da9df5cbeb Export/Ebics: Warn user if no client IBAN is set
Some checks failed
Test / Run tests (push) Failing after 2m22s
2024-06-14 12:11:49 +02:00
cc0aa6046f Export/Ebics: Also export Ctry in address line mode
All checks were successful
Test / Run tests (push) Successful in 2m25s
2024-06-13 10:00:49 +02:00
5cb7d2cbb0 Export/Ebics: Escape address properly
All checks were successful
Test / Run tests (push) Successful in 1m47s
2024-06-13 01:48:37 +02:00
6c1e50ad02 Bump version to 0.8.4
All checks were successful
Test / Run tests (push) Successful in 1m44s
Deploy / Build and Deploy (push) Successful in 2m23s
2024-06-13 01:45:53 +02:00
46551fb142 Tests: Implement tests for Austrian Ebics
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-06-13 01:43:23 +02:00
b404839ad1 Tests: Fix DocumentTests? 2024-06-13 01:39:12 +02:00
ab926421b0 Export/Ebics: Implement version customization
Some checks failed
Test / Run tests (push) Failing after 2m22s
2024-06-13 01:19:36 +02:00
bbd8b67afd MainWindow: Unify gaps between buttons
All checks were successful
Test / Run tests (push) Successful in 1m45s
2024-06-12 18:55:50 +02:00
70f8276808 MainWindow: Fix crash on closing, when other window is in editing or creating mode
All checks were successful
Test / Run tests (push) Successful in 2m1s
2024-06-12 17:05:57 +02:00
4483eb6a69 [#37] Controls: Implement CheckComboBox and remove xctk
All checks were successful
Test / Run tests (push) Successful in 2m26s
2024-06-12 16:29:57 +02:00
6fc38b9db0 Bump version to 0.8.3
All checks were successful
Test / Run tests (push) Successful in 1m44s
Deploy / Build and Deploy (push) Successful in 2m27s
2024-06-11 12:43:13 +02:00
5a4ff26f31 [#16] DeleteMemberDialog: Highlight invalid/not-checked inputs
All checks were successful
Test / Run tests (push) Successful in 1m59s
2024-06-11 12:34:07 +02:00
012352c562 DeliveryAdminWindow: Fix ModifierInput source
All checks were successful
Test / Run tests (push) Successful in 1m45s
2024-06-11 11:55:47 +02:00
81f286f504 BaseDataWindow: Set SeasonPenaltyPerBs inputs to readonly when applicable
All checks were successful
Test / Run tests (push) Successful in 2m21s
2024-06-11 11:21:21 +02:00
324a63cf9a DeliveryAdminWindow: Fix modifier bug
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-06-11 01:22:43 +02:00
ca0497e396 [#44] BaseDataWindow: Fix conversion between season precisions
All checks were successful
Test / Run tests (push) Successful in 1m59s
2024-06-10 23:01:42 +02:00
08f551a394 PaymentVariantSummary: Show net/gross modifier in statistics
All checks were successful
Test / Run tests (push) Successful in 2m18s
2024-06-10 22:48:44 +02:00
3460b9378c [#44] BaseDataWindow: Add button to add/delete seasons
All checks were successful
Test / Run tests (push) Successful in 2m1s
2024-06-10 20:43:38 +02:00
a06921d4ec Windows: Minor UI text changes
All checks were successful
Test / Run tests (push) Successful in 1m57s
2024-06-10 17:38:27 +02:00
f2c2d3270b ChartWindow: Round PriceInput.Text
All checks were successful
Test / Run tests (push) Successful in 1m44s
2024-06-10 16:30:21 +02:00
6927d44b82 AreaComWindow: Add style for UnitTextBox
All checks were successful
Test / Run tests (push) Successful in 1m55s
2024-06-10 16:26:25 +02:00
cc0843f183 [#45] MemberAdminWindow: Add dialog for area commitment cancellation/transfer
Some checks failed
Test / Run tests (push) Failing after 52s
2024-06-10 16:22:28 +02:00
5039c1252a MailWindow: Fix crash on area commitment filter
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-06-10 12:43:42 +02:00
6e4f3b799d MailWindow: Fix crash when selecting custom members
All checks were successful
Test / Run tests (push) Successful in 1m44s
2024-06-10 11:53:53 +02:00
4c9a151f77 DeliveryConfirmation: Do not print sender by default
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-06-10 11:49:20 +02:00
03cacf604b Dialogs: Refactor XAML
All checks were successful
Test / Run tests (push) Successful in 2m27s
2024-06-10 10:10:45 +02:00
c12d111c57 [#16] Dialogs: Add DeleteMemberDialog
All checks were successful
Test / Run tests (push) Successful in 2m0s
2024-06-08 18:22:55 +02:00
302870fb58 [#47] Billing: Add penalty per business share
All checks were successful
Test / Run tests (push) Successful in 2m2s
2024-06-08 16:13:01 +02:00
f756220d75 BaseDataWindow: Fix 'Schilling crash'
All checks were successful
Test / Run tests (push) Successful in 2m17s
2024-06-07 09:51:23 +02:00
293c8967be Installer: Update URLs in config.ini
All checks were successful
Test / Run tests (push) Successful in 2m27s
2024-06-07 00:23:34 +02:00
601ac548fe Tests: Update dependencies
All checks were successful
Test / Run tests (push) Successful in 2m7s
2024-06-03 18:30:42 +02:00
4e477c38e0 Elwig: Update dependencies 2024-06-03 18:30:34 +02:00
46fc0db6ba IntegerUpDown: Fix xml spacing
All checks were successful
Test / Run tests (push) Successful in 1m41s
2024-06-03 17:13:37 +02:00
a531e948c1 [#37] IntegerUpDown: Add middle line
All checks were successful
Test / Run tests (push) Successful in 1m42s
2024-06-03 17:07:40 +02:00
cc4ec6c5db [#37] Controls: Implement IntegerUpDown
All checks were successful
Test / Run tests (push) Successful in 2m28s
2024-06-03 16:59:45 +02:00
ff375e3caf curl: Add '--fail' argument to return a meaningful status code
All checks were successful
Test / Run tests (push) Successful in 1m54s
2024-05-15 00:24:42 +02:00
264 changed files with 20714 additions and 5292 deletions

View File

@@ -1,7 +1,7 @@
name: Deploy
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
tags: ["v[0-9]+.[0-9]+.[0-9]+.[0-9]+"]
jobs:
deploy:
name: Build and Deploy
@@ -41,6 +41,7 @@ jobs:
uses: akkuman/gitea-release-action@v1
with:
name: Elwig ${{ env.APP_VERSION }}
body: "**[Changelog](src/branch/main/CHANGELOG.md#v${{ env.APP_VERSION }})**"
files: |-
Setup/bin/x64/Release/Elwig-${{ env.APP_VERSION }}.exe
- name: Upload to website

View File

@@ -2,6 +2,7 @@ name: Test
on:
push:
branches: ["**"]
paths: ["Elwig/**", "Tests/**", "Installer/Files/*.exe", ".gitea/workflows/test.yaml"]
jobs:
test:
name: Run tests
@@ -9,6 +10,19 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for Byte order marks
shell: powershell
run: |
$pattern = [char]::ConvertFromUtf32(0xFEFF)
$files = git grep -IEl "^$pattern"
if ( $lastexitcode -ne 1 ) {
echo "Files with BOM found:"
echo $files
exit 1
} else {
echo "No files with BOM found"
exit 0
}
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
- name: Setup NuGet
@@ -26,4 +40,4 @@ jobs:
shell: powershell
run: |
$env:PATH = "$(pwd)\Installer\Files;" + $env:PATH
$(& dotnet test Tests; $a=$lastexitcode) | findstr x*; exit $a
$(& dotnet test Tests --filter "FullyQualifiedName!~E2ETests"; $a=$lastexitcode) | findstr x*; exit $a

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ bin/
Tests/Resources/Sql/Create.sql
*.exe
!WinziPrint.exe
*.sqlite3

1023
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -30,17 +30,25 @@
<DataTemplate x:Key="WineVarietyTemplateCollapsed">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Name}" Foreground="{Binding Color}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="WineVarietyTemplateExpanded">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SortId}" MinWidth="36" Margin="0,0,10,0"/>
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding SortId}" Foreground="{Binding Color}" MinWidth="36" Margin="0,0,10,0"/>
<TextBlock Text="{Binding Name}" Foreground="{Binding Color}"/>
<TextBlock Text="{Binding CommentFormat}" FontSize="10" VerticalAlignment="Bottom" Margin="0,0,0,2"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="AreaCommitmentTypeTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding WineVar.Name}" Foreground="{Binding WineVar.Color}"/>
<TextBlock Text="{Binding WineAttr.Name}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding Discriminator}" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ModifierTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" MinWidth="250" Margin="0,0,10,0"/>

View File

@@ -7,9 +7,6 @@ using Elwig.Helpers;
using Elwig.Helpers.Weighing;
using System.Collections.Generic;
using System.Windows.Threading;
using System.Globalization;
using System.Threading;
using System.Windows.Markup;
using System.Reflection;
using Elwig.Helpers.Printing;
using Elwig.Windows;
@@ -28,23 +25,17 @@ namespace Elwig {
private readonly DispatcherTimer _autoUpdateTimer = new() { Interval = TimeSpan.FromHours(1) };
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
public static readonly string ExePath = @"C:\Program Files\Elwig\";
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Elwig");
public static readonly string MailsPath = Path.Combine(DataPath, "mails");
public static readonly string ConfigPath = Path.Combine(DataPath, "config.ini");
public static readonly string InstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Elwig");
public static readonly string DocumentsPath = (Assembly.GetEntryAssembly()?.Location.Contains(@"\bin\") ?? false) ?
Path.Combine(Assembly.GetEntryAssembly()!.Location.Split(@"\bin\")[0], "../Elwig/Documents") :
Path.Combine(InstallPath, "resources/Documents");
public static readonly string TempPath = Path.Combine(Path.GetTempPath(), "Elwig");
public static readonly Config Config = new(DataPath + "config.ini");
public static int VersionMajor { get; private set; }
public static int VersionMinor { get; private set; }
public static int VersionPatch { get; private set; }
public static string Version {
get => $"{VersionMajor}.{VersionMinor}.{VersionPatch}";
private set {
var p = value.Split(".").Select(p => int.Parse(p.Trim())).ToArray();
VersionMajor = p.ElementAtOrDefault(0);
VersionMinor = p.ElementAtOrDefault(1);
VersionPatch = p.ElementAtOrDefault(2);
}
}
public static Config Config { get; private set; } = new(ConfigPath);
public static Version Version { get; private set; } = new();
public static int BranchNum { get; private set; }
public static string ZwstId { get; private set; }
@@ -69,42 +60,32 @@ namespace Elwig {
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Directory.CreateDirectory(TempPath);
Directory.CreateDirectory(DataPath);
Directory.CreateDirectory(MailsPath);
MainDispatcher = Dispatcher;
Scales = [];
CurrentApp = this;
OverrideCulture();
Utils.OverrideCulture();
var args = Environment.GetCommandLineArgs();
if (args.Length >= 2) {
Config = new(Path.GetFullPath(args[1]));
}
ContextTimer.Tick += (object? sender, EventArgs evt) => {
if (CurrentLastWrite > LastChanged) {
LastChanged = CurrentLastWrite;
var ch = CurrentLastWrite;
if (ch > LastChanged) {
LastChanged = ch;
OnContextChanged();
}
};
}
private static void OnContextChanged() {
MainDispatcher.BeginInvoke(async () => await HintContextChange());
}
private static void OverrideCulture() {
var locale = new CultureInfo("de-AT", false);
locale.NumberFormat.CurrencyGroupSeparator = Utils.GroupSeparator;
locale.NumberFormat.NumberGroupSeparator = Utils.GroupSeparator;
locale.NumberFormat.PercentGroupSeparator = Utils.GroupSeparator;
CultureInfo.CurrentCulture = locale;
CultureInfo.CurrentUICulture = locale;
Thread.CurrentThread.CurrentCulture = locale;
Thread.CurrentThread.CurrentUICulture = locale;
CultureInfo.DefaultThreadCurrentCulture = locale;
CultureInfo.DefaultThreadCurrentUICulture = locale;
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name))
);
MainDispatcher.BeginInvoke(HintContextChange);
}
protected override async void OnStartup(StartupEventArgs evt) {
Version = typeof(App).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split('+')[0] ?? "0.0.0";
Version = new Version(typeof(App).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split('+')[0] ?? "0.0.0.0");
try {
await AppDbUpdater.CheckDb();
@@ -159,7 +140,7 @@ namespace Elwig {
list.Add(Scale.FromConfig(s));
} catch (Exception e) {
list.Add(new InvalidScale(s.Id));
if (Config.Debug || s.Required)
if (s.Required)
MessageBox.Show($"Unable to create scale {s.Id}:\n\n{e.Message}", "Scale Error",
MessageBoxButton.OK, MessageBoxImage.Error);
}
@@ -187,6 +168,9 @@ namespace Elwig {
}
private async void Application_Exit(object sender, ExitEventArgs evt) {
foreach (var s in EventScales) {
s.Dispose();
}
await Pdf.Cleanup();
}
@@ -198,19 +182,30 @@ namespace Elwig {
ZwstId = entry.Item1;
BranchName = entry.Item2;
BranchPlz = entry.Item3;
BranchLocation = entry.Item4?.Split(" im ")[0].Split(" an ")[0].Split(" bei ")[0]; // FIXME
BranchLocation = entry.Item4?
.Split(" in ")[0]
.Split(" im ")[0]
.Split(" an ")[0]
.Split(" am ")[0]
.Split(" bei ")[0]
.Split(" beim ")[0];
BranchAddress = entry.Item5;
BranchPhoneNr = entry.Item6;
BranchFaxNr = entry.Item7;
BranchMobileNr = entry.Item8;
}
public static async Task HintContextChange() {
CurrentApp.LastChanged = CurrentLastWrite;
foreach (Window w in CurrentApp.Windows) {
if (w is not ContextWindow c) continue;
await c.HintContextChange();
}
public static void HintContextChange() {
if (CurrentApp == null) return;
var ch = CurrentLastWrite;
if (ch > CurrentApp.LastChanged)
CurrentApp.LastChanged = ch;
MainDispatcher.Invoke(() => {
foreach (Window w in CurrentApp.Windows) {
if (w is not ContextWindow c) continue;
MainDispatcher.BeginInvoke(c.HintContextChange);
}
});
}
private void OnAutoUpdateTimer(object? sender, EventArgs? evt) {
@@ -222,10 +217,10 @@ namespace Elwig {
}
}
public static async Task CheckForUpdates(bool showSuccess = false) {
public static async Task CheckForUpdates(bool showAlert = false) {
if (Config.UpdateUrl == null) return;
var latest = await Utils.GetLatestInstallerUrl(Config.UpdateUrl);
if (latest != null && new Version(latest.Value.Version) > new Version(Version)) {
if (latest != null && new Version(latest.Value.Version) > Version) {
await MainDispatcher.BeginInvoke(() => {
var d = new UpdateDialog(latest.Value.Version, latest.Value.Url, latest.Value.Size);
if (d.ShowDialog() == true) {
@@ -233,9 +228,14 @@ namespace Elwig {
Current.Shutdown();
}
});
} else if (showSuccess) {
MessageBox.Show("Elwig ist auf dem aktuellsten Stand!", "Nach Updates suchen",
MessageBoxButton.OK, MessageBoxImage.Information);
} else if (showAlert) {
if (latest == null) {
MessageBox.Show("Informationen konnten nicht abgerufen werden!", "Nach Updates suchen",
MessageBoxButton.OK, MessageBoxImage.Error);
} else {
MessageBox.Show($"Elwig ist auf dem aktuellsten Stand! (Version: {latest.Value.Version})", "Nach Updates suchen",
MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
@@ -254,15 +254,15 @@ namespace Elwig {
}
public static DeliveryAdminWindow FocusReceipt() {
return FocusWindow<DeliveryAdminWindow>(() => new(true), w => w.IsReceipt);
return FocusWindow<DeliveryAdminWindow>(() => new(true), w => w.ViewModel.IsReceipt);
}
public static DeliveryAdminWindow FocusMemberDeliveries(int mgnr) {
return FocusWindow<DeliveryAdminWindow>(() => new(mgnr), w => w.MgNr == mgnr);
return FocusWindow<DeliveryAdminWindow>(() => new(mgnr), w => w.ViewModel.FilterMember?.MgNr == mgnr);
}
public static AreaComAdminWindow FocusMemberAreaComs(int mgnr) {
return FocusWindow<AreaComAdminWindow>(() => new(mgnr), w => w.MgNr == mgnr);
return FocusWindow<AreaComAdminWindow>(() => new(mgnr), w => w.ViewModel.FilterMember.MgNr == mgnr);
}
public static BaseDataWindow FocusBaseData() {
@@ -292,10 +292,22 @@ namespace Elwig {
return w;
}
public static DeliveryAncmtAdminWindow FocusDeliveryAncmt() {
return FocusWindow<DeliveryAncmtAdminWindow>(() => new());
}
public static DeliveryScheduleAdminWindow FocusDeliverySchedule() {
return FocusWindow<DeliveryScheduleAdminWindow>(() => new());
}
public static PaymentVariantsWindow FocusPaymentVariants(int year) {
return FocusWindow<PaymentVariantsWindow>(() => new(year), w => w.Year == year);
}
public static PaymentAdjustmentWindow FocusPaymentAdjustment(int year) {
return FocusWindow<PaymentAdjustmentWindow>(() => new(year), w => w.Year == year);
}
public static ChartWindow FocusChartWindow(int year, int avnr) {
return FocusWindow<ChartWindow>(() => new(year, avnr), w => w.Year == year && w.AvNr == avnr);
}

View File

@@ -0,0 +1,167 @@
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace Elwig.Controls {
public class CheckComboBox : ListBox {
public new static readonly DependencyProperty SelectedItemsProperty = DependencyProperty.Register(nameof(SelectedItems), typeof(IList), typeof(CheckComboBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedItemsChangedCallback));
public new IList SelectedItems {
get => (IList)GetValue(SelectedItemsProperty);
set => SetValue(SelectedItemsProperty, value);
}
public static readonly DependencyProperty DelimiterProperty = DependencyProperty.Register(nameof(Delimiter), typeof(string), typeof(CheckComboBox), new FrameworkPropertyMetadata(", "));
public string Delimiter {
get => (string)GetValue(DelimiterProperty);
set => SetValue(DelimiterProperty, value);
}
public static readonly DependencyProperty ListDisplayMemberPathProperty = DependencyProperty.Register(nameof(ListDisplayMemberPath), typeof(string), typeof(CheckComboBox), new FrameworkPropertyMetadata(null));
public string ListDisplayMemberPath {
get => (string)GetValue(ListDisplayMemberPathProperty);
set => SetValue(ListDisplayMemberPathProperty, value);
}
public static readonly DependencyProperty AllItemsSelectedContentProperty = DependencyProperty.Register(nameof(AllItemsSelectedContent), typeof(string), typeof(CheckComboBox), new FrameworkPropertyMetadata("All"));
public string AllItemsSelectedContent {
get => (string)GetValue(AllItemsSelectedContentProperty);
set => SetValue(AllItemsSelectedContentProperty, value);
}
public static readonly DependencyProperty IsSelectAllActiveProperty = DependencyProperty.Register(nameof(IsSelectAllActive), typeof(bool), typeof(CheckComboBox), new FrameworkPropertyMetadata(false));
public bool IsSelectAllActive {
get => (bool)GetValue(IsSelectAllActiveProperty);
set => SetValue(IsSelectAllActiveProperty, value);
}
public static readonly DependencyProperty SelectAllContentProperty = DependencyProperty.Register(nameof(SelectAllContent), typeof(string), typeof(CheckComboBox), new FrameworkPropertyMetadata("All"));
public string SelectAllContent {
get => (string)GetValue(SelectAllContentProperty);
set => SetValue(SelectAllContentProperty, value);
}
public static readonly DependencyProperty AllItemsSelectedProperty = DependencyProperty.Register(nameof(AllItemsSelected), typeof(bool?), typeof(CheckComboBox), new FrameworkPropertyMetadata(false));
public bool? AllItemsSelected {
get => (bool?)GetValue(AllItemsSelectedProperty);
set => SetValue(AllItemsSelectedProperty, value);
}
public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register(nameof(IsDropDownOpen), typeof(bool), typeof(CheckComboBox), new FrameworkPropertyMetadata(false));
public bool IsDropDownOpen {
get => (bool)GetValue(IsDropDownOpenProperty);
set => SetValue(IsDropDownOpenProperty, value);
}
public static readonly DependencyProperty MaxDropDownHeightProperty = DependencyProperty.Register(nameof(MaxDropDownHeight), typeof(double), typeof(CheckComboBox), new FrameworkPropertyMetadata(ComboBox.MaxDropDownHeightProperty.DefaultMetadata.DefaultValue));
public double MaxDropDownHeight {
get => (double)GetValue(MaxDropDownHeightProperty);
set => SetValue(MaxDropDownHeightProperty, value);
}
public new static readonly RoutedEvent SelectionChangedEvent = EventManager.RegisterRoutedEvent(nameof(SelectionChanged), RoutingStrategy.Bubble, typeof(SelectionChangedEventHandler), typeof(CheckComboBox));
public new event SelectionChangedEventHandler SelectionChanged {
add => AddHandler(SelectionChangedEvent, value);
remove => RemoveHandler(SelectionChangedEvent, value);
}
static CheckComboBox() {
DefaultStyleKeyProperty.OverrideMetadata(typeof(CheckComboBox), new FrameworkPropertyMetadata(typeof(CheckComboBox)));
}
private bool _viewHandled;
private bool _modelHandled;
private TextBlock _textBox;
public CheckComboBox() {
SelectionMode = SelectionMode.Multiple;
SelectedItems = new ObservableCollection<object>();
}
public override void OnApplyTemplate() {
_textBox = (GetTemplateChild("TextBox") as TextBlock)!;
var button = GetTemplateChild("Button") as Button;
button!.Click += Button_MouseDown;
var item = GetTemplateChild("SelectAllItem") as ListBoxItem;
item!.PreviewMouseDown += SelectAllItem_MouseDown;
if (SelectedItems is INotifyCollectionChanged collection) {
collection.CollectionChanged += (s, e) => { SelectItems(); };
}
IsEnabledChanged += OnIsEnabledChanged;
base.SelectionChanged += OnSelectionChanged;
base.OnApplyTemplate();
}
private static void OnSelectedItemsChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) {
if (sender is CheckComboBox ccb)
ccb.OnSelectedItemsChanged();
}
private void OnSelectedItemsChanged() {
if (SelectedItems is INotifyCollectionChanged collection) {
collection.CollectionChanged += (s, e) => { SelectItems(); };
}
SelectItems();
}
private void Button_MouseDown(object sender, RoutedEventArgs evt) {
IsDropDownOpen = !IsDropDownOpen;
}
private void SelectAllItem_MouseDown(object sender, RoutedEventArgs evt) {
if (AllItemsSelected == false) {
SelectAll();
} else {
UnselectAll();
}
evt.Handled = true;
}
private void OnSelectionChanged(object sender, SelectionChangedEventArgs evt) {
SelectItemsReverse();
var dmp = !string.IsNullOrEmpty(ListDisplayMemberPath) ? ListDisplayMemberPath : !string.IsNullOrEmpty(DisplayMemberPath) ? DisplayMemberPath : null;
if (SelectedItems.Count == ItemsSource.Cast<object>().Count() && AllItemsSelectedContent != null) {
_textBox.Text = AllItemsSelectedContent;
AllItemsSelected = true;
} else if (SelectedItems.Count == 0) {
_textBox.Text = "";
AllItemsSelected = false;
} else {
_textBox.Text = string.Join(Delimiter,
dmp == null ? SelectedItems.Cast<object>() :
SelectedItems.Cast<object>()
.Select(i => i.GetType().GetProperty(dmp)?.GetValue(i))
);
AllItemsSelected = null;
}
RaiseEvent(new SelectionChangedEventArgs(SelectionChangedEvent, evt.RemovedItems, evt.AddedItems));
}
private void OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs evt) {
if (!IsEnabled) IsDropDownOpen = false;
}
private void SelectItems() {
if (_viewHandled || _modelHandled)
return;
_viewHandled = true;
base.SelectedItems.Clear();
foreach (var item in SelectedItems)
base.SelectedItems.Add(item);
_viewHandled = false;
}
private void SelectItemsReverse() {
if (_modelHandled || _viewHandled)
return;
_modelHandled = true;
SelectedItems.Clear();
foreach (var item in base.SelectedItems)
SelectedItems.Add(item);
_modelHandled = false;
}
}
}

View File

@@ -0,0 +1,118 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:Elwig.Controls">
<ctrl:VisibilityConverter x:Key="VisibilityConverter"/>
<Style TargetType="ctrl:CheckComboBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ctrl:CheckComboBox">
<Grid Style="{x:Null}">
<Button x:Name="Button" ClickMode="Press" BorderThickness="1"
BorderBrush="{TemplateBinding BorderBrush}"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource TemplatedParent}}">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
<Path x:Name="IconDropdown" Data="M 0,0 L 3,3 L 6,0" Stroke="#FF606060" StrokeThickness="1" Margin="0,0,5,0"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
</Button>
<TextBlock x:Name="TextBox" Style="{x:Null}" Margin="6,0,18,0" IsHitTestVisible="False"
HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
<Popup x:Name="Popup" Placement="Bottom" Focusable="True"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
PopupAnimation="Slide" AllowsTransparency="True">
<Popup.Style>
<Style TargetType="{x:Type Popup}">
<Setter Property="StaysOpen" Value="False"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=Button}" Value="True">
<Setter Property="StaysOpen" Value="True"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=Border}" Value="True">
<Setter Property="StaysOpen" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Popup.Style>
<Border x:Name="Border" Style="{x:Null}" BorderThickness="1" BorderBrush="Gray" Background="White" SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<DockPanel>
<ListBoxItem x:Name="SelectAllItem" Padding="2,1,2,1" DockPanel.Dock="Top"
Visibility="{TemplateBinding IsSelectAllActive, Converter={StaticResource VisibilityConverter}}">
<StackPanel Orientation="Horizontal">
<CheckBox VerticalAlignment="Center" Margin="0,0,5,0" IsThreeState="True"
IsChecked="{Binding AllItemsSelected, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
<TextBlock Text="{TemplateBinding SelectAllContent}" VerticalAlignment="Center" Margin="0" SnapsToDevicePixels="True"/>
</StackPanel>
</ListBoxItem>
<ScrollViewer Style="{x:Null}">
<StackPanel Style="{x:Null}" IsItemsHost="True" SnapsToDevicePixels="True"
KeyboardNavigation.DirectionalNavigation="Contained"/>
</ScrollViewer>
</DockPanel>
</Border>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="IconDropdown" Property="Stroke" Value="#FFA0A0A0"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="IconDropdown" Property="Stroke" Value="Black"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="2,1,2,1">
<StackPanel Orientation="Horizontal">
<CheckBox VerticalAlignment="Center" Margin="0,0,5,0"
IsChecked="{Binding IsSelected, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ListBoxItem}}"/>
<ContentPresenter VerticalAlignment="Center" Margin="0" SnapsToDevicePixels="True"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="1"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="#FF70C0E7"/>
<Setter Property="Background" Value="#FFE5F3FB"/>
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="#FF7EB4EA"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,106 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace Elwig.Controls {
public class IntegerUpDown : TextBox {
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(nameof(Minimum), typeof(int?), typeof(IntegerUpDown), new FrameworkPropertyMetadata(null));
public int? Minimum {
get => (int?)GetValue(MinimumProperty);
set => SetValue(MinimumProperty, value);
}
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(nameof(Maximum), typeof(int?), typeof(IntegerUpDown), new FrameworkPropertyMetadata(null));
public int? Maximum {
get => (int?)GetValue(MaximumProperty);
set => SetValue(MaximumProperty, value);
}
public int? Value {
get => int.TryParse(Text, out var res) ? res : null;
set => Text = $"{value}";
}
static IntegerUpDown() {
DefaultStyleKeyProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(typeof(IntegerUpDown)));
}
public IntegerUpDown() {
TextChanged += IntegerUpDown_TextChanged;
LostFocus += IntegerUpDown_LostFocus;
KeyUp += IntegerUpDown_KeyUp;
}
public override void OnApplyTemplate() {
var incButton = GetTemplateChild("IncrementButton") as RepeatButton;
var decButton = GetTemplateChild("DecrementButton") as RepeatButton;
incButton!.Click += IncrementButton_Click;
decButton!.Click += DecrementButton_Click;
base.OnApplyTemplate();
}
private void IntegerUpDown_TextChanged(object sender, TextChangedEventArgs evt) {
var idx = CaretIndex;
Text = new string(Text.Where(char.IsAsciiDigit).Take(4).ToArray());
CaretIndex = idx;
evt.Handled = !(Value >= Minimum && Value <= Maximum);
if (idx >= 4) {
if (Value < Minimum) {
Value = Minimum;
} else if (Value > Maximum) {
Value = Maximum;
}
CaretIndex = 4;
}
}
private void IntegerUpDown_LostFocus(object sender, RoutedEventArgs evt) {
if (Value < Minimum) {
Value = Minimum;
} else if (Value > Maximum) {
Value = Maximum;
}
}
private void IncrementButton_Click(object sender, RoutedEventArgs evt) {
Value = Math.Min((Value ?? 0) + 1, Maximum ?? int.MaxValue);
}
private void DecrementButton_Click(object sender, RoutedEventArgs evt) {
Value = Math.Max((Value ?? 0) - 1, Minimum ?? int.MinValue);
}
private void IntegerUpDown_KeyUp(object sender, KeyEventArgs evt) {
switch (evt.Key) {
case Key.Up:
case Key.Add:
case Key.OemPlus:
Value = Math.Min((Value ?? 0) + 1, Maximum ?? int.MaxValue);
evt.Handled = true;
CaretIndex = 4;
break;
case Key.Down:
case Key.Subtract:
case Key.OemMinus:
Value = Math.Max((Value ?? 0) - 1, Minimum ?? int.MinValue);
evt.Handled = true;
CaretIndex = 4;
break;
case Key.PageUp:
Value = Math.Min((Value ?? 0) + 10, Maximum ?? int.MaxValue);
evt.Handled = true;
CaretIndex = 4;
break;
case Key.PageDown:
Value = Math.Max((Value ?? 0) - 10, Minimum ?? int.MinValue);
evt.Handled = true;
CaretIndex = 4;
break;
}
}
}
}

View File

@@ -0,0 +1,53 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:Elwig.Controls">
<Style TargetType="ctrl:IntegerUpDown" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ctrl:IntegerUpDown">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="18"/>
</Grid.ColumnDefinitions>
<Border x:Name="Border" BorderThickness="1,1,0,1" Grid.RowSpan="2"
BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
</Border>
<RepeatButton x:Name="IncrementButton" Padding="0" Height="Auto" Width="Auto" BorderThickness="1,1,1,1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Grid.Column="1">
<Path x:Name="IconIncrement" Data="M 0,4 L 4,0 L 8,4 Z" Fill="#FF444444"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</RepeatButton>
<RepeatButton x:Name="DecrementButton" Padding="0" Height="Auto" Width="Auto" BorderThickness="1,0,1,1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" Grid.Column="1">
<Path x:Name="IconDecrement" Data="M 0,0 L 4,4 L 8,0 Z" Fill="#FF444444"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</RepeatButton>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="BorderBrush" Value="LightGray"/>
<Setter TargetName="IconIncrement" Property="Fill" Value="#FF888888"/>
<Setter TargetName="IconDecrement" Property="Fill" Value="#FF888888"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="TextAlignment" Value="Right"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,41 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Elwig.Controls {
public class UnitConverter : DependencyObject, IValueConverter {
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register(nameof(Unit), typeof(string), typeof(UnitConverter), new FrameworkPropertyMetadata(null));
public string Unit {
get => (string)GetValue(UnitProperty);
set => SetValue(UnitProperty, value);
}
public static readonly DependencyProperty PrecisionProperty = DependencyProperty.Register(nameof(Precision), typeof(byte), typeof(UnitConverter), new FrameworkPropertyMetadata((byte)0));
public byte Precision {
get => (byte)GetValue(PrecisionProperty);
set => SetValue(PrecisionProperty, value);
}
public object? Convert(object? value, Type targetType, object parameter, CultureInfo culture) {
if (value == null) {
return null;
}
var fmt = $"{{0:N{Precision}}}";
var unit = $"{(Unit != null ? " " : "")}{Unit}";
if (value is int i) {
return $"{string.Format(fmt, i)}{unit}";
} else if (value is decimal d) {
return $"{string.Format(fmt, d)}{unit}";
}
return Binding.DoNothing;
}
public object? ConvertBack(object? value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}
}

View File

@@ -1,10 +1,10 @@
using System.Windows;
using System.Windows;
using System.Windows.Controls;
namespace Elwig.Controls {
public class UnitTextBox : TextBox {
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register("Unit", typeof(string), typeof(UnitTextBox), new FrameworkPropertyMetadata(""));
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register(nameof(Unit), typeof(string), typeof(UnitTextBox), new FrameworkPropertyMetadata(""));
public string Unit {
get => (string)GetValue(UnitProperty);
set => SetValue(UnitProperty, value);

View File

@@ -1,14 +1,14 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:Elwig.Controls">
<Style TargetType="ctrl:UnitTextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ctrl:UnitTextBox">
<Border BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
SnapsToDevicePixels="True">
<Grid>
<Border x:Name="Border"
BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
BorderBrush="{Binding Path=BorderBrush, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<Grid Background="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Bottom">
<ScrollViewer.Margin>
<Binding ElementName="UnitBlock" Path="ActualWidth">
@@ -22,9 +22,21 @@
FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="3"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Border" Property="BorderBrush" Value="LightGray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="TextAlignment" Value="Right"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,16 @@
using System;
using System.Windows;
using System.Windows.Data;
using System.Globalization;
namespace Elwig.Controls {
public class VisibilityConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return (Visibility)value == Visibility.Visible;
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Windows;
using System.Windows.Data;
using System.Globalization;

View File

@@ -1,4 +1,4 @@
using System.Windows.Controls;
using System.Windows.Controls;
using System.Windows;
namespace Elwig.Controls {
@@ -12,4 +12,4 @@ namespace Elwig.Controls {
}
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Windows.Controls;
using System.Windows.Controls;
using System.Windows;
namespace Elwig.Controls {

View File

@@ -1,4 +1,4 @@
using System.Windows.Controls;
using System.Windows.Controls;
using System.Windows;
namespace Elwig.Controls {

View File

@@ -1,59 +0,0 @@
<Window x:Class="Elwig.Dialogs.AbwertenDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
mc:Ignorable="d"
ResizeMode="NoResize"
ShowInTaskbar="False"
Topmost="True"
WindowStartupLocation="CenterOwner"
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
Title="Teillieferung abwerten" Height="190" Width="400">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="2,4,2,4"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Height" Value="25"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Margin="10,10,10,10" Grid.ColumnSpan="2" TextWrapping="Wrap" TextAlignment="Center">
Welche Menge der Teillieferung <Run x:Name="TextLsNr" FontWeight="Bold" Text="20201010A000/1"/><LineBreak/>
von <Run x:Name="TextMember" FontWeight="Bold" Text="Max Mustermann"/><LineBreak/>
mit <Run x:Name="TextWeight" FontWeight="Bold" Text="1&#x202f;000&#x202f;kg"/> soll abgewertet werden?
</TextBlock>
<Label Content="Gewicht:" Margin="10,70,10,10"/>
<Grid Grid.Column="1" Width="70" Height="25" Margin="0,70,10,10" HorizontalAlignment="Left" VerticalAlignment="Top">
<TextBox x:Name="WeightInput" TextAlignment="Right" Padding="2,2,17,2"
TextChanged="WeightInput_TextChanged"/>
<Label Content="kg" Margin="0,4,3,0" HorizontalAlignment="Right" FontSize="10" Padding="2,4,2,4"/>
</Grid>
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.Column="1" IsEnabled="False" IsDefault="True"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
</Grid>
</Window>

View File

@@ -1,33 +0,0 @@
using Elwig.Helpers;
using System.Windows;
using System.Windows.Controls;
namespace Elwig.Dialogs {
public partial class AbwertenDialog : Window {
public int Weight;
public AbwertenDialog(string lsnr, string name, int weight) {
Weight = weight;
InitializeComponent();
TextLsNr.Text = lsnr;
TextMember.Text = name;
TextWeight.Text = $"{weight:N0}{Utils.UnitSeparator}kg";
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
Weight = int.Parse(WeightInput.Text);
Close();
}
private void UpdateButtons() {
ConfirmButton.IsEnabled = int.TryParse(WeightInput.Text, out var w) && w > 0 && w <= Weight;
}
private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
Validator.CheckInteger(WeightInput, true, 5);
UpdateButtons();
}
}
}

View File

@@ -0,0 +1,71 @@
<Window x:Class="Elwig.Dialogs.AreaComModifyDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
xmlns:ctrl="clr-namespace:Elwig.Controls"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Flächenbindungen bearbeiten" Height="220" Width="450">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="2,4,2,4"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Height" Value="25"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<TextBlock x:Name="QuestionBlock1" TextAlignment="Center" Margin="0,10,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top">
Soll die Flächenbindung (<Run Text="{Binding Area}"/> m², <Run Text="{Binding OrigYearFrom}"/><Run Text="{Binding OrigYearTo}"/>) rückwirkend bearbeitet werden,<LineBreak/>
oder erst ab der angegebenen Saison?
</TextBlock>
<TextBlock x:Name="QuestionBlock2" TextAlignment="Center" Margin="0,10,0,0" Visibility="Hidden"
HorizontalAlignment="Center" VerticalAlignment="Top">
Soll die Flächenbindung (<Run Text="{Binding Area}"/> m², <Run Text="{Binding OrigYearFrom}"/><Run Text="{Binding OrigYearTo}"/>) rückwirkend gelöscht werden,<LineBreak/>
oder erst ab der angegebenen Saison?
</TextBlock>
<Label x:Name="SeasonLabel" Content="Saison:" Margin="0,50,100,0"
HorizontalAlignment="Center" VerticalAlignment="Top"/>
<ctrl:IntegerUpDown x:Name="SeasonInput" Width="56" Height="25" Margin="0,50,0,0" FontSize="14"
Minimum="1900" Maximum="9999"
HorizontalAlignment="Center" VerticalAlignment="Top"
TextChanged="SeasonInput_TextChanged"/>
<CheckBox x:Name="RetroactiveInput" Content="Rückwirkend bearbeiten" Margin="0,80,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top"
Checked="RetroactiveInput_Changed" Unchecked="RetroactiveInput_Changed"
IsChecked="{Binding ModifyRetroactively}"/>
<TextBlock x:Name="DescBlock1" Margin="0,105,0,0" TextAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Top">
Die Flächenbindung bleibt bis inkl. Saison <Bold><Run x:Name="CancelSeason1"/></Bold> unverändert,<LineBreak/>
und wird ab inkl. Saison <Bold><Run x:Name="NewSeason1"/></Bold> in geänderter Form übernommen.
</TextBlock>
<TextBlock x:Name="DescBlock2" Margin="0,105,0,0" TextAlignment="Center" Visibility="Hidden"
HorizontalAlignment="Center" VerticalAlignment="Top">
Die Flächenbindung bleibt bis inklusive Saison <Bold><Run x:Name="CancelSeason2"/></Bold> gültig.
</TextBlock>
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.Column="1"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
</Grid>
</Window>

View File

@@ -0,0 +1,62 @@
using Elwig.Helpers;
using System.Windows;
using System.Windows.Controls;
namespace Elwig.Dialogs {
public partial class AreaComModifyDialog : Window {
public int? YearTo { get; set; }
public bool ModifyRetroactively { get; set; }
public string OrigYearFrom { get; set; }
public string OrigYearTo { get; set; }
public string Area { get; set; }
public AreaComModifyDialog(int? yearFrom, int? yearTo, int area, bool delete) {
Area = $"{area:N0}";
OrigYearFrom = $"{yearFrom}";
OrigYearTo = $"{yearTo}";
InitializeComponent();
Title = delete ? "Flächenbindung löschen" : "Flächenbindung bearbeiten";
RetroactiveInput.Content = delete ? "Rückwirkend löschen" : "Rückwirkend bearbeiten";
if (delete) {
QuestionBlock1.Visibility = Visibility.Hidden;
QuestionBlock2.Visibility = Visibility.Visible;
DescBlock1.Visibility = Visibility.Hidden;
DescBlock2.Visibility = Visibility.Visible;
}
if ((yearTo.HasValue && yearTo < Utils.CurrentNextSeason) || (yearFrom.HasValue && yearFrom >= Utils.CurrentNextSeason)) {
RetroactiveInput.IsChecked = true;
} else {
SeasonInput.Text = $"{Utils.CurrentNextSeason}";
}
}
private void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
YearTo = SeasonInput.Value! - 1;
CancelSeason1.Text = $"{YearTo}";
CancelSeason2.Text = $"{YearTo}";
NewSeason1.Text = $"{YearTo + 1}";
}
private void RetroactiveInput_Changed(object sender, RoutedEventArgs evt) {
if (ModifyRetroactively) {
SeasonInput.IsEnabled = false;
SeasonInput.Text = "";
YearTo = null;
DescBlock1.Visibility = Visibility.Hidden;
DescBlock2.Visibility = Visibility.Hidden;
} else {
SeasonInput.IsEnabled = true;
SeasonInput.Text = $"{Utils.CurrentNextSeason}";
DescBlock1.Visibility = QuestionBlock1.Visibility;
DescBlock2.Visibility = QuestionBlock2.Visibility;
}
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
Close();
}
}
}

View File

@@ -0,0 +1,78 @@
<Window x:Class="Elwig.Dialogs.AreaComTransferDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
xmlns:ctrl="clr-namespace:Elwig.Controls"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Flächenbindungen übertragen" Height="260" Width="450">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="2,4,2,4"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Height" Value="25"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<TextBlock x:Name="QuestionBlock1" TextAlignment="Center" Margin="0,10,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top">
Sollen die aktiven Flächenbindungen des angegebenen Vorgängers<LineBreak/>
übernommen werden? (<Run Text="{Binding AreaComNum}"/> FB, <Run Text="{Binding Area}"/> m²)
</TextBlock>
<TextBlock x:Name="QuestionBlock2" TextAlignment="Center" Margin="0,10,0,0" Visibility="Hidden"
HorizontalAlignment="Center" VerticalAlignment="Top">
Sollen die aktiven Flächenbindungen gekündigt werden? (<Run Text="{Binding AreaComNum}"/> FB, <Run Text="{Binding Area}"/> m²)
</TextBlock>
<Label x:Name="SeasonLabel" Content="Saison:" Margin="0,50,100,0"
HorizontalAlignment="Center" VerticalAlignment="Top"/>
<ctrl:IntegerUpDown x:Name="SeasonInput" Width="56" Height="25" Margin="0,50,0,0" FontSize="14"
Minimum="1900" Maximum="9999"
HorizontalAlignment="Center" VerticalAlignment="Top"
TextChanged="SeasonInput_TextChanged"/>
<CheckBox x:Name="CopyYearToInput" Content="Beginn der Laufzeit von Vorgänger übernehmen" Margin="0,80,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top"
Checked="CopyYearToInput_Changed" Unchecked="CopyYearToInput_Changed"
IsChecked="{Binding MaintainYearFrom}"/>
<TextBlock x:Name="DescBlock1" Margin="0,105,0,0" TextAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Top">
Die Flächenbindungen beim <Bold>Vorgänger</Bold> sind bis inkl. Saison <Bold><Run x:Name="CancelSeason1"/></Bold> gültig,<LineBreak/>
und werden beim <Bold>Nachfolger</Bold> ab <Run x:Name="DescBlock1Season" Text="inkl. Saison "/><Bold><Run x:Name="TransferSeason"/></Bold> übernommen.
</TextBlock>
<TextBlock x:Name="DescBlock2" Margin="0,70,0,0" TextAlignment="Center" Visibility="Hidden"
HorizontalAlignment="Center" VerticalAlignment="Top">
Die Flächenbindungen sind bis inklusive Saison <Bold><Run x:Name="CancelSeason2"/></Bold> gültig.
</TextBlock>
<TextBlock x:Name="InfoBlock" Margin="0,0,0,75" TextAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Bottom">
Falls die Flächenbindungen später an ein neues Mitglied<LineBreak/>
übertragen werden sollen bitte <Italic>Nein</Italic> auswählen!
</TextBlock>
<TextBlock Text="Die Änderungen werden erst beim Speichern übernommen!"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,50"/>
<Button x:Name="ConfirmButton" Content="Ja" Margin="10,10,115,10" Grid.Column="1"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Nein" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
</Grid>
</Window>

View File

@@ -0,0 +1,60 @@
using Elwig.Helpers;
using System.Windows;
using System.Windows.Controls;
namespace Elwig.Dialogs {
public partial class AreaComTransferDialog : Window {
public int CancelSeason { get; set; }
public int SuccessorSeason => CancelSeason + 1;
public bool MaintainYearFrom { get; set; }
public string AreaComNum { get; set; }
public string Area { get; set; }
public AreaComTransferDialog(string name, int areaComNum, int area) {
CancelSeason = Utils.FollowingSeason - 1;
AreaComNum = $"{areaComNum:N0}";
Area = $"{area:N0}";
InitializeComponent();
SeasonInput.Text = $"{CancelSeason}";
Title = $"Aktive Flächenbindungen kündigen - {name}";
QuestionBlock1.Visibility = Visibility.Hidden;
QuestionBlock2.Visibility = Visibility.Visible;
DescBlock1.Visibility = Visibility.Hidden;
DescBlock2.Visibility = Visibility.Visible;
CopyYearToInput.Visibility = Visibility.Hidden;
Height = 240;
SeasonInput.Margin = new(0, 40, 0, 0);
SeasonLabel.Margin = new(0, 40, 100, 0);
}
public AreaComTransferDialog(string name, string successorName, int areaComNum, int area) {
CancelSeason = Utils.FollowingSeason - 1;
AreaComNum = $"{areaComNum:N0}";
Area = $"{area:N0}";
InitializeComponent();
SeasonInput.Text = $"{CancelSeason}";
Title = $"Aktive Flächenbindungen übertragen - {name} - {successorName}";
InfoBlock.Visibility = Visibility.Hidden;
}
private void SeasonInput_TextChanged(object sender, TextChangedEventArgs evt) {
CancelSeason = (int)SeasonInput.Value!;
CancelSeason1.Text = $"{CancelSeason}";
CancelSeason2.Text = $"{CancelSeason}";
TransferSeason.Text = MaintainYearFrom ? "" : $"{SuccessorSeason}";
DescBlock1Season.Text = MaintainYearFrom ? "dem originalen Beginn der FB" : "inkl. Saison ";
}
private void CopyYearToInput_Changed(object sender, RoutedEventArgs evt) {
TransferSeason.Text = MaintainYearFrom ? "" : $"{SuccessorSeason}";
DescBlock1Season.Text = MaintainYearFrom ? "dem originalen Beginn der FB" : "inkl. Saison ";
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
Close();
}
}
}

View File

@@ -0,0 +1,64 @@
<Window x:Class="Elwig.Dialogs.DeleteMemberDialog"
AutomationProperties.AutomationId="DeleteMemberDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Mitglied löschen" Height="280" Width="400">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="2,4,2,4"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Height" Value="25"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
<Style TargetType="CheckBox">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<TextBlock TextAlignment="Center" Margin="10,10,10,10" VerticalAlignment="Top">
Bei Bestätigung wird das Mitglied samt zugehöriger Daten<LineBreak/>
<Bold>unwiderruflich gelöscht!</Bold> Wenn möglich sollte stattdessen<LineBreak/>
der Status des Mitglieds auf <Italic>Inaktiv</Italic> gesetzt werden!
</TextBlock>
<Label Content="Name u. MgNr. wiederholen:" Margin="10,60,10,10" HorizontalAlignment="Center"/>
<TextBox x:Name="NameInput" Margin="10,85,10,10"
TextChanged="NameInput_TextChanged"/>
<Label Content="Beim Löschen müssen folgende Daten auch gelöscht werden:" Margin="10,120,10,10"/>
<CheckBox x:Name="AreaComInput" Content="Flächenbindungen" Margin="40,145,0,0"
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
IsChecked="{Binding DeleteAreaComs}"/>
<CheckBox x:Name="DeliveryInput" Content="Lieferungen" Margin="40,165,0,0"
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
IsChecked="{Binding DeleteDeliveries}"/>
<CheckBox x:Name="PaymentInput" Content="Auszahlungsdaten" Margin="40,185,0,0"
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"
IsChecked="{Binding DeletePaymentData}"/>
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" IsEnabled="False"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" IsCancel="True"/>
</Grid>
</Window>

View File

@@ -0,0 +1,66 @@
using Elwig.Helpers;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace Elwig.Dialogs {
public partial class DeleteMemberDialog : Window {
protected string[] NameParts;
public bool DeleteAreaComs { get; set; }
public bool DeleteDeliveries { get; set; }
public bool DeletePaymentData { get; set; }
public DeleteMemberDialog(int mgnr, string name, int numAreaComs, int numDeliveries, int numCredits) {
NameParts = name.ToLower().Split(' ').Where(p => p.Length > 0).Append($"{mgnr}").ToArray();
InitializeComponent();
Title += " - " + name;
AreaComInput.IsEnabled = numAreaComs != 0;
AreaComInput.Content += $" ({numAreaComs:N0})";
DeliveryInput.IsEnabled = numDeliveries != 0;
DeliveryInput.Content += $" ({numDeliveries:N0})";
PaymentInput.IsEnabled = numCredits != 0;
PaymentInput.Content += $" ({numCredits:N0})";
}
private void NameInput_TextChanged(object sender, TextChangedEventArgs evt) {
Update();
}
private void CheckBox_Changed(object sender, RoutedEventArgs evt) {
Update();
}
private static void UpdateCheckBox(CheckBox cb) {
if (cb.IsEnabled && cb.IsChecked != true) {
ControlUtils.SetInputInvalid(cb);
} else {
ControlUtils.ClearInputState(cb);
}
}
private void Update() {
var t = NameInput.Text.ToLower().Split(' ');
var nameValid = NameParts.All(t.Contains);
UpdateCheckBox(AreaComInput);
UpdateCheckBox(DeliveryInput);
UpdateCheckBox(PaymentInput);
if (!nameValid) {
ControlUtils.SetInputInvalid(NameInput);
} else {
ControlUtils.ClearInputState(NameInput);
}
ConfirmButton.IsEnabled =
(!AreaComInput.IsEnabled || DeleteAreaComs) &&
(!DeliveryInput.IsEnabled || DeleteDeliveries) &&
(!PaymentInput.IsEnabled || DeletePaymentData) &&
nameValid;
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
Close();
}
}
}

View File

@@ -1,60 +0,0 @@
<Window x:Class="Elwig.Dialogs.DeliveryExtractionDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
mc:Ignorable="d"
ResizeMode="NoResize"
ShowInTaskbar="False"
Topmost="True"
WindowStartupLocation="CenterOwner"
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
Title="Teillieferung extrahieren" Height="210" Width="380">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="2,4,2,4"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Height" Value="25"/>
<Setter Property="TextWrapping" Value="NoWrap"/>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Margin="10,10,0,10" TextWrapping="Wrap">
Was soll mit der Teillieferung <Run x:Name="TextLsNr" FontWeight="Bold" Text="20201010A000/1"/><LineBreak/>
von <Run x:Name="TextMember" FontWeight="Bold" Text="Max Mustermann"/> geschehen?
</TextBlock>
<RadioButton x:Name="NewDeliveryButton" Content="Neue Lieferung erstellen"
Margin="10,80,0,10" HorizontalAlignment="Left" VerticalAlignment="Top"
Checked="Selection_Changed" Unchecked="Selection_Changed"/>
<RadioButton x:Name="AddToDeliveryButton" Content="Zu Lieferung hinzufügen"
Margin="10,100,0,10" HorizontalAlignment="Left" VerticalAlignment="Top"
Checked="Selection_Changed" Unchecked="Selection_Changed"/>
<ListBox x:Name="DeliveryList" Grid.Column="1" Margin="10,10,10,45"
SelectionChanged="DeliveryList_SelectionChanged"/>
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.ColumnSpan="2" IsEnabled="False" IsDefault="True"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.ColumnSpan="2" IsCancel="True"/>
</Grid>
</Window>

View File

@@ -1,37 +0,0 @@
using System.Collections.Generic;
using System.Windows;
namespace Elwig.Dialogs {
public partial class DeliveryExtractionDialog : Window {
public string? AddTo;
public DeliveryExtractionDialog(string lsnr, string name, bool single, IEnumerable<string> lsnrs) {
InitializeComponent();
TextLsNr.Text = lsnr;
TextMember.Text = name;
NewDeliveryButton.IsEnabled = !single;
DeliveryList.IsEnabled = false;
DeliveryList.ItemsSource = lsnrs;
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
AddTo = NewDeliveryButton.IsChecked == true ? "new" : DeliveryList.SelectedItem as string;
Close();
}
private void UpdateButtons() {
ConfirmButton.IsEnabled = NewDeliveryButton.IsChecked == true || (AddToDeliveryButton.IsChecked == true && DeliveryList.SelectedItem != null);
DeliveryList.IsEnabled = AddToDeliveryButton.IsChecked == true;
}
private void Selection_Changed(object sender, RoutedEventArgs evt) {
UpdateButtons();
}
private void DeliveryList_SelectionChanged(object sender, RoutedEventArgs evt) {
UpdateButtons();
}
}
}

View File

@@ -0,0 +1,104 @@
<local:ContextWindow
x:Class="Elwig.Dialogs.DeliverySplittingDialog"
AutomationProperties.AutomationId="DeliverySplittingDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Elwig.Windows"
xmlns:ctrl="clr-namespace:Elwig.Controls"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Lieferung abwerten oder aufteilen" Height="400" Width="600">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<RadioButton x:Name="DepreciateModeInput" GroupName="ModeInput" Content="Abwerten" Margin="15,10,10,10" IsChecked="True"
VerticalAlignment="Top" HorizontalAlignment="Left"
Checked="ModeInput_Changed"/>
<RadioButton x:Name="MemberModeInput" GroupName="ModeInput" Content="Auf Mitglied übertragen" Margin="15,30,10,10"
VerticalAlignment="Top" HorizontalAlignment="Left"
Checked="ModeInput_Changed"/>
<RadioButton x:Name="DeliveryModeInput" GroupName="ModeInput" Content="Zu anderer Lieferung hinzufügen" Margin="15,50,10,10"
VerticalAlignment="Top" HorizontalAlignment="Left"
Checked="ModeInput_Changed"/>
<TextBox x:Name="MgNrInput" FontSize="14" Padding="2" Visibility="Hidden"
Width="48" Margin="220,10,0,0" Height="25" TextAlignment="Right"
TextChanged="MgNrInput_TextChanged"
VerticalAlignment="Top" HorizontalAlignment="Left"/>
<ComboBox x:Name="MemberInput" FontSize="14" Visibility="Hidden"
Margin="273,10,40,10" IsEditable="True" Height="25"
ItemTemplate="{StaticResource MemberAdminNameTemplate}" TextSearch.TextPath="AdministrativeName"
SelectionChanged="MemberInput_SelectionChanged"
VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
<Button x:Name="MemberReferenceButton" Height="25" Width="25" FontFamily="Segoe MDL2 Assets" Content="&#xEE35;" Padding="0"
Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Right" ToolTip="Zu Mitglied springen" FontSize="14" Visibility="Hidden"
Click="MemberReferenceButton_Click"/>
<ComboBox x:Name="DeliveryInput" FontSize="14" Visibility="Hidden"
Margin="220,10,10,10" Height="25"
TextSearch.TextPath="LsNr"
SelectionChanged="DeliveryInput_SelectionChanged"
VerticalAlignment="Top" HorizontalAlignment="Stretch">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding LsNr}" Width="100"/>
<TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="80" TextAlignment="Right" Margin="0,0,10,0"/>
<TextBlock Text="{Binding Member.AdministrativeName}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock x:Name="InfoBlock" Margin="230,45,10,10" FontSize="14" TextAlignment="Right"
VerticalAlignment="Top" HorizontalAlignment="Stretch"
Text="Insgesamt 0 kg / 0 kg ausgewählt."/>
<ListBox x:Name="DeliveryPartList" Margin="10,75,10,40" ItemsSource="{Binding DeliveryParts, Mode=TwoWay}">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Focusable" Value="False"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Part.DPNr}" Width="20" TextAlignment="Right"
VerticalAlignment="Center" Margin="0,0,5,0" FontSize="14"/>
<TextBlock Text="{Binding Part.SortId}" Width="40" TextAlignment="Center"
VerticalAlignment="Center" Margin="0,0,0,0" FontSize="14"/>
<TextBlock Text="{Binding Part.Kmw, StringFormat='{}{0:N1}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Part.QualId}" Width="30"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Part.Weight, StringFormat='{}{0:N0} kg'}" Width="70" TextAlignment="Right"
VerticalAlignment="Center" Margin="0,0,10,0" FontSize="14"/>
<TextBlock Text="{Binding Part.Attribute.Name}" Width="60"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Part.Cultivation.Name}" Width="50"
VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding SplitCompletely, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Content="Vollständig" Tag="{Binding Part.DPNr}"
VerticalAlignment="Center" Margin="20,0,5,0"
Checked="SplitCompletelyInput_Changed" Unchecked="SplitCompletelyInput_Changed"/>
<ctrl:UnitTextBox Text="{Binding SplitWeightString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Unit="kg" Width="70" Height="25" IsEnabled="{Binding SplitWeightEnabled}" Tag="{Binding Part.DPNr}"
VerticalAlignment="Center" Margin="5,0,5,0" FontSize="14" Padding="2" Background="White"
TextChanged="SplitWeightInput_TextChanged"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" IsEnabled="False"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" IsCancel="True"/>
</Grid>
</local:ContextWindow>

View File

@@ -0,0 +1,163 @@
using Elwig.Helpers;
using Elwig.Models.Entities;
using Elwig.Windows;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace Elwig.Dialogs {
public partial class DeliverySplittingDialog : ContextWindow {
public class Row {
public DeliveryPart Part { get; set; }
public bool SplitCompletely { get; set; }
public string? SplitWeightString { get; set; }
public int? SplitWeight {
get => int.TryParse(SplitWeightString, out var v) ? v : null;
set => SplitWeightString = $"{value}";
}
public bool SplitWeightEnabled { get; set; }
}
private readonly Delivery _delivery;
public int? MgNr { get; set; }
public string? LsNr { get; set; }
public int[]? Weights => DeliveryParts.Select(r => r.SplitCompletely ? r.Part.Weight : r.SplitWeight ?? 0).ToArray();
public ObservableCollection<Row> DeliveryParts { get; set; }
public DeliverySplittingDialog(Delivery d) {
_delivery = d;
DeliveryParts = new(d.Parts.Select(p => new Row {
Part = p,
SplitCompletely = false,
SplitWeight = null,
SplitWeightEnabled = true,
}).ToList());
InitializeComponent();
}
protected override async Task OnRenewContext(AppDbContext ctx) {
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
.Where(m => m.IsActive)
.OrderBy(m => m.Name)
.ThenBy(m => m.GivenName)
.ToListAsync());
ControlUtils.RenewItemsSource(DeliveryInput, await ctx.Deliveries
.Where(d => d.DateString == $"{_delivery.Date:yyyy-MM-dd}" && d.ZwstId == _delivery.ZwstId)
.OrderBy(d => d.LsNr)
.Include(d => d.Member)
.Include(d => d.Parts)
.ToListAsync());
if (DeliveryInput.SelectedItem == null)
ControlUtils.SelectItem(DeliveryInput, _delivery);
CheckValidity();
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
if (DepreciateModeInput.IsChecked == true) {
MgNr = null;
LsNr = null;
} else if (MemberModeInput.IsChecked == true) {
MgNr = ((Member)MemberInput.SelectedItem).MgNr;
LsNr = null;
} else if (DeliveryModeInput.IsChecked == true) {
MgNr = null;
LsNr = ((Delivery)DeliveryInput.SelectedItem).LsNr;
}
DialogResult = true;
Close();
}
private void ModeInput_Changed(object sender, RoutedEventArgs evt) {
if (!IsLoaded) return;
CheckValidity();
if (DepreciateModeInput.IsChecked == true) {
MgNrInput.Visibility = Visibility.Hidden;
MemberInput.Visibility = Visibility.Hidden;
MemberReferenceButton.Visibility = Visibility.Hidden;
DeliveryInput.Visibility = Visibility.Hidden;
} else if (MemberModeInput.IsChecked == true) {
MgNrInput.Visibility = Visibility.Visible;
MemberInput.Visibility = Visibility.Visible;
MemberReferenceButton.Visibility = Visibility.Visible;
DeliveryInput.Visibility = Visibility.Hidden;
} else if (DeliveryModeInput.IsChecked == true) {
MgNrInput.Visibility = Visibility.Hidden;
MemberInput.Visibility = Visibility.Hidden;
MemberReferenceButton.Visibility = Visibility.Hidden;
DeliveryInput.Visibility = Visibility.Visible;
}
}
private void CheckValidity() {
var weight = DeliveryParts.Sum(r => r.SplitCompletely ? r.Part.Weight : r.SplitWeight ?? 0);
var total = DeliveryParts.Sum(r => r.Part.Weight);
InfoBlock.Text = $"Insgesamt {weight:N0} kg / {total:N0} kg ausgewählt.";
ConfirmButton.IsEnabled = DeliveryParts.Any(r => r.SplitCompletely || r.SplitWeight > 0) && (
DepreciateModeInput.IsChecked == true ||
(MemberModeInput.IsChecked == true && MemberInput.SelectedItem != null && !DeliveryParts.All(r => r.SplitCompletely)) ||
(DeliveryModeInput.IsChecked == true && DeliveryInput.SelectedItem != null));
}
private void MgNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
var res = Validator.CheckMgNr((TextBox)sender, true);
var text = MgNrInput.Text;
var caret = MgNrInput.CaretIndex;
ControlUtils.SelectItemWithPk(MemberInput, res.IsValid ? int.Parse(MgNrInput.Text) : null);
MgNrInput.Text = text;
MgNrInput.CaretIndex = caret;
}
private void MemberInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
var m = MemberInput.SelectedItem as Member;
MgNrInput.Text = m?.MgNr.ToString();
CheckValidity();
}
private void MemberReferenceButton_Click(object sender, RoutedEventArgs evt) {
if (MemberInput.SelectedItem is not Member m) return;
App.FocusMember(m.MgNr);
}
private void DeliveryInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
CheckValidity();
}
private void SplitCompletelyInput_Changed(object sender, RoutedEventArgs evt) {
var checkbox = (CheckBox)sender;
var dpnr = int.Parse(checkbox.Tag.ToString()!);
var row = DeliveryParts.First(d => d.Part.DPNr == dpnr);
if (checkbox.IsChecked == true) {
row.SplitWeightEnabled = false;
row.SplitWeight = row.Part.Weight;
} else if (checkbox.IsChecked == false) {
row.SplitWeightEnabled = true;
row.SplitWeight = null;
}
CollectionViewSource.GetDefaultView(DeliveryParts).Refresh();
CheckValidity();
}
private void SplitWeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
var textbox = (TextBox)sender;
Validator.CheckInteger(textbox, false, 6);
var dpnr = int.Parse(textbox.Tag.ToString()!);
var row = DeliveryParts.First(d => d.Part.DPNr == dpnr);
var w = int.TryParse(textbox.Text, out var v) ? v : (int?)null;
if (w >= row.Part.Weight) {
row.SplitCompletely = true;
row.SplitWeightEnabled = false;
row.SplitWeight = row.Part.Weight;
CollectionViewSource.GetDefaultView(DeliveryParts).Refresh();
}
CheckValidity();
}
}
}

View File

@@ -4,10 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
mc:Ignorable="d"
ResizeMode="NoResize"
ShowInTaskbar="False"
Topmost="True"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
FocusManager.FocusedElement="{Binding ElementName=PriceInput}"
Title="Linear wachsen" Height="140" Width="270">

View File

@@ -4,10 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
mc:Ignorable="d"
ResizeMode="NoResize"
ShowInTaskbar="False"
Topmost="True"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
FocusManager.FocusedElement="{Binding ElementName=WeightInput}"
Title="Handwiegung" Height="170" Width="400">

View File

@@ -0,0 +1,69 @@
<Window x:Class="Elwig.Dialogs.NewSeasonDialog"
AutomationProperties.AutomationId="NewSeasonDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Dialogs"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Saison anlegen" Height="180" Width="400">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="2,4,2,4"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="ComboBox">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="CheckBox">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
</Style>
<Style TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Height" Value="25"/>
</Style>
</Window.Resources>
<Grid>
<Label Content="Währung:" Margin="10,10,10,10"/>
<ComboBox x:Name="CurrencyInput" Width="150" Margin="130,10,10,10"
ItemsSource="{Binding Currencies}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Code}" Width="30"/>
<TextBlock Text="- "/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Content="Nachkommastellen:" Margin="10,40,10,10"/>
<ComboBox x:Name="PrecisionInput" Width="50" Margin="130,40,10,10">
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
<ComboBoxItem IsSelected="True">4</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
<ComboBoxItem>6</ComboBoxItem>
<ComboBoxItem>7</ComboBoxItem>
<ComboBoxItem>8</ComboBoxItem>
</ComboBox>
<CheckBox x:Name="CopyModifiersInput" Content="Zu-/Abschläge der letzten Saison übernehmen"
Margin="15,75,10,10" IsChecked="{Binding CopyModifiers}"/>
<Button x:Name="ConfirmButton" Content="Bestätigen" Margin="10,10,115,10" Grid.Column="1" IsDefault="True"
Click="ConfirmButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" Grid.Column="1" IsCancel="True"/>
</Grid>
</Window>

View File

@@ -0,0 +1,30 @@
using Elwig.Helpers;
using Elwig.Models.Entities;
using System.Collections.Generic;
using System.Windows;
namespace Elwig.Dialogs {
public partial class NewSeasonDialog : Window {
public IEnumerable<Currency> Currencies { get; set; }
public int Year { get; set; }
public string CurrencyCode => (CurrencyInput.SelectedItem as Currency)!.Code;
public byte Precision => (byte)(PrecisionInput.SelectedIndex + 2);
public bool CopyModifiers { get; set; }
public NewSeasonDialog(Season? s, IEnumerable<Currency> currencies) {
Currencies = currencies;
CopyModifiers = s != null;
InitializeComponent();
CopyModifiersInput.IsEnabled = s != null;
ControlUtils.SelectItemWithPk(CurrencyInput, s?.CurrencyCode ?? "EUR");
PrecisionInput.SelectedIndex = (s?.Precision ?? 4) - 2;
}
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
DialogResult = true;
Close();
}
}
}

View File

@@ -1,18 +1,17 @@
<Window x:Class="Elwig.Dialogs.UpdateDialog"
<Window x:Class="Elwig.Dialogs.UpdateDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
ResizeMode="NoResize"
ShowInTaskbar="False"
Topmost="True"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
WindowStartupLocation="CenterOwner"
Title="Neues Update verfügbar - Elwig" Height="180" Width="400">
Title="Neues Update verfügbar - Elwig" Height="190" Width="400"
Closed="OnClosed">
<Grid>
<TextBlock x:Name="Description" FontSize="14" Margin="0,0,0,30"
<TextBlock x:Name="Description" FontSize="14" Margin="0,0,0,40"
HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center">
Version <Run x:Name="VersionText" FontWeight="Bold">0.0.0</Run> von Elwig ist verfügbar!<LineBreak/>
Version <Run x:Name="VersionText" FontWeight="Bold">0.0.0</Run> von Elwig ist verfügbar!
(<Hyperlink NavigateUri="https://elwig.at/changelog" RequestNavigate="Hyperlink_RequestNavigate">Änderungen</Hyperlink>)<LineBreak/>
Soll das Update heruntergeladen und<LineBreak/>
installiert werden? (ca. <Run x:Name="SizeText">100</Run> MB)<LineBreak/>
<Run FontWeight="Bold">Achtung</Run>: Elwig wird dabei geschlossen!
@@ -22,12 +21,12 @@
HorizontalAlignment="Center" VerticalAlignment="Center"
Height="27" Width="300" SnapsToDevicePixels="True"/>
<Button x:Name="InstallButton" Content="Installieren" Margin="10,10,115,10"
FontSize="14" HorizontalAlignment="Right" VerticalAlignment="Bottom"
<Button x:Name="InstallButton" Content="Installieren" Margin="10,10,115,20"
FontSize="14" HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="100" Height="27"
Click="InstallButton_Click"/>
<Button x:Name="CancelButton" Content="Abbrechen" Margin="10,10,10,10" IsCancel="True" IsDefault="True"
FontSize="14" HorizontalAlignment="Right" VerticalAlignment="Bottom"
<Button x:Name="CancelButton" Content="Abbrechen" Margin="115,10,10,20" IsCancel="True"
FontSize="14" HorizontalAlignment="Center" VerticalAlignment="Bottom"
Width="100" Height="27"/>
</Grid>
</Window>

View File

@@ -1,10 +1,12 @@
using Elwig.Helpers;
using Elwig.Helpers;
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Navigation;
namespace Elwig.Dialogs {
public partial class UpdateDialog : Window {
@@ -12,36 +14,54 @@ namespace Elwig.Dialogs {
public string Version { get; private set; }
public string Url { get; private set; }
private readonly CancellationTokenSource Cancellation;
public UpdateDialog(string version, string url, long size) {
Version = version;
Url = url;
Cancellation = new();
InitializeComponent();
VersionText.Text = version;
SizeText.Text = $"{size / 1024 / 1024}";
}
private void OnClosed(object sender, EventArgs evt) {
Cancellation.Cancel();
}
private async void InstallButton_Click(object sender, RoutedEventArgs evt) {
Description.Visibility = Visibility.Hidden;
ProgressBar.Visibility = Visibility.Visible;
InstallButton.IsEnabled = false;
await Install();
DialogResult = true;
Close();
}
public async Task Install() {
var fileName = Path.Combine(App.TempPath, $"Elwig-{Version}.exe");
{
try {
using var stream = new FileStream(fileName, FileMode.Create);
using var client = new HttpClient() {
Timeout = TimeSpan.FromSeconds(5),
};
await client.DownloadAsync(Url, stream, new Progress<double>(p => {
ProgressBar.Value = p * 100.0;
}));
}), Cancellation.Token);
} catch (OperationCanceledException) {
File.Delete(fileName);
return;
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
}
Process.Start(fileName);
DialogResult = true;
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) {
Process.Start(new ProcessStartInfo {
FileName = e.Uri.ToString(),
UseShellExecute = true,
});
}
}
}

View File

@@ -22,9 +22,9 @@ namespace Elwig.Documents {
var uid = (m.UstIdNr ?? "-") + (m.IsBuchführend ? "" : " <i>(pauschaliert)</i>");
Aside = $"<table><colgroup><col span='1' style='width: 22.5mm;'/><col span='1' style='width: 42.5mm;'/></colgroup>" +
$"<thead><tr><th colspan='2'>Mitglied</th></tr></thead><tbody>" +
$"<tr><th>Mitglieds-Nr.</th><td>{m.MgNr}</td></tr>" +
$"<tr><th>Betriebs-Nr.</th><td>{m.LfbisNr}</td></tr>" +
$"<tr><th>UID</th><td>{uid}</td></tr>" +
$"<tr><th>Mitglieds-Nr.:</th><td>{m.MgNr}</td></tr>" +
$"<tr><th>Betriebs-Nr.:</th><td>{m.LfbisNr}</td></tr>" +
$"<tr><th>UID:</th><td>{uid}</td></tr>" +
$"</tbody></table>";
}
@@ -32,7 +32,7 @@ namespace Elwig.Documents {
get {
IAddress addr = (Member.BillingAddress != null && UseBillingAddress) ? Member.BillingAddress : Member;
var plz = addr.PostalDest.AtPlz;
return (addr is BillingAddr ? $"{addr.Name}\n" : "") + $"{Member.AdministrativeName}\n{addr.Address}\n{plz?.Plz} {plz?.Ort.Name.Split(",")[0]}\n{addr.PostalDest.Country.Name}";
return string.Join("\n", ((string?[])[Member.BillingAddress?.FullName, Member.AdministrativeName, Member.ForTheAttentionOf, addr.Address, $"{plz?.Plz} {plz?.Ort.Name.Split(",")[0]}", addr.PostalDest.Country.Name]).Where(s => !string.IsNullOrWhiteSpace(s)));
}
}
@@ -81,11 +81,11 @@ namespace Elwig.Documents {
}
private static string FormatRow(
int obligation, int right, int delivery, int? payment = null, int? area = null,
int obligation, int right, int delivery, int? totalDelivery = null, int? payment = null, int? area = null,
bool isGa = false, bool showPayment = false, bool showArea = false
) {
totalDelivery ??= delivery;
payment ??= delivery;
var baseline = showPayment ? payment : delivery;
if (showArea) {
return $"<td>{(area == null ? "" : $"{area:N0}")}</td>" +
@@ -95,15 +95,15 @@ namespace Elwig.Documents {
return $"<td>{(obligation == 0 ? "-" : $"{obligation:N0}")}</td>" +
$"<td>{(right == 0 ? "-" : $"{right:N0}")}</td>" +
$"<td>{(baseline < obligation ? $"<b>{obligation - baseline:N0}</b>" : "-")}</td>" +
$"<td>{(baseline >= obligation && delivery <= right ? $"{right - delivery:N0}" : "-")}</td>" +
$"<td>{(totalDelivery < obligation ? $"<b>{obligation - totalDelivery:N0}</b>" : "-")}</td>" +
$"<td>{(delivery <= right ? $"{right - delivery:N0}" : "-")}</td>" +
$"<td>{(obligation == 0 && right == 0 ? "-" : (delivery > right ? ((isGa ? "<b>" : "") + $"{delivery - right:N0}" + (isGa ? "</b>" : "")) : "-"))}</td>" +
(showPayment ? $"<td>{(isGa ? "" : obligation == 0 && right == 0 ? "-" : $"{payment:N0}")}</td>" : "") +
$"<td>{delivery:N0}</td>";
$"<td>{totalDelivery:N0}</td>";
}
private static string FormatRow(MemberBucket bucket, bool isGa = false, bool showPayment = false, bool showArea = false) {
return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment, bucket.Area, isGa, showPayment, showArea);
return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.DeliveryTotal, bucket.Payment, bucket.Area, isGa, showPayment, showArea);
}
public string PrintBucketTable(

View File

@@ -2,7 +2,7 @@
@inherits TemplatePage<Elwig.Documents.BusinessDocument>
@model Elwig.Documents.BusinessDocument
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\BusinessDocument.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\BusinessDocument.css"/>
<div class="info-wrapper">
<div class="address-wrapper">
<div class="sender">

View File

@@ -1,6 +1,7 @@
using Elwig.Helpers;
using Elwig.Models.Dtos;
using Elwig.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -18,7 +19,9 @@ namespace Elwig.Documents {
public string MemberModifier;
public IEnumerable<(string Name, int Kg, decimal Amount)>? MemberUnderDeliveries;
public decimal MemberTotalUnderDelivery;
public decimal MemberAutoBusinessShares;
public int MemberAutoBusinessShares;
public decimal MemberAutoBusinessSharesAmount;
public PaymentCustom? CustomPayment;
public CreditNote(
AppDbContext ctx,
@@ -27,26 +30,33 @@ namespace Elwig.Documents {
bool considerContractPenalties,
bool considerTotalPenalty,
bool considerAutoBusinessShares,
bool considerCustomModifiers,
Dictionary<string, UnderDelivery>? underDeliveries = null
) :
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.Name)} {p.Variant.Name}", p.Member) {
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.FullName)} {p.Variant.Name}", p.Member) {
UseBillingAddress = true;
ShowDateAndLocation = true;
Data = data;
Payment = p;
Credit = p.Credit;
var season = p.Variant.Season;
if (considerCustomModifiers) {
CustomPayment = ctx.CustomPayments.Find(p.Year, p.MgNr);
}
var mod = App.Client.IsMatzen ? ctx.Modifiers.Where(m => m.Year == season.Year && m.Name.StartsWith("Treue")).FirstOrDefault() : null;
if (mod != null) {
if (CustomPayment?.ModComment != null) {
MemberModifier = CustomPayment.ModComment;
} else if (mod != null) {
MemberModifier = $"{mod.Name} ({mod.ValueStr})";
} else {
MemberModifier = "Sonstige Zu-/Abschläge";
}
Aside = Aside.Replace("</table>", "") +
$"<thead><tr><th colspan='2'>Gutschrift</th></tr></thead><tbody>" +
$"<tr><th>TG-Nr.</th><td>{(p.Credit != null ? $"{p.Credit.Year}/{p.Credit.TgNr:000}" : "-")}</td></tr>" +
$"<tr><th>Überw. am</th><td>{p.Variant.TransferDate:dd.MM.yyyy}</td></tr>" +
$"<tr><th>Datum/Zeit</th><td>{p.Credit?.ModifiedTimestamp:dd.MM.yyyy} / {p.Credit?.ModifiedTimestamp:HH:mm}</td></tr>" +
$"<tr><th>TG-Nr.:</th><td>{(p.Credit != null ? $"{p.Credit.Year}/{p.Credit.TgNr:000}" : "-")}</td></tr>" +
$"<tr><th>Datum:</th><td>{p.Variant.Date:dd.MM.yyyy}</td></tr>" +
$"<tr><th>Überw. am:</th><td>{p.Variant.TransferDate:dd.MM.yyyy}</td></tr>" +
$"</tbody></table>";
Text = App.Client.TextCreditNote;
DocumentId = $"Tr.-Gutschr. " + (p.Credit != null ? $"{p.Credit.Year}/{p.Credit.TgNr:000}" : p.MgNr);
@@ -56,9 +66,9 @@ namespace Elwig.Documents {
if (considerTotalPenalty) {
var total = data.Rows.SelectMany(r => r.Buckets).Sum(b => b.Value);
var totalUnderDelivery = total - p.Member.BusinessShares * season.MinKgPerBusinessShare;
MemberTotalUnderDelivery = totalUnderDelivery < 0 ? totalUnderDelivery * (season.PenaltyPerKg ?? 0) - (season.PenaltyAmount ?? 0) : 0;
MemberTotalUnderDelivery = totalUnderDelivery < 0 ? totalUnderDelivery * (season.PenaltyPerKg ?? 0) - (season.PenaltyAmount ?? 0) - (season.PenaltyPerBsAmount * Math.Floor(-(decimal)totalUnderDelivery / season.MinKgPerBusinessShare) ?? 0) : 0;
if (total == 0)
MemberTotalUnderDelivery -= (season.PenaltyNone ?? 0);
MemberTotalUnderDelivery -= (season.PenaltyNone ?? 0) + (season.PenaltyPerBsNone * p.Member.BusinessShares ?? 0);
}
if (considerAutoBusinessShares) {
var fromDate = $"{season.Year}-01-01";
@@ -66,7 +76,8 @@ namespace Elwig.Documents {
MemberAutoBusinessShares = ctx.MemberHistory
.Where(h => h.MgNr == p.Member.MgNr && h.Type == "auto")
.Where(h => h.DateString.CompareTo(fromDate) >= 0 && h.DateString.CompareTo(toDate) <= 0)
.Sum(h => h.BusinessShares) * (-season.BusinessShareValue ?? 0);
.Sum(h => h.BusinessShares);
MemberAutoBusinessSharesAmount = MemberAutoBusinessShares * (-season.BusinessShareValue ?? 0);
}
if (considerContractPenalties) {
var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);

View File

@@ -3,14 +3,14 @@
@inherits TemplatePage<Elwig.Documents.CreditNote>
@model Elwig.Documents.CreditNote
@{ Layout = "BusinessDocument"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\CreditNote.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\CreditNote.css" />
<main>
<h1>@Model.Title</h1>
<table class="credit">
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 22mm;"/>
<col style="width: 6mm;"/>
<col style="width: 21mm;"/>
<col style="width: 15mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
@@ -51,7 +51,7 @@
<tr class="@(i == 0 ? "first" : "") @(rows == i + 1 ? "last" : "")">
@if (i == 0) {
<td rowspan="@rows">@p.LsNr</td>
<td rowspan="@rows">@p.DPNr</td>
<td rowspan="@rows" class="center narrow">@p.DPNr</td>
<td class="small">@p.Variety</td>
<td class="small">
@p.Attribute@(p.Attribute != null && p.Cultivation != null ? " / " : "")@p.Cultivation
@@ -136,7 +136,10 @@
}
</tbody>
<tbody style="break-inside: avoid;">
@{ decimal penalty = 0; }
@{
decimal penalty = 0;
string? comment = null;
}
@if (Model.MemberUnderDeliveries != null && Model.MemberUnderDeliveries.Count() > 0) {
<tr class="small">
@@ -153,9 +156,19 @@
@Raw(FormatRow("Unterlieferung (GA)", Model.MemberTotalUnderDelivery, add: true));
penalty += Model.MemberTotalUnderDelivery;
}
@if (Model.MemberAutoBusinessShares != 0) {
@Raw(FormatRow("Autom. Nachz. von GA", Model.MemberAutoBusinessShares, add: true));
penalty += Model.MemberAutoBusinessShares;
@if (Model.MemberAutoBusinessSharesAmount != 0) {
@Raw(FormatRow($"Autom. Nachz. von GA ({Model.MemberAutoBusinessShares})", Model.MemberAutoBusinessSharesAmount, add: true));
penalty += Model.MemberAutoBusinessSharesAmount;
}
@if (Model.CustomPayment?.Amount != null) {
comment = Model.CustomPayment.Comment;
string text = (Model.CustomPayment.Amount.Value < 0 ? "Weitere Abzüge" : "Weitere Zuschläge") + (comment != null ? "*" : "");
if (comment != null && comment!.Length <= 30) {
text = comment;
comment = null;
}
@Raw(FormatRow(text, Model.CustomPayment.Amount.Value, add: true));
penalty += Model.CustomPayment.Amount.Value;
}
@if (Model.Credit == null) {
@@ -163,7 +176,7 @@
} else {
var diff = Model.Credit.Modifiers - penalty;
if (diff != 0) {
@Raw(FormatRow(diff < 0 ? "Weitere Abzüge" : "Weitere Zuschläge", diff, add: true))
@Raw(FormatRow(diff < 0 ? "Sonstige Abzüge" : "Sonstige Zuschläge", diff, add: true))
}
if (Model.Credit.PrevModifiers != null && Model.Credit.PrevModifiers != 0) {
@Raw(FormatRow("Bereits berücksichtigte Abzüge", -Model.Credit.PrevModifiers, add: true))
@@ -172,6 +185,9 @@
}
</tbody>
</table>
@if (comment != null) {
<p>* @comment</p>
}
<p>Überweisung erfolgt auf Konto @(Elwig.Helpers.Utils.FormatIban(Model.Member.Iban ?? "-")).</p>
<div style="margin-top: 1em;">
@if (Model.Text != null) {

View File

@@ -0,0 +1,21 @@
using Elwig.Models.Dtos;
using System.Collections.Generic;
namespace Elwig.Documents {
public class DeliveryAncmtList : Document {
public new static string Name => "Anmeldeliste";
public string Filter;
public IEnumerable<DeliveryAncmtListRow> Announcements;
public DeliveryAncmtList(string filter, IEnumerable<DeliveryAncmtListRow> announcements) : base($"{Name} {filter}") {
Filter = filter;
Announcements = announcements;
}
public DeliveryAncmtList(string filter, DeliveryAncmtListData data) :
this(filter, data.Rows) {
}
}
}

View File

@@ -0,0 +1,52 @@
@using RazorLight
@inherits TemplatePage<Elwig.Documents.DeliveryAncmtList>
@model Elwig.Documents.DeliveryAncmtList
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\DeliveryAncmtList.css" />
<main>
<h1>Anmeldeliste</h1>
<h2>@Model.Filter</h2>
<table class="announcement-list">
<colgroup>
<col style="width: 15mm;"/>
<col style="width: 12mm;"/>
<col style="width: 50mm;"/>
<col style="width: 25mm;"/>
<col style="width: 38mm;"/>
<col style="width: 11mm;"/>
<col style="width: 14mm;"/>
</colgroup>
<thead>
<tr>
<th rowspan="2">Datum</th>
<th rowspan="2">MgNr.</th>
<th rowspan="2" style="text-align: left;">Mitglied</th>
<th rowspan="2" style="text-align: left;">Ort</th>
<th rowspan="2" style="text-align: left;">Sorte</th>
<th rowspan="2">Anmldg.</th>
<th>Menge</th>
</tr>
<tr>
<th class="unit">[kg]</th>
</tr>
</thead>
<tbody>
@foreach (var a in Model.Announcements) {
<tr>
<td class="small">@($"{a.Date:dd.MM.yyyy}")</td>
<td class="number">@a.MgNr</td>
<td>@a.AdministrativeName</td>
<td class="small">@a.DefaultKg</td>
<td>@a.Variety</td>
<td class="small center">@(a.Status ?? "-")</td>
<td class="number">@($"{a.Weight:N0}")</td>
</tr>
}
<tr class="sum bold">
<td colspan="2">Gesamt:</td>
<td colspan="3">Anmeldungen: @($"{Model.Announcements.Count():N0}")</td>
<td colspan="2" class="number">@($"{Model.Announcements.Sum(a => a.Weight):N0}")</td>
</tr>
</tbody>
</table>
</main>

View File

@@ -0,0 +1,13 @@
h1 {
text-align: center;
font-size: 24pt;
margin-top: 10mm;
margin-bottom: 2mm;
}
h2 {
text-align: center;
font-size: 14pt;
margin-top: 2mm;
}

View File

@@ -20,7 +20,6 @@ namespace Elwig.Documents {
Season = ctx.Seasons.Find(year) ?? throw new ArgumentException("invalid season");
ShowDateAndLocation = true;
UseBillingAddress = true;
IncludeSender = true;
DocumentId = $"Anl.-Best. {Season.Year}/{m.MgNr}";
Data = data;
MemberBuckets = ctx.GetMemberBuckets(Season.Year, m.MgNr).GetAwaiter().GetResult();

View File

@@ -3,14 +3,14 @@
@inherits TemplatePage<Elwig.Documents.DeliveryConfirmation>
@model Elwig.Documents.DeliveryConfirmation
@{ Layout = "BusinessDocument"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\DeliveryConfirmation.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\DeliveryConfirmation.css" />
<main>
<h1>@Model.Title</h1>
<table class="delivery-confirmation">
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 24mm;"/>
<col style="width: 6mm;"/>
<col style="width: 23mm;"/>
<col style="width: 16mm;"/>
<col style="width: 17mm;"/>
<col style="width: 10mm;"/>
@@ -30,12 +30,12 @@
<th rowspan="2" style="text-align: left;">Qualitätsstufe</th>
<th colspan="2">Gradation</th>
<th colspan="2">Flächenbindung</th>
<th>Gewicht</th>
<th>Menge</th>
<th rowspan="3" style="padding: 0;">
<svg width="10" height="40" xmlns="http://www.w3.org/2000/svg">
<text x="-40" y="5" transform="rotate(270)" font-size="8pt" font-style="italic" font-family="Times New Roman"
<text x="-40" y="4" transform="rotate(270)" font-size="8pt" font-style="italic" font-family="Times New Roman"
style="text-anchor: start; alignment-baseline: middle;">
bto./nto.
gerebelt
</text>
</svg>
</th>
@@ -60,7 +60,7 @@
<tr class="@(first ? "first" : "") @(p.Variety != lastVariety && lastVariety != "" ? "new": "") @(rows > i + 1 ? "last" : "")">
@if (first) {
<td rowspan="@rows">@p.LsNr</td>
<td rowspan="@rows">@p.DPNr</td>
<td rowspan="@rows" class="center narrow">@p.DPNr</td>
<td class="small">@p.Variety</td>
<td class="small">@p.Attribute@(p.Attribute != null && p.Cultivation != null ? " / " : "")@p.Cultivation</td>
<td class="small">@p.QualityLevel</td>
@@ -81,7 +81,7 @@
}
@if (i == p.Buckets.Length - 1) {
<td class="number">@($"{p.Weight:N0}")</td>
<td class="small">@(p.IsNetWeight ? "n" : "b")</td>
<td style="font-size: 7pt;">@(p.IsNetWeight ? "\u2611" : "\u2610")</td>
} else {
<td></td>
<td></td>

View File

@@ -0,0 +1,22 @@
using Elwig.Models.Dtos;
using System.Collections.Generic;
namespace Elwig.Documents {
public class DeliveryDepreciationList : Document {
public new static string Name => "Abwertungsliste";
public string Filter;
public IEnumerable<DeliveryJournalRow> Deliveries;
public DeliveryDepreciationList(string filter, IEnumerable<DeliveryJournalRow> deliveries) :
base($"{Name} {filter}") {
Filter = filter;
Deliveries = deliveries;
}
public DeliveryDepreciationList(string filter, DeliveryJournalData data) :
this(filter, data.Rows) {
}
}
}

View File

@@ -0,0 +1,104 @@
@using RazorLight
@inherits TemplatePage<Elwig.Documents.DeliveryDepreciationList>
@model Elwig.Documents.DeliveryDepreciationList
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\DeliveryDepreciationList.css" />
<main>
<h1>Abwertungsliste</h1>
<h2>@Model.Filter</h2>
<table class="journal">
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 6mm;"/>
<col style="width: 20mm;"/>
<col style="width: 15mm;"/>
<col style="width: 35mm;"/>
<col style="width: 30mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
<col style="width: 14mm;"/>
</colgroup>
<thead>
<tr>
<th rowspan="2" style="text-align: left;">Lieferschein-Nr.</th>
<th rowspan="2" class="narrow">Pos.</th>
<th rowspan="2">Datum</th>
<th rowspan="2">Zeit</th>
<th rowspan="2" style="text-align: left;">Sorte</th>
<th rowspan="2" style="text-align: left;">Attr./Bewirt.</th>
<th colspan="2">Gradation</th>
<th>Menge</th>
</tr>
<tr>
<th class="unit">[°Oe]</th>
<th class="unit narrow">[°KMW]</th>
<th class="unit">[kg]</th>
</tr>
</thead>
<tbody>
@{
int? lastMember = null;
}
@foreach (var p in Model.Deliveries) {
if (lastMember != p.MgNr) {
<tr class="subheading @(lastMember != null ? "new" : "")">
@{
var memberDeliveries = Model.Deliveries.Where(d => d.MgNr == p.MgNr).ToList();
var memberKmw = Elwig.Helpers.Utils.AggregateDeliveryPartsKmw(memberDeliveries);
var memberOe = Elwig.Helpers.Utils.KmwToOe(memberKmw);
}
<th colspan="5">
@($"{p.MgNr}, {p.AdministrativeName}")
</th>
<td>Teil-Lfrg.: <span style="float: right;">@($"{memberDeliveries.Count():N0}")</span></td>
<td class="center">@($"{memberOe:N0}")</td>
<td class="center">@($"{memberKmw:N1}")</td>
<td class="number">@($"{memberDeliveries.Sum(p => p.Weight):N0}")</td>
</tr>
}
<tr>
<td>@p.LsNr</td>
<td class="center narrow">@p.Pos</td>
<td>@($"{p.Date:dd.MM.yyyy}")</td>
<td>@($"{p.Time:HH:mm}")</td>
<td>@p.Variety</td>
<td>@p.Attribute@(p.Attribute != null && p.Cultivation != null ? " / " : "")@p.Cultivation</td>
<td class="center">@($"{p.Oe:N0}")</td>
<td class="center">@($"{p.Kmw:N1}")</td>
<td class="number">@($"{p.Weight:N0}")</td>
</tr>
lastMember = p.MgNr;
}
@{
var branches = Model.Deliveries.Select(d => d.DeliveryBranch).Distinct().Order().ToArray();
if (branches.Length > 1) {
foreach (var b in branches) {
<tr class="@(branches[0] == b ? "sum" : "") bold">
@{
var branchDeliveries = Model.Deliveries.Where(d => d.DeliveryBranch == b).ToList();
var branchKmw = Elwig.Helpers.Utils.AggregateDeliveryPartsKmw(branchDeliveries);
var branchOe = Elwig.Helpers.Utils.KmwToOe(branchKmw);
}
<td colspan="2">@b:</td>
<td colspan="4">(Teil-)Lieferungen: @($"{branchDeliveries.DistinctBy(p => p.LsNr).Count():N0}") (@($"{branchDeliveries.Count():N0}"))</td>
<td class="center">@($"{branchOe:N0}")</td>
<td class="center">@($"{branchKmw:N1}")</td>
<td class="number">@($"{branchDeliveries.Sum(p => p.Weight):N0}")</td>
</tr>
}
}
}
<tr class="sum bold">
@{
var kmw = Elwig.Helpers.Utils.AggregateDeliveryPartsKmw(Model.Deliveries);
var oe = Elwig.Helpers.Utils.KmwToOe(kmw);
}
<td colspan="2">Gesamt:</td>
<td colspan="4">(Teil-)Lieferungen: @($"{Model.Deliveries.DistinctBy(p => p.LsNr).Count():N0}") (@($"{Model.Deliveries.Count():N0}"))</td>
<td class="center">@($"{oe:N0}")</td>
<td class="center">@($"{kmw:N1}")</td>
<td class="number">@($"{Model.Deliveries.Sum(p => p.Weight):N0}")</td>
</tr>
</tbody>
</table>
</main>

View File

@@ -0,0 +1,13 @@
h1 {
text-align: center;
font-size: 24pt;
margin-top: 10mm;
margin-bottom: 2mm;
}
h2 {
text-align: center;
font-size: 14pt;
margin-top: 2mm;
}

View File

@@ -9,7 +9,8 @@ namespace Elwig.Documents {
public string Filter;
public IEnumerable<DeliveryJournalRow> Deliveries;
public DeliveryJournal(string filter, IEnumerable<DeliveryJournalRow> deliveries) : base($"{Name} {filter}") {
public DeliveryJournal(string filter, IEnumerable<DeliveryJournalRow> deliveries) :
base($"{Name} {filter}") {
Filter = filter;
Deliveries = deliveries;
}

View File

@@ -2,17 +2,17 @@
@inherits TemplatePage<Elwig.Documents.DeliveryJournal>
@model Elwig.Documents.DeliveryJournal
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\DeliveryJournal.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\DeliveryJournal.css"/>
<main>
<h1>Lieferjournal</h1>
<h2>@Model.Filter</h2>
<table class="journal">
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 6mm;"/>
<col style="width: 15mm;"/>
<col style="width: 8mm;"/>
<col style="width: 12mm;"/>
<col style="width: 8mm;"/>
<col style="width: 11mm;"/>
<col style="width: 38mm;"/>
<col style="width: 28mm;"/>
<col style="width: 10mm;"/>
@@ -29,7 +29,7 @@
<th rowspan="2" style="text-align: left;">Mitglied</th>
<th rowspan="2" style="text-align: left;">Sorte</th>
<th colspan="2">Gradation</th>
<th>Gewicht</th>
<th>Menge</th>
</tr>
<tr>
<th class="unit">[°Oe]</th>
@@ -41,7 +41,7 @@
@foreach (var p in Model.Deliveries) {
<tr>
<td>@p.LsNr</td>
<td>@p.Pos</td>
<td class="center narrow">@p.Pos</td>
<td class="small">@($"{p.Date:dd.MM.yyyy}")</td>
<td class="small">@($"{p.Time:HH:mm}")</td>
<td class="number">@p.MgNr</td>
@@ -52,6 +52,25 @@
<td class="number">@($"{p.Weight:N0}")</td>
</tr>
}
@{
var branches = Model.Deliveries.Select(d => d.DeliveryBranch).Distinct().Order().ToArray();
if (branches.Length > 1) {
foreach (var b in branches) {
<tr class="@(branches[0] == b ? "sum" : "") bold">
@{
var branchDeliveries = Model.Deliveries.Where(d => d.DeliveryBranch == b).ToList();
var branchKmw = Elwig.Helpers.Utils.AggregateDeliveryPartsKmw(branchDeliveries);
var branchOe = Elwig.Helpers.Utils.KmwToOe(branchKmw);
}
<td colspan="2">@b:</td>
<td colspan="5">(Teil-)Lieferungen: @($"{branchDeliveries.DistinctBy(p => p.LsNr).Count():N0}") (@($"{branchDeliveries.Count():N0}"))</td>
<td class="center">@($"{branchOe:N0}")</td>
<td class="center">@($"{branchKmw:N1}")</td>
<td class="number">@($"{branchDeliveries.Sum(p => p.Weight):N0}")</td>
</tr>
}
}
}
<tr class="sum bold">
@{
var kmw = Elwig.Helpers.Utils.AggregateDeliveryPartsKmw(Model.Deliveries);

View File

@@ -23,9 +23,9 @@ namespace Elwig.Documents {
Delivery = d;
Aside = Aside.Replace("</table>", "") +
$"<thead><tr><th colspan='2'>Lieferung</th></tr></thead><tbody>" +
$"<tr><th>LS-Nr.</th><td>{d.LsNr}</td></tr>" +
$"<tr><th>Datum/Zeit</th><td>{d.Date:dd.MM.yyyy} / {d.Time:HH:mm}</td></tr>" +
$"<tr><th>Zweigstelle</th><td>{d.Branch.Name}</td></tr>" +
$"<tr><th>LS-Nr.:</th><td>{d.LsNr}</td></tr>" +
$"<tr><th>Datum/Zeit:</th><td>{d.Date:dd.MM.yyyy} / {d.Time:HH:mm}</td></tr>" +
$"<tr><th>Zweigstelle:</th><td>{d.Branch.Name}</td></tr>" +
$"</tbody></table>";
Text = App.Client.TextDeliveryNote;
DocumentId = d.LsNr;

View File

@@ -2,7 +2,7 @@
@inherits TemplatePage<Elwig.Documents.DeliveryNote>
@model Elwig.Documents.DeliveryNote
@{ Layout = "BusinessDocument"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\DeliveryNote.css" />
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\DeliveryNote.css" />
<main>
<h1>@Model.Title</h1>
<table class="delivery large">
@@ -24,7 +24,7 @@
<th class="main" rowspan="2" colspan="2">Attribut</th>
<th class="main" rowspan="2">Qualitätsstufe</th>
<th colspan="2">Gradation</th>
<th>Gewicht</th>
<th>Menge</th>
</tr>
<tr>
<th class="unit">[°Oe]</th>
@@ -60,8 +60,18 @@
}
}
<tr><td></td><td colspan="5">
@Raw(part.IsManualWeighing ? "<i>Handwiegung</i>" : $"<i>Waage:</i> {part.ScaleId ?? "?"}, <i>ID:</i> {part.WeighingId ?? "?"}")
(@(part.IsNetWeight ? "netto/gerebelt gewogen" : "brutto/nicht gerebelt gewogen"))@Raw(part.WeighingReason != null ? $", <i>Begründung:</i>" : "") @part.WeighingReason
@if (part.IsManualWeighing) {
<i>Handwiegung @(part.IsNetWeight ? " (gerebelt gewogen)" : " (nicht gerebelt gewogen)")</i>@Raw(part.WeighingReason != null ? ", <i>Begründung:</i> " : "") @part.WeighingReason
} else {
var info = part.WeighingInfo;
<i>Waage:</i> @(part.ScaleId ?? "?")@(", ") <i>ID:</i> @(info.Id ?? "?")
@(info.Date != null || info.Time != null ? " " : "")@(info.Time != null ? $"{info.Time:HH:mm}" : "")@(info.Date != null ? $", {info.Date:dd.MM.yyyy}" : "")
@if (info.Gross != null && info.Tare != null && info.Net != null) {
<br/><i>Brutto:</i> @($"{info.Gross:N0} kg")@(" ") <i>Tara:</i> @($"{info.Tare:N0} kg")@(" ") <i>Netto:</i> @($"{info.Net:N0} kg")@(" ")@Raw(part.IsNetWeight ? "<i>gerebelt gewogen</i>" : "<i>nicht gerebelt gewogen</i>")
} else {
@Raw($" <i>({(part.IsNetWeight ? "gerebelt gewogen" : "nicht gerebelt gewogen")})</i>")
}
}
</td></tr>
@if (part.Comment != null) {
<tr><td></td><td colspan="5"><i>Anmerkung:</i> @part.Comment</td></tr>

View File

@@ -23,18 +23,18 @@ namespace Elwig.Documents {
public bool ShowFoldMarks = App.Config.Debug;
public bool DoublePaged = false;
public string DataPath;
public string DocumentsPath;
public int CurrentNextSeason;
public string? DocumentId;
public string Title;
public string Author;
public string Header;
public string Footer;
public DateTime Date;
public DateOnly Date;
public Document(string title) {
var c = App.Client;
DataPath = App.DataPath;
DocumentsPath = App.DocumentsPath;
CurrentNextSeason = Utils.CurrentNextSeason;
Title = title;
Author = c.NameFull;
@@ -44,10 +44,10 @@ namespace Elwig.Documents {
.Item(c.Address).Item($"{c.Plz} {c.Ort}").Item("Österreich").Item("Tel.", c.PhoneNr).Item("Fax", c.FaxNr).NextLine()
.Item(c.EmailAddress != null ? $"<a href=\"mailto:{c.Name} {c.NameSuffix} <{c.EmailAddress}>\">{c.EmailAddress}</a>" : null)
.Item(c.Website != null ? $"<a href=\"http://{c.Website}/\">{c.Website}</a>" : null)
.Item("Betriebs-Nr.", c.LfbisNr).Item("UID", c.UstIdNr).NextLine()
.Item("BIC", c.Bic).Item("IBAN", c.Iban)
.Item("Betriebs-Nr.", c.LfbisNr).Item("Bio-KSt.", c.OrganicAuthority).NextLine()
.Item("UID", c.UstIdNr).Item("BIC", c.Bic).Item("IBAN", c.Iban)
.ToString();
Date = DateTime.Today;
Date = DateOnly.FromDateTime(Utils.Today);
}
~Document() {
@@ -78,6 +78,8 @@ namespace Elwig.Documents {
name = "CreditNote";
} else if (this is DeliveryJournal) {
name = "DeliveryJournal";
} else if (this is DeliveryDepreciationList) {
name = "DeliveryDepreciationList";
} else if (this is Letterhead) {
name = "Letterhead";
} else if (this is DeliveryConfirmation) {
@@ -90,6 +92,8 @@ namespace Elwig.Documents {
name = "WineQualityStatistics";
} else if (this is PaymentVariantSummary) {
name = "PaymentVariantSummary";
} else if (this is DeliveryAncmtList) {
name = "DeliveryAncmtList";
} else {
throw new InvalidOperationException("Invalid document object");
}
@@ -151,12 +155,12 @@ namespace Elwig.Documents {
public async Task Print(int copies = 1) {
if (PdfPath == null) throw new InvalidOperationException("Pdf file has not been generated yet");
await Pdf.Print(PdfPath, copies);
await Pdf.Print(PdfPath, copies, DoublePaged);
}
public void Show() {
if (_pdfFile == null) throw new InvalidOperationException("Pdf file has not been generated yet");
Pdf.Show(_pdfFile.NewReference(), Title + (this is BusinessDocument b ? $" - {b.Member.Name}" : ""));
Pdf.Show(_pdfFile.NewReference(), Title + (this is BusinessDocument b ? $" - {b.Member.FullName}" : ""));
}
public MimePart AsEmailAttachment(string filename) {

View File

@@ -7,9 +7,9 @@
<title>@Model.Title</title>
<meta name="author" value="@Model.Author"/>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\Document.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\Document.Page.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\Document.Table.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\Document.css" />
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\Document.Page.css" />
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\Document.Table.css" />
@if (Model.DoublePaged) {
<style>
@@page :left {

View File

@@ -2,7 +2,7 @@ using Elwig.Models.Entities;
namespace Elwig.Documents {
public class Letterhead : BusinessDocument {
public Letterhead(Member m) : base($"Briefkopf {m.Name}", m, true) {
public Letterhead(Member m) : base($"Briefkopf {m.FullName}", m, true) {
Aside = "";
}
}

View File

@@ -1,4 +1,4 @@
using Elwig.Helpers;
using Elwig.Helpers;
using Elwig.Models.Entities;
using System;
using System.Collections.Generic;

View File

@@ -1,9 +1,9 @@
@using RazorLight
@using RazorLight
@using Elwig.Helpers
@inherits TemplatePage<Elwig.Documents.MemberDataSheet>
@model Elwig.Documents.MemberDataSheet
@{ Layout = "BusinessDocument"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\MemberDataSheet.css" />
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\MemberDataSheet.css" />
<main>
<h1>@Model.Title</h1>
<table class="member border">
@@ -18,21 +18,31 @@
<tbody>
<tr class="sectionheading"><th colspan="6">Persönliche Daten</th></tr>
<tr>
<th class="small">Titel (vorangestellt)</th>
<th class="small">Vorname</th>
<th colspan="3" class="small">Nachname</th>
<th class="small">Titel (nachgestellt)</th>
@if (Model.Member.IsJuridicalPerson) {
<th colspan="3" class="small">Name</th>
<th colspan="3" class="small">Zu Handen</th>
} else {
<th class="small">Titel (vorangestellt)</th>
<th class="small">Vorname</th>
<th colspan="3" class="small">Nachname</th>
<th class="small">Titel (nachgestellt)</th>
}
</tr>
<tr>
<td class="large">@Model.Member.Prefix</td>
<td class="large">@Model.Member.GivenName @Model.Member.MiddleName</td>
<td class="large" colspan="3">@Model.Member.FamilyName</td>
<td class="large">@Model.Member.Suffix</td>
@if (Model.Member.IsJuridicalPerson) {
<td colspan="3" class="large">@Model.Member.Name</td>
<td colspan="3" class="large">@Model.Member.ForTheAttentionOf</td>
} else {
<td class="large">@Model.Member.Prefix</td>
<td class="large">@Model.Member.GivenName @Model.Member.MiddleName</td>
<td class="large" colspan="3">@Model.Member.Name</td>
<td class="large">@Model.Member.Suffix</td>
}
</tr>
<tr>
<th>Mitglieds-Nr.:</th>
<td>@Model.Member.MgNr</td>
<th colspan="2">Geburtsjahr/-tag:</th>
<th colspan="2">@(Model.Member.IsJuridicalPerson ? "Gründungsjahr/-tag" : "Geburtsjahr/-tag"):</th>
<td colspan="2">@(string.Join('.', Model.Member.Birthday?.Split('-')?.Reverse() ?? Array.Empty<string>()))</td>
</tr>
<tr>
@@ -50,7 +60,7 @@
<tr class="sectionheading"><th colspan="6">Rechnungsadresse (optional)</th></tr>
<tr>
<th>Name:</th>
<td colspan="5">@Model.Member.BillingAddress?.Name</td>
<td colspan="5">@Model.Member.BillingAddress?.FullName</td>
</tr>
<tr>
<th>Adresse:</th>
@@ -105,7 +115,7 @@
<th>Stammgemeinde:</th>
<td>@Model.Member.DefaultKg?.Name</td>
<th colspan="2">Buchführend:</th>
<td colspan="2">@(Model.Member.IsBuchführend ? "Ja" : "Nein")</td>
<td colspan="2">@(Model.Member.IsBuchführend ? "Ja" : "Nein") <span class="small">(@((Model.Member.IsBuchführend ? Model.Season.VatNormal : Model.Season.VatFlatrate) * 100)% USt.)</span></td>
</tr>
<tr>
<th colspan="2" class="small">(Katastralgemeinde mit dem größten Anteil an Weinbauflächen)</th>
@@ -196,7 +206,7 @@
<td class="text">@areaCom.GstNr.Replace(",", ", ").Replace("-", "")</td>
<td class="number">@($"{areaCom.Area:N0}")</td>
<td class="center">@areaCom.WineCult?.Name</td>
<td class="center">@(areaCom.YearTo == null ? $"ab {areaCom.YearFrom}" : $"{areaCom.YearFrom}{areaCom.YearTo}")</td>
<td class="center">@(areaCom.YearTo == null ? (areaCom.YearFrom == null ? "unbefristet" : $"ab {areaCom.YearFrom}") : (areaCom.YearFrom == null ? $"bis {areaCom.YearTo}" : $"{areaCom.YearFrom}{areaCom.YearTo}"))</td>
</tr>
lastContract = contractType.AreaComType.DisplayName;
}

View File

@@ -1,4 +1,4 @@

h2 {
margin-bottom: 0.5em !important;
}

View File

@@ -1,5 +1,6 @@
using Elwig.Models.Dtos;
using Elwig.Models.Dtos;
using System.Collections.Generic;
using System.Linq;
namespace Elwig.Documents {
public class MemberList : Document {
@@ -9,9 +10,17 @@ namespace Elwig.Documents {
public string Filter;
public IEnumerable<MemberListRow> Members;
public string[] AreaComFilters;
public bool FilterAreaComs => AreaComFilters.Length > 0;
public MemberList(string filter, IEnumerable<MemberListRow> members) : base(Name) {
Filter = filter;
Members = members;
AreaComFilters = [..members
.SelectMany(m => m.AreaCommitmentsFiltered)
.Select(c => c.VtrgId)
.Distinct()
.Order()];
}
public MemberList(string filter, MemberListData data) :

View File

@@ -2,36 +2,67 @@
@inherits TemplatePage<Elwig.Documents.MemberList>
@model Elwig.Documents.MemberList
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\MemberList.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\MemberList.css" />
<main>
<h1>Mitgliederliste</h1>
<h2>@Model.Filter</h2>
<table class="members">
<colgroup>
<col style="width: 8mm;"/>
<col style="width: 42mm;"/>
<col style="width: 40mm;"/>
<col style="width: 8mm;"/>
<col style="width: 20mm;"/>
@if (Model.AreaComFilters.Length > 1) {
<col style="width: 38mm;"/>
} else {
<col style="width: 42mm;"/>
}
@if (Model.AreaComFilters.Length > 1) {
<col style="width: 36mm;"/>
} else {
<col style="width: 40mm;"/>
}
<col style="width: 8mm;"/>
@if (Model.AreaComFilters.Length > 1) {
<col style="width: 18mm;"/>
} else {
<col style="width: 20mm;"/>
}
<col style="width: 12mm;"/>
<col style="width: 5mm;" />
<col style="width: 18mm;"/>
<col style="width: 5mm;"/>
@if (Model.AreaComFilters.Length > 1) {
<col style="width: 16mm;"/>
} else {
<col style="width: 18mm;"/>
}
<col style="width: 12mm;"/>
@if (Model.AreaComFilters.Length > 1) {
<col style="width: 12mm;"/>
}
</colgroup>
<thead>
<tr>
<th rowspan="2">Nr.</th>
<th rowspan="2" style="text-align: left;">Name</th>
<th rowspan="2" style="text-align: left;">Adresse</th>
<th rowspan="2">PLZ</th>
<th rowspan="2" style="text-align: left;">Ort</th>
<th rowspan="2">Betr.-Nr.</th>
<th rowspan="2">GA</th>
<th rowspan="2" style="text-align: left;">Stamm-KG</th>
<th>Geb. Fl.</th>
@{
var headerSpan = Model.FilterAreaComs ? 3 : 2;
}
<th rowspan="@headerSpan">Nr.</th>
<th rowspan="@headerSpan" style="text-align: left;">Name</th>
<th rowspan="@headerSpan" style="text-align: left;">Adresse</th>
<th rowspan="@headerSpan">PLZ</th>
<th rowspan="@headerSpan" style="text-align: left;">Ort</th>
<th rowspan="@headerSpan">Betr.-Nr.</th>
<th rowspan="@headerSpan">GA</th>
<th rowspan="@headerSpan" style="text-align: left;">Stamm-KG</th>
<th colspan="@(Model.FilterAreaComs ? Model.AreaComFilters.Length : 1)">Geb. Fl.</th>
</tr>
@if (Model.FilterAreaComs) {
<tr>
@foreach (var vtrgId in Model.AreaComFilters) {
<th>@vtrgId</th>
}
</tr>
}
<tr>
<th class="unit">[m²]</th>
@for (int i = 0; i < Math.Max(Model.AreaComFilters.Length, 1); i++) {
<th class="unit">[m²]</th>
}
</tr>
</thead>
<tbody class="small">
@@ -40,22 +71,28 @@
}
@foreach (var m in Model.Members) {
if (lastBranch != null && m.Branch != lastBranch) {
<tr class="spacing"><td colspan="9"></td></tr>
<tr class="spacing"><td colspan="@(8 + Math.Max(Model.AreaComFilters.Length, 1))"></td></tr>
<tr class="header">
<th colspan="9">@m.Branch</th>
<th colspan="@(8 + Math.Max(Model.AreaComFilters.Length, 1))">@m.Branch</th>
</tr>
lastBranch = m.Branch;
}
<tr>
<td class="number" rowspan="@(m.BillingName != null ? 2 : 1)">@m.MgNr</td>
<td>@m.Name1.Replace('ß', 'ẞ').ToUpper() @m.Name2</td>
<td>@m.AdminName1 @m.Name2</td>
<td>@m.Address</td>
<td>@m.Plz</td>
<td class="tiny">@m.Locality</td>
<td>@m.LfbisNr</td>
<td class="number">@m.BusinessShares</td>
<td class="tiny">@m.DefaultKg</td>
<td class="number">@($"{m.AreaCommitment:N0}")</td>
@if (Model.AreaComFilters.Length > 0) {
foreach (var v in Model.AreaComFilters) {
<td class="number">@($"{m.AreaCommitmentsFiltered.FirstOrDefault(c => c.VtrgId == v).Area:N0}")</td>
}
} else {
<td class="number">@($"{m.AreaCommitment:N0}")</td>
}
</tr>
if (m.BillingName != null) {
<tr>

View File

@@ -1,6 +1,8 @@
using Elwig.Helpers.Billing;
using Elwig.Helpers;
using Elwig.Helpers.Billing;
using Elwig.Models.Dtos;
using Elwig.Models.Entities;
using System.Collections.Generic;
using System.Linq;
namespace Elwig.Documents {
@@ -15,6 +17,8 @@ namespace Elwig.Documents {
public int MemberNum;
public int DeliveryNum;
public int DeliveryPartNum;
public List<ModifierStat> ModifierStat;
public Dictionary<string, Modifier> Modifiers;
public PaymentVariantSummary(PaymentVar v, PaymentVariantSummaryData data) :
base($"{Name} {v.Year} - {v.Name}") {
@@ -25,6 +29,8 @@ namespace Elwig.Documents {
MemberNum = v.Credits.Count;
DeliveryNum = v.DeliveryPartPayments.DistinctBy(p => p.DeliveryPart.Delivery).Count();
DeliveryPartNum = v.DeliveryPartPayments.Count;
ModifierStat = AppDbContext.GetModifierStats(v.Year, v.AvNr).GetAwaiter().GetResult();
Modifiers = v.Season.Modifiers.ToDictionary(m => m.ModId);
}
}
}

View File

@@ -3,7 +3,7 @@
@inherits TemplatePage<Elwig.Documents.PaymentVariantSummary>
@model Elwig.Documents.PaymentVariantSummary
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\PaymentVariantSummary.css" />
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\PaymentVariantSummary.css" />
<main>
<h1>Auszahlungsvariante Lese @Model.Variant.Year</h1>
<h2>@Model.Variant.Name</h2>
@@ -20,9 +20,10 @@
@{
//var sum1 = Model.Variant.DeliveryPartPayments.Sum(p => p.NetAmount);
//var sum2 = Model.Variant.Credits.Sum(p => p.); //Model.Variant.MemberPayments.Sum(p => p.Amount);
var modifiers = Model.Variant.DeliveryPartPayments.Sum(p => p.Amount - p.NetAmount);
var deliveryModifiers = Model.Variant.DeliveryPartPayments.Sum(p => p.Amount - p.NetAmount);
var memberModifiers = Model.Variant.Credits.Sum(c => c.Payment.Amount - c.Payment.NetAmount);
var sum2 = Model.Variant.Credits.Sum(p => p.NetAmount);
var sum1 = sum2 - modifiers;
var sum1 = sum2 - deliveryModifiers - memberModifiers;
var payed = -Model.Variant.Credits.Sum(p => p.PrevNetAmount ?? 0m);
var netSum = Model.Variant.Credits.Sum(p => p.NetAmount) - Model.Variant.Credits.Sum(p => p.PrevNetAmount ?? 0m);
var vat = Model.Variant.Credits.Sum(p => p.VatAmount);
@@ -49,17 +50,29 @@
<td class="center">@(Model.BillingData.ConsiderContractPenalties ? "Ja" : "Nein")</td>
</tr>
<tr>
<th>Datum:</th>
<td colspan="3">@($"{Model.Variant.Date:dd.MM.yyyy}")</td>
<th style="overflow: visible;">Rebel-Zuschl.:</th>
<td colspan="3" class="center">
@($"{Utils.GetSign(Model.BillingData.NetWeightModifier)}{Math.Abs(Model.BillingData.NetWeightModifier) * 100:N2}") % /
@($"{Utils.GetSign(Model.BillingData.GrossWeightModifier)}{Math.Abs(Model.BillingData.GrossWeightModifier) * 100:N2}") %
</td>
<th colspan="2" class="lborder">Strafen bei Unterlieferungen (GA):</th>
<td class="center">@(Model.BillingData.ConsiderTotalPenalty ? "Ja" : "Nein")</td>
</tr>
<tr>
<th>Überw.:</th>
<td colspan="3">@($"{Model.Variant.TransferDate:dd.MM.yyyy}")</td>
<th style="overflow: visible;">Datum/Überw.:</th>
<td colspan="3" class="center">
@($"{Model.Variant.Date:dd.MM.yyyy}") /
@($"{Model.Variant.TransferDate:dd.MM.yyyy}")
</td>
<th colspan="2" class="lborder">Automatische Nachzeichnung der GA:</th>
<td class="center">@(Model.BillingData.ConsiderAutoBusinessShares ? "Ja" : "Nein")</td>
</tr>
<tr>
<th>Berechnung:</th>
<td colspan="3" class="center">@($"{Model.Variant.CalcTime:dd.MM.yyyy, HH:mm:ss}")</td>
<th colspan="2" class="lborder">Benutzerdef. Zu-/Abschläge pro Mitglied:</th>
<td class="center">@(Model.BillingData.ConsiderCustomModifiers ? "Ja" : "Nein")</td>
</tr>
<tr class="sectionheading">
<th colspan="4">Beträge</th>
<th colspan="3" class="lborder">Statistik</th>
@@ -72,58 +85,58 @@
<td colspan="2" class="number">@($"{Model.MemberNum:N0}")</td>
</tr>
<tr>
<th colspan="2">Zu-/Abschläge (Lieferungen):</th>
<td class="number">@Utils.GetSign(modifiers)</td>
<td class="number"><span class="fleft">@Model.CurrencySymbol</span>@($"{Math.Abs(modifiers):N2}")</td>
<th colspan="2">Zu-/Abschläge (Mitglieder):</th>
<td class="number">@Utils.GetSign(memberModifiers)</td>
<td class="number"><span class="fleft">@Model.CurrencySymbol</span>@($"{Math.Abs(memberModifiers):N2}")</td>
<th class="lborder">Lieferungen:</th>
<td colspan="2" class="number">@($"{Model.DeliveryNum:N0}")</td>
</tr>
<tr>
<th colspan="2">Zu-/Abschläge (Lieferungen):</th>
<td class="number">@Utils.GetSign(deliveryModifiers)</td>
<td class="number"><span class="fleft">@Model.CurrencySymbol</span>@($"{Math.Abs(deliveryModifiers):N2}")</td>
<th class="lborder">Teillieferungen:</th>
<td colspan="2" class="number">@($"{Model.DeliveryPartNum:N0}")</td>
</tr>
<tr>
<th colspan="2">Gesamtsumme:</th>
<td class="number tborder"></td>
<td class="number tborder"><span class="fleft">@Model.CurrencySymbol</span>@($"{sum2:N2}")</td>
<th class="lborder">Teillieferungen:</th>
<td colspan="2" class="number">@($"{Model.DeliveryPartNum:N0}")</td>
<th class="lborder"></th>
<td colspan="2"></td>
</tr>
<tr>
<th colspan="2">Bisher ausgezahlt:</th>
<td class="number">@Utils.GetSign(payed)</td>
<td class="number"><span class="fleft">@Model.CurrencySymbol</span>@($"{Math.Abs(payed):N2}")</td>
<th class="lborder"></th>
<td colspan="2"></td>
@{
var weiRows = Model.Data.Rows.Where(r => r.QualityLevel == "Wein");
var minWei = weiRows.Min(r => r.Ungeb.MinPrice);
var maxWei = weiRows.Max(r => r.Ungeb.MaxPrice);
}
<th class="lborder tborder">Preis (abgewertet):</th>
<td colspan="2" class="center tborder">@(minWei != maxWei ? $"{minWei:N4}{maxWei:N4}" : $"{minWei:N4}") @Model.CurrencySymbol/kg</td>
</tr>
<tr>
<th colspan="2">Nettosumme:</th>
<td class="number tborder"></td>
<td class="number tborder"><span class="fleft">@Model.CurrencySymbol</span>@($"{netSum:N2}")</td>
@{
var weiRows = Model.Data.Rows.Where(r => r.QualityLevel == "Wein");
var minWei = weiRows.Min(r => r.Ungeb.Price);
var maxWei = weiRows.Max(r => r.Ungeb.Price);
var quwRows = Model.Data.Rows.Where(r => r.QualityLevel != "Wein");
var minPrice = quwRows.Min(r => r.Ungeb.MinPrice);
var maxPrice = quwRows.Max(r => r.Ungeb.MaxPrice);
}
<th class="lborder tborder">Preis (abgewertet):</th>
<td colspan="2" class="center tborder">@(minWei != maxWei ? $"{minWei:N4}{maxWei:N4}" : $"{minWei:N4}") @Model.CurrencySymbol/kg</td>
<th class="lborder">Preis (ungeb., nicht abgew.):</th>
<td colspan="2" class="center">@(minPrice != maxPrice ? $"{minPrice:N4}{maxPrice:N4}" : $"{minPrice:N4}") @Model.CurrencySymbol/kg</td>
</tr>
<tr>
<th colspan="2">Mehrwertsteuer:</th>
<td class="number">@Utils.GetSign(vat)</td>
<td class="number"><span class="fleft">@Model.CurrencySymbol</span>@($"{Math.Abs(vat):N2}")</td>
@{
var quwRows = Model.Data.Rows.Where(r => r.QualityLevel != "Wein");
var minPrice = quwRows.Min(r => r.Ungeb.Price);
var maxPrice = quwRows.Max(r => r.Ungeb.Price);
}
<th class="lborder">Preis (ungeb., nicht abgew.):</th>
<td colspan="2" class="center">@(minPrice != maxPrice ? $"{minPrice:N4}{maxPrice:N4}" : $"{minPrice:N4}") @Model.CurrencySymbol/kg</td>
</tr>
<tr>
<th colspan="2">Bruttosumme:</th>
<td class="number tborder"></td>
<td class="number tborder"><span class="fleft">@Model.CurrencySymbol</span>@($"{grossSum:N2}")</td>
@{
var gebRows = Model.Data.Rows
.Where(r => r.Geb.Price != null && r.Ungeb.Price != null)
.Select(r => r.Geb.Price - r.Ungeb.Price);
.Where(r => r.Geb.MaxPrice != null && r.Ungeb.MinPrice != null)
.Select(r => r.Geb.MaxPrice - r.Ungeb.MinPrice);
var minGeb = gebRows.Min();
var maxGeb = gebRows.Max();
}
@@ -132,6 +145,13 @@
@(minGeb != maxGeb ? $"{minGeb:N4}{maxGeb:N4} {Model.CurrencySymbol}/kg" : minGeb == 0 ? "-" : $"{minGeb:N4} {Model.CurrencySymbol}/kg")
</td>
</tr>
<tr>
<th colspan="2">Bruttosumme:</th>
<td class="number tborder"></td>
<td class="number tborder"><span class="fleft">@Model.CurrencySymbol</span>@($"{grossSum:N2}")</td>
<th class="lborder"></th>
<td colspan="2"></td>
</tr>
<tr>
<th colspan="2">Abzüge (Strafen/Pönalen, GA, ...):</th>
<td class="number">@Utils.GetSign(totalMods)</td>
@@ -155,21 +175,66 @@
</tr>
</tbody>
</table>
<table class="payment-variant border">
<colgroup>
<col style="width: 35mm;"/>
<col style="width: 30mm;"/>
<col style="width: 25mm;"/>
<col style="width: 25mm;"/>
<col style="width: 25mm;"/>
<col style="width: 25mm;"/>
</colgroup>
<thead>
<tr class="sectionheading">
<th colspan="6">Statistik Zu-/Abschläge</th>
</tr>
<tr>
<th rowspan="2">Name</th>
<th rowspan="2">Zu-/Abschlag</th>
<th>Lieferungen</th>
<th>Minimum</th>
<th>Maximum</th>
<th>Betrag</th>
</tr>
<tr>
<th>[#]</th>
<th>[@Model.CurrencySymbol]</th>
<th>[@Model.CurrencySymbol]</th>
<th>[@Model.CurrencySymbol]</th>
</tr>
</thead>
<tbody>
@foreach (var m in Model.ModifierStat) {
var mod = Model.Modifiers[m.ModId];
<tr>
<th>@mod.Name</th>
<td class="number">@mod.ValueStr</td>
<td class="number">@($"{m.Count:N0}")</td>
<td class="number">@($"{m.Min:N2}")</td>
<td class="number">@($"{m.Max:N2}")</td>
<td class="number">@($"{m.Sum:N2}")</td>
</tr>
}
</tbody>
</table>
<table class="payment-variant-data">
<colgroup>
<col style="width: 30mm;"/>
<col style="width: 20mm;"/>
<col style="width: 25mm;"/>
<col style="width: 20mm;"/>
<col style="width: 25mm;"/>
<col style="width: 20mm;"/>
<col style="width: 25mm;"/>
<col style="width: 19mm;"/>
<col style="width: 18mm;"/>
<col style="width: 15mm;"/>
<col style="width: 18mm;"/>
<col style="width: 15mm;"/>
<col style="width: 18mm;"/>
<col style="width: 15mm;"/>
<col style="width: 22mm;"/>
</colgroup>
<thead>
<tr>
<th rowspan="2" style="text-align: left;">Qualitätsstufe</th>
<th>Gradation</th>
<th colspan="2">ungebunden</th>
<th colspan="2">attributlos gebunden</th>
<th colspan="2">gebunden</th>
<th>Gesamt</th>
</tr>
@@ -179,6 +244,8 @@
<th>[@(Model.CurrencySymbol)/kg]</th>
<th>[kg]</th>
<th>[@(Model.CurrencySymbol)/kg]</th>
<th>[kg]</th>
<th>[@(Model.CurrencySymbol)/kg]</th>
<th>[@(Model.CurrencySymbol)]</th>
</tr>
</thead>
@@ -196,6 +263,8 @@
<th colspan="2">@hdr</th>
<td class="number">@($"{rows.Sum(r => r.Ungeb.Weight):N0}")</td>
<td></td>
<td class="number">@($"{rows.Sum(r => r.LowGeb.Weight):N0}")</td>
<td></td>
<td class="number">@($"{rows.Sum(r => r.Geb.Weight):N0}")</td>
<td></td>
<td class="number">@($"{rows.Sum(r => r.Amount):N2}")</td>
@@ -205,9 +274,11 @@
<td>@(row.QualityLevel)</td>
<td class="center">@($"{row.Oe:N0}")</td>
<td class="number">@(row.Ungeb.Weight != 0 ? $"{row.Ungeb.Weight:N0}" : "-")</td>
<td class="number">@(row.Ungeb.Price != null ? $"{row.Ungeb.Price:N4}" : "-")</td>
<td class="number">@(row.Ungeb.MaxPrice != null ? $"{row.Ungeb.MaxPrice:N4}" : "-")</td>
<td class="number">@(row.LowGeb.Weight != 0 ? $"{row.LowGeb.Weight:N0}" : "-")</td>
<td class="number">@(row.LowGeb.MaxPrice != null ? $"{row.LowGeb.MaxPrice:N4}" : "-")</td>
<td class="number">@(row.Geb.Weight != 0 ? $"{row.Geb.Weight:N0}" : "-")</td>
<td class="number">@(row.Geb.Price != null ? $"{row.Geb.Price:N4}" : "-")</td>
<td class="number">@(row.Geb.MaxPrice != null ? $"{row.Geb.MaxPrice:N4}" : "-")</td>
<td class="number">@($"{row.Amount:N2}")</td>
</tr>
lastHdr = hdr;

View File

@@ -1,4 +1,4 @@
using Elwig.Models.Dtos;
using Elwig.Models.Dtos;
using System.Collections.Generic;
namespace Elwig.Documents {

View File

@@ -3,7 +3,7 @@
@inherits TemplatePage<Elwig.Documents.WineQualityStatistics>
@model Elwig.Documents.WineQualityStatistics
@{ Layout = "Document"; }
<link rel="stylesheet" href="file:///@Raw(Model.DataPath)\resources\WineQualityStatistics.css"/>
<link rel="stylesheet" href="file:///@Raw(Model.DocumentsPath)\WineQualityStatistics.css" />
<main>
<h1>Qualitätsstatistik</h1>
<h2>@Model.Filter</h2>

View File

@@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<PreserveCompilationContext>true</PreserveCompilationContext>
<ApplicationIcon>Resources\Images\Elwig.ico</ApplicationIcon>
<Version>0.8.2</Version>
<Version>1.0.0.0</Version>
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationManifest>app.manifest</ApplicationManifest>
@@ -20,24 +20,22 @@
<EmbeddedResource Include="Resources\Sql\*" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call fetch-resources.bat" />
</Target>
<ItemGroup>
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.0" />
<PackageReference Include="LinqKit" Version="1.2.5" />
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2478.35" />
<PackageReference Include="NJsonSchema" Version="11.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="LinqKit" Version="1.3.8" />
<PackageReference Include="MailKit" Version="4.13.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.36" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="9.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="9.0.7" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3351.48" />
<PackageReference Include="NJsonSchema" Version="11.3.2" />
<PackageReference Include="PdfiumViewer" Version="2.13.0" />
<PackageReference Include="PdfiumViewer.Native.x86_64.no_v8-no_xfa" Version="2018.4.8.256" />
<PackageReference Include="RazorLight" Version="2.3.1" />
<PackageReference Include="ScottPlot.WPF" Version="5.0.31" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="ScottPlot.WPF" Version="5.0.55" />
<PackageReference Include="System.IO.Ports" Version="9.0.7" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.7" />
</ItemGroup>
</Project>

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Windows.Input;
namespace Elwig.Helpers {

View File

@@ -17,8 +17,9 @@ namespace Elwig.Helpers {
public record struct AreaComBucket(int Area, int Obligation, int Right);
public record struct UnderDelivery(int Weight, int Diff);
public record struct MemberBucket(string Name, int Area, int Obligation, int Right, int Delivery, int DeliveryStrict, int Payment);
public record struct MemberBucket(string Name, int Area, int Obligation, int Right, int Delivery, int DeliveryStrict, int DeliveryTotal, int Payment);
public record struct MemberStat(string Variety, string Discr, int Weight);
public record struct ModifierStat(string ModId, string Name, int Count, decimal? Min, decimal? Max, decimal Sum);
public class AppDbContext : DbContext {
@@ -50,6 +51,9 @@ namespace Elwig.Helpers {
public DbSet<MemberHistory> MemberHistory { get; private set; }
public DbSet<AreaCom> AreaCommitments { get; private set; }
public DbSet<Season> Seasons { get; private set; }
public DbSet<DeliverySchedule> DeliverySchedules { get; private set; }
public DbSet<DeliveryScheduleWineVar> DeliveryScheduleWineVarieties { get; private set; }
public DbSet<DeliveryAncmt> DeliveryAnnouncements { get; private set; }
public DbSet<Modifier> Modifiers { get; private set; }
public DbSet<Delivery> Deliveries { get; private set; }
public DbSet<DeliveryPart> DeliveryParts { get; private set; }
@@ -57,11 +61,14 @@ namespace Elwig.Helpers {
public DbSet<PaymentVar> PaymentVariants { get; private set; }
public DbSet<PaymentMember> MemberPayments { get; private set; }
public DbSet<PaymentDeliveryPart> PaymentDeliveryParts { get; private set; }
public DbSet<PaymentCustom> CustomPayments { get; private set; }
public DbSet<Credit> Credits { get; private set; }
public DbSet<DeliveryPartBucket> DeliveryPartBuckets { get; private set; }
public DbSet<OverUnderDeliveryRow> OverUnderDeliveryRows { get; private set; }
public DbSet<AreaComUnderDeliveryRowSingle> AreaComUnderDeliveryRows { get; private set; }
public DbSet<MemberDeliveryPerVariantRowSingle> MemberDeliveryPerVariantRows { get; private set; }
public DbSet<MemberAreaComsRowSingle> MemberAreaComsRows { get; private set; }
public DbSet<CreditNoteDeliveryRowSingle> CreditNoteDeliveryRows { get; private set; }
public DbSet<CreditNoteRowSingle> CreditNoteRows { get; private set; }
public DbSet<WeightBreakdownRow> WeightBreakDownRows { get; private set; }
@@ -73,7 +80,7 @@ namespace Elwig.Helpers {
public bool HasBackendChanged => SavedLastWriteTime != LastWriteTime;
public static string? ConnectionStringOverride { get; set; } = null;
public static string ConnectionString => ConnectionStringOverride ?? $"Data Source=\"{App.Config.DatabaseFile}\"; Mode=ReadWrite; Foreign Keys=True; Cache=Default";
public static string ConnectionString => ConnectionStringOverride ?? $"Data Source=\"{App.Config.DatabaseFile}\"; Mode=ReadWrite; Foreign Keys=True; Cache=Default; Pooling=False";
private readonly Dictionary<int, Dictionary<int, Dictionary<string, AreaComBucket>>> _memberAreaCommitmentBuckets = [];
private readonly Dictionary<int, Dictionary<int, Dictionary<string, int>>> _memberDeliveryBuckets = [];
@@ -96,15 +103,15 @@ namespace Elwig.Helpers {
SavedChanges += OnSavedChanges;
}
public static SqliteConnection Connect() {
var cnx = new SqliteConnection(ConnectionString);
public static SqliteConnection Connect(string? connectionString = null) {
var cnx = new SqliteConnection(connectionString ?? ConnectionString);
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
cnx.Open();
return cnx;
}
public static async Task<SqliteConnection> ConnectAsync() {
var cnx = new SqliteConnection(ConnectionString);
public static async Task<SqliteConnection> ConnectAsync(string? connectionString = null) {
var cnx = new SqliteConnection(connectionString ?? ConnectionString);
cnx.CreateFunction<string, string?, bool?>("REGEXP", (pattern, value) => value == null ? null : Regex.Match(value, pattern).Success, true);
await cnx.OpenAsync();
return cnx;
@@ -198,10 +205,10 @@ namespace Elwig.Helpers {
return c + 1;
}
public async Task<int> NextLNr(DateOnly date) {
public async Task<int> NextLNr(DateOnly date, string zwstid) {
var dateStr = date.ToString("yyyy-MM-dd");
int c = 0;
(await Deliveries.Where(d => d.DateString == dateStr).Select(d => d.LNr).ToListAsync())
(await Deliveries.Where(d => d.DateString == dateStr && d.ZwstId == zwstid).Select(d => d.LNr).ToListAsync())
.ForEach(a => { if (a <= c + 100) c = a; });
return c + 1;
}
@@ -234,6 +241,13 @@ namespace Elwig.Helpers {
return c + 1;
}
public async Task<int> NextDsNr(int year) {
int c = 0;
(await DeliverySchedules.Where(s => s.Year == year).Select(s => s.DsNr).ToListAsync())
.ForEach(a => { if (a <= c + 100) c = a; });
return c + 1;
}
public async Task<WineQualLevel> GetWineQualityLevel(double kmw) {
return await WineQualityLevels
.Where(q => !q.IsPredicate && (q.MinKmw == null || q.MinKmw <= kmw))
@@ -241,29 +255,54 @@ namespace Elwig.Helpers {
.LastAsync();
}
public void UpdateDeliveryPartModifiers(DeliveryPart part, IEnumerable<Modifier> modifiers) {
public void UpdateDeliveryPartModifiers(DeliveryPart part, IEnumerable<Modifier> oldModifiers, IEnumerable<Modifier> newModifiers) {
foreach (var m in Modifiers.Where(m => m.Year == part.Year)) {
var mod = part.PartModifiers.Where(pa => pa.ModId == m.ModId).FirstOrDefault();
if (modifiers.Contains(m)) {
var dpm = new DeliveryPartModifier {
Year = part.Year,
DId = part.DId,
DPNr = part.DPNr,
ModId = m.ModId,
};
if (mod == null) {
Add(dpm);
var mod = new DeliveryPartModifier {
Year = part.Year,
DId = part.DId,
DPNr = part.DPNr,
ModId = m.ModId,
};
var old = oldModifiers.Where(pa => pa.ModId == m.ModId).FirstOrDefault();
if (newModifiers.Any(md => md.ModId == m.ModId)) {
if (old == null) {
Add(mod);
} else {
Update(dpm);
Update(mod);
}
} else {
if (mod != null) {
if (old != null) {
Remove(mod);
}
}
}
}
public void UpdateDeliveryScheduleWineVarieties(DeliverySchedule schedule, IEnumerable<(WineVar, int)> oldVarieties, IEnumerable<(WineVar, int)> newVarieties) {
foreach (var v in WineVarieties) {
var e = new DeliveryScheduleWineVar {
Year = schedule.Year,
DsNr = schedule.DsNr,
SortId = v.SortId,
Priority = 1,
};
var o = oldVarieties.Where(x => x.Item1.SortId == e.SortId).Select(x => x.Item2).FirstOrDefault(-1);
var n = newVarieties.Where(x => x.Item1.SortId == e.SortId).Select(x => x.Item2).FirstOrDefault(-1);
if (n != -1) {
e.Priority = n;
if (o == -1) {
Add(e);
} else {
Update(e);
}
} else {
if (o != -1) {
Remove(e);
}
}
}
}
private async Task FetchMemberAreaCommitmentBuckets(int year, SqliteConnection? cnx = null) {
var ownCnx = cnx == null;
cnx ??= await ConnectAsync();
@@ -405,6 +444,7 @@ namespace Elwig.Helpers {
rightsAndObligations.GetValueOrDefault(id).Right,
deliveryBuckets.GetValueOrDefault(id),
deliveryBucketsStrict.GetValueOrDefault(id),
deliveryBuckets.GetValueOrDefault(id) + deliveryBuckets.GetValueOrDefault(id + "_"),
paymentBuckets.GetValueOrDefault(id)
);
}
@@ -436,5 +476,34 @@ namespace Elwig.Helpers {
if (ownCnx) await cnx.DisposeAsync();
return list;
}
public static async Task<List<ModifierStat>> GetModifierStats(int year, int avnr, SqliteConnection? cnx = null) {
var ownCnx = cnx == null;
cnx ??= await ConnectAsync();
var list = new List<ModifierStat>();
using (var cmd = cnx.CreateCommand()) {
cmd.CommandText = $"""
SELECT m.modid, m.name, m.count, m.min, m.max, m.sum, s.precision
FROM v_stat_modifier m
JOIN season s ON s.year = m.year
WHERE m.year = {year} AND m.avnr = {avnr}
""";
using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync()) {
var prec = (byte)reader.GetInt16(6);
long? min = reader.IsDBNull(3) ? null : reader.GetInt64(3);
long? max = reader.IsDBNull(4) ? null : reader.GetInt64(4);
var sum = reader.GetInt64(5);
if (min != null && max != null && Math.Abs((long)min) > Math.Abs((long)max))
(min, max) = (max, min);
list.Add(new(reader.GetString(0), reader.GetString(1), reader.GetInt32(2),
min == null ? null : Utils.DecFromDb((long)min, prec),
max == null ? null : Utils.DecFromDb((long)max, prec),
Utils.DecFromDb(sum, prec)));
}
}
if (ownCnx) await cnx.DisposeAsync();
return list;
}
}
}

View File

@@ -9,15 +9,15 @@ namespace Elwig.Helpers {
public static class AppDbUpdater {
// Don't forget to update value in Tests/fetch-resources.bat!
public static readonly int RequiredSchemaVersion = 19;
public static readonly int RequiredSchemaVersion = 32;
private static int VersionOffset = 0;
public static async Task<string> CheckDb() {
public static async Task<Version> CheckDb() {
using var cnx = AppDbContext.Connect();
var applId = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA application_id") ?? 0;
if (applId != 0x454C5747) throw new Exception("Invalid application_id of database");
if (applId != 0x454C5747) throw new Exception($"Invalid application_id in database (0x{applId:X08})");
var schemaVers = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA schema_version") ?? 0;
VersionOffset = (int)(schemaVers % 100);
@@ -28,18 +28,14 @@ namespace Elwig.Helpers {
await UpdateDbSchema(cnx, (int)(schemaVers / 100), RequiredSchemaVersion);
var userVers = (long?)await AppDbContext.ExecuteScalar(cnx, "PRAGMA user_version") ?? 0;
var major = userVers >> 24;
var minor = (userVers >> 16) & 0xFF;
var patch = userVers & 0xFFFF;
var v = new Version((int)(userVers >> 24), (int)((userVers >> 16) & 0xFF), (int)((userVers >> 8) & 0xFF), (int)(userVers & 0xFF));
if (App.VersionMajor > major ||
(App.VersionMajor == major && App.VersionMinor > minor) ||
(App.VersionMajor == major && App.VersionMinor == minor && App.VersionPatch > patch)) {
long vers = (App.VersionMajor << 24) | (App.VersionMinor << 16) | App.VersionPatch;
if (App.Version > v) {
long vers = (App.Version.Major << 24) | (App.Version.Minor << 16) | (App.Version.Build << 8) | App.Version.Revision;
await AppDbContext.ExecuteBatch(cnx, $"PRAGMA user_version = {vers}");
}
return $"{major}.{minor}.{patch}";
return v;
}
private static async Task UpdateDbSchema(SqliteConnection cnx, int fromVersion, int toVersion) {

View File

@@ -3,6 +3,7 @@ using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
@@ -33,15 +34,45 @@ namespace Elwig.Helpers.Billing {
""");
}
public async Task AutoAdjustBusinessShare() {
public async Task AutoAdjustBusinessShares(DateOnly date, int allowanceKg = 0, double allowanceBs = 0, int allowanceKgPerBs = 0, double allowanceRel = 0, int addMinBs = 1) {
if (addMinBs < 1) addMinBs = 1;
using var cnx = await AppDbContext.ConnectAsync();
await AppDbContext.ExecuteBatch(cnx, $"""
INSERT INTO member_history (mgnr, date, business_shares, type)
SELECT u.mgnr, '{Utils.Today:yyyy-MM-dd}', u.diff / s.max_kg_per_bs AS bs, 'auto'
UPDATE member
SET business_shares = member.business_shares - h.business_shares
FROM member_history h
WHERE h.date = '{Year}-11-30' AND h.type = 'auto' AND h.mgnr = member.mgnr AND member.active;
INSERT INTO member_history (mgnr, date, type, business_shares)
SELECT u.mgnr,
'{date:yyyy-MM-dd}',
'auto',
CEIL((u.diff - {allowanceKg}.0 - {allowanceKgPerBs}.0 * u.business_shares) / s.max_kg_per_bs
- {allowanceBs.ToString(CultureInfo.InvariantCulture)}
- {allowanceRel.ToString(CultureInfo.InvariantCulture)} * u.business_shares) AS bs
FROM v_total_under_delivery u
JOIN season s ON s.year = u.year
WHERE s.year = {Year} AND bs > 0
ON CONFLICT DO NOTHING
JOIN member m ON m.mgnr = u.mgnr
WHERE s.year = {Year} AND bs >= {addMinBs} AND m.active
ON CONFLICT DO UPDATE
SET business_shares = excluded.business_shares;
UPDATE member
SET business_shares = member.business_shares + h.business_shares
FROM member_history h
WHERE h.date = '{Year}-11-30' AND h.type = 'auto' AND h.mgnr = member.mgnr;
""");
}
public async Task UnAdjustBusinessShares() {
using var cnx = await AppDbContext.ConnectAsync();
await AppDbContext.ExecuteBatch(cnx, $"""
UPDATE member
SET business_shares = member.business_shares - h.business_shares
FROM member_history h
WHERE h.date = '{Year}-11-30' AND h.type = 'auto' AND h.mgnr = member.mgnr AND member.active;
DELETE FROM member_history WHERE date = '{Year}-11-30' AND type = 'auto';
""");
}
@@ -126,13 +157,15 @@ namespace Elwig.Helpers.Billing {
lastMgNr = mgnr;
}
await AppDbContext.ExecuteBatch(cnx, $"""
UPDATE delivery_part_bucket SET value = 0 WHERE year = {Year};
INSERT INTO delivery_part_bucket (year, did, dpnr, bktnr, discr, value)
VALUES {string.Join(",\n ", inserts.Select(i => $"({Year}, {i.Item1}, {i.Item2}, {i.Item3}, '{i.Item4}', {i.Item5})"))}
ON CONFLICT DO UPDATE
SET discr = excluded.discr, value = value + excluded.value;
""");
await AppDbContext.ExecuteBatch(cnx, $"UPDATE delivery_part_bucket SET value = 0 WHERE year = {Year}");
if (inserts.Count > 0) {
await AppDbContext.ExecuteBatch(cnx, $"""
INSERT INTO delivery_part_bucket (year, did, dpnr, bktnr, discr, value)
VALUES {string.Join(",\n ", inserts.Select(i => $"({Year}, {i.Item1}, {i.Item2}, {i.Item3}, '{i.Item4}', {i.Item5})"))}
ON CONFLICT DO UPDATE
SET discr = excluded.discr, value = value + excluded.value;
""");
}
if (!avoidUnderDlvrs) {
if (ownCnx) await cnx.DisposeAsync();

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using NJsonSchema;
using System;
using System.Collections.Generic;
@@ -41,6 +41,10 @@ namespace Elwig.Helpers.Billing {
get => GetConsider("consider_auto_business_shares");
set => SetConsider(value, "consider_auto_business_shares");
}
public bool ConsiderCustomModifiers {
get => GetConsider("consider_custom_modifiers");
set => SetConsider(value, "consider_custom_modifiers");
}
public double NetWeightModifier {
get => GetWeightModifier("net_weight_modifier", "Rebelzuschlag");
@@ -295,22 +299,30 @@ namespace Elwig.Helpers.Billing {
return (rev1, rev2);
}
protected static void CollapsePaymentData(JsonObject data, IEnumerable<RawVaribute> vaributes, bool useDefault = true) {
protected static void CollapsePaymentData(JsonObject data, JsonObject originalData, IEnumerable<RawVaribute> vaributes, bool useDefault = true) {
var (rev1, rev2) = GetReverseKeys(data);
if (!data.ContainsKey("default")) {
foreach (var (v, ks) in rev1) {
if ((ks.Count >= vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
foreach (var k in ks) data.Remove(k);
if ((ks.Count > vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
foreach (var k in ks) {
if (!(originalData[$"{k[..2]}/"]?.AsValue().TryGetValue<string>(out var o) ?? false) || o == v)
if (!(originalData[k.Split('-')[0]]?.AsValue().TryGetValue<string>(out var o2) ?? false) || o2 == v)
data.Remove(k);
}
data["default"] = v;
CollapsePaymentData(data, vaributes, useDefault);
CollapsePaymentData(data, originalData, vaributes, useDefault);
return;
}
}
foreach (var (v, ks) in rev2) {
if ((ks.Count >= vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
foreach (var k in ks) data.Remove(k);
if ((ks.Count > vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
foreach (var k in ks) {
if (!(originalData[$"{k[..2]}/"]?.AsValue().TryGetValue<decimal>(out var o) ?? false) || o == v)
if (!(originalData[k.Split('-')[0]]?.AsValue().TryGetValue<decimal>(out var o2) ?? false) || o2 == v)
data.Remove(k);
}
data["default"] = v;
CollapsePaymentData(data, vaributes, useDefault);
CollapsePaymentData(data, originalData, vaributes, useDefault);
return;
}
}
@@ -326,16 +338,26 @@ namespace Elwig.Helpers.Billing {
var len = vaributes.Count(e => $"{e.AttrId}{(e.CultId != null && e.CultId != "" ? "-" : "")}{e.CultId}" == idx);
foreach (var (v, ks) in rev1) {
var myKs = ks.Where(k => k.EndsWith($"/{idx}")).ToList();
if (myKs.Count > 1 && ((myKs.Count >= len * 0.5 && useDefault) || myKs.Count == len)) {
if (myKs.Count > 1 && ((myKs.Count > len * 0.5 && useDefault) || myKs.Count == len)) {
foreach (var k in myKs) data.Remove(k);
data[(idx.StartsWith('-') && !useDefault ? "" : "/") + idx] = v;
var discr = (idx.StartsWith('-') && !useDefault ? "" : "/") + idx;
data[discr] = v;
foreach (var (k, o) in originalData) {
if (o!.AsValue().TryGetValue<string>(out var o2) && o2 != v && k.Contains(discr))
data[k] = o2;
}
}
}
foreach (var (v, ks) in rev2) {
var myKs = ks.Where(k => k.EndsWith($"/{idx}")).ToList();
if (myKs.Count > 1 && ((myKs.Count >= len * 0.5 && useDefault) || myKs.Count == len)) {
if (myKs.Count > 1 && ((myKs.Count > len * 0.5 && useDefault) || myKs.Count == len)) {
foreach (var k in myKs) data.Remove(k);
data[(idx.StartsWith('-') && !useDefault ? "" : "/") + idx] = v;
var discr = (idx.StartsWith('-') && !useDefault ? "" : "/") + idx;
data[discr] = v;
foreach (var (k, o) in originalData) {
if (o!.AsValue().TryGetValue<decimal>(out var o2) && o2 != v && k.Contains(discr))
data[k] = o2;
}
}
}
}
@@ -351,13 +373,22 @@ namespace Elwig.Helpers.Billing {
} else if (k.Contains("/-")) {
data.Remove(k, out var val);
data.Add(k.Replace("/-", "-"), val);
if (k[0] == '/' || k.Contains('-')) {
foreach (var (k2, o) in originalData) {
if (!data.ContainsKey(k2) && k2.Contains('-') && k2.Contains("-" + k.Split('-')[1]) && !k2.Contains("/-")
&& (!k2.Contains('/') || k2.Length <= 4 || !data.ContainsKey(k2[2..])))
{
data[k2] = o?.DeepClone();
}
}
}
}
}
(rev1, rev2) = GetReverseKeys(data, false);
var keyVaributes = data
.Select(e => e.Key.Split('-')[0])
.Where(e => e.Length > 0 && e != "default")
.Select(e => e.Key)
.Where(e => e.Length > 0 && !e.Contains('-') && e != "default")
.Distinct()
.ToList();
foreach (var idx in keyVaributes) {
@@ -415,8 +446,8 @@ namespace Elwig.Helpers.Billing {
}
}
CollapsePaymentData(payment, vaributes ?? payment.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultPayment);
CollapsePaymentData(qualityWei, vaributes ?? qualityWei.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultQuality);
CollapsePaymentData(payment, payment.DeepClone().AsObject(), vaributes ?? payment.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultPayment);
CollapsePaymentData(qualityWei, qualityWei.DeepClone().AsObject(), vaributes ?? qualityWei.Select(e => new RawVaribute(e.Key)).ToList(), useDefaultQuality);
var data = new JsonObject {
["mode"] = "elwig",

View File

@@ -29,6 +29,8 @@ namespace Elwig.Helpers.Billing {
await CalculatePrices(cnx);
if (Data.ConsiderDelieryModifiers) {
await CalculateDeliveryModifiers(cnx);
}
if (Data.ConsiderCustomModifiers) {
await CalculateMemberModifiers(cnx);
}
await tx.CommitAsync();
@@ -44,13 +46,14 @@ namespace Elwig.Helpers.Billing {
m.mgnr,
v.avnr,
ROUND(p.amount / POW(10, s.precision - 2)) AS net_amount,
ROUND(lp.amount / POW(10, s.precision - 2)) AS prev_amount,
IIF(lc.amount >= 0, ROUND(lp.amount / POW(10, s.precision - 2)), 0) AS prev_net_amount,
IIF(m.buchführend, s.vat_normal, s.vat_flatrate) AS vat,
ROUND(IIF({Data.ConsiderContractPenalties}, COALESCE(u.total_penalty, 0), 0) / POW(10, 4 - 2)) +
ROUND(IIF({Data.ConsiderTotalPenalty}, COALESCE(b.total_penalty, 0), 0) / POW(10, s.precision - 2)) +
ROUND(IIF({Data.ConsiderAutoBusinessShares}, -COALESCE(a.total_amount, 0), 0) / POW(10, s.precision - 2))
ROUND(IIF({Data.ConsiderContractPenalties}, COALESCE(u.total_penalty, 0), 0) / POW(10, 4 - 2)) +
ROUND(IIF({Data.ConsiderAutoBusinessShares}, -COALESCE(a.total_amount, 0), 0) / POW(10, s.precision - 2)) +
IIF({Data.ConsiderCustomModifiers}, COALESCE(x.amount, 0), 0)
AS modifiers,
lc.modifiers AS prev_modifiers
IIF(lc.amount >= 0, lc.modifiers, 0) AS prev_modifiers
FROM season s
JOIN payment_variant v ON v.year = s.year
LEFT JOIN payment_variant l ON l.year = s.year
@@ -65,13 +68,15 @@ namespace Elwig.Helpers.Billing {
LEFT JOIN payment_member lp ON (lp.year, lp.avnr, lp.mgnr) = (l.year, l.avnr, m.mgnr)
LEFT JOIN payment_member p ON (p.year, p.avnr, p.mgnr) = (v.year, v.avnr, m.mgnr)
LEFT JOIN credit lc ON (lc.year, lc.avnr, lc.mgnr) = (l.year, l.avnr, m.mgnr)
LEFT JOIN v_penalty_area_commitments u ON (u.year, u.mgnr) = (s.year, m.mgnr)
LEFT JOIN v_penalty_business_shares b ON (b.year, b.mgnr) = (s.year, m.mgnr)
LEFT JOIN v_penalty_area_commitments u ON (u.year, u.mgnr) = (s.year, m.mgnr)
LEFT JOIN v_auto_business_shares a ON (a.year, a.mgnr) = (s.year, m.mgnr)
LEFT JOIN payment_custom x ON (x.year, x.mgnr) = (s.year, m.mgnr)
WHERE s.year = {Year} AND v.avnr = {AvNr};
UPDATE payment_variant SET test_variant = FALSE WHERE (year, avnr) = ({Year}, {AvNr});
""");
await AppDbContext.ExecuteBatch(cnx, $"""
UPDATE payment_variant SET test_variant = FALSE WHERE (year, avnr) = ({Year}, {AvNr});
""");
}
public async Task Revert() {
@@ -101,18 +106,21 @@ namespace Elwig.Helpers.Billing {
if (App.Client.IsMatzen) {
var lastYears = 3;
var multiplier = 0.50;
var includePredecessor = true;
var modName = "Treue%";
await AppDbContext.ExecuteBatch(cnx, $"""
INSERT INTO payment_member (year, avnr, mgnr, net_amount, mod_abs, mod_rel)
SELECT c.year, {AvNr}, s.mgnr, 0,
ROUND(s.sum * COALESCE(m.abs, 0)),
COALESCE(m.rel, 0)
FROM (SELECT {Year} AS year, mgnr,
ROUND(AVG(sum) * {multiplier}) AS baseline,
COUNT(*) = {lastYears} AND MIN(sum) > 0 AS allowed
FROM v_stat_member
WHERE year > {Year} - {lastYears}
GROUP BY mgnr
FROM (SELECT {Year} AS year, m.mgnr,
ROUND(AVG(COALESCE(a.sum, b.sum)) * {multiplier}) AS baseline,
COUNT(*) = {lastYears} AND MIN(COALESCE(a.sum, b.sum)) > 0 AS allowed
FROM member m
LEFT JOIN v_stat_member a ON a.mgnr = m.mgnr
FULL OUTER JOIN v_stat_member b ON b.mgnr = m.predecessor_mgnr AND b.year = a.year AND {(includePredecessor ? "TRUE" : "FALSE")}
WHERE a.year > {Year} - {lastYears}
GROUP BY m.mgnr
HAVING allowed) c
JOIN v_stat_member s ON (s.year, s.mgnr) = (c.year, c.mgnr)
LEFT JOIN modifier m ON m.year = c.year AND m.name LIKE '{modName}'
@@ -122,6 +130,16 @@ namespace Elwig.Helpers.Billing {
mod_rel = mod_rel + excluded.mod_rel
""");
}
await AppDbContext.ExecuteBatch(cnx, $"""
INSERT INTO payment_member (year, avnr, mgnr, net_amount, mod_abs, mod_rel)
SELECT x.year, {AvNr}, x.mgnr, 0, COALESCE(x.mod_abs * POW(10, s.precision - 2), 0), COALESCE(x.mod_rel, 0)
FROM payment_custom x
JOIN season s ON s.year = x.year
WHERE x.year = {Year}
ON CONFLICT DO UPDATE
SET mod_abs = mod_abs + excluded.mod_abs,
mod_rel = mod_rel + excluded.mod_rel
""");
}
protected async Task CalculatePrices(SqliteConnection cnx) {

View File

@@ -1,4 +1,4 @@
using Elwig.Models.Entities;
using Elwig.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -1,6 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
namespace Elwig.Helpers.Billing {
public class GraphEntry {
@@ -40,6 +41,7 @@ namespace Elwig.Helpers.Billing {
public string VaributeStringSimple => (Abgewertet ? "Abgew.: " : "") + (Vaributes.Count != 0 ? (Vaributes.Count >= 25 ? "Restliche Sorten" : string.Join(", ", Vaributes.Select(c => c.Listing))) : "-");
public string VaributeString => Vaributes.Count != 0 ? string.Join("\n", Vaributes.Select(c => c.FullName)) : "-";
public string VaributeStringChange => (Abgewertet ? "A." : "") + string.Join(",", Vaributes.Select(c => c.Listing));
public Brush? Color => Vaributes.Select(v => v.Variety?.Color).Distinct().SingleOrDefault();
private readonly int Precision;
public GraphEntry(int id, int precision, BillingData.CurveMode mode) {

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;

View File

@@ -1,4 +1,4 @@
using Elwig.Models.Entities;
using Elwig.Models.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;

View File

@@ -1,6 +1,7 @@
using Elwig.Models.Entities;
using Microsoft.Data.Sqlite;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
@@ -22,6 +23,10 @@ namespace Elwig.Helpers {
public bool HasNetWeighing(Branch? b) => HasNetWeighing(b?.ZwstId);
public bool HasNetWeighing() => HasNetWeighing(App.ZwstId);
public bool HasBoxWeighing(string? zwstId) => IsWinzerkeller && (zwstId != "W");
public bool HasBoxWeighing(Branch? b) => HasBoxWeighing(b?.ZwstId);
public bool HasBoxWeighing() => HasBoxWeighing(App.ZwstId);
public string NameToken;
public string NameShort;
public string Name;
@@ -50,6 +55,7 @@ namespace Elwig.Helpers {
public string? Bic;
public string? UstIdNr;
public string? LfbisNr;
public string? OrganicAuthority;
public string? PhoneNr;
public string? FaxNr;
@@ -66,6 +72,17 @@ namespace Elwig.Helpers {
public string? TextEmailSubject;
public string? TextEmailBody;
public bool MailIncludeNonDeliverers;
public bool MailDoublePaged;
public int MailSendPostal;
public int MailSendEmail;
public int MailOrdering;
public int ExportEbicsVersion;
public int ExportEbicsAddress;
public (int? AllowanceKg, double? AllowanceBs, int? AllowanceKgPerBs, double? AllowancePercent, int? MinBs) AutoAdjustBs;
public ClientParameters(AppDbContext ctx) : this(ctx.ClientParameters.ToDictionary(e => e.Param, e => e.Value)) { }
public ClientParameters(Dictionary<string, string?> parameters) {
@@ -97,6 +114,7 @@ namespace Elwig.Helpers {
UstIdNr = parameters.GetValueOrDefault("CLIENT_USTIDNR");
Bic = parameters.GetValueOrDefault("CLIENT_BIC");
Iban = parameters.GetValueOrDefault("CLIENT_IBAN");
OrganicAuthority = parameters.GetValueOrDefault("CLIENT_ORGANIC_AUTHORITY");
switch (parameters.GetValueOrDefault("MODE_DELIVERYNOTE_STATS", "SHORT")?.ToUpper()) {
case "NONE": ModeDeliveryNoteStats = 0; break;
@@ -111,7 +129,7 @@ namespace Elwig.Helpers {
case "KMW/5": ModeWineQualityStatistics = 3; break;
case "KMW/10": ModeWineQualityStatistics = 4; break;
}
switch (parameters.GetValueOrDefault("ORDERING_MEMBERLIST", "")?.ToUpper()) {
switch (parameters.GetValueOrDefault("ORDERING_MEMBERLIST", "MGNR")?.ToUpper()) {
case "MGNR": OrderingMemberList = 0; break;
case "NAME": OrderingMemberList = 1; break;
case "KG": OrderingMemberList = 2; break;
@@ -128,6 +146,47 @@ namespace Elwig.Helpers {
if (TextEmailSubject == "") TextEmailSubject = null;
TextEmailBody = parameters.GetValueOrDefault("TEXT_EMAIL_BODY");
if (TextEmailBody == "") TextEmailBody = null;
MailIncludeNonDeliverers = (parameters.GetValueOrDefault("MAIL_INCLUDE_NON_DELIVERERS")?.ToUpper()) switch {
"1" or "TRUE" or "YES" or "JA" => true,
_ => false,
};
MailDoublePaged = (parameters.GetValueOrDefault("MAIL_DOUBLE_PAGED")?.ToUpper()) switch {
"1" or "TRUE" or "YES" or "JA" => true,
_ => false,
};
switch (parameters.GetValueOrDefault("MAIL_SEND_POSTAL", "WISH")?.ToUpper()) {
case "ALL": MailSendPostal = 3; break;
case "WISH": MailSendPostal = 2; break;
case "NO_EMAIL": MailSendPostal = 1; break;
case "NONE": MailSendPostal = 0; break;
}
switch (parameters.GetValueOrDefault("MAIL_SEND_EMAIL", "WISH")?.ToUpper()) {
case "ALL": MailSendEmail = 2; break;
case "WISH": MailSendEmail = 1; break;
case "NONE": MailSendEmail = 0; break;
}
switch (parameters.GetValueOrDefault("MAIL_ORDERING", "MGNR")?.ToUpper()) {
case "MGNR": MailOrdering = 0; break;
case "NAME": MailOrdering = 1; break;
case "PLZ": MailOrdering = 2; break;
}
ExportEbicsVersion = int.TryParse(parameters.GetValueOrDefault("EXPORT_EBICS_VERSION"), out var v) ? v : 9;
switch (parameters.GetValueOrDefault("EXPORT_EBICS_ADDRESS", "FULL")?.ToUpper()) {
case "OMIT": ExportEbicsAddress = 0; break;
case "LINES": ExportEbicsAddress = 1; break;
case "FULL": ExportEbicsAddress = 2; break;
}
var autoAdjust = (parameters.GetValueOrDefault("AUTOADJUST_BUSINESSSHARES") ?? "").Split(';');
AutoAdjustBs = autoAdjust.Length == 5 ? (
int.TryParse(autoAdjust[0], out var v1) ? v1 : null,
double.TryParse(autoAdjust[1], out var v2) ? v2 : null,
int.TryParse(autoAdjust[2], out var v3) ? v3 : null,
double.TryParse(autoAdjust[3], out var v4) ? v4 : null,
int.TryParse(autoAdjust[4], out var v5) ? v5 : null
) : (null, null, null, null, null);
} catch {
throw new KeyNotFoundException();
}
@@ -155,6 +214,34 @@ namespace Elwig.Helpers {
case 1: orderingMemberList = "NAME"; break;
case 2: orderingMemberList = "KG"; break;
}
string mailSendPostal = "MGNR";
switch (MailOrdering) {
case 0: mailSendPostal = "NONE"; break;
case 1: mailSendPostal = "NO_EMAIL"; break;
case 2: mailSendPostal = "WISH"; break;
case 3: mailSendPostal = "ALL"; break;
}
string mailSendEmail = "MGNR";
switch (MailOrdering) {
case 0: mailSendEmail = "NONE"; break;
case 1: mailSendEmail = "WISH"; break;
case 2: mailSendEmail = "ALL"; break;
}
string mailOrdering = "MGNR";
switch (MailOrdering) {
case 0: mailOrdering = "MGNR"; break;
case 1: mailOrdering = "NAME"; break;
case 2: mailOrdering = "PLZ"; break;
}
string exportEbicsAddress = "FULL";
switch (ExportEbicsAddress) {
case 0: exportEbicsAddress = "OMIT"; break;
case 1: exportEbicsAddress = "LINES"; break;
case 2: exportEbicsAddress = "FULL"; break;
}
string autoAdjust = $"{AutoAdjustBs.AllowanceKg};{AutoAdjustBs.AllowanceBs?.ToString(CultureInfo.InvariantCulture)};" +
$"{AutoAdjustBs.AllowanceKgPerBs};{AutoAdjustBs.AllowancePercent?.ToString(CultureInfo.InvariantCulture)};" +
$"{AutoAdjustBs.MinBs}";
return [
("CLIENT_NAME_TOKEN", NameToken),
("CLIENT_NAME_SHORT", NameShort),
@@ -172,6 +259,7 @@ namespace Elwig.Helpers {
("CLIENT_USTIDNR", UstIdNr),
("CLIENT_BIC", Bic),
("CLIENT_IBAN", Iban),
("CLIENT_ORGANIC_AUTHORITY", OrganicAuthority),
("MODE_DELIVERYNOTE_STATS", deliveryNoteStats),
("MODE_WINEQUALITYSTATISTICS", modeWineQualityStatistics),
("ORDERING_MEMBERLIST", orderingMemberList),
@@ -180,7 +268,15 @@ namespace Elwig.Helpers {
("TEXT_DELIVERYCONFIRMATION", TextDeliveryConfirmation),
("TEXT_CREDITNOTE", TextCreditNote),
("TEXT_EMAIL_SUBJECT", TextEmailSubject),
("TEXT_EMAIL_BODY", TextEmailBody)
("TEXT_EMAIL_BODY", TextEmailBody),
("MAIL_INCLUDE_NON_DELIVERERS", MailIncludeNonDeliverers ? "YES" : "NO"),
("MAIL_DOUBLE_PAGED", MailDoublePaged ? "YES" : "NO"),
("MAIL_SEND_POSTAL", mailSendPostal),
("MAIL_SEND_EMAIL", mailSendEmail),
("MAIL_ORDERING", mailOrdering),
("EXPORT_EBICS_VERSION", ExportEbicsVersion.ToString()),
("EXPORT_EBICS_ADDRESS", exportEbicsAddress),
("AUTOADJUST_BUSINESSSHARES", autoAdjust),
];
}

View File

@@ -69,9 +69,9 @@ namespace Elwig.Helpers {
public void Read() {
var config = new ConfigurationBuilder().AddIniFile(FileName).Build();
DatabaseFile = Path.Combine(App.DataPath, config["database:file"] ?? "database.sqlite3");
DatabaseFile = Path.Combine(Path.GetDirectoryName(FileName) ?? App.DataPath, config["database:file"] ?? "database.sqlite3");
var log = config["database:log"];
DatabaseLog = log != null ? Path.Combine(App.DataPath, log) : null;
DatabaseLog = log != null ? Path.Combine(Path.GetDirectoryName(FileName) ?? App.DataPath, log) : null;
Branch = config["general:branch"];
Debug = TrueValues.Contains(config["general:debug"]?.ToLower());
UpdateUrl = config["update:url"];
@@ -87,7 +87,7 @@ namespace Elwig.Helpers {
SmtpPassword = config["smtp:password"];
SmtpFrom = config["smtp:from"];
var scales = config.AsEnumerable().Where(i => i.Key.StartsWith("scale.")).GroupBy(i => i.Key.Split(':')[0][6..]).Select(i => i.Key);
var scales = config.AsEnumerable().Where(i => i.Key.StartsWith("scale.")).GroupBy(i => i.Key.Split(':')[0][6..]).Select(i => i.Key).Order();
ScaleList.Clear();
Scales = ScaleList;
foreach (var s in scales) {

View File

@@ -5,17 +5,14 @@ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Threading;
using Brush = System.Windows.Media.Brush;
using Brushes = System.Windows.Media.Brushes;
namespace Elwig.Helpers {
public class ControlUtils {
public enum RenewSourceDefault {
None,
IfOnly,
First
}
public enum RenewSourceDefault { None, IfOnly, First }
private static void SetControlBorderBrush(Control input, Brush brush) {
if (input is ComboBox cb) {
@@ -102,20 +99,6 @@ namespace Elwig.Helpers {
selector.SelectedItem = selItem;
}
public static void RenewItemsSource(Xceed.Wpf.Toolkit.Primitives.Selector selector, IEnumerable? source, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventHandler? handler = null) {
if (selector.ItemsSource == source)
return;
var selectedIds = selector.SelectedItems.Cast<object>().Select(i => Utils.GetEntityIdentifier(i)).ToList();
if (handler != null && selectedIds != null) selector.ItemSelectionChanged -= handler;
selector.ItemsSource = source;
if (source != null) {
selector.SelectedItems.Clear();
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(Utils.GetEntityIdentifier(i))))
selector.SelectedItems.Add(i);
}
if (handler != null && selectedIds != null) selector.ItemSelectionChanged += handler;
}
public static void RenewItemsSource(DataGrid dataGrid, IEnumerable? source, SelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None, bool keepSort = true) {
if (dataGrid.ItemsSource == source)
return;
@@ -148,19 +131,31 @@ namespace Elwig.Helpers {
public static void RenewItemsSource(ListBox listBox, IEnumerable? source, SelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None) {
if (listBox.ItemsSource == source)
return;
var selectedId = Utils.GetEntityIdentifier(listBox.SelectedItem);
object? selItem = null;
if (selectedId != 0 && source != null)
selItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(Utils.GetEntityIdentifier(i)));
if (source != null && selItem == null) {
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
selItem = source.Cast<object>().FirstOrDefault();
if (listBox.SelectionMode == SelectionMode.Single) {
var selectedId = Utils.GetEntityIdentifier(listBox.SelectedItem);
object? selItem = null;
if (selectedId != 0 && source != null)
selItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(Utils.GetEntityIdentifier(i)));
if (source != null && selItem == null) {
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
selItem = source.Cast<object>().FirstOrDefault();
}
}
if (handler != null && selItem != null) listBox.SelectionChanged -= handler;
listBox.ItemsSource = source;
if (handler != null && selItem != null) listBox.SelectionChanged += handler;
listBox.SelectedItem = selItem;
} else {
var selectedIds = listBox.SelectedItems.Cast<object>().Select(Utils.GetEntityIdentifier).ToList();
if (handler != null && selectedIds != null) listBox.SelectionChanged -= handler;
listBox.ItemsSource = source;
if (source != null && selectedIds != null) {
listBox.SelectedItems.Clear();
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(Utils.GetEntityIdentifier(i))))
listBox.SelectedItems.Add(i);
}
if (handler != null && selectedIds != null) listBox.SelectionChanged += handler;
}
if (handler != null && selItem != null) listBox.SelectionChanged -= handler;
listBox.ItemsSource = source;
if (handler != null && selItem != null) listBox.SelectionChanged += handler;
listBox.SelectedItem = selItem;
}
public static object? GetItemFromSource(IEnumerable source, int? hash) {
@@ -173,15 +168,19 @@ namespace Elwig.Helpers {
return item;
}
public static object? GetItemFromSource(IEnumerable source, object? item) {
return GetItemFromSource(source, Utils.GetEntityIdentifier(item));
public static T? GetItemFromSource<T>(IEnumerable source, T? item) {
return (T?)GetItemFromSource(source, Utils.GetEntityIdentifier(item));
}
public static object? GetItemFromSourceWithPk(IEnumerable source, params object?[] primaryKey) {
return GetItemFromSource(source, (int?)Utils.GetEntityIdetifierForPk(primaryKey));
}
public static void SelectItemWithHash(Selector input, int? hash) {
if (hash == null) {
input.SelectedItem = null;
} else {
input.SelectedItem = GetItemFromSource(input.ItemsSource, (int)hash);
input.SelectedItem = GetItemFromSource(input.ItemsSource, hash);
}
if (input is ListBox lb && lb.SelectedItem is object lbItem) {
lb.ScrollIntoView(lbItem);
@@ -210,15 +209,15 @@ namespace Elwig.Helpers {
return GetItemsFromSource(source, items.Select(Utils.GetEntityIdentifier));
}
public static void SelectItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, IEnumerable<int?>? ids) {
ccb.SelectedItems.Clear();
public static void SelectItems(ListBox lb, IEnumerable<int?>? ids) {
lb.SelectedItems.Clear();
if (ids == null) return;
foreach (var id in ids)
ccb.SelectedItems.Add(GetItemFromSource(ccb.ItemsSource, id));
lb.SelectedItems.Add(GetItemFromSource(lb.ItemsSource, id));
}
public static void SelectItems(Xceed.Wpf.Toolkit.CheckComboBox ccb, IEnumerable<object>? items) {
SelectItems(ccb, items?.Select(Utils.GetEntityIdentifier));
public static void SelectItems(ListBox lb, IEnumerable<object>? items) {
SelectItems(lb, items?.Select(Utils.GetEntityIdentifier));
}
public static int? GetInputHashCode(Control input) {
@@ -226,8 +225,8 @@ namespace Elwig.Helpers {
return Utils.GetEntityIdentifier(tb.Text);
} else if (input is ComboBox sb) {
return Utils.GetEntityIdentifier(sb.SelectedItem);
} else if (input is Xceed.Wpf.Toolkit.CheckComboBox ccb) {
return Utils.GetEntityIdentifier(ccb.SelectedItems);
} else if (input is ListBox lb) {
return Utils.GetEntityIdentifier(lb.SelectedItems);
} else if (input is CheckBox cb) {
return Utils.GetEntityIdentifier(cb.IsChecked);
} else if (input is RadioButton rb) {
@@ -236,5 +235,21 @@ namespace Elwig.Helpers {
return null;
}
}
public static void InitializeDelayTimer(TextBox tb, Action<object, TextChangedEventArgs> handler) {
var timer = new DispatcherTimer {
Interval = TimeSpan.FromMilliseconds(250)
};
timer.Tick += (object? sender, EventArgs evt) => {
timer.Stop();
var (oSender, oEvent) = ((object, TextChangedEventArgs))timer.Tag;
handler(oSender, oEvent);
};
tb.TextChanged += (object sender, TextChangedEventArgs evt) => {
timer.Stop();
timer.Tag = (sender, evt);
timer.Start();
};
}
}
}

View File

@@ -22,20 +22,20 @@ namespace Elwig.Helpers.Export {
""";
var c = App.Client;
var (a1, a2) = Utils.SplitAddress(c.Address);
_clientData = $"{c.LfbisNr};{c.NameFull};;{a1};{a2};{c.Plz};{c.Ort}";
_clientData = $"{c.LfbisNr};{c.NameFull};;{a1};\t{a2};{c.Plz};{c.Ort}";
}
public async Task ExportAsync(int year) {
using var cnx = await AppDbContext.ConnectAsync();
using var cmd = cnx.CreateCommand();
cmd.CommandText = $"""
SELECT lfbis_nr, family_name, name, billing_name, address, plz, ort, area,
SELECT lfbis_nr, name, other_names, billing_name, address, plz, ort, area,
date, weight, type, sortid, qualid, year, hkid, kmw, oe
FROM v_bki_delivery
WHERE year = {year}
""";
var r = await cmd.ExecuteReaderAsync();
List<Row> rows = new();
List<Row> rows = [];
while (await r.ReadAsync()) {
rows.Add(new(
(r.IsDBNull(0) ? null : r.GetString(0), r.IsDBNull(1) ? null : r.GetString(1), r.IsDBNull(2) ? null : r.GetString(2), r.IsDBNull(3) ? null : r.GetString(3), r.GetString(4), r.GetInt32(5), r.GetString(6), r.GetInt32(7)),
@@ -57,7 +57,7 @@ namespace Elwig.Helpers.Export {
var (n1, n2) = billingName == null ? (familyName, name) : Utils.SplitName(billingName, familyName);
var (a1, a2) = Utils.SplitAddress(address);
var memberData = $"{lfBisNr};{n1};{n2};{a1};{a2};{plz};{ort}";
var memberData = $"{lfBisNr};{n1};{n2};{a1};\t{a2};{plz};{ort}";
var deliveryData = $"{string.Join(".", date.Split("-").Reverse())};{weight};TB;{(type == "W" ? "J" : "")};{(type == "R" ? "J" : "")};{sortid};;;{qualid};{year};{hkid};{kmw:0.0};{oe:0}";
var vollData = $"N;;;{area / 10_000.0}";

View File

@@ -9,7 +9,9 @@ using System.Security;
using System.Threading.Tasks;
namespace Elwig.Helpers.Export {
public class Ebics(PaymentVar variant, string filename, int version) : IBankingExporter {
public class Ebics(PaymentVar variant, string filename, int version, Ebics.AddressMode mode = Ebics.AddressMode.Full) : IBankingExporter {
public enum AddressMode { Omit = 0, Lines = 1, Full = 2 }
public static string FileExtension => "xml";
@@ -19,6 +21,7 @@ namespace Elwig.Helpers.Export {
private readonly string Name = variant.Name;
private readonly int AvNr = variant.AvNr;
private readonly int Version = version;
private readonly AddressMode ShowAddresses = mode;
public void Dispose() {
GC.SuppressFinalize(this);
@@ -35,8 +38,11 @@ namespace Elwig.Helpers.Export {
}
public async Task ExportAsync(IEnumerable<Transaction> transactions, IProgress<double>? progress = null) {
if (transactions.Any(tx => tx.Amount < 0))
if (transactions.Any(tx => tx.Amount < 0)) {
throw new ArgumentException("Tranaction amount may not be negative");
} else if (App.Client.Iban == null) {
throw new ArgumentException("Client IBAN has to be set");
}
progress?.Report(0.0);
var nbOfTxs = transactions.Count();
int count = nbOfTxs + 2, i = 0;
@@ -77,12 +83,19 @@ namespace Elwig.Helpers.Export {
<PmtId><EndToEndId>{id}</EndToEndId></PmtId>
<Amt><InstdAmt Ccy="{tx.Currency}">{Transaction.FormatAmount(tx.Amount)}</InstdAmt></Amt>
<Cdtr>
<Nm>{SecurityElement.Escape(a.Name[..Math.Min(140, a.Name.Length)])}</Nm>
<PstlAdr>
<StrtNm>{a1?[..Math.Min(70, a1.Length)]}</StrtNm><BldgNb>{SecurityElement.Escape(a2?[..Math.Min(16, a2.Length)])}</BldgNb>
<PstCd>{a.PostalDest.AtPlz?.Plz}</PstCd><TwnNm>{SecurityElement.Escape(a.PostalDest.AtPlz?.Ort.Name)}</TwnNm>
<Ctry>{a.PostalDest.Country.Alpha2}</Ctry>
</PstlAdr>
<Nm>{SecurityElement.Escape(a.FullName[..Math.Min(140, a.FullName.Length)])}</Nm>
""");
if (ShowAddresses != AddressMode.Omit) {
var full = ShowAddresses == AddressMode.Full;
await Writer.WriteLineAsync($"""
<PstlAdr>{(full ? "" : $"\r\n <Ctry>{a.PostalDest.Country.Alpha2}</Ctry>")}
{(full ? $"<StrtNm>{SecurityElement.Escape(a1?[..Math.Min(70, a1.Length)])}</StrtNm> <BldgNb>{SecurityElement.Escape(a2?[..Math.Min(16, a2.Length)])}</BldgNb>" :
$"<AdrLine>{SecurityElement.Escape(a.Address[..Math.Min(70, a.Address.Length)])}</AdrLine>")}
<{(full ? "PstCd" : "AdrLine")}>{a.PostalDest.AtPlz?.Plz}{(full ? "</PstCd> <TwnNm>" : " ")}{SecurityElement.Escape(a.PostalDest.AtPlz?.Ort.Name)}</{(full ? "TwnNm" : "AdrLine")}>
{(full ? $" <Ctry>{a.PostalDest.Country.Alpha2}</Ctry>\r\n " : "")}</PstlAdr>
""");
}
await Writer.WriteLineAsync($"""
</Cdtr>
<CdtrAcct><Id><IBAN>{tx.Member.Iban!}</IBAN></Id></CdtrAcct>
<RmtInf><Ustrd>{SecurityElement.Escape(info)}</Ustrd></RmtInf>

View File

@@ -1,19 +1,25 @@
using System.IO.Compression;
using System.IO;
using System.Threading.Tasks;
using Elwig.Models.Entities;
using System.Collections.Generic;
using System;
using System.Text.Json.Nodes;
using System.Linq;
using System.Windows;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using System.Windows;
namespace Elwig.Helpers.Export {
public static class ElwigData {
public enum ImportMode { Auto, Interactively, FromBranches }
public static readonly string ImportedTxt = Path.Combine(App.DataPath, "imported.txt");
private static readonly JsonSerializerOptions JsonOpts = new() { Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
public static async Task<string[]> GetImportedFiles() {
try {
return await File.ReadAllLinesAsync(ImportedTxt, Utils.UTF8);
@@ -22,40 +28,80 @@ namespace Elwig.Helpers.Export {
}
}
public static async Task AddImportedFiles(IEnumerable<string> filenames) {
public static async Task AddImportedFiles(params string[] filenames) {
await File.AppendAllLinesAsync(ImportedTxt, filenames, Utils.UTF8);
}
public static Task Import(string filename, bool interactive) => Import([filename], interactive);
public static Task Import(string filename, ImportMode mode) => Import([filename], mode);
public static async Task Import(IEnumerable<string> filenames, bool interactive) {
public static async Task Import(IEnumerable<string> filenames, ImportMode mode) {
try {
using var ctx = new AppDbContext();
var currentDids = await ctx.Deliveries
.GroupBy(d => d.Year)
.ToDictionaryAsync(g => g.Key, g => g.Max(d => d.DId));
Dictionary<string, Branch> branches;
Dictionary<int, int> currentDids;
Dictionary<string, int> currentLsNrs;
Dictionary<int, List<WbRd>> currentWbRde;
Dictionary<int, AT_Kg> kgs;
var deliveries = new List<Delivery>();
var deliveryParts = new List<DeliveryPart>();
var modifiers = new List<DeliveryPartModifier>();
using (var ctx = new AppDbContext()) {
branches = await ctx.Branches.ToDictionaryAsync(b => b.ZwstId);
currentDids = await ctx.Deliveries
.GroupBy(d => d.Year)
.ToDictionaryAsync(g => g.Key, g => g.Max(d => d.DId));
currentLsNrs = await ctx.Deliveries
.ToDictionaryAsync(d => d.LsNr, d => d.DId);
currentWbRde = await ctx.WbRde
.GroupBy(r => r.KgNr)
.ToDictionaryAsync(g => g.Key, g => g.ToList());
kgs = await ctx.Katastralgemeinden.Include(k => k.WbKg).ToDictionaryAsync(k => k.KgNr);
}
var metaData = new List<(string Name, int DeliveryNum, string Filters)>();
var data = new List<(
List<Member> Members,
List<BillingAddr> BillingAddresses,
List<MemberTelNr> TelephoneNumbers,
List<MemberEmailAddr> EmailAddresses,
List<AreaCom> AreaCommitments,
List<WbRd> Riede,
List<Delivery> Deliveries,
List<DeliveryPart> DeliveryParts,
List<DeliveryPartModifier> Modifiers,
Dictionary<string, List<(int Id1, int Id2, DateTime CreatedAt, DateTime ModifiedAt)>> Timestamps)>();
var metaData = new List<(string FileName, string ZwstId, string Device,
int? MemberNum, string? MemberFilters,
int? AreaComNum, string? AreaComFilters,
int? DeliveryNum, string? DeliveryFilters)>();
foreach (var filename in filenames) {
// TODO read encrypted files
using var zip = ZipFile.Open(filename, ZipArchiveMode.Read);
var version = zip.GetEntry("version");
using (var reader = new StreamReader(version!.Open(), Utils.UTF8)) {
if (await reader.ReadToEndAsync() != "elwig:1")
throw new FileFormatException("Ungültige Export-Datei");
throw new FileFormatException($"Ungültige Export-Datei ({filename})");
}
var metaJson = zip.GetEntry("meta.json");
var meta = await JsonNode.ParseAsync(metaJson!.Open());
var deliveryCount = meta!["deliveries"]?["count"]!.AsValue().GetValue<int>();
var deliveryFilters = meta!["deliveries"]?["filters"]!.AsArray().Select(f => f!.AsValue().GetValue<string>()).ToArray();
if (deliveryCount != null && deliveryFilters != null)
metaData.Add((Path.GetFileName(filename), (int)deliveryCount, string.Join(" / ", deliveryFilters)));
var memberCount = meta!["members"]?["count"]?.AsValue().GetValue<int>();
var memberFilters = meta!["members"]?["filters"]?.AsArray().Select(f => f!.AsValue().GetValue<string>()).ToArray();
var areaComCount = meta!["area_commitments"]?["count"]?.AsValue().GetValue<int>();
var areaComFilters = meta!["area_commitments"]?["filters"]?.AsArray().Select(f => f!.AsValue().GetValue<string>()).ToArray();
var deliveryCount = meta!["deliveries"]?["count"]?.AsValue().GetValue<int>();
var deliveryFilters = meta!["deliveries"]?["filters"]?.AsArray().Select(f => f!.AsValue().GetValue<string>()).ToArray();
metaData.Add((Path.GetFileName(filename),
meta["zwstid"]!.AsValue().GetValue<string>(), meta["device"]!.AsValue().GetValue<string>(),
memberCount, memberFilters != null ? string.Join(" / ", memberFilters) : null,
areaComCount, areaComFilters != null ? string.Join(" / ", areaComFilters) : null,
deliveryCount, deliveryFilters != null ? string.Join(" / ", deliveryFilters) : null));
data.Add(new([], [], [], [], [], [], [], new([], [], new() {
["member"] = [],
["area_commitment"] = [],
["delivery"] = [],
})));
var r = data[^1];
var membersJson = zip.GetEntry("members.json");
if (membersJson != null) {
@@ -63,7 +109,13 @@ namespace Elwig.Helpers.Export {
string? line;
while ((line = await reader.ReadLineAsync()) != null) {
var obj = JsonNode.Parse(line)!.AsObject();
// TODO import members.json
var (m, b, telNrs, emailAddrs, timestamps) = obj.ToMember(kgs);
r.Members.Add(m);
if (b != null) r.BillingAddresses.Add(b);
r.TelephoneNumbers.AddRange(telNrs);
r.EmailAddresses.AddRange(emailAddrs);
if (timestamps.HasValue)
r.Timestamps["member"].Add((m.MgNr, 0, timestamps.Value.CreatedAt, timestamps.Value.ModifiedAt));
}
}
@@ -73,7 +125,14 @@ namespace Elwig.Helpers.Export {
string? line;
while ((line = await reader.ReadLineAsync()) != null) {
var obj = JsonNode.Parse(line)!.AsObject();
// TODO import area_commitments.json
var (areaCom, wbrd, timestamps) = obj.ToAreaCom(kgs, currentWbRde);
r.AreaCommitments.Add(areaCom);
if (wbrd != null) {
currentWbRde[wbrd.KgNr].Add(wbrd);
r.Riede.Add(wbrd);
}
if (timestamps.HasValue)
r.Timestamps["area_commitment"].Add((areaCom.FbNr, 0, timestamps.Value.CreatedAt, timestamps.Value.ModifiedAt));
}
}
@@ -83,85 +142,484 @@ namespace Elwig.Helpers.Export {
string? line;
while ((line = await reader.ReadLineAsync()) != null) {
var obj = JsonNode.Parse(line)!.AsObject();
var (d, parts, mods) = JsonToDelivery(obj, currentDids);
deliveries.Add(d);
deliveryParts.AddRange(parts);
modifiers.AddRange(mods);
var (d, parts, mods, timestamps) = obj.ToDelivery(currentLsNrs, currentDids);
r.Deliveries.Add(d);
r.DeliveryParts.AddRange(parts);
r.Modifiers.AddRange(mods);
if (timestamps.HasValue)
r.Timestamps["delivery"].Add((d.Year, d.DId, timestamps.Value.CreatedAt, timestamps.Value.ModifiedAt));
}
}
}
var lsnrs = deliveries.Select(d => d.LsNr).ToList();
var duplicateLsNrs = await ctx.Deliveries
.Where(d => lsnrs.Contains(d.LsNr))
.Select(d => d.LsNr)
.ToListAsync();
var duplicateDIds = deliveries
.Where(d => duplicateLsNrs.Contains(d.LsNr))
.Select(d => (d.Year, d.DId))
.ToList();
bool overwriteDelivieries = false;
if (duplicateLsNrs.Count > 0) {
var res = MessageBox.Show($"Sollen {duplicateLsNrs.Count} Lieferungen überschreiben werden?", "Lieferungen überschreiben",
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
overwriteDelivieries = res == MessageBoxResult.Yes;
var importedMembers = new List<(string FileName, string ZwstId, string Device, int New, int Overwritten, int NotImported, string Filters)>();
var importedAreaComs = new List<(string FileName, string ZwstId, string Device, int Imported, int NotImported, string Filters)>();
var importedDeliveries = new List<(string FileName, string ZwstId, string Device, int New, int Overwritten, int NotImported, string Filters)>();
foreach (var ((members, billingAddresses, telephoneNumbers, emailAddresses, areaCommitments, riede, deliveries, deliveryParts, modifiers, timestamps), meta) in data.Zip(metaData)) {
var branch = branches[meta.ZwstId];
var device = meta.Device;
using var ctx = new AppDbContext();
var mgnrs = members.Select(m => m.MgNr).ToList();
var duplicateMgNrs = await ctx.Members
.Where(m => mgnrs.Contains(m.MgNr))
.Select(m => m.MgNr)
.ToListAsync();
bool importNewMembers = false, importDuplicateMembers = false;
if (mode == ImportMode.Interactively) {
if (mgnrs.Count - duplicateMgNrs.Count > 0)
importNewMembers = ImportQuestion(branch.Name, device, "Mitglieder", false, mgnrs.Count - duplicateMgNrs.Count);
} else {
importNewMembers = true;
}
if (duplicateMgNrs.Count > 0)
importDuplicateMembers = ImportQuestion(branch.Name, device, "Mitglieder", true, duplicateMgNrs.Count);
var fbnrs = areaCommitments.Select(c => c.FbNr).ToList();
var duplicateFbNrs = await ctx.AreaCommitments
.Where(c => fbnrs.Contains(c.FbNr))
.Select(c => c.FbNr)
.ToListAsync();
var lsnrs = deliveries.Select(d => d.LsNr).ToList();
var duplicateLsNrs = await ctx.Deliveries
.Where(d => lsnrs.Contains(d.LsNr))
.Select(d => d.LsNr)
.ToListAsync();
var duplicateDIds = deliveries
.Where(d => duplicateLsNrs.Contains(d.LsNr))
.Select(d => (d.Year, d.DId))
.ToList();
var allowedDuplicateLsNrs = new List<string>();
bool importNewDeliveries = false, importDuplicateDeliveries = false;
if (mode == ImportMode.Interactively) {
if (lsnrs.Count - duplicateLsNrs.Count > 0)
importNewDeliveries = ImportQuestion(branch.Name, device, "Lieferungen", false, lsnrs.Count - duplicateLsNrs.Count);
if (duplicateLsNrs.Count > 0)
importDuplicateDeliveries = ImportQuestion(branch.Name, device, "Lieferungen", true, duplicateLsNrs.Count);
} else if (mode == ImportMode.FromBranches) {
importNewDeliveries = true;
if (duplicateLsNrs.Count > 0) {
allowedDuplicateLsNrs = await ctx.Deliveries
.Where(d => lsnrs.Contains(d.LsNr) && d.ZwstId == branch.ZwstId)
.Select(d => d.LsNr)
.ToListAsync();
if (duplicateLsNrs.Count - allowedDuplicateLsNrs.Count > 0)
importDuplicateDeliveries = ImportQuestion(branch.Name, device, "Lieferungen", true, duplicateLsNrs.Count - allowedDuplicateLsNrs.Count);
}
} else {
importNewDeliveries = true;
if (duplicateLsNrs.Count > 0)
importDuplicateDeliveries = ImportQuestion(branch.Name, device, "Lieferungen", true, duplicateLsNrs.Count);
}
if (importDuplicateMembers) {
ctx.RemoveRange(ctx.BillingAddresses.Where(a => duplicateMgNrs.Contains(a.MgNr)));
ctx.RemoveRange(ctx.MemberTelephoneNrs.Where(n => duplicateMgNrs.Contains(n.MgNr)));
ctx.RemoveRange(ctx.MemberEmailAddrs.Where(a => duplicateMgNrs.Contains(a.MgNr)));
ctx.UpdateRange(members.Where(m => duplicateMgNrs.Contains(m.MgNr)));
ctx.AddRange(billingAddresses.Where(a => duplicateMgNrs.Contains(a.MgNr)));
ctx.AddRange(telephoneNumbers.Where(n => duplicateMgNrs.Contains(n.MgNr)));
ctx.AddRange(emailAddresses.Where(a => duplicateMgNrs.Contains(a.MgNr)));
ctx.UpdateRange(areaCommitments.Where(c => duplicateMgNrs.Contains(c.MgNr) && duplicateFbNrs.Contains(c.FbNr)));
ctx.AddRange(areaCommitments.Where(c => duplicateMgNrs.Contains(c.MgNr) && !duplicateFbNrs.Contains(c.FbNr)));
}
if (importNewMembers) {
ctx.AddRange(members.Where(m => !duplicateMgNrs.Contains(m.MgNr)));
ctx.AddRange(billingAddresses.Where(a => !duplicateMgNrs.Contains(a.MgNr)));
ctx.AddRange(telephoneNumbers.Where(n => !duplicateMgNrs.Contains(n.MgNr)));
ctx.AddRange(emailAddresses.Where(a => !duplicateMgNrs.Contains(a.MgNr)));
ctx.UpdateRange(areaCommitments.Where(c => !duplicateMgNrs.Contains(c.MgNr) && duplicateFbNrs.Contains(c.FbNr)));
ctx.AddRange(areaCommitments.Where(c => !duplicateMgNrs.Contains(c.MgNr) && !duplicateFbNrs.Contains(c.FbNr)));
}
if (members.Count > 0) {
var n = importNewMembers ? members.Count - duplicateMgNrs.Count : 0;
var o = importDuplicateMembers ? duplicateMgNrs.Count : 0;
importedMembers.Add((meta.FileName, meta.ZwstId, meta.Device, n, o, members.Count - n - o, meta.MemberFilters));
}
if (areaCommitments.Count > 0) {
ctx.AddRange(riede);
var imported = areaCommitments.Where(c => (importNewMembers && !duplicateMgNrs.Contains(c.MgNr)) || (importDuplicateMembers && duplicateMgNrs.Contains(c.MgNr))).ToList();
importedAreaComs.Add((meta.FileName, meta.ZwstId, meta.Device, imported.Count, areaCommitments.Count - imported.Count, meta.AreaComFilters));
}
if (allowedDuplicateLsNrs.Count > 0) {
var dids = deliveries
.Where(d => allowedDuplicateLsNrs.Contains(d.LsNr))
.Select(d => (d.Year, d.DId))
.ToList();
ctx.RemoveRange(ctx.DeliveryParts
.Where(p => allowedDuplicateLsNrs.Contains(p.Delivery.LsNr))
.SelectMany(p => p.PartModifiers));
ctx.RemoveRange(ctx.DeliveryParts.Where(p => allowedDuplicateLsNrs.Contains(p.Delivery.LsNr)));
ctx.UpdateRange(deliveries.Where(d => dids.Contains((d.Year, d.DId))));
ctx.AddRange(deliveryParts.Where(p => dids.Contains((p.Year, p.DId))));
ctx.AddRange(modifiers.Where(m => dids.Contains((m.Year, m.DId))));
}
if (importDuplicateDeliveries) {
var l = duplicateLsNrs.Except(allowedDuplicateLsNrs).ToList();
var dids = deliveries
.Where(d => l.Contains(d.LsNr))
.Select(d => (d.Year, d.DId))
.ToList();
ctx.RemoveRange(ctx.DeliveryParts
.Where(p => l.Contains(p.Delivery.LsNr))
.SelectMany(p => p.PartModifiers));
ctx.RemoveRange(ctx.DeliveryParts.Where(p => l.Contains(p.Delivery.LsNr)));
ctx.UpdateRange(deliveries.Where(d => dids.Contains((d.Year, d.DId))));
ctx.AddRange(deliveryParts.Where(p => dids.Contains((p.Year, p.DId))));
ctx.AddRange(modifiers.Where(m => dids.Contains((m.Year, m.DId))));
}
if (importNewDeliveries) {
ctx.AddRange(deliveries.Where(d => !duplicateDIds.Contains((d.Year, d.DId))));
ctx.AddRange(deliveryParts.Where(p => !duplicateDIds.Contains((p.Year, p.DId))));
ctx.AddRange(modifiers.Where(m => !duplicateDIds.Contains((m.Year, m.DId))));
}
if (deliveries.Count > 0) {
var n = importNewDeliveries ? deliveries.Count - duplicateDIds.Count : 0;
var o = allowedDuplicateLsNrs.Count + (importDuplicateDeliveries ? duplicateDIds.Count - allowedDuplicateLsNrs.Count : 0);
importedDeliveries.Add((meta.FileName, meta.ZwstId, meta.Device, n, o, deliveries.Count - n - o, meta.DeliveryFilters));
}
await ctx.SaveChangesAsync();
var primaryKeys = new Dictionary<string, string>() {
["member"] = "mgnr, 0",
["area_commitment"] = "fbnr, 0",
["delivery"] = "year, did",
};
var updateStmts = timestamps
.SelectMany(e => e.Value.Select(m => $"UPDATE {e.Key} " +
$"SET ctime = {((DateTimeOffset)m.CreatedAt.ToUniversalTime()).ToUnixTimeSeconds()}, " +
$"mtime = {((DateTimeOffset)m.ModifiedAt.ToUniversalTime()).ToUnixTimeSeconds()} " +
$"WHERE ({primaryKeys[e.Key]}) = ({m.Id1}, {m.Id2});"));
using var cnx = AppDbContext.Connect();
await AppDbContext.ExecuteBatch(cnx, $"""
BEGIN;
UPDATE client_parameter SET value = '0' WHERE param = 'ENABLE_TIME_TRIGGERS';
{string.Join("\n", updateStmts)}
UPDATE client_parameter SET value = '1' WHERE param = 'ENABLE_TIME_TRIGGERS';
COMMIT;
""");
await AddImportedFiles(Path.GetFileName(meta.FileName));
}
if (overwriteDelivieries) {
ctx.RemoveRange(ctx.Deliveries.Where(d => duplicateLsNrs.Contains(d.LsNr)));
ctx.AddRange(deliveries);
ctx.AddRange(deliveryParts);
ctx.AddRange(modifiers);
} else {
ctx.AddRange(deliveries.Where(d => !duplicateDIds.Contains((d.Year, d.DId))));
ctx.AddRange(deliveryParts.Where(p => !duplicateDIds.Contains((p.Year, p.DId))));
ctx.AddRange(modifiers.Where(m => !duplicateDIds.Contains((m.Year, m.DId))));
}
await ctx.SaveChangesAsync();
await AddImportedFiles(filenames.Select(f => Path.GetFileName(f)));
await App.HintContextChange();
App.HintContextChange();
MessageBox.Show(
$"Das importieren der Daten war erfolgreich!\n" +
$"Folgendes wurde importiert:\n" +
$" Lieferungen: {deliveries.Count}\n" +
string.Join("\n", metaData.Select(d => $" {d.Name} ({d.DeliveryNum})\n {d.Filters}")) +
"\n", "Importieren erfolgreich",
string.Join("\n", [
$"Mitglieder: {importedMembers.Sum(d => d.New + d.Overwritten)}",
..importedMembers.Select(d =>
$" {d.FileName} ({d.New + d.Overwritten})\n" +
$" ({d.New} neu, {d.Overwritten} überschrieben, {d.NotImported} nicht importiert)\n" +
$" Zweigstelle: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
$" Filter: {d.Filters}"),
$"Flächenbindungen: {importedAreaComs.Sum(d => d.Imported)}",
..importedAreaComs.Select(d =>
$" {d.FileName} ({d.Imported})\n" +
$" ({d.Imported} importiert, {d.NotImported} nicht importiert)\n" +
$" Zweigstelle: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
$" Filter: {d.Filters}"),
$"Lieferungen: {importedDeliveries.Sum(d => d.New + d.Overwritten)}",
..importedDeliveries.Select(d =>
$" {d.FileName} ({d.New + d.Overwritten})\n" +
$" ({d.New} neu, {d.Overwritten} überschr., {d.NotImported} nicht importiert)\n" +
$" Zwst.: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
$" Filter: {d.Filters}")
]),
"Importieren erfolgreich",
MessageBoxButton.OK, MessageBoxImage.Information);
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
MessageBox.Show(str, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
}
GC.Collect();
GC.WaitForPendingFinalizers();
}
public static async Task ExportDeliveries(string filename, IEnumerable<Delivery> deliveries, IEnumerable<string> filters) {
File.Delete(filename);
using var zip = ZipFile.Open(filename, ZipArchiveMode.Create);
private static bool ImportQuestion(string branch, string device, string subject, bool duplicate, int number) {
return MessageBox.Show(
$"Sollen {number} {(duplicate ? "" : "neue ")}{subject} durch die Zweigstelle\n" +
$"{branch} (Gerät {device}) {(duplicate ? "überschrieben" : "importiert")} werden?",
$"{subject} importieren",
MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes
) == MessageBoxResult.Yes;
}
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
using (var writer = new StreamWriter(version.Open(), Utils.UTF8)) {
await writer.WriteAsync("elwig:1");
}
public static Task Export(string filename, IEnumerable<Member> members, IEnumerable<string> filters) {
return new ElwigExport {
Members = (members, filters)
}.Export(filename);
}
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
using (var writer = new StreamWriter(meta.Open(), Utils.UTF8)) {
await writer.WriteAsync(
$"{{\"timestamp\": \"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}\", " +
$"\"zwstid\": \"{App.ZwstId}\", \"device\": \"{Environment.MachineName}\", " +
$"\"deliveries\": {{" +
$"\"count\": {deliveries.Count()}, " +
$"\"parts\": {deliveries.Sum(d => d.Parts.Count)}, " +
$"\"filters\": [{string.Join(", ", filters.Select(f => '"' + f + '"'))}]" +
$"}}}}");
}
public static Task Export(string filename, IEnumerable<Member> members, IEnumerable<AreaCom> areaComs, IEnumerable<string> filters) {
return new ElwigExport {
Members = (members, filters),
AreaComs = (areaComs, ["von exportierten Mitgliedern"]),
}.Export(filename);
}
var json = zip.CreateEntry("deliveries.json");
using (var writer = new StreamWriter(json.Open(), Utils.UTF8)) {
foreach (var d in deliveries) {
await writer.WriteLineAsync(DeliveryToJson(d).ToJsonString());
public static Task Export(string filename, IEnumerable<Delivery> deliveries, IEnumerable<string> filters) {
return new ElwigExport {
Deliveries = (deliveries, filters)
}.Export(filename);
}
public class ElwigExport {
public (IEnumerable<Member> Members, IEnumerable<string> Filters)? Members { get; set; }
public (IEnumerable<AreaCom> AreaComs, IEnumerable<string> Filters)? AreaComs { get; set; }
public (IEnumerable<Delivery> Deliveries, IEnumerable<string> Filters)? Deliveries { get; set; }
public async Task Export(string filename) {
File.Delete(filename);
using var zip = ZipFile.Open(filename, ZipArchiveMode.Create);
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
using (var writer = new StreamWriter(version.Open(), Utils.UTF8)) {
await writer.WriteAsync("elwig:1");
}
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
using (var writer = new StreamWriter(meta.Open(), Utils.UTF8)) {
var obj = new JsonObject {
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
["zwstid"] = App.ZwstId,
["device"] = Environment.MachineName,
};
if (Members != null)
obj["members"] = new JsonObject {
["count"] = Members.Value.Members.Count(),
["filters"] = new JsonArray(Members.Value.Filters.Select(f => (JsonNode)f).ToArray()),
};
if (AreaComs != null)
obj["area_commitments"] = new JsonObject {
["count"] = AreaComs.Value.AreaComs.Count(),
["filters"] = new JsonArray(AreaComs.Value.Filters.Select(f => (JsonNode)f).ToArray()),
};
if (Deliveries != null)
obj["deliveries"] = new JsonObject {
["count"] = Deliveries.Value.Deliveries.Count(),
["parts"] = Deliveries.Value.Deliveries.Sum(d => d.Parts.Count),
["filters"] = new JsonArray(Deliveries.Value.Filters.Select(f => (JsonNode)f).ToArray()),
};
await writer.WriteAsync(obj.ToJsonString(JsonOpts));
}
// TODO encrypt files
if (Members != null) {
var json = zip.CreateEntry("members.json", CompressionLevel.SmallestSize);
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
foreach (var m in Members.Value.Members) {
await writer.WriteLineAsync(m.ToJson().ToJsonString(JsonOpts));
}
}
if (AreaComs != null) {
var json = zip.CreateEntry("area_commitments.json", CompressionLevel.SmallestSize);
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
foreach (var c in AreaComs.Value.AreaComs) {
await writer.WriteLineAsync(c.ToJson().ToJsonString(JsonOpts));
}
}
if (Deliveries != null) {
var json = zip.CreateEntry("deliveries.json", CompressionLevel.SmallestSize);
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
foreach (var d in Deliveries.Value.Deliveries) {
await writer.WriteLineAsync(d.ToJson().ToJsonString(JsonOpts));
}
}
}
}
public static JsonObject DeliveryToJson(Delivery d) {
public static JsonObject ToJson(this Member m) {
return new JsonObject {
["mgnr"] = m.MgNr,
["predecessor_mgnr"] = m.PredecessorMgNr,
["name"] = m.Name,
["prefix"] = m.Prefix,
["given_name"] = m.GivenName,
["middle_names"] = m.MiddleName,
["suffix"] = m.Suffix,
["attn"] = m.ForTheAttentionOf,
["birthday"] = m.Birthday,
["entry_date"] = m.EntryDate != null ? $"{m.EntryDate:yyyy-MM-dd}" : null,
["exit_date"] = m.ExitDate != null ? $"{m.ExitDate:yyyy-MM-dd}" : null,
["business_shares"] = m.BusinessShares,
["accounting_nr"] = m.AccountingNr,
["zwstid"] = m.ZwstId,
["lfbis_nr"] = m.LfbisNr,
["ustid_nr"] = m.UstIdNr,
["juridical_pers"] = m.IsJuridicalPerson,
["volllieferant"] = m.IsVollLieferant,
["buchführend"] = m.IsBuchführend,
["organic"] = m.IsOrganic,
["funktionär"] = m.IsFunktionär,
["active"] = m.IsActive,
["deceased"] = m.IsDeceased,
["iban"] = m.Iban,
["bic"] = m.Bic,
["default_kgnr"] = m.DefaultKgNr,
["contact_postal"] = m.ContactViaPost,
["contact_email"] = m.ContactViaEmail,
["address"] = new JsonObject {
["address"] = m.Address,
["postal_dest"] = m.PostalDestId,
["country"] = m.CountryNum,
},
["billing_address"] = m.BillingAddress != null ? new JsonObject {
["name"] = m.BillingAddress.FullName,
["address"] = m.BillingAddress.Address,
["postal_dest"] = m.BillingAddress.PostalDestId,
["country"] = m.BillingAddress.CountryNum,
} : null,
["telephone_numbers"] = new JsonArray(m.TelephoneNumbers.OrderBy(n => n.Nr).Select(n => {
var obj = new JsonObject {
["number"] = n.Number,
["type"] = n.Type,
};
if (n.Comment != null) obj["comment"] = n.Comment;
return obj;
}).ToArray()),
["email_addresses"] = new JsonArray(m.EmailAddresses.OrderBy(a => a.Nr).Select(a => {
var obj = new JsonObject {
["address"] = a.Address,
};
if (a.Comment != null) obj["comment"] = a.Comment;
return obj;
}).ToArray()),
["comment"] = m.Comment,
["created_at"] = $"{m.CreatedAt:yyyy-MM-ddTHH:mm:ssK}",
["modified_at"] = $"{m.ModifiedAt:yyyy-MM-ddTHH:mm:ssK}",
};
}
public static (Member, BillingAddr?, List<MemberTelNr>, List<MemberEmailAddr>, (DateTime CreatedAt, DateTime ModifiedAt)?) ToMember(this JsonNode json, Dictionary<int, AT_Kg> kgs) {
var mgnr = json["mgnr"]!.AsValue().GetValue<int>();
var kgnr = json["default_kgnr"]?.AsValue().GetValue<int>();
if (kgnr != null && !kgs.Values.Any(k => k.WbKg?.KgNr == kgnr)) {
throw new ArgumentException($"Für KG {(kgs.TryGetValue(kgnr.Value, out var k) ? k.Name : "?")} ({kgnr:00000}) ist noch keine Großlage festgelegt!\n(Stammdaten → Herkunftshierarchie)");
}
var createdAt = json["created_at"]?.AsValue().GetValue<string>();
var modifiedAt = json["modified_at"]?.AsValue().GetValue<string>();
return (new Member {
MgNr = mgnr,
PredecessorMgNr = json["predecessor_mgnr"]?.AsValue().GetValue<int>(),
Name = json["name"]?.AsValue().GetValue<string>() ?? json["family_name"]!.AsValue().GetValue<string>(),
Prefix = json["prefix"]?.AsValue().GetValue<string>(),
GivenName = json["given_name"]?.AsValue().GetValue<string>(),
MiddleName = json["middle_names"]?.AsValue().GetValue<string>(),
Suffix = json["suffix"]?.AsValue().GetValue<string>(),
ForTheAttentionOf = json["attn"]?.AsValue().GetValue<string>(),
Birthday = json["birthday"]?.AsValue().GetValue<string>(),
EntryDateString = json["entry_date"]?.AsValue().GetValue<string>(),
ExitDateString = json["exit_date"]?.AsValue().GetValue<string>(),
BusinessShares = json["business_shares"]?.AsValue().GetValue<int>() ?? 0,
AccountingNr = json["accounting_nr"]?.AsValue().GetValue<string>(),
ZwstId = json["zwstid"]?.AsValue().GetValue<string>(),
LfbisNr = json["lfbis_nr"]?.AsValue().GetValue<string>(),
UstIdNr = json["ustid_nr"]?.AsValue().GetValue<string>(),
IsJuridicalPerson = json["juridical_pers"]?.AsValue().GetValue<bool>() ?? false,
IsVollLieferant = json["volllieferant"]?.AsValue().GetValue<bool>() ?? false,
IsBuchführend = json["buchführend"]?.AsValue().GetValue<bool>() ?? false,
IsOrganic = json["organic"]?.AsValue().GetValue<bool>() ?? false,
IsFunktionär = json["funktionär"]?.AsValue().GetValue<bool>() ?? false,
IsActive = json["active"]?.AsValue().GetValue<bool>() ?? false,
IsDeceased = json["deceased"]?.AsValue().GetValue<bool>() ?? false,
Iban = json["iban"]?.AsValue().GetValue<string>(),
Bic = json["bic"]?.AsValue().GetValue<string>(),
CountryNum = json["address"]!["country"]!.AsValue().GetValue<int>(),
PostalDestId = json["address"]!["postal_dest"]!.AsValue().GetValue<string>(),
Address = json["address"]!["address"]!.AsValue().GetValue<string>(),
DefaultKgNr = kgnr,
ContactViaPost = json["contact_postal"]?.AsValue().GetValue<bool>() ?? false,
ContactViaEmail = json["contact_email"]?.AsValue().GetValue<bool>() ?? false,
Comment = json["comment"]?.AsValue().GetValue<string>(),
ImportedAt = DateTime.Now,
}, json["billing_address"] is JsonObject a ? new BillingAddr {
MgNr = mgnr,
FullName = a["name"]!.AsValue().GetValue<string>(),
CountryNum = a["country"]!.AsValue().GetValue<int>(),
PostalDestId = a["postal_dest"]!.AsValue().GetValue<string>(),
Address = a["address"]!.AsValue().GetValue<string>(),
} : null, json["telephone_numbers"]!.AsArray().Select(n => n!.AsObject()).Select((n, i) => new MemberTelNr {
MgNr = mgnr,
Nr = i + 1,
Type = n["type"]!.AsValue().GetValue<string>(),
Number = n["number"]!.AsValue().GetValue<string>(),
Comment = n["comment"]?.AsValue().GetValue<string>(),
}).ToList(), json["email_addresses"]!.AsArray().Select(a => a!.AsObject()).Select((a, i) => new MemberEmailAddr {
MgNr = mgnr,
Nr = i + 1,
Address = a["address"]!.AsValue().GetValue<string>(),
Comment = a["comment"]?.AsValue().GetValue<string>(),
}).ToList(),
createdAt == null || modifiedAt == null ? null :
(DateTime.ParseExact(createdAt, "yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture, DateTimeStyles.None),
DateTime.ParseExact(modifiedAt, "yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture, DateTimeStyles.None)));
}
public static JsonObject ToJson(this AreaCom c) {
return new JsonObject {
["fbnr"] = c.FbNr,
["mgnr"] = c.MgNr,
["vtrgid"] = c.VtrgId,
["cultid"] = c.CultId,
["area"] = c.Area,
["kgnr"] = c.KgNr,
["gstnr"] = c.GstNr,
["ried"] = c.Rd?.Name,
["year_from"] = c.YearFrom,
["year_to"] = c.YearTo,
["comment"] = c.Comment,
["created_at"] = $"{c.CreatedAt:yyyy-MM-ddTHH:mm:ssK}",
["modified_at"] = $"{c.ModifiedAt:yyyy-MM-ddTHH:mm:ssK}",
};
}
public static (AreaCom, WbRd?, (DateTime CreatedAt, DateTime ModifiedAt)?) ToAreaCom(this JsonNode json, Dictionary<int, AT_Kg> kgs, Dictionary<int, List<WbRd>> riede) {
var kgnr = json["kgnr"]!.AsValue().GetValue<int>();
var ried = json["ried"]?.AsValue().GetValue<string>();
WbRd? rd = null;
bool newRd = false;
if (ried != null) {
var rde = riede[kgnr] ?? throw new ArgumentException($"Für KG {(kgs.TryGetValue(kgnr, out var k) ? k.Name : "?")} ({kgnr:00000}) ist noch keine Großlage festgelegt!\n(Stammdaten → Herkunftshierarchie)");
rd = rde.FirstOrDefault(r => r.Name == ried);
if (rd == null) {
newRd = true;
rd = new WbRd {
KgNr = kgnr,
RdNr = (rde.Count == 0 ? 0 : rde.Max(r => r.RdNr)) + 1,
Name = ried,
};
rde.Add(rd);
}
}
var createdAt = json["created_at"]?.AsValue().GetValue<string>();
var modifiedAt = json["modified_at"]?.AsValue().GetValue<string>();
return (new AreaCom {
FbNr = json["fbnr"]!.AsValue().GetValue<int>(),
MgNr = json["mgnr"]!.AsValue().GetValue<int>(),
VtrgId = json["vtrgid"]!.AsValue().GetValue<string>(),
CultId = json["cultid"]?.AsValue().GetValue<string>(),
Area = json["area"]!.AsValue().GetValue<int>(),
KgNr = kgnr,
GstNr = json["gstnr"]?.AsValue().GetValue<string>() ?? "-",
RdNr = rd?.RdNr,
YearFrom = json["year_from"]?.AsValue().GetValue<int>(),
YearTo = json["year_to"]?.AsValue().GetValue<int>(),
Comment = json["comment"]?.AsValue().GetValue<string>(),
ImportedAt = DateTime.Now,
}, newRd ? rd : null,
createdAt == null || modifiedAt == null ? null :
(DateTime.ParseExact(createdAt, "yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture, DateTimeStyles.None),
DateTime.ParseExact(modifiedAt, "yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture, DateTimeStyles.None)));
}
public static JsonObject ToJson(this Delivery d) {
return new JsonObject {
["lsnr"] = d.LsNr,
["year"] = d.Year,
@@ -186,6 +644,8 @@ namespace Elwig.Helpers.Export {
["manual_weighing"] = p.IsManualWeighing,
["modids"] = new JsonArray(p.Modifiers.Select(m => (JsonNode)m.ModId).ToArray()),
["comment"] = p.Comment,
["created_at"] = $"{p.CreatedAt:yyyy-MM-ddTHH:mm:ssK}",
["modified_at"] = $"{p.ModifiedAt:yyyy-MM-ddTHH:mm:ssK}",
};
if (p.IsSplCheck) obj["spl_check"] = p.IsSplCheck;
if (p.IsHandPicked != null) obj["hand_picked"] = p.IsHandPicked;
@@ -194,17 +654,27 @@ namespace Elwig.Helpers.Export {
if (p.Temperature != null) obj["temperature"] = p.Temperature;
if (p.Acid != null) obj["acid"] = p.Acid;
if (p.ScaleId != null) obj["scale_id"] = p.ScaleId;
if (p.WeighingId != null) obj["weighing_id"] = p.WeighingId;
if (p.WeighingData != null) obj["weighing_data"] = JsonNode.Parse(p.WeighingData);
if (p.WeighingReason != null) obj["weighing_reason"] = p.WeighingReason;
return obj;
}).ToArray()),
["comment"] = d.Comment,
["created_at"] = $"{d.CreatedAt:yyyy-MM-ddTHH:mm:ssK}",
["modified_at"] = $"{d.ModifiedAt:yyyy-MM-ddTHH:mm:ssK}",
};
}
public static (Delivery, List<DeliveryPart>, List<DeliveryPartModifier>) JsonToDelivery(JsonNode json, Dictionary<int, int> currentDids) {
public static (Delivery, List<DeliveryPart>, List<DeliveryPartModifier>, (DateTime CreatedAt, DateTime ModifiedAt)?) ToDelivery(this JsonNode json, Dictionary<string, int> currentLsNrs, Dictionary<int, int> currentDids) {
var year = json["year"]!.AsValue().GetValue<int>();
var did = ++currentDids[year];
var lsnr = json["lsnr"]!.AsValue().GetValue<string>();
var did = currentLsNrs.GetValueOrDefault(lsnr, -1);
if (did == -1) {
if (!currentDids.ContainsKey(year)) currentDids[year] = 0;
did = ++currentDids[year];
}
currentLsNrs[lsnr] = did;
var createdAt = json["created_at"]?.AsValue().GetValue<string>();
var modifiedAt = json["modified_at"]?.AsValue().GetValue<string>();
return (new Delivery {
Year = year,
DId = did,
@@ -212,9 +682,10 @@ namespace Elwig.Helpers.Export {
TimeString = json["time"]?.AsValue().GetValue<string>(),
ZwstId = json["zwstid"]!.AsValue().GetValue<string>(),
LNr = json["lnr"]!.AsValue().GetValue<int>(),
LsNr = json["lsnr"]!.AsValue().GetValue<string>(),
LsNr = lsnr,
MgNr = json["mgnr"]!.AsValue().GetValue<int>(),
Comment = json["comment"]?.AsValue().GetValue<string>(),
ImportedAt = DateTime.Now,
}, json["parts"]!.AsArray().Select(p => p!.AsObject()).Select(p => new DeliveryPart {
Year = year,
DId = did,
@@ -238,14 +709,17 @@ namespace Elwig.Helpers.Export {
Temperature = p["temperature"]?.AsValue().GetValue<double>(),
Acid = p["acid"]?.AsValue().GetValue<double>(),
ScaleId = p["scale_id"]?.AsValue().GetValue<string>(),
WeighingId = p["weighing_id"]?.AsValue().GetValue<string>(),
WeighingData = p["weighing_data"]?.AsObject().ToJsonString(JsonOpts),
WeighingReason = p["weighing_reason"]?.AsValue().GetValue<string>(),
}).ToList(), json["parts"]!.AsArray().SelectMany(p => p!["modids"]!.AsArray().Select(m => new DeliveryPartModifier {
Year = year,
DId = did,
DPNr = p["dpnr"]!.AsValue().GetValue<int>(),
ModId = m!.AsValue().GetValue<string>(),
})).ToList());
})).ToList(),
createdAt == null || modifiedAt == null ? null :
(DateTime.ParseExact(createdAt, "yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture, DateTimeStyles.None),
DateTime.ParseExact(modifiedAt, "yyyy-MM-ddTHH:mm:ssK", CultureInfo.InvariantCulture, DateTimeStyles.None)));
}
}
}

View File

@@ -1,4 +1,4 @@
using Elwig.Models.Dtos;
using Elwig.Models.Dtos;
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
@@ -6,6 +6,7 @@ using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Security;
using System.Threading.Tasks;
namespace Elwig.Helpers.Export {
@@ -300,6 +301,7 @@ namespace Elwig.Helpers.Export {
if (units != null && units.Length > 0) {
int n = -1;
switch (units[0]) {
case "#": n = 0; data = $"{v:N0}"; break;
case "%": n = 1; data = $"{v:N1}"; break;
case "€": n = 2; data = $"{v:N2}"; break;
case "€/kg": n = 4; data = $"{v:N4}"; break;
@@ -312,10 +314,10 @@ namespace Elwig.Helpers.Export {
}
c = $"<{ct} office:value-type=\"float\" calcext:value-type=\"float\" office:value=\"{v.ToString(CultureInfo.InvariantCulture)}\"{add}><text:p>{data}</text:p></{ct}>";
} else {
c = $"<{ct} office:value-type=\"string\" calcext:value-type=\"string\"{add}><text:p>{data}</text:p></{ct}>";
c = $"<{ct} office:value-type=\"string\" calcext:value-type=\"string\"{add}><text:p>{SecurityElement.Escape(data.ToString())}</text:p></{ct}>";
}
return $" {c}\r\n" + (colSpan > 1 ? $" <table:covered-table-cell table:number-rows-repeated=\"{colSpan - 1}\"/>\r\n" : "");
return $" {c}\r\n" + (colSpan > 1 ? $" <table:covered-table-cell table:number-columns-repeated=\"{colSpan - 1}\"/>\r\n" : "");
}
}
}

View File

@@ -1,4 +1,4 @@
namespace Elwig.Helpers {
namespace Elwig.Helpers {
public enum ExportMode {
Show, SaveList, SavePdf, Print, Email, Export, Upload
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Net.Http;
using System.Runtime.InteropServices;
@@ -23,7 +23,7 @@ namespace Elwig.Helpers {
}
public static string? ReadUntil(this StreamReader reader, char delimiter) {
return ReadUntil(reader, new char[] { delimiter });
return ReadUntil(reader, [ delimiter ]);
}
public static string? ReadUntil(this StreamReader reader, char[] delimiter) {
@@ -45,7 +45,7 @@ namespace Elwig.Helpers {
}
public static Task<string?> ReadUntilAsync(this StreamReader reader, char delimiter) {
return ReadUntilAsync(reader, new char[] { delimiter });
return ReadUntilAsync(reader, [ delimiter ]);
}
public static async Task<string?> ReadUntilAsync(this StreamReader reader, char[] delimiter) {

View File

@@ -10,7 +10,7 @@ namespace Elwig.Helpers.Printing {
public static async Task Init(Action? evtHandler = null) {
var e = new RazorLightEngineBuilder()
.UseFileSystemProject(App.DataPath + "resources")
.UseFileSystemProject(App.DocumentsPath)
.UseMemoryCachingProvider()
.Build();

View File

@@ -8,17 +8,13 @@ using System.Windows;
using System.Text.RegularExpressions;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using PdfiumViewer;
using System.Drawing.Printing;
namespace Elwig.Helpers.Printing {
public static class Pdf {
private static readonly string PdfToPrinter = new string[] { App.ExePath }
.Union(Environment.GetEnvironmentVariable("PATH")?.Split(';') ?? [])
.Select(x => Path.Combine(x, "PDFtoPrinter.exe"))
.Where(File.Exists)
.FirstOrDefault() ?? throw new FileNotFoundException("PDFtoPrinter executable not found");
private static readonly string WinziPrint = new string[] { App.ExePath }
private static readonly string WinziPrint = new string[] { App.InstallPath }
.Union(Environment.GetEnvironmentVariable("PATH")?.Split(';') ?? [])
.Select(x => Path.Combine(x, "WinziPrint.exe"))
.Where(File.Exists)
@@ -92,17 +88,24 @@ namespace Elwig.Helpers.Printing {
});
}
public static async Task Print(string path, int copies = 1) {
public static async Task Print(string path, int copies = 1, bool doublePaged = false) {
await Print(path, new() {
Copies = (short)copies,
Collate = true,
Duplex = doublePaged ? Duplex.Vertical : Duplex.Simplex,
});
}
public static Task Print(string path, PrinterSettings settings) {
try {
var p = new Process() { StartInfo = new() { FileName = PdfToPrinter } };
p.StartInfo.ArgumentList.Add(path);
p.StartInfo.ArgumentList.Add("/s");
p.StartInfo.ArgumentList.Add($"copies={copies}");
p.Start();
await p.WaitForExitAsync();
using var doc = PdfDocument.Load(path);
using var printDoc = doc.CreatePrintDocument(PdfPrintMode.CutMargin);
printDoc.PrinterSettings = settings;
printDoc.Print();
} catch (Exception e) {
MessageBox.Show("Beim Drucken ist ein Fehler aufgetreten:\n\n" + e.Message, "Fehler beim Drucken");
MessageBox.Show("Beim Drucken ist ein Fehler aufgetreten:\n\n" + e.Message, "Fehler beim Drucken", MessageBoxButton.OK, MessageBoxImage.Error);
}
return Task.CompletedTask;
}
}
}

View File

@@ -28,6 +28,9 @@ using LinqKit;
using System.Linq.Expressions;
using Elwig.Models;
using Microsoft.Win32;
using System.Globalization;
using System.Threading;
using System.Windows.Markup;
namespace Elwig.Helpers {
public static partial class Utils {
@@ -36,7 +39,7 @@ namespace Elwig.Helpers {
public static int CurrentYear => DateTime.Now.Year;
public static int CurrentNextSeason => DateTime.Now.Year - (DateTime.Now.Month <= 3 ? 1 : 0);
public static int CurrentLastSeason => DateTime.Now.Year - (DateTime.Now.Month <= 7 ? 1 : 0);
public static int CurrentLastSeason => DateTime.Now.Year - (DateTime.Now.Month <= 6 ? 1 : 0);
public static int FollowingSeason => DateTime.Now.Year + (DateTime.Now.Month >= 11 ? 1 : 0);
public static DateTime Today => (DateTime.Now.Hour >= 3) ? DateTime.Today : DateTime.Today.AddDays(-1);
@@ -118,6 +121,23 @@ namespace Elwig.Helpers {
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040,
];
public static void OverrideCulture() {
var locale = new CultureInfo("de-AT", false);
locale.NumberFormat.CurrencyGroupSeparator = Utils.GroupSeparator;
locale.NumberFormat.NumberGroupSeparator = Utils.GroupSeparator;
locale.NumberFormat.PercentGroupSeparator = Utils.GroupSeparator;
CultureInfo.CurrentCulture = locale;
CultureInfo.CurrentUICulture = locale;
Thread.CurrentThread.CurrentCulture = locale;
Thread.CurrentThread.CurrentUICulture = locale;
CultureInfo.DefaultThreadCurrentCulture = locale;
CultureInfo.DefaultThreadCurrentUICulture = locale;
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name))
);
}
public static SerialPort OpenSerialConnection(string connection) {
var m = SerialRegex.Match(connection);
if (!m.Success)
@@ -197,7 +217,7 @@ namespace Elwig.Helpers {
}
public static void MailTo(string emailAddress) {
MailTo(new string[] { emailAddress });
MailTo([emailAddress]);
}
public static void MailTo(IEnumerable<string> emailAddresses) {
@@ -267,9 +287,9 @@ namespace Elwig.Helpers {
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
}
public static int? ShowAbwertenDialog(string lsnr, string name, int weight) {
var d = new AbwertenDialog(lsnr, name, weight);
return d.ShowDialog() == true ? d.Weight : null;
public static (string?, int[])? ShowDeliverySplittingDialog(Delivery delivery) {
var d = new DeliverySplittingDialog(delivery);
return d.ShowDialog() == true ? (d.MgNr?.ToString() ?? d.LsNr, d.Weights ?? []) : null;
}
public static double? ShowLinearPriceIncreaseDialog() {
@@ -277,11 +297,6 @@ namespace Elwig.Helpers {
return d.ShowDialog() == true ? d.Price : null;
}
public static string? ShowDeliveryExtractionDialog(string lsnr, string name, bool single, IEnumerable<string> lsnrs) {
var d = new DeliveryExtractionDialog(lsnr, name, single, lsnrs);
return d.ShowDialog() == true ? d.AddTo : null;
}
public static Footer GenerateFooter(string lineBreak, string seperator) {
return new Footer(lineBreak, seperator);
}
@@ -348,7 +363,7 @@ namespace Elwig.Helpers {
}
public static (string, string?) SplitName(string fullName, string? familyName) {
if (familyName == null || familyName == "") return (fullName, null);
if (string.IsNullOrWhiteSpace(familyName)) return (fullName, null);
var p0 = fullName.IndexOf(familyName, StringComparison.CurrentCultureIgnoreCase);
if (p0 == -1) return (fullName, null);
var p1 = fullName.IndexOf(" und ");
@@ -362,8 +377,10 @@ namespace Elwig.Helpers {
var p3 = fullName.LastIndexOf(' ', p2 - 1);
return (fullName[0..p3], fullName[(p3 + 1)..^0]);
}
} else {
} else if (p0 + familyName.Length >= fullName.Length || fullName[p0 + familyName.Length] == ' ') {
return (familyName, fullName.Replace(familyName, "").Replace(" ", " ").Trim());
} else {
return (fullName, null);
}
}
@@ -417,16 +434,18 @@ namespace Elwig.Helpers {
if (accept != null)
client.DefaultRequestHeaders.Accept.Add(new(accept));
if (username != null || password != null)
client.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(
Utils.UTF8.GetBytes($"{username}:{password}")));
client.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(Utils.UTF8.GetBytes($"{username}:{password}")));
return client;
}
public static async Task<(string Version, string Url, long Size)?> GetLatestInstallerUrl(string url) {
try {
using var client = GetHttpClient(accept: "application/json");
var resJson = JsonNode.Parse(await client.GetStringAsync(url));
var data = resJson!["data"]![0]!;
using var res = await client.GetAsync(url);
if (!res.IsSuccessStatusCode)
return null;
var resJson = JsonNode.Parse(await res.Content.ReadAsStringAsync());
var data = resJson!["data"]!.AsArray()[^1]!;
return ((string)data["version"]!, (string)data["url"]!, (long)data["size"]!);
} catch {
return null;
@@ -434,6 +453,8 @@ namespace Elwig.Helpers {
}
public static async Task UploadExportData(string zip, string url, string username, string password) {
if (url.StartsWith("https://elwig.at/clients/"))
url = "https://sync.elwig.at/" + url[25..];
if (!url.EndsWith('/')) url += "/";
using var client = GetHttpClient(username, password, accept: "application/json");
var content = new StreamContent(new FileStream(zip, FileMode.Open, FileAccess.Read));
@@ -443,6 +464,8 @@ namespace Elwig.Helpers {
}
public static async Task<JsonArray> GetExportMetaData(string url, string username, string password) {
if (url.StartsWith("https://elwig.at/clients/"))
url = "https://sync.elwig.at/" + url[25..];
using var client = GetHttpClient(username, password, accept: "application/json");
using var res = await client.GetAsync(url);
res.EnsureSuccessStatusCode();
@@ -476,34 +499,39 @@ namespace Elwig.Helpers {
if (App.Config.Smtp == null)
return false;
SmtpClient? client = null;
try {
Mouse.OverrideCursor = Cursors.AppStarting;
client = await GetSmtpClient();
Mouse.OverrideCursor = Cursors.Wait;
using var msg = new MimeMessage();
msg.From.Add(new MailboxAddress(App.Client.NameFull, App.Config.Smtp.Value.From));
msg.To.AddRange(member.EmailAddresses.OrderBy(a => a.Nr).Select(a => new MailboxAddress(member.AdministrativeName, a.Address)));
msg.Subject = subject;
var body = new Multipart("mixed") {
new TextPart("plain") { Text = text }
};
foreach (var doc in docs) {
var name = NormalizeFileName(doc.Title);
body.Add(doc.AsEmailAttachment($"{name}.pdf"));
var success = await Task.Run(async () => {
SmtpClient? client = null;
try {
client = await GetSmtpClient();
using var msg = new MimeMessage();
msg.From.Add(new MailboxAddress(App.Client.NameFull, App.Config.Smtp.Value.From));
msg.To.AddRange(member.EmailAddresses.OrderBy(a => a.Nr).Select(a => new MailboxAddress(member.AdministrativeName, a.Address)));
msg.Subject = subject;
var body = new Multipart("mixed") {
new TextPart("plain") { Text = text }
};
foreach (var doc in docs) {
var name = NormalizeFileName(doc.Title);
body.Add(doc.AsEmailAttachment($"{name}.pdf"));
}
msg.Body = body;
await client!.SendAsync(msg);
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
} finally {
if (client != null)
await client.DisconnectAsync(true);
client?.Dispose();
}
msg.Body = body;
await client!.SendAsync(msg);
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
return false;
} finally {
if (client != null)
await client.DisconnectAsync(true);
client?.Dispose();
Mouse.OverrideCursor = null;
}
return true;
return true;
});
Mouse.OverrideCursor = null;
return success;
}
public static async Task ExportDocument(Document doc, ExportMode mode, string? filename = null, (Member, string, string)? emailData = null) {
@@ -534,6 +562,21 @@ namespace Elwig.Helpers {
}
}
public static List<EventLogEntry> GetLogEntries() {
using var log = new EventLog {
Log = "Application",
Source = ".NET Runtime",
};
return log.Entries.Cast<EventLogEntry>()
.Where(e => e.Message.StartsWith("Application: Elwig.exe"))
.ToList();
}
public static int GetEntityIdetifierForPk(params object?[] primaryKey) {
var pk = primaryKey.Select(k => k?.GetHashCode() ?? 0).ToArray();
return ((IStructuralEquatable)pk).GetHashCode(EqualityComparer<int>.Default);
}
public static int? GetEntityIdentifier(object? obj) {
if (obj == null) {
return null;
@@ -549,15 +592,86 @@ namespace Elwig.Helpers {
}
public static Expression<Func<AreaCom, bool>> ActiveAreaCommitments() => ActiveAreaCommitments(CurrentYear);
public static Expression<Func<AreaCom, bool>> ActiveAreaCommitments(int yearTo) =>
c => (c.YearFrom <= yearTo) && (c.YearTo == null || c.YearTo >= yearTo);
public static Expression<Func<AreaCom, bool>> ActiveAreaCommitments(int year) =>
c => (c.YearFrom == null || c.YearFrom <= year) && (c.YearTo == null || c.YearTo >= year);
public static IQueryable<AreaCom> ActiveAreaCommitments(IQueryable<AreaCom> query) => ActiveAreaCommitments(query, CurrentYear);
public static IQueryable<AreaCom> ActiveAreaCommitments(IQueryable<AreaCom> query, int yearTo) =>
query.Where(ActiveAreaCommitments(yearTo));
public static IQueryable<AreaCom> ActiveAreaCommitments(IQueryable<AreaCom> query, int year) =>
query.Where(ActiveAreaCommitments(year));
public static IEnumerable<AreaCom> ActiveAreaCommitments(IEnumerable<AreaCom> query) => ActiveAreaCommitments(query, CurrentYear);
public static IEnumerable<AreaCom> ActiveAreaCommitments(IEnumerable<AreaCom> query, int yearTo) =>
query.Where(c => ActiveAreaCommitments(yearTo).Invoke(c));
public static IEnumerable<AreaCom> ActiveAreaCommitments(IEnumerable<AreaCom> query, int year) =>
query.Where(c => ActiveAreaCommitments(year).Invoke(c));
public static async Task<(DateTime DateTime, string Type, int MgNr, string Name, string[] Addresses, string Subject, string[] Attachments)[]> GetSentMails(DateOnly? fromDate = null, DateOnly? toDate = null) {
var f = $"{fromDate:yyyy-MM-dd}";
var t = $"{toDate:yyyy-MM-dd}";
try {
var rows = new List<(DateTime, string, int, string, string[], string, string[])>();
var filenames = Directory.GetFiles(App.MailsPath, "????.csv")
.Where(n => fromDate == null || Path.GetFileName(n).CompareTo($"{fromDate.Value.Year}.csv") >= 0)
.Where(n => toDate == null || Path.GetFileName(n).CompareTo($"{toDate.Value.Year}.csv") <= 0)
.Order();
foreach (var filename in filenames) {
using var reader = new StreamReader(filename, Utils.UTF8);
string? line;
while ((line = await reader.ReadLineAsync()) != null) {
try {
if (line.Length < 20 || line[10] != ';' || line[19] != ';')
continue;
var date = line[..10];
if (fromDate != null && date.CompareTo(f) < 0) {
continue;
} else if (toDate != null && date.CompareTo(t) > 0) {
break;
}
var p = line.Split(';');
rows.Add((
DateOnly.ParseExact(p[0], "yyyy-MM-dd").ToDateTime(TimeOnly.ParseExact(p[1], "HH:mm:ss")),
p[2],
int.Parse(p[3]),
p[4],
p[5].Split(',').Select(a => a.Replace(" | ", "\n")).ToArray(),
p[6],
p[7].Split(',')
));
} catch {
continue;
}
}
}
return [.. rows];
} catch {
return [];
}
}
public static async Task AddSentMails(IEnumerable<(string Type, int MgNr, string Name, string[] Addresses, string Subject, string[] Attachments)> data) {
var now = DateTime.Now;
var filename = Path.Combine(App.MailsPath, $"{now.Year}.csv");
await File.AppendAllLinesAsync(filename, data.Select(d =>
$"{now:yyyy-MM-dd;HH:mm:ss};{d.Type};" +
$"{d.MgNr};{d.Name.Replace(';', ' ')};" +
$"{string.Join(',', d.Addresses.Select(a => a.Replace(';', ' ').Replace(',', ' ').Replace("\n", " | ")))};" +
$"{d.Subject.Replace(';', ' ')};" +
$"{string.Join(',', d.Attachments.Select(a => a.Replace(';', ' ').Replace(',', ' ')))}"
), Utils.UTF8);
}
public static async Task<string?> FindSentMailBody(DateTime target) {
var dt = $"{target:yyyy-MM-dd_HH-mm-ss}_";
var filename = Directory.GetFiles(App.MailsPath, "????-??-??_??-??-??_*.txt")
.Where(n => Path.GetFileName(n).CompareTo(dt) <= 0)
.Order()
.LastOrDefault();
if (filename == null)
return null;
return await File.ReadAllTextAsync(filename, Utils.UTF8);
}
public static async Task AddSentMailBody(string subject, string body, int recipients) {
var filename = Path.Combine(App.MailsPath, $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{NormalizeFileName(subject)}.txt");
await File.WriteAllTextAsync(filename, $"# {subject}\r\n# Vorgesehene Empfänger: {recipients}\r\n\r\n" + body, Utils.UTF8);
}
}
}

View File

@@ -8,7 +8,7 @@ namespace Elwig.Helpers {
public static class Validator {
private static readonly Dictionary<string, string[][]> PHONE_NRS = new() {
{ "43", new string[][] {
{ "43", [
[],
["57", "59"],
[
@@ -17,17 +17,17 @@ namespace Elwig.Helpers {
"650", "651", "652", "653", "655", "657", "659", "660", "661",
"663", "664", "665", "666", "667", "668", "669", "67", "68", "69"
]
} },
{ "49", Array.Empty<string[]>() },
{ "48", Array.Empty<string[]>() },
{ "420", Array.Empty<string[]>() },
{ "421", Array.Empty<string[]>() },
{ "36", Array.Empty<string[]>() },
{ "386", Array.Empty<string[]>() },
{ "39", Array.Empty<string[]>() },
{ "33", Array.Empty<string[]>() },
{ "41", Array.Empty<string[]>() },
{ "423", Array.Empty<string[]>() },
] },
{ "49", [] },
{ "48", [] },
{ "420", [] },
{ "421", [] },
{ "36", [] },
{ "386", [] },
{ "39", [] },
{ "33", [] },
{ "41", [] },
{ "423", [] },
};
public static ValidationResult CheckInteger(TextBox input, bool required) {
@@ -628,5 +628,55 @@ namespace Elwig.Helpers {
return new(true, null);
}
public static ValidationResult CheckOrganicAuthorityCode(TextBox input, bool required) {
string text = "";
int pos = input.CaretIndex;
for (int i = 0, v = 0; i < input.Text.Length; i++) {
char ch = char.ToUpper(input.Text[i]);
if (v < 2 && char.IsAsciiLetter(ch)) {
v++;
text += ch;
} else if ((v == 2 || v == 6) && ch == '-') {
v++;
text += ch;
} else if (v >= 2 && char.IsLetterOrDigit(ch)) {
if (text.StartsWith("AT")) {
if (v == 3 && ch == 'B' || v == 4 && ch == 'I' || v == 5 && ch == 'O') {
v++;
text += ch;
} else if (v > 6 && char.IsAsciiDigit(ch)) {
v++;
text += ch;
}
} else {
v++;
text += ch;
}
}
if (i == input.CaretIndex - 1) {
pos = text.Length;
} else if (text.StartsWith("AT") && v >= 10) {
break;
}
}
input.Text = text;
input.CaretIndex = pos;
if (text.Length == 0)
return required ? new(false, "Bio-Kontrollstellen-Code ist nicht optional") : new(true, null);
if (text.StartsWith("AT")) {
if (text.Length != 10) {
return new(false, "Bio-Kontrollstellen-Code ist ungültig");
}
} else {
return new(false, "Not implemented yet");
}
return new(true, null);
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Text;
using System.Threading;
@@ -58,11 +58,19 @@ namespace Elwig.Helpers.Weighing {
}
protected async Task<WeighingResult?> Receive() {
var line = await Reader.ReadUntilAsync("\r\n");
var line = "";
while (line.Length < 33) {
var ch = Reader.Read();
if (ch == -1) {
return null;
} else if (line.Length > 0 || ch == ' ') {
line += char.ToString((char)ch);
}
}
if (LogPath != null) await File.AppendAllTextAsync(LogPath, line);
if (line == null || line == "") {
return null;
} else if (line.Length != 35 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') {
} else if (line.Length != 33 || line[0] != ' ' || line[9] != ' ' || line[15] != ' ' || line[20] != ' ' || line[32] != ' ') {
throw new IOException($"Invalid event from scale: '{line}'");
}
@@ -79,7 +87,7 @@ namespace Elwig.Helpers.Weighing {
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
var parsedDate = DateOnly.Parse(date);
return new() {
Weight = int.Parse(netto),
NetWeight = int.Parse(netto),
WeighingId = identNr,
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
Date = parsedDate,

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.IO.Ports;
using System.Text;
@@ -60,23 +60,23 @@ namespace Elwig.Helpers.Weighing {
throw new IOException("Invalid response from scale: Received record has invalid size");
var line = record[2..];
var status = line[ 0.. 2];
var brutto = line[ 2.. 9].Trim();
var tara = line[ 9..16].Trim();
var netto = line[16..23].Trim();
var scaleNr = line[23..25].Trim();
var identNr = line[25..31].Trim();
var date = line[31..39];
var time = line[39..45];
var brutto = line[ 0.. 7].Trim();
var tara = line[ 7..14].Trim();
var netto = line[14..21].Trim();
var scaleNr = line[21..23].Trim();
var identNr = line[23..29].Trim();
var date = line[29..37];
var time = line[37..43];
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
var parsedDate = DateOnly.ParseExact(date, "yyyyMMdd");
return new() {
Weight = int.Parse(netto),
GrossWeight = int.Parse(brutto),
TareWeight = int.Parse(tara),
NetWeight = int.Parse(netto),
WeighingId = identNr,
FullWeighingId = identNr,
Date = parsedDate,
Time = TimeOnly.ParseExact(time, "HHmmss"),
Date = DateOnly.TryParseExact(date, "yyyyMMdd", out var d) ? d : null,
Time = TimeOnly.TryParseExact(time, "HHmmss", out var t) ? t : null,
};
}
@@ -118,5 +118,9 @@ namespace Elwig.Helpers.Weighing {
public async Task RevokeFillingClearance() {
await SetFillingClearance(false);
}
public Task SetDateAndTime(DateTime dateTime) {
throw new NotImplementedException("Für Waagen vom Typ 'Gassner' ist diese Funktion noch nicht implementiert");
}
}
}

View File

@@ -1,8 +1,9 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
namespace Elwig.Helpers.Weighing {
/// <summary>
/// Interface for controlling a a scale which responds to commands sent to it
/// Interface for controlling a weighing scale which responds to commands sent to it
/// </summary>
public interface ICommandScale : IScale {
/// <summary>
@@ -31,5 +32,10 @@ namespace Elwig.Helpers.Weighing {
/// Revoke clearance to fill the scale container
/// </summary>
Task RevokeFillingClearance();
/// <summary>
/// Try to set date and time on the scale
/// </summary>
Task SetDateAndTime(DateTime dateTime);
}
}

View File

@@ -1,6 +1,6 @@
namespace Elwig.Helpers.Weighing {
namespace Elwig.Helpers.Weighing {
/// <summary>
/// Interface for controlling a a scale which automatically sends weighing updates
/// Interface for controlling a weighing scale which automatically sends weighing updates
/// </summary>
public interface IEventScale : IScale {

View File

@@ -2,7 +2,7 @@ using System;
namespace Elwig.Helpers.Weighing {
/// <summary>
/// Interface for controlling a industrial scale (industrial terminal, "IT")
/// Interface for controlling a industrial weighing scale (industrial terminal, "IT")
/// </summary>
public interface IScale : IDisposable {
/// <summary>

View File

@@ -1,4 +1,4 @@
using System.IO.Ports;
using System.IO.Ports;
using System.IO;
using System.Net.Sockets;
using System;

View File

@@ -38,12 +38,12 @@ namespace Elwig.Helpers.Weighing {
}
var error = line[1..3];
string msg = $"Unbekannter Fehler (Fehler code {error})";
if (error[0] == '0') {
if (error[1] != '0') {
throw new IOException($"Invalid response from scale (error code {error})");
}
} else if (error[0] == '1') {
string msg = $"Unbekannter Fehler (Fehler code {error})";
switch (error[1]) {
case '1': msg = "Allgemeiner Waagenfehler"; break;
case '2': msg = "Waage in Überlast"; break;
@@ -53,8 +53,12 @@ namespace Elwig.Helpers.Weighing {
case '7': msg = "Druckmuster enthält ungültiges Kommando"; break;
}
throw new IOException($"Waagenfehler {error}: {msg}");
} else if (error[0] == '2') {
switch (error[1]) {
case '0': msg = "Brutto negativ"; break;
}
throw new IOException($"Fehler {error}: {msg}");
} else if (error[0] == '3') {
string msg = $"Unbekannter Fehler (Fehler code {error})";
switch (error[1]) {
case '1': msg = "Übertragunsfehler"; break;
case '2': msg = "Ungültiger Befehl"; break;
@@ -98,7 +102,9 @@ namespace Elwig.Helpers.Weighing {
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
var parsedDate = DateOnly.Parse(date);
return new() {
Weight = int.Parse(netto),
GrossWeight = int.Parse(brutto),
TareWeight = int.Parse(tara),
NetWeight = int.Parse(netto),
WeighingId = identNr,
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
Date = parsedDate,
@@ -155,5 +161,10 @@ namespace Elwig.Helpers.Weighing {
public async Task RevokeFillingClearance() {
await SetFillingClearance(false);
}
public async Task SetDateAndTime(DateTime dateTime) {
await SendCommand($"ST{dateTime:dd.MM.yyHH:mm:ss}");
await ReceiveResponse();
}
}
}

View File

@@ -1,12 +1,7 @@
using System;
using System;
namespace Elwig.Helpers.Weighing {
public class WeighingEventArgs : EventArgs {
public WeighingResult Result { get; set; }
public WeighingEventArgs(WeighingResult result) {
Result = result;
}
public class WeighingEventArgs(WeighingResult result) : EventArgs {
public readonly WeighingResult Result = result;
}
}

View File

@@ -1,14 +1,25 @@
using System;
using System.Text.Json.Nodes;
namespace Elwig.Helpers.Weighing {
/// <summary>
/// Result of a weighing process on an industrial scale
/// Result of a weighing process on an industrial weighing scale
/// </summary>
public struct WeighingResult {
/// <summary>
/// Measured gross weight in kg
/// </summary>
public int? GrossWeight;
/// <summary>
/// Measured tare weight in kg
/// </summary>
public int? TareWeight;
/// <summary>
/// Measured net weight in kg
/// </summary>
public int? Weight;
public int? NetWeight;
/// <summary>
/// Weighing id (or IdentNr) provided by the scale
@@ -30,12 +41,22 @@ namespace Elwig.Helpers.Weighing {
/// </summary>
public TimeOnly? Time;
/// <returns>&lt;Weight/WeighingId/Date/Time&gt;</returns>
/// <returns>&lt;[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time&gt;</returns>
public override readonly string ToString() {
var w = Weight != null ? $"{Weight}kg" : "";
var w = NetWeight != null ? (GrossWeight != null && TareWeight != null ? $"{GrossWeight}-{TareWeight}=" : "") + $"{NetWeight}kg" : "";
return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm}>";
}
public readonly JsonObject ToJson() {
var obj = new JsonObject();
if (FullWeighingId != null) obj["id"] = FullWeighingId;
if (WeighingId != null) obj["nr"] = int.Parse(WeighingId);
if (Date != null) obj["date"] = $"{Date:yyyy-MM-dd}";
if (Time != null) obj["time"] = $"{Time:HH:mm:ss}";
if (GrossWeight != null) obj["gross_weight"] = GrossWeight;
if (TareWeight != null) obj["tare_weight"] = TareWeight;
if (NetWeight != null) obj["net_weight"] = NetWeight;
return obj;
}
}
}

View File

@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
@@ -34,18 +34,18 @@ namespace Elwig.Models.Dtos {
}
private static async Task<IEnumerable<AreaComUnderDeliveryRowSingle>> FromDbSet(DbSet<AreaComUnderDeliveryRowSingle> table, int year) {
return await table.FromSqlRaw($"""
SELECT m.mgnr, m.family_name AS name_1,
return await table.FromSql($"""
SELECT m.mgnr, m.name AS name_1,
COALESCE(m.prefix || ' ', '') || m.given_name ||
COALESCE(' ' || m.middle_names, '') || COALESCE(' ' || m.suffix, '') AS name_2,
p.plz, o.name AS ort, m.address,
c.bucket, c.area, u.min_kg, u.weight
FROM member m
FROM v_area_commitment_bucket_strict c
LEFT JOIN member m ON m.mgnr = c.mgnr
LEFT JOIN AT_plz_dest p ON p.id = m.postal_dest
LEFT JOIN AT_ort o ON o.okz = p.okz
LEFT JOIN v_area_commitment_bucket_strict c ON c.mgnr = m.mgnr AND c.year = {year}
JOIN v_under_delivery u ON (u.mgnr, u.bucket, u.year) = (m.mgnr, c.bucket, c.year)
WHERE m.active = 1
WHERE c.year = {year}
ORDER BY m.mgnr, c.bucket
""").ToListAsync();
}
@@ -54,7 +54,7 @@ namespace Elwig.Models.Dtos {
public class AreaComUnderDeliveryRow {
public int MgNr;
public string Name1;
public string Name2;
public string? Name2;
public string Address;
public int Plz;
public string Locality;
@@ -88,7 +88,7 @@ namespace Elwig.Models.Dtos {
[Column("name_1")]
public required string Name1 { get; set; }
[Column("name_2")]
public required string Name2 { get; set; }
public string? Name2 { get; set; }
[Column("address")]
public required string Address { get; set; }
[Column("plz")]

View File

@@ -1,4 +1,4 @@
using Elwig.Helpers;
using Elwig.Helpers;
using Elwig.Helpers.Billing;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
@@ -30,6 +30,7 @@ namespace Elwig.Models.Dtos {
("Penalties", "Pönalen FB", "€", 20),
("Penalty", "Unterl. GA", "€", 20),
("AutoBs", "GA Nachz.", "€", 20),
("Custom", "Weitere", "€", 20),
("Others", "Sonstige", "€", 20),
("Considered", "Berückstgt.", "€", 20),
("Amount", "Betrag", "€", 20),
@@ -48,25 +49,27 @@ namespace Elwig.Models.Dtos {
}
private static async Task<IEnumerable<CreditNoteRowSingle>> FromDbSet(DbSet<CreditNoteRowSingle> table, int year, int avnr) {
return await table.FromSqlRaw($"""
SELECT m.mgnr, m.family_name AS name_1,
return await table.FromSql($"""
SELECT m.mgnr, m.name AS name_1,
COALESCE(m.prefix || ' ', '') || m.given_name ||
COALESCE(' ' || m.middle_names, '') || COALESCE(' ' || m.suffix, '') AS name_2,
p.plz, o.name AS ort, m.address, m.iban, c.tgnr, s.year, s.precision,
p.amount - p.net_amount AS surcharge,
c.net_amount, c.prev_net_amount, c.vat, c.vat_amount, c.gross_amount, c.modifiers, c.prev_modifiers, c.amount,
ROUND(COALESCE(u.total_penalty, 0) / POW(10, 4 - 2)) AS fb_penalty,
ROUND(COALESCE(b.total_penalty, 0) / POW(10, s.precision - 2)) AS bs_penalty,
ROUND(COALESCE(a.total_amount, 0) / POW(10, s.precision - 2)) AS auto_bs
ROUND(b.total_penalty / POW(10, s.precision - 2)) AS bs_penalty,
ROUND(u.total_penalty / POW(10, 4 - 2)) AS fb_penalty,
ROUND(-a.total_amount / POW(10, s.precision - 2)) AS auto_bs,
x.amount AS custom_mod
FROM credit c
LEFT JOIN member m ON m.mgnr = c.mgnr
LEFT JOIN payment_member p ON (p.year, p.avnr, p.mgnr) = (c.year, c.avnr, c.mgnr)
LEFT JOIN AT_plz_dest p ON p.id = m.postal_dest
LEFT JOIN AT_ort o ON o.okz = p.okz
LEFT JOIN season s ON s.year = c.year
LEFT JOIN v_penalty_area_commitments u ON (u.year, u.mgnr) = (s.year, m.mgnr)
LEFT JOIN v_penalty_business_shares b ON (b.year, b.mgnr) = (s.year, m.mgnr)
LEFT JOIN v_penalty_area_commitments u ON (u.year, u.mgnr) = (s.year, m.mgnr)
LEFT JOIN v_auto_business_shares a ON (a.year, a.mgnr) = (s.year, m.mgnr)
LEFT JOIN payment_custom x ON (x.year, x.mgnr) = (s.year, m.mgnr)
WHERE c.year = {year} AND c.avnr = {avnr}
ORDER BY m.mgnr
""").ToListAsync();
@@ -76,7 +79,7 @@ namespace Elwig.Models.Dtos {
public class CreditNoteRow {
public int MgNr;
public string Name1;
public string Name2;
public string? Name2;
public string Address;
public int Plz;
public string Locality;
@@ -92,6 +95,7 @@ namespace Elwig.Models.Dtos {
public decimal? Penalties;
public decimal? Penalty;
public decimal? AutoBs;
public decimal? Custom;
public decimal? Others;
public decimal? Considered;
public decimal Amount;
@@ -118,12 +122,14 @@ namespace Elwig.Models.Dtos {
}
decimal mod = (row.Modifiers == null) ? 0 : Utils.DecFromDb((long)row.Modifiers, prec1);
if (data.ConsiderContractPenalties)
Penalties = (row.FbPenalty == null || row.FbPenalty == 0) ? null : Utils.DecFromDb((long)row.FbPenalty, prec1);
Penalties = (row.FbPenalty == null) ? null : Utils.DecFromDb((long)row.FbPenalty, prec1);
if (data.ConsiderTotalPenalty)
Penalty = (row.BsPealty == null || row.BsPealty == 0) ? null : Utils.DecFromDb((long)row.BsPealty, prec1);
Penalty = (row.BsPenalty == null) ? null : Utils.DecFromDb((long)row.BsPenalty, prec1);
if (data.ConsiderAutoBusinessShares)
AutoBs = (row.AutoBs == null || row.AutoBs == 0) ? null : -Utils.DecFromDb((long)row.AutoBs, prec1);
mod -= (Penalties ?? 0) + (Penalty ?? 0) + (AutoBs ?? 0);
AutoBs = (row.AutoBs == null) ? null : Utils.DecFromDb((long)row.AutoBs, prec1);
if (data.ConsiderCustomModifiers)
Custom = (row.CustomMod == null) ? null : Utils.DecFromDb((long)row.CustomMod, prec1);
mod -= (Penalties ?? 0) + (Penalty ?? 0) + (AutoBs ?? 0) + (Custom ?? 0);
Others = (mod == 0) ? null : mod;
Gross = Utils.DecFromDb(row.GrossAmount, prec1);
Considered = (row.PrevModifiers == null || row.PrevModifiers == 0) ? null : -Utils.DecFromDb((long)row.PrevModifiers, prec1);
@@ -138,7 +144,7 @@ namespace Elwig.Models.Dtos {
[Column("name_1")]
public required string Name1 { get; set; }
[Column("name_2")]
public required string Name2 { get; set; }
public string? Name2 { get; set; }
[Column("address")]
public required string Address { get; set; }
[Column("plz")]
@@ -173,11 +179,13 @@ namespace Elwig.Models.Dtos {
public long? PrevModifiers { get; set; }
[Column("amount")]
public long Amount { get; set; }
[Column("bs_penalty")]
public long? BsPenalty { get; set; }
[Column("fb_penalty")]
public long? FbPenalty { get; set; }
[Column("bs_penalty")]
public long? BsPealty { get; set; }
[Column("auto_bs")]
public long? AutoBs { get; set; }
[Column("custom_mod")]
public long? CustomMod { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
using Elwig.Helpers.Billing;
using Elwig.Helpers.Billing;
using Elwig.Models.Entities;
using Microsoft.EntityFrameworkCore;
using System;
@@ -27,14 +27,14 @@ namespace Elwig.Models.Dtos {
MgNr = mgnr;
}
public static async Task<IDictionary<int, CreditNoteDeliveryData>> ForPaymentVariant(DbSet<CreditNoteDeliveryRowSingle> table, DbSet<Season> seasons, int year, int avnr) {
var variant = (await seasons.FindAsync(year))?.PaymentVariants.Where(v => v.AvNr == avnr).SingleOrDefault();
public static async Task<IDictionary<int, CreditNoteDeliveryData>> ForPaymentVariant(DbSet<CreditNoteDeliveryRowSingle> table, DbSet<PaymentVar> paymentVariants, int year, int avnr) {
var variant = await paymentVariants.FindAsync(year, avnr);
BillingData? varData = null;
try { varData = variant != null ? BillingData.FromJson(variant.Data) : null; } catch { }
return (await FromDbSet(table, year, avnr))
.GroupBy(
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr, r.DId, r.DPNr },
(k, g) => new CreditNoteDeliveryRow(g, seasons, varData?.NetWeightModifier ?? 0.0, varData?.GrossWeightModifier ?? 0.0))
(k, g) => new CreditNoteDeliveryRow(g, variant, varData))
.GroupBy(
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr },
(k, g) => new CreditNoteDeliveryData(g, k.Year, k.TgNr, mgnr: k.MgNr))
@@ -86,13 +86,13 @@ namespace Elwig.Models.Dtos {
public decimal? Amount;
public double WeighingModifier;
public CreditNoteDeliveryRow(IEnumerable<CreditNoteDeliveryRowSingle> rows, DbSet<Season> seasons, double netWeightModifier, double grossWeightModifier) {
public CreditNoteDeliveryRow(IEnumerable<CreditNoteDeliveryRowSingle> rows, PaymentVar paymentVariant, BillingData? varData) {
var f = rows.First();
Year = f.Year;
TgNr = f.TgNr;
AvNr = f.AvNr;
MgNr = f.MgNr;
var season = seasons.Find(Year);
var season = paymentVariant.Season;
LsNr = f.LsNr;
DPNr = f.DPNr;
@@ -115,7 +115,7 @@ namespace Elwig.Models.Dtos {
b.Price != null ? season?.DecFromDb((long)b.Price) : null,
b.Amount != null ? season?.DecFromDb((long)b.Amount) : null))
.ToArray();
WeighingModifier = f.NetWeight ? netWeightModifier : grossWeightModifier;
WeighingModifier = (varData == null || !varData.ConsiderDelieryModifiers) ? 0 : f.NetWeight ? varData.NetWeightModifier : varData.GrossWeightModifier;
Amount = f.TotalAmount != null ? season?.DecFromDb((long)f.TotalAmount) : null;
var netAmount = f.NetAmount != null ? season?.DecFromDb((long)f.NetAmount) : null;
var amt = netAmount * (decimal)(1.0 + WeighingModifier);

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