-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from ucdavis/JCS/OrderingSystem
Jcs/ordering system
- Loading branch information
Showing
135 changed files
with
42,024 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Hippo.Core.Domain | ||
{ | ||
public class Billing | ||
{ | ||
[Key] | ||
public int Id { get; set; } | ||
[Required] | ||
[MaxLength(128)] | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Hippo.Core.Domain | ||
{ | ||
public class FinancialDetail | ||
{ | ||
[Key] | ||
public int Id { get; set; } | ||
[MaxLength(200)] | ||
public string SecretAccessKey { get; set; } //Used to get the FinancialSystemApiKey from the secret service | ||
[Required] | ||
[MaxLength(50)] | ||
public string FinancialSystemApiSource { get; set; } | ||
[MaxLength(128)] | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
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; } | ||
[MaxLength(20)] | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
} | ||
} | ||
} |
Oops, something went wrong.