Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jcs/ordering system #321

Merged
merged 360 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
360 commits
Select commit Hold shift + click to select a range
6b3ba29
styling
laholstege May 23, 2024
4fbaf65
WIP Create Order
jSylvestre May 23, 2024
bf2fa35
Merge pull request #338 from ucdavis/RH/order-form
laholstege May 23, 2024
0a751c1
better way to catch unspecified fields
laholstege May 23, 2024
29de6d1
Merge remote-tracking branch 'origin/JCS/OrderForm' into JCS/CreateOr…
laholstege May 23, 2024
cc768b2
readOnly for metadata
laholstege May 23, 2024
549cc36
Merge branch 'JCS/OrderForm' into JCS/OrderForm20240523
jSylvestre May 24, 2024
0e91d93
Fix missing children
jSylvestre May 24, 2024
81628db
Trying to get it to work...
jSylvestre May 24, 2024
59fce1e
fix typing
laholstege May 24, 2024
0ca6bf7
Merge branch 'JCS/CreateOrder20240523' into JCS/OrderForm20240523
laholstege May 24, 2024
4bae787
cleanup cru
laholstege May 24, 2024
ce6656f
Merge pull request #337 from ucdavis/JCS/OrderForm20240523
laholstege May 24, 2024
b17c0e3
Merge pull request #335 from ucdavis/JCS/OrderForm
jSylvestre May 24, 2024
c43df8c
Merge pull request #327 from ucdavis/JCS/OrderController
jSylvestre May 24, 2024
f36100d
Merge remote-tracking branch 'origin/main' into JCS/OrderingSystem
jSylvestre May 24, 2024
9a250e1
update usePermissions
jSylvestre May 24, 2024
fb00ca9
WIP
jSylvestre May 24, 2024
23b809b
Use the product to set order values.
jSylvestre May 28, 2024
70faf93
WIP and Untested
jSylvestre May 28, 2024
41bdb45
wip
jSylvestre May 29, 2024
3199aeb
Move this out to prevent multiple calls
jSylvestre May 29, 2024
99d0d11
wip
jSylvestre May 29, 2024
5a5aacb
wip
jSylvestre May 29, 2024
8cf6cee
Use the notification to display saving
jSylvestre May 29, 2024
01e079d
Try to update totals.
jSylvestre May 29, 2024
fc82884
sigh
jSylvestre May 29, 2024
cb79414
Update subtotal and total on order form
jSylvestre May 29, 2024
98ed30f
trying errors. Also some oddness with adjustment
jSylvestre May 29, 2024
44fdb2a
cleanup
jSylvestre May 29, 2024
c26d6a1
Getting file renamed
jSylvestre May 29, 2024
2778994
renamed back
jSylvestre May 29, 2024
b3c61d1
Deal with errors.
jSylvestre May 30, 2024
770f764
Wrapper to disable fields
jSylvestre May 30, 2024
ea9a49f
some more validation
jSylvestre May 30, 2024
00e51a4
typing
laholstege May 30, 2024
2f91a50
Merge remote-tracking branch 'origin/JCS/OrderCreate20240524' into RH…
laholstege May 30, 2024
2e2e10f
Product validation.
jSylvestre May 30, 2024
84dced7
minLength
laholstege May 30, 2024
2157761
Merge pull request #343 from ucdavis/RH/validate
jSylvestre May 30, 2024
3bef6dc
useWatch instead of manually handling change
laholstege May 30, 2024
1abdbf3
Meta data changes (removed table)
jSylvestre May 30, 2024
370d244
number issues
jSylvestre May 30, 2024
00b8957
Merge remote-tracking branch 'origin/main' into JCS/MergeMain20240531
jSylvestre May 31, 2024
794c48a
Product page
jSylvestre May 31, 2024
e19b691
First pass to update react tables
jSylvestre May 31, 2024
863f7bb
still need to fix these
jSylvestre May 31, 2024
0cb2c61
New react table version
jSylvestre Jun 4, 2024
15708ae
Initial state
jSylvestre Jun 4, 2024
860528c
Merge pull request #346 from ucdavis/JCS/MergeMain20240531
jSylvestre Jun 4, 2024
519770f
Merge pull request #342 from ucdavis/JCS/OrderCreate20240524
jSylvestre Jun 4, 2024
4ff65db
wip
jSylvestre Jun 4, 2024
03cb52b
Do a lookup on cluster user
jSylvestre Jun 4, 2024
b45fa4d
Change User to Account for PI
jSylvestre Jun 5, 2024
f9be9bf
Migration
jSylvestre Jun 5, 2024
c659d8f
Show Order Owner
jSylvestre Jun 5, 2024
2cd393f
wip
jSylvestre Jun 5, 2024
eef1049
Add fields and move common fields into base
jSylvestre Jun 6, 2024
3ddc7f2
Default 5 years/60 months
jSylvestre Jun 6, 2024
b47ab7e
Don't have updated date in order
jSylvestre Jun 6, 2024
f929391
Migration
jSylvestre Jun 6, 2024
a861cc6
products
jSylvestre Jun 6, 2024
27a757a
wip
jSylvestre Jun 6, 2024
528ce81
Make product desc a textArea
jSylvestre Jun 6, 2024
2ec9059
wip dates
jSylvestre Jun 6, 2024
9981986
Allow saving dates
jSylvestre Jun 6, 2024
2e8bf56
Pass the dates
jSylvestre Jun 6, 2024
eeedb07
useWatch to show/hide installments
jSylvestre Jun 6, 2024
628fc9c
Set installments to 1 if it is onetime
jSylvestre Jun 6, 2024
994b296
Use a local state to determine if installments should be changed
jSylvestre Jun 7, 2024
a75dfae
Merge pull request #348 from ucdavis/JCS/DbChanges20240606
jSylvestre Jun 7, 2024
635f4b1
Merge pull request #347 from ucdavis/JCS/LinkToAccountsInstead
jSylvestre Jun 7, 2024
8e5da81
First pass at passing order billing info
jSylvestre Jun 18, 2024
8b57ee5
wip
jSylvestre Jun 18, 2024
a700e84
Add a lookup button
jSylvestre Jun 18, 2024
a865694
Use a table instead
jSylvestre Jun 20, 2024
14381c9
Add an update
jSylvestre Jun 20, 2024
a35f31d
fixing billing bindings
jSylvestre Jun 20, 2024
1cd0408
wip
jSylvestre Jun 20, 2024
ebd4a39
Save the existing percentage
jSylvestre Jun 20, 2024
5ac80a6
widths
jSylvestre Jun 20, 2024
5fdc0ad
save the id.
jSylvestre Jun 20, 2024
96436b4
Deal with manually changing chart string
jSylvestre Jun 21, 2024
475899e
cleanup
jSylvestre Jun 21, 2024
a4a81df
Show running percent total
jSylvestre Jun 21, 2024
c797929
Put it in a table footer
jSylvestre Jun 21, 2024
ee956f2
Comment this out for now
jSylvestre Jun 21, 2024
46a1ae5
Placeholder buttons
jSylvestre Jun 24, 2024
1e205f4
Default percentage
jSylvestre Jun 24, 2024
9d5d9bc
Some percentage validation
jSylvestre Jun 24, 2024
3a1fecd
Trying to get edit to post
jSylvestre Jun 24, 2024
ba647d2
Sigh, this was preventing model binding...
jSylvestre Jun 24, 2024
37d359b
just a comment, cauze I forgot what it was.
jSylvestre Jun 24, 2024
c2f2498
Merge pull request #351 from ucdavis/JCS/OrderingEditPage
jSylvestre Jun 24, 2024
b0fd3ea
Endpoint to just update billing info
jSylvestre Jun 24, 2024
eb21cf1
Move common code
jSylvestre Jun 25, 2024
f7ff31f
If I make this required, I can't trigger it without clicking it
jSylvestre Jun 25, 2024
b0bc982
cleanup
jSylvestre Jun 25, 2024
8f7b61c
sigh
jSylvestre Jun 25, 2024
05a76f4
Onetime payment
jSylvestre Jun 25, 2024
e861f3e
Manual payments
jSylvestre Jun 25, 2024
ad1d423
Trying a diablog
jSylvestre Jun 25, 2024
1788747
need to grab the info
jSylvestre Jun 25, 2024
4b6f72f
cleanup
jSylvestre Jun 25, 2024
957f996
Merge pull request #352 from ucdavis/JCS/PaymentDialog
jSylvestre Jun 25, 2024
a1fb4f3
Merge pull request #350 from ucdavis/JCS/PostChartStrings
jSylvestre Jun 25, 2024
5456046
Cleanup
jSylvestre Jun 25, 2024
165b509
Update Chart string page and fix server side code
jSylvestre Jun 25, 2024
0a9a423
Merge pull request #353 from ucdavis/JCS/FormDialog
jSylvestre Jun 26, 2024
2f1d9a1
Change status endpoint
jSylvestre Jun 26, 2024
3f76bf1
Some more checks.
jSylvestre Jun 26, 2024
c620e2c
Update status
jSylvestre Jun 27, 2024
424ee3c
cleanup
jSylvestre Jun 27, 2024
9614bfc
Cancel order
jSylvestre Jun 27, 2024
40597e6
Update the orderform's status when changed with api call
jSylvestre Jun 27, 2024
0bbf346
Merge pull request #355 from ucdavis/JCS/UpdateOrderStatus
jSylvestre Jun 27, 2024
0fbb1c7
Add a next payment date to orders
jSylvestre Jun 27, 2024
06ee2d7
Will need a notification date too
jSylvestre Jun 28, 2024
224d54b
Migration
jSylvestre Jun 28, 2024
7e4d0bb
Merge pull request #356 from ucdavis/JCS/NextPaymentDateDbChange
jSylvestre Jun 28, 2024
cba477c
Reject order
jSylvestre Jul 1, 2024
2791d15
Merge pull request #357 from ucdavis/JCS/Reject
jSylvestre Jul 1, 2024
b2307ff
History needs cluster to be included.
jSylvestre Jul 1, 2024
86ead98
Some show for conditional actions
jSylvestre Jul 1, 2024
311e5fa
WIP Show for
jSylvestre Jul 1, 2024
f3f2841
payment info
jSylvestre Jul 1, 2024
49652cb
I think we will allow a sloth cancelled payment.
jSylvestre Jul 1, 2024
40258fb
Readonly, but not disabled allowed this to be changed.
jSylvestre Jul 8, 2024
8c31469
Moving stuff around and hide/show
jSylvestre Jul 8, 2024
7dd0d45
Admin vs personal orders
jSylvestre Jul 8, 2024
e01e328
Add the sponsor name to the list of orders
jSylvestre Jul 8, 2024
554ad1a
Ugly way to have extra column for admin
jSylvestre Jul 8, 2024
7b2acc0
a little cleaner
jSylvestre Jul 8, 2024
1ebfbff
Merge remote-tracking branch 'origin/main' into JCS/ShowFor20240701
jSylvestre Jul 9, 2024
83e6e3f
Include owner
jSylvestre Jul 9, 2024
9c0940e
Merge pull request #358 from ucdavis/JCS/ShowFor20240701
jSylvestre Jul 9, 2024
18dfc49
Fixing server side issues
jSylvestre Jul 9, 2024
9df4383
Fix adding and removing meta data
jSylvestre Jul 9, 2024
f7b3258
Don't allow duplicate chart strings
jSylvestre Jul 9, 2024
949df86
Some Showfor based on status on edit page
jSylvestre Jul 9, 2024
69c940d
Merge pull request #361 from ucdavis/JCS/Orders20240709
jSylvestre Jul 9, 2024
5ed831b
Order page
jSylvestre Jul 9, 2024
f47207a
WIP
jSylvestre Jul 9, 2024
83d8eed
UTC to PST
jSylvestre Jul 9, 2024
d050348
ShowFor the nav buttons
jSylvestre Jul 10, 2024
90950f5
Fix typing a decimal
jSylvestre Jul 10, 2024
086fec5
Merge pull request #362 from ucdavis/JCS/Orders20240709b
jSylvestre Jul 10, 2024
d352216
Refactor change status
jSylvestre Jul 10, 2024
04214b5
Sorting and display date
jSylvestre Jul 10, 2024
98577b3
fix null check
jSylvestre Jul 10, 2024
c04d73f
fix installment type being changed
jSylvestre Jul 10, 2024
8b064ac
Deal with bad billing info on create
jSylvestre Jul 10, 2024
bd228bb
Server side refactoring and validation
jSylvestre Jul 10, 2024
376de60
Don't allow a submitted status to be edited by admin
jSylvestre Jul 10, 2024
f28f934
Move update into a method.
jSylvestre Jul 10, 2024
3ef1a16
Admin list
jSylvestre Jul 10, 2024
985a950
update existing order
jSylvestre Jul 11, 2024
821a4a5
bad request on invalid edit
jSylvestre Jul 11, 2024
99f91cd
showfor
jSylvestre Jul 11, 2024
f16e273
Merge pull request #363 from ucdavis/JCS/Orders20240710
jSylvestre Jul 11, 2024
9975716
Show the id in the list
jSylvestre Jul 11, 2024
0d8c217
Migration Cleanup
jSylvestre Jul 11, 2024
4ae132c
Migration to get the Order.OnModelCreating Working
jSylvestre Jul 11, 2024
8a86c8b
Merge pull request #368 from ucdavis/JCS/CleanupMigration20240711
jSylvestre Jul 11, 2024
736437e
Merge remote-tracking branch 'origin/main' into JCS/OrderMerge20240712
jSylvestre Jul 12, 2024
2ea235b
Merge pull request #369 from ucdavis/JCS/OrderMerge20240712
jSylvestre Jul 12, 2024
7af18be
Indexes for Orders
jSylvestre Jul 12, 2024
aae241e
Migration
jSylvestre Jul 12, 2024
988db5c
Merge pull request #370 from ucdavis/JCS/OrderIndexes20240712
jSylvestre Jul 12, 2024
b3b2ae0
update balance remaining on one time payment
jSylvestre Jul 12, 2024
0d55847
Merge pull request #371 from ucdavis/JCS/FixBalanceUpdate
jSylvestre Jul 12, 2024
183f2f5
Show/Hide order info per cluster
jSylvestre Jul 12, 2024
d27fbae
Duh, don't need to include with projection
jSylvestre Jul 12, 2024
8a698f5
Merge pull request #373 from ucdavis/JCS/OrdersAllowCLuster
jSylvestre Jul 12, 2024
ca19405
Merge remote-tracking branch 'origin/main' into JCS/OrderingSystem
jSylvestre Jul 12, 2024
1761bf7
Sloth Service
jSylvestre Jul 15, 2024
f2e760a
validate sloth source and secret
jSylvestre Jul 15, 2024
499dab6
some style, but not much :)
jSylvestre Jul 15, 2024
9f16fe5
WIP
jSylvestre Jul 16, 2024
36567bb
Natural Account stuff.
jSylvestre Jul 16, 2024
f9ef42f
debit/credit
jSylvestre Jul 16, 2024
9980966
Update chart string with natural account
jSylvestre Jul 16, 2024
51f02e6
Pop up a warning that the chart string has been modified.
jSylvestre Jul 16, 2024
216e37a
Merge pull request #376 from ucdavis/JCS/AeValidation20240716
jSylvestre Jul 16, 2024
0f36e8c
wip
jSylvestre Jul 16, 2024
37f2131
Fix deleting a billing record
jSylvestre Jul 16, 2024
2c72996
Merge pull request #377 from ucdavis/JCS/BillingCascadeDelete
jSylvestre Jul 16, 2024
08680b4
wip
jSylvestre Jul 16, 2024
4538e73
WIP
jSylvestre Jul 16, 2024
b30e63c
WIP
jSylvestre Jul 16, 2024
da03dcf
Getting closer
jSylvestre Jul 16, 2024
f41a5a1
Sloth stuff
jSylvestre Jul 17, 2024
3599767
Logic and language
jSylvestre Jul 18, 2024
bfda180
Fix bug. Could create multiple
jSylvestre Jul 18, 2024
53e6ebf
Merge pull request #375 from ucdavis/JCS/OrderSloth20240715
jSylvestre Jul 18, 2024
0b27502
Merge remote-tracking branch 'origin/main' into JCS/PullInMain20240718
jSylvestre Jul 18, 2024
20fbebb
Merge pull request #381 from ucdavis/JCS/PullInMain20240718
jSylvestre Jul 18, 2024
8d8b67b
New job for order processing
jSylvestre Jul 18, 2024
308cfd5
Payment Service
jSylvestre Jul 19, 2024
a1b4b88
Fixes
jSylvestre Jul 19, 2024
d83e130
Oops
jSylvestre Jul 19, 2024
609bf14
Merge pull request #382 from ucdavis/JCS/OrderJobsService
jSylvestre Jul 19, 2024
bb24d8a
wip
jSylvestre Jul 19, 2024
11c416a
Merge remote-tracking branch 'origin/JCS/OrderingSystem' into JCS/Pay…
jSylvestre Jul 19, 2024
fda247c
wip
jSylvestre Jul 19, 2024
5959dd4
WIP - Still need to test
jSylvestre Jul 19, 2024
0d1eac9
WIP display next payment date.
jSylvestre Jul 19, 2024
e19916c
Sigh. but it looks like it works
jSylvestre Jul 19, 2024
86635a3
Next Payment Date
jSylvestre Jul 23, 2024
96664b2
wip
jSylvestre Jul 23, 2024
242f4e2
Think this is correct now.
jSylvestre Jul 23, 2024
8f987ea
some extra checks to avoid over billing
jSylvestre Jul 23, 2024
1bfe701
sigh
jSylvestre Jul 23, 2024
3d64d1e
write balance remaining to sloth meta data
jSylvestre Jul 23, 2024
611a287
Show next payment amount
jSylvestre Jul 23, 2024
42e7623
Merge pull request #383 from ucdavis/JCS/PaymentsService
jSylvestre Jul 23, 2024
3f9139b
Fix description required
jSylvestre Jul 23, 2024
56ccc57
Merge pull request #385 from ucdavis/JCS/PaymentsService
jSylvestre Jul 23, 2024
176c6b5
service to check for failed payments
jSylvestre Jul 23, 2024
54525f6
cleanup
jSylvestre Jul 23, 2024
26f580e
Fixes
jSylvestre Jul 24, 2024
af4fe9e
DB change. Make vault key a string, set it to a guid
jSylvestre Jul 24, 2024
c77f7e1
Unneeded includes
jSylvestre Jul 24, 2024
4bba780
migration
jSylvestre Jul 24, 2024
48a30a2
cleanup
jSylvestre Jul 24, 2024
da41322
Consistency
jSylvestre Jul 24, 2024
096edd8
remove page reload
jSylvestre Jul 24, 2024
d8df60a
cleanup
jSylvestre Jul 24, 2024
62e93c6
cleanup
jSylvestre Jul 24, 2024
d04f8f6
cleanup
jSylvestre Jul 24, 2024
69aeee7
Merge pull request #387 from ucdavis/JCS/OrderFixes20240724
jSylvestre Jul 24, 2024
57939a6
use routing
jSylvestre Jul 24, 2024
a5a8e06
routing here too
jSylvestre Jul 24, 2024
d569960
Merge pull request #388 from ucdavis/JCS/OrderFixes20240724
jSylvestre Jul 24, 2024
b335924
cleanup
jSylvestre Jul 24, 2024
44fcc3d
cleanup debugging code
jSylvestre Jul 24, 2024
c654749
cleanup
jSylvestre Jul 24, 2024
0d1dbbc
cleanup
jSylvestre Jul 24, 2024
1383a08
Merge pull request #389 from ucdavis/JCS/OrderFixes20240724
jSylvestre Jul 24, 2024
ad366ae
cleanup
jSylvestre Jul 24, 2024
8c24728
Use a classname for background
jSylvestre Jul 24, 2024
a18a476
cleanup
jSylvestre Jul 24, 2024
52f35cd
cleanup
jSylvestre Jul 24, 2024
30a7b69
cleanup
jSylvestre Jul 24, 2024
1515997
Merge pull request #390 from ucdavis/JCS/OrderFixes20240724
jSylvestre Jul 24, 2024
136e8d5
Merge branch 'JCS/OrderingSystem' into JCS/InvalidChartStringNotifica…
jSylvestre Jul 24, 2024
d52ff4d
Merge pull request #386 from ucdavis/JCS/InvalidChartStringNotification
jSylvestre Jul 24, 2024
8f7119b
Set some max lengths for strings
jSylvestre Jul 25, 2024
4eee69f
Migration
jSylvestre Jul 25, 2024
e4fb1b4
Merge pull request #397 from ucdavis/JCS/DbChanges20240725
jSylvestre Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Hippo.Core/Data/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -41,6 +41,12 @@ protected AppDbContext(DbContextOptions options) : base(options)
public virtual DbSet<TempKerberos> TempKerberos { get; set; }
public virtual DbSet<QueuedEvent> QueuedEvents { get; set; }
public virtual DbSet<AccessType> AccessTypes { get; set; }
public virtual DbSet<FinancialDetail> FinancialDetails { get; set; }
public virtual DbSet<Product> Products { get; set; }
public virtual DbSet<Order> Orders { get; set; }
public virtual DbSet<Billing> Billings { get; set; }
public virtual DbSet<OrderMetaData> MetaData { get; set; }
public virtual DbSet<Payment> Payments { get; set; }

protected override void OnModelCreating(ModelBuilder builder)
{
Expand All @@ -57,6 +63,11 @@ protected override void OnModelCreating(ModelBuilder builder)
Domain.GroupMemberAccount.OnModelCreating(builder);
QueuedEvent.OnModelCreating(builder, this);
AccessType.OnModelCreating(builder);
FinancialDetail.OnModelCreating(builder);
Product.OnModelCreating(builder);
OrderMetaData.OnModelCreating(builder);
Order.OnModelCreating(builder);
Payment.OnModelCreating(builder);
TempGroup.OnModelCreating(builder);
Domain.TempKerberos.OnModelCreating(builder);
}
Expand Down
5 changes: 4 additions & 1 deletion Hippo.Core/Domain/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public Account()

[JsonIgnore]
public List<AccessType> AccessTypes { get; set; } = new();


[JsonIgnore]
public List<Order> Orders { get; set; } = new();

internal static void OnModelCreating(ModelBuilder modelBuilder, DbContext dbContext)
{
modelBuilder.Entity<Account>().HasQueryFilter(a => a.Cluster.IsActive);
Expand Down
19 changes: 19 additions & 0 deletions Hippo.Core/Domain/Billing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace Hippo.Core.Domain
{
public class Billing
{
[Key]
public int Id { get; set; }
[Required]
public string ChartString { get; set; }
public decimal Percentage { get; set; } = 100;
[Required]
public int OrderId { get; set; }
[JsonIgnore]
public Order Order { get; set; }
public DateTime Updated { get; set; } = DateTime.UtcNow;
}
}
27 changes: 27 additions & 0 deletions Hippo.Core/Domain/Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public class Cluster
[MinLength(1)]
public List<AccessType> AccessTypes { get; set; } = new();

[JsonIgnore]
public FinancialDetail FinancialDetail { get; set; }

[JsonIgnore]
public List<Product> Products { get; set; } = new();

[JsonIgnore]
public List<Order> Orders { get; set; } = new();

internal static void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Cluster>().HasQueryFilter(a => a.IsActive);
Expand All @@ -67,6 +76,24 @@ internal static void OnModelCreating(ModelBuilder modelBuilder)
.WithMany()
.HasForeignKey(p => p.ClusterId)
.OnDelete(DeleteBehavior.Restrict);

// Cluster has a one to one relationship with FinancialDetail where the financial detail is nullable
modelBuilder.Entity<Cluster>()
.HasOne(c => c.FinancialDetail)
.WithOne(c => c.Cluster)
.HasForeignKey<FinancialDetail>(fd => fd.ClusterId)
.OnDelete(DeleteBehavior.Restrict);

modelBuilder.Entity<Product>()
.HasOne(p => p.Cluster)
.WithMany(c => c.Products)
.HasForeignKey(p => p.ClusterId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Order>()
.HasOne(o => o.Cluster)
.WithMany(c => c.Orders)
.HasForeignKey(o => o.ClusterId)
.OnDelete(DeleteBehavior.Restrict);
}
}
}
25 changes: 25 additions & 0 deletions Hippo.Core/Domain/FinancialDetail.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;

namespace Hippo.Core.Domain
{
public class FinancialDetail
{
[Key]
public int Id { get; set; }
public string SecretAccessKey { get; set; } //Used to get the FinancialSystemApiKey from the secret service
[Required]
[MaxLength(50)]
public string FinancialSystemApiSource { get; set; }
public string ChartString { get; set; }
public bool AutoApprove { get; set; }
[Required]
public int ClusterId { get; set; }
public Cluster Cluster { get; set; }

internal static void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<FinancialDetail>().Property(a => a.AutoApprove).HasDefaultValue(true);
}
}
}
51 changes: 51 additions & 0 deletions Hippo.Core/Domain/History.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,26 @@ public History()
public int? ClusterId { get; set; } //When we have a cluster identifier
public Cluster Cluster { get; set; }

public int? OrderId { get; set; }
public Order Order { get; set; }

[MaxLength(50)]
public string Status { get; set; }

[MaxLength(50)]
public string Type { get; set; } = HistoryTypes.Detail;

internal static void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<History>().HasQueryFilter(h => h.Cluster == null || h.Cluster.IsActive);
modelBuilder.Entity<History>().HasIndex(h => h.ActedDate);
modelBuilder.Entity<History>().HasIndex(h => h.Action);
modelBuilder.Entity<History>().HasIndex(h => h.ClusterId);
modelBuilder.Entity<History>().HasIndex(h => h.Type);
modelBuilder.Entity<History>().HasIndex(h => h.OrderId);
modelBuilder.Entity<History>().HasOne(h => h.ActedBy).WithMany().HasForeignKey(a => a.ActedById).OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<History>().HasOne(h => h.Cluster).WithMany().HasForeignKey(a => a.ClusterId).OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<History>().HasOne(h => h.Order).WithMany(o => o.History).HasForeignKey(a => a.OrderId).OnDelete(DeleteBehavior.Restrict);
}

public class Actions
Expand Down Expand Up @@ -75,5 +84,47 @@ public class Actions
}.ToList();

}

public class OrderActions
{
public const string Created = "Created";
public const string Updated = "Updated";
public const string Submitted = "Submitted";
public const string Processing = "Processing";
public const string Cancelled = "Cancelled";
public const string Active = "Active";
public const string Rejected = "Rejected";
public const string Completed = "Completed";
public const string AdhocPayment = "Adhoc Payment";
public const string ChartStringUpdated = "Chart String Updated";
public const string PaymentFailed = "Payment Failed";

public static List<string> TypeList = new List<string>
laholstege marked this conversation as resolved.
Show resolved Hide resolved
{
Created,
Updated,
Submitted,
Processing,
Cancelled,
Active,
Rejected,
Completed,
AdhocPayment,
ChartStringUpdated,
PaymentFailed
}.ToList();
}

public class HistoryTypes
{
public const string Primary = "Primary";
public const string Detail = "Detail";

public static List<string> TypeList = new List<string>
{
Primary,
Detail
}.ToList();
}
}
}
110 changes: 110 additions & 0 deletions Hippo.Core/Domain/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using static Hippo.Core.Domain.Product;

namespace Hippo.Core.Domain
{
public class Order :ProductBase
{

[Required]
[MaxLength(50)]
public string ProductName { get; set; }

[MaxLength(150)]
public string ExternalReference { get; set; }

[Required]
[Range(0.0001, double.MaxValue)]
public decimal Quantity { get; set; }

public decimal Adjustment { get; set; }
public string AdjustmentReason { get; set; }
public decimal SubTotal { get; set; }
public decimal Total { get; set; }
public decimal BalanceRemaining { get; set; } //We will also calculate this when we do a payment
public string Notes { get; set; }
public string AdminNotes { get; set; }
public string Status { get; set; }

public DateTime? InstallmentDate { get; set; }
public DateTime? ExpirationDate { get; set; } //This would default to InstallmentDate + LifeCycle Months

public DateTime? NextPaymentDate { get; set; } //When we start payments, this will be set to trigger the auto creation of a payment. Onetime=tomorrow, Monthly=1st of next month, yearly= jan 1st of next year.

public DateTime? NextNotificationDate { get; set; } //This will be used to send notification to the sponsor once the ExpirationDate is reached. This will be set to ExpirationDate - 30 days?

public decimal InstallmentAmount => Math.Round(Total / Installments, 2);

[Required]
public int ClusterId { get; set; }
[JsonIgnore]
public Cluster Cluster { get; set; }


[Required]
public int PrincipalInvestigatorId { get; set; }
public Account PrincipalInvestigator { get; set; }

public DateTime CreatedOn { get; set; } = DateTime.UtcNow;

public List<Billing> Billings { get; set; } = new();

public List<OrderMetaData> MetaData { get; set; } = new();

public void AddMetaData(string key, string value)
{
MetaData.Add(new OrderMetaData { Name = key, Value = value, Order = this });
}
[JsonIgnore]
public List<Payment> Payments { get; set; } = new();

[JsonIgnore]
public List<History> History { get; set; } = new();

public class Statuses
{
public const string Created = "Created";
public const string Submitted = "Submitted";
public const string Processing = "Processing";
public const string Cancelled = "Cancelled";
public const string Active = "Active";
public const string Rejected = "Rejected"; //Not sure if we need this
public const string Completed = "Completed";

public static List<string> StatusTypes = new List<string>
{
Created,
Submitted,
Processing,
Cancelled,
Active,
Rejected,
Completed
};
}
internal static void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Order>().HasQueryFilter(o => o.Cluster.IsActive);
modelBuilder.Entity<Order>().HasIndex(o => o.PrincipalInvestigatorId);
modelBuilder.Entity<Order>().HasIndex(o => o.ClusterId);
modelBuilder.Entity<Order>().HasIndex(o => o.Status);
modelBuilder.Entity<Order>().HasIndex(o => o.ExpirationDate);
modelBuilder.Entity<Order>().HasIndex(o => o.NextNotificationDate);
modelBuilder.Entity<Billing>().HasOne(o => o.Order).WithMany(o => o.Billings).HasForeignKey(o => o.OrderId).OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<OrderMetaData>().HasOne(o => o.Order).WithMany(o => o.MetaData).HasForeignKey(o => o.OrderId).OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Payment>().HasOne(o => o.Order).WithMany(o => o.Payments).HasForeignKey(o => o.OrderId).OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<Order>()
.HasOne(o => o.PrincipalInvestigator)
.WithMany(u => u.Orders)
.HasForeignKey(o => o.PrincipalInvestigatorId)
.OnDelete(DeleteBehavior.Restrict);
}
}
}
34 changes: 34 additions & 0 deletions Hippo.Core/Domain/OrderMetaData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Hippo.Core.Domain
{
public class OrderMetaData
{
[Key]
public int Id { get; set; }
[Required]
public int OrderId { get; set; }
[JsonIgnore]
public Order Order { get; set; }
[Required]
[MaxLength(128)]
public string Name { get; set; }

[Required]
[MaxLength(450)]
public string Value { get; set; }

internal static void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<OrderMetaData>().HasIndex(a => a.OrderId);
modelBuilder.Entity<OrderMetaData>().HasIndex(a => new {a.OrderId, a.Name, a.Value });
}
}
}
Loading