diff --git a/Directory.Build.props b/Directory.Build.props index 81b1f2a6..112f8a83 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - 3.837.0 + 3.838.0 $(VersionSuffix)-$(BuildNumber) diff --git a/src/VirtoCommerce.OrdersModule.Core/Model/LineItem.cs b/src/VirtoCommerce.OrdersModule.Core/Model/LineItem.cs index 7f61412f..e0f30983 100644 --- a/src/VirtoCommerce.OrdersModule.Core/Model/LineItem.cs +++ b/src/VirtoCommerce.OrdersModule.Core/Model/LineItem.cs @@ -27,6 +27,9 @@ public class LineItem : AuditableEntity, IHasTaxDetalization, ISupportCancellati public virtual decimal PriceWithTax { get; set; } + public decimal ListTotal { get; set; } + public decimal ListTotalWithTax { get; set; } + /// /// Resulting price with discount for one unit /// @@ -43,6 +46,13 @@ public class LineItem : AuditableEntity, IHasTaxDetalization, ISupportCancellati /// public virtual decimal DiscountAmount { get; set; } + /// + /// Indicates whether the discount amount per item was rounded according to the currency settings. + /// If false, DiscountAmount and PlacedPrice should not be visible to the customer, as these values may be incorrect; + /// in this case, DiscountTotal and ExtendedPrice should be used. + /// + public bool IsDiscountAmountRounded { get; set; } + public virtual decimal DiscountAmountWithTax { get; set; } public decimal DiscountTotal { get; set; } diff --git a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj index 18011af6..9e163106 100644 --- a/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj +++ b/src/VirtoCommerce.OrdersModule.Core/VirtoCommerce.OrdersModule.Core.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/20241205094730_AddIsDiscountAmountRounded.Designer.cs b/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/20241205094730_AddIsDiscountAmountRounded.Designer.cs new file mode 100644 index 00000000..0e36cd86 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/20241205094730_AddIsDiscountAmountRounded.Designer.cs @@ -0,0 +1,2149 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VirtoCommerce.OrdersModule.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.OrdersModule.Data.MySql.Migrations +{ + [DbContext(typeof(OrderDbContext))] + [Migration("20241205094730_AddIsDiscountAmountRounded")] + partial class AddIsDiscountAmountRounded + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.AddressEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("AddressType") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CountryCode") + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CountryName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("FirstName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("LastName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Line1") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("Line2") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("Name") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("Organization") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PaymentInId") + .HasColumnType("varchar(128)"); + + b.Property("Phone") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("PostalCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("RegionId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("RegionName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderAddress", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Amount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("CloseTransaction") + .HasColumnType("tinyint(1)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("IsCancelled") + .HasColumnType("tinyint(1)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PaymentId") + .HasColumnType("varchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Sum") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("VendorId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("TransactionId", "CustomerOrderId") + .IsUnique(); + + b.ToTable("OrderCapture", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CaptureId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaptureId"); + + b.HasIndex("LineItemId"); + + b.ToTable("OrderCaptureItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ConfigurationItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CatalogId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CategoryId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("ImageUrl") + .HasMaxLength(1028) + .HasColumnType("varchar(1028)"); + + b.Property("LineItemId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("ProductId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("Sku") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.ToTable("OrderConfigurationItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("ChannelId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CustomerName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("DiscountTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("DiscountTotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("EmployeeId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("EmployeeName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Fee") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FeeTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FeeTotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FeeWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("HandlingTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("HandlingTotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("IsAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("IsCancelled") + .HasColumnType("tinyint(1)"); + + b.Property("IsPrototype") + .HasColumnType("tinyint(1)"); + + b.Property("LanguageCode") + .HasMaxLength(16) + .HasColumnType("varchar(16)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PaymentTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("PaymentTotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("PurchaseOrderNumber") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("timestamp(6)"); + + b.Property("ShippingTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("ShippingTotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("ShoppingCartId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("StoreId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("StoreName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("SubTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("SubTotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("SubscriptionId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("SubscriptionNumber") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Sum") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("Total") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.HasKey("Id"); + + b.ToTable("CustomerOrder", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.DiscountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CouponCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CouponInvalidDescription") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("DiscountAmountWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("LineItemId") + .HasColumnType("varchar(128)"); + + b.Property("PaymentInId") + .HasColumnType("varchar(128)"); + + b.Property("PromotionDescription") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("PromotionId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("PromotionName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderDiscount", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.FeeDetailEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Amount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("Currency") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("Description") + .HasColumnType("longtext"); + + b.Property("FeeId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("LineItemId") + .HasColumnType("varchar(128)"); + + b.Property("PaymentInId") + .HasColumnType("varchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderFeeDetail", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime(6)"); + + b.Property("CatalogId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CategoryId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("DiscountAmountWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("Fee") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FeeWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FulfillmentCenterId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("FulfillmentCenterName") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("FulfillmentLocationCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("ImageUrl") + .HasMaxLength(1028) + .HasColumnType("varchar(1028)"); + + b.Property("IsCancelled") + .HasColumnType("tinyint(1)"); + + b.Property("IsConfigured") + .HasColumnType("tinyint(1)"); + + b.Property("IsDiscountAmountRounded") + .HasColumnType("tinyint(1)"); + + b.Property("IsGift") + .HasColumnType("tinyint(1)"); + + b.Property("IsReccuring") + .HasColumnType("tinyint(1)"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Price") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("PriceId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PriceWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("ProductId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProductOuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ProductType") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("ShippingMethodCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Sku") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("VendorId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.ToTable("OrderLineItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.OrderDynamicPropertyObjectValueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("BooleanValue") + .HasColumnType("tinyint(1)"); + + b.Property("CaptureId") + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("DateTimeValue") + .HasColumnType("datetime(6)"); + + b.Property("DecimalValue") + .HasColumnType("decimal(18,5)"); + + b.Property("DictionaryItemId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IntegerValue") + .HasColumnType("int"); + + b.Property("LineItemId") + .HasColumnType("varchar(128)"); + + b.Property("Locale") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("LongTextValue") + .HasColumnType("longtext"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("ObjectId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ObjectType") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PaymentInId") + .HasColumnType("varchar(128)"); + + b.Property("PropertyId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PropertyName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("RefundId") + .HasColumnType("varchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("varchar(128)"); + + b.Property("ShortTextValue") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("CaptureId"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("RefundId"); + + b.HasIndex("ShipmentId"); + + b.HasIndex("ObjectType", "CustomerOrderId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_CustomerOrderId"); + + b.HasIndex("ObjectType", "LineItemId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_LineItemId"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_ObjectId"); + + b.HasIndex("ObjectType", "PaymentInId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_PaymentInId"); + + b.HasIndex("ObjectType", "RefundId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_RefundId"); + + b.HasIndex("ObjectType", "ShipmentId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_ShipmentId"); + + b.ToTable("OrderDynamicPropertyObjectValue", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentGatewayTransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Amount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("GatewayIpAddress") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("IsProcessed") + .HasColumnType("tinyint(1)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("PaymentInId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("ProcessAttemptCount") + .HasColumnType("int"); + + b.Property("ProcessError") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime(6)"); + + b.Property("RequestData") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ResponseData") + .HasColumnType("longtext"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Type") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("PaymentInId"); + + b.ToTable("OrderPaymentGatewayTransaction", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("AuthorizedDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("CapturedDate") + .HasColumnType("datetime(6)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CustomerName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("DiscountAmountWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("GatewayCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("IncomingDate") + .HasColumnType("datetime(6)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("IsCancelled") + .HasColumnType("tinyint(1)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Price") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("PriceWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("Purpose") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("ShipmentId") + .HasColumnType("varchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Sum") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Total") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("VendorId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("VoidedDate") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderPaymentIn", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Amount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("IsCancelled") + .HasColumnType("tinyint(1)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("PaymentId") + .HasColumnType("varchar(128)"); + + b.Property("ReasonCode") + .HasColumnType("longtext"); + + b.Property("ReasonMessage") + .HasColumnType("longtext"); + + b.Property("RejectReasonMessage") + .HasColumnType("longtext"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Sum") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("VendorId") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("TransactionId", "CustomerOrderId") + .IsUnique(); + + b.ToTable("OrderRefund", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("RefundId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.HasIndex("RefundId"); + + b.ToTable("OrderRefundItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime(6)"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("varchar(3)"); + + b.Property("CustomerOrderId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("DeliveryDate") + .HasColumnType("datetime(6)"); + + b.Property("DiscountAmount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("DiscountAmountWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("EmployeeId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("EmployeeName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Fee") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FeeWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("FulfillmentCenterId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("FulfillmentCenterName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("IsCancelled") + .HasColumnType("tinyint(1)"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Price") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("PriceWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("ShipmentMethodCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ShipmentMethodOption") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Sum") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Total") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TotalWithTax") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("TrackingNumber") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("TrackingUrl") + .HasColumnType("longtext"); + + b.Property("VendorId") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("VolumetricWeight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.ToTable("OrderShipment", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("BarCode") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("ShipmentId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("ShipmentPackageId") + .HasColumnType("varchar(128)"); + + b.Property("Status") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.HasIndex("ShipmentId"); + + b.HasIndex("ShipmentPackageId"); + + b.ToTable("OrderShipmentItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("BarCode") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime(6)"); + + b.Property("PackageType") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ShipmentId") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderShipmentPackage", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.TaxDetailEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Amount") + .HasPrecision(18, 4) + .HasColumnType("decimal"); + + b.Property("CustomerOrderId") + .HasColumnType("varchar(128)"); + + b.Property("LineItemId") + .HasColumnType("varchar(128)"); + + b.Property("Name") + .HasMaxLength(1024) + .HasColumnType("varchar(1024)"); + + b.Property("PaymentInId") + .HasColumnType("varchar(128)"); + + b.Property("Rate") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ShipmentId") + .HasColumnType("varchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderTaxDetail", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.AddressEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Addresses") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Addresses") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Addresses") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany() + .HasForeignKey("CustomerOrderId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "Payment") + .WithMany("Captures") + .HasForeignKey("PaymentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("Payment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", "Capture") + .WithMany("Items") + .HasForeignKey("CaptureId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("CaptureItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Capture"); + + b.Navigation("LineItem"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ConfigurationItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("ConfigurationItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("LineItem"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.DiscountEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Discounts") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("Discounts") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Discounts") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Discounts") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.FeeDetailEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("FeeDetails") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("FeeDetails") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("FeeDetails") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("FeeDetails") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Items") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.OrderDynamicPropertyObjectValueEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", "Capture") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("CaptureId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", "Refund") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("RefundId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Capture"); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Refund"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentGatewayTransactionEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Transactions") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PaymentIn"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("InPayments") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("InPayments") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CustomerOrder"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany() + .HasForeignKey("CustomerOrderId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "Payment") + .WithMany("Refunds") + .HasForeignKey("PaymentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("Payment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("RefundItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", "Refund") + .WithMany("Items") + .HasForeignKey("RefundId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("LineItem"); + + b.Navigation("Refund"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Shipments") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomerOrder"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("ShipmentItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Items") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", "ShipmentPackage") + .WithMany("Items") + .HasForeignKey("ShipmentPackageId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("LineItem"); + + b.Navigation("Shipment"); + + b.Navigation("ShipmentPackage"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Packages") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.TaxDetailEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("TaxDetails") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("TaxDetails") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("TaxDetails") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("TaxDetails") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("Items"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("InPayments"); + + b.Navigation("Items"); + + b.Navigation("Shipments"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.Navigation("CaptureItems"); + + b.Navigation("ConfigurationItems"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("RefundItems"); + + b.Navigation("ShipmentItems"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Captures"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("Refunds"); + + b.Navigation("TaxDetails"); + + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("Items"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("InPayments"); + + b.Navigation("Items"); + + b.Navigation("Packages"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.Navigation("Items"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/20241205094730_AddIsDiscountAmountRounded.cs b/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/20241205094730_AddIsDiscountAmountRounded.cs new file mode 100644 index 00000000..82323fc0 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/20241205094730_AddIsDiscountAmountRounded.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.OrdersModule.Data.MySql.Migrations +{ + /// + public partial class AddIsDiscountAmountRounded : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsDiscountAmountRounded", + table: "OrderLineItem", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDiscountAmountRounded", + table: "OrderLineItem"); + } + } +} diff --git a/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/OrderDbContextModelSnapshot.cs b/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/OrderDbContextModelSnapshot.cs index a7ed7402..cf535f96 100644 --- a/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/OrderDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.OrdersModule.Data.MySql/Migrations/OrderDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "8.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 64); MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); @@ -735,6 +735,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsConfigured") .HasColumnType("tinyint(1)"); + b.Property("IsDiscountAmountRounded") + .HasColumnType("tinyint(1)"); + b.Property("IsGift") .HasColumnType("tinyint(1)"); diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/20241205094652_AddIsDiscountAmountRounded.Designer.cs b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/20241205094652_AddIsDiscountAmountRounded.Designer.cs new file mode 100644 index 00000000..5e8ebcb3 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/20241205094652_AddIsDiscountAmountRounded.Designer.cs @@ -0,0 +1,2098 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using VirtoCommerce.OrdersModule.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.OrdersModule.Data.PostgreSql.Migrations +{ + [DbContext(typeof(OrderDbContext))] + [Migration("20241205094652_AddIsDiscountAmountRounded")] + partial class AddIsDiscountAmountRounded + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.AddressEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("AddressType") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CountryCode") + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CountryName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("FirstName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("LastName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Line1") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("Line2") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("Name") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("Organization") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PaymentInId") + .HasColumnType("character varying(128)"); + + b.Property("Phone") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PostalCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("RegionId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("RegionName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ShipmentId") + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderAddress", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CancelledDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CloseTransaction") + .HasColumnType("boolean"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("IsCancelled") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PaymentId") + .HasColumnType("character varying(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("VendorId") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("TransactionId", "CustomerOrderId") + .IsUnique(); + + b.ToTable("OrderCapture", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CaptureId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CaptureId"); + + b.HasIndex("LineItemId"); + + b.ToTable("OrderCaptureItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ConfigurationItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CatalogId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CategoryId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ImageUrl") + .HasMaxLength(1028) + .HasColumnType("character varying(1028)"); + + b.Property("LineItemId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("ProductId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("Sku") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.ToTable("OrderConfigurationItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CancelledDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ChannelId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CustomerName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountTotal") + .HasColumnType("Money"); + + b.Property("DiscountTotalWithTax") + .HasColumnType("Money"); + + b.Property("EmployeeId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("EmployeeName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Fee") + .HasColumnType("Money"); + + b.Property("FeeTotal") + .HasColumnType("Money"); + + b.Property("FeeTotalWithTax") + .HasColumnType("Money"); + + b.Property("FeeWithTax") + .HasColumnType("Money"); + + b.Property("HandlingTotal") + .HasColumnType("Money"); + + b.Property("HandlingTotalWithTax") + .HasColumnType("Money"); + + b.Property("IsAnonymous") + .HasColumnType("boolean"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("IsCancelled") + .HasColumnType("boolean"); + + b.Property("IsPrototype") + .HasColumnType("boolean"); + + b.Property("LanguageCode") + .HasMaxLength(16) + .HasColumnType("character varying(16)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PaymentTotal") + .HasColumnType("Money"); + + b.Property("PaymentTotalWithTax") + .HasColumnType("Money"); + + b.Property("PurchaseOrderNumber") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.Property("ShippingTotal") + .HasColumnType("Money"); + + b.Property("ShippingTotalWithTax") + .HasColumnType("Money"); + + b.Property("ShoppingCartId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("StoreId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("StoreName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("SubTotal") + .HasColumnType("Money"); + + b.Property("SubTotalWithTax") + .HasColumnType("Money"); + + b.Property("SubscriptionId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("SubscriptionNumber") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("Total") + .HasColumnType("Money"); + + b.HasKey("Id"); + + b.ToTable("CustomerOrder", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.DiscountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CouponCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CouponInvalidDescription") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("LineItemId") + .HasColumnType("character varying(128)"); + + b.Property("PaymentInId") + .HasColumnType("character varying(128)"); + + b.Property("PromotionDescription") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("PromotionId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("PromotionName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ShipmentId") + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderDiscount", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.FeeDetailEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("Currency") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("FeeId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("LineItemId") + .HasColumnType("character varying(128)"); + + b.Property("PaymentInId") + .HasColumnType("character varying(128)"); + + b.Property("ShipmentId") + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderFeeDetail", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CancelledDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CatalogId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CategoryId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("Fee") + .HasColumnType("Money"); + + b.Property("FeeWithTax") + .HasColumnType("Money"); + + b.Property("FulfillmentCenterId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("FulfillmentCenterName") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("FulfillmentLocationCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("ImageUrl") + .HasMaxLength(1028) + .HasColumnType("character varying(1028)"); + + b.Property("IsCancelled") + .HasColumnType("boolean"); + + b.Property("IsConfigured") + .HasColumnType("boolean"); + + b.Property("IsDiscountAmountRounded") + .HasColumnType("boolean"); + + b.Property("IsGift") + .HasColumnType("boolean"); + + b.Property("IsReccuring") + .HasColumnType("boolean"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Price") + .HasColumnType("Money"); + + b.Property("PriceId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PriceWithTax") + .HasColumnType("Money"); + + b.Property("ProductId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ProductOuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ProductType") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("ShippingMethodCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Sku") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("VendorId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.ToTable("OrderLineItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.OrderDynamicPropertyObjectValueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("BooleanValue") + .HasColumnType("boolean"); + + b.Property("CaptureId") + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("DateTimeValue") + .HasColumnType("timestamp with time zone"); + + b.Property("DecimalValue") + .HasColumnType("decimal(18,5)"); + + b.Property("DictionaryItemId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("IntegerValue") + .HasColumnType("integer"); + + b.Property("LineItemId") + .HasColumnType("character varying(128)"); + + b.Property("Locale") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("LongTextValue") + .HasColumnType("text"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ObjectId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ObjectType") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PaymentInId") + .HasColumnType("character varying(128)"); + + b.Property("PropertyId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PropertyName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("RefundId") + .HasColumnType("character varying(128)"); + + b.Property("ShipmentId") + .HasColumnType("character varying(128)"); + + b.Property("ShortTextValue") + .HasMaxLength(512) + .HasColumnType("character varying(512)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("CaptureId"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("RefundId"); + + b.HasIndex("ShipmentId"); + + b.HasIndex("ObjectType", "CustomerOrderId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_CustomerOrderId"); + + b.HasIndex("ObjectType", "LineItemId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_LineItemId"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_ObjectId"); + + b.HasIndex("ObjectType", "PaymentInId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_PaymentInId"); + + b.HasIndex("ObjectType", "RefundId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_RefundId"); + + b.HasIndex("ObjectType", "ShipmentId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_ShipmentId"); + + b.ToTable("OrderDynamicPropertyObjectValue", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentGatewayTransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("GatewayIpAddress") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("IsProcessed") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Note") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("PaymentInId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("ProcessAttemptCount") + .HasColumnType("integer"); + + b.Property("ProcessError") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("ProcessedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("RequestData") + .HasColumnType("text"); + + b.Property("ResponseCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ResponseData") + .HasColumnType("text"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Type") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.HasKey("Id"); + + b.HasIndex("PaymentInId"); + + b.ToTable("OrderPaymentGatewayTransaction", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("AuthorizedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CancelledDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("CapturedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CustomerName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("GatewayCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("IncomingDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("IsCancelled") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Price") + .HasColumnType("Money"); + + b.Property("PriceWithTax") + .HasColumnType("Money"); + + b.Property("Purpose") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("ShipmentId") + .HasColumnType("character varying(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Total") + .HasColumnType("Money"); + + b.Property("TotalWithTax") + .HasColumnType("Money"); + + b.Property("VendorId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("VoidedDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderPaymentIn", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CancelledDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("IsCancelled") + .HasColumnType("boolean"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("PaymentId") + .HasColumnType("character varying(128)"); + + b.Property("ReasonCode") + .HasColumnType("text"); + + b.Property("ReasonMessage") + .HasColumnType("text"); + + b.Property("RejectReasonMessage") + .HasColumnType("text"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("VendorId") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("TransactionId", "CustomerOrderId") + .IsUnique(); + + b.ToTable("OrderRefund", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("RefundId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.HasIndex("RefundId"); + + b.ToTable("OrderRefundItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CancelledDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("character varying(3)"); + + b.Property("CustomerOrderId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("DeliveryDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("EmployeeId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("EmployeeName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Fee") + .HasColumnType("Money"); + + b.Property("FeeWithTax") + .HasColumnType("Money"); + + b.Property("FulfillmentCenterId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("FulfillmentCenterName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("IsApproved") + .HasColumnType("boolean"); + + b.Property("IsCancelled") + .HasColumnType("boolean"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Price") + .HasColumnType("Money"); + + b.Property("PriceWithTax") + .HasColumnType("Money"); + + b.Property("ShipmentMethodCode") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ShipmentMethodOption") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("Total") + .HasColumnType("Money"); + + b.Property("TotalWithTax") + .HasColumnType("Money"); + + b.Property("TrackingNumber") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TrackingUrl") + .HasColumnType("text"); + + b.Property("VendorId") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("VolumetricWeight") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.ToTable("OrderShipment", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("BarCode") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("ShipmentId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("ShipmentPackageId") + .HasColumnType("character varying(128)"); + + b.Property("Status") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.HasIndex("ShipmentId"); + + b.HasIndex("ShipmentPackageId"); + + b.ToTable("OrderShipmentItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("BarCode") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ModifiedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("PackageType") + .HasMaxLength(64) + .HasColumnType("character varying(64)"); + + b.Property("ShipmentId") + .IsRequired() + .HasColumnType("character varying(128)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("character varying(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("numeric(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderShipmentPackage", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.TaxDetailEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CustomerOrderId") + .HasColumnType("character varying(128)"); + + b.Property("LineItemId") + .HasColumnType("character varying(128)"); + + b.Property("Name") + .HasMaxLength(1024) + .HasColumnType("character varying(1024)"); + + b.Property("PaymentInId") + .HasColumnType("character varying(128)"); + + b.Property("Rate") + .HasPrecision(18, 2) + .HasColumnType("numeric(18,2)"); + + b.Property("ShipmentId") + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderTaxDetail", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.AddressEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Addresses") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Addresses") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Addresses") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany() + .HasForeignKey("CustomerOrderId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "Payment") + .WithMany("Captures") + .HasForeignKey("PaymentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("Payment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", "Capture") + .WithMany("Items") + .HasForeignKey("CaptureId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("CaptureItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Capture"); + + b.Navigation("LineItem"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ConfigurationItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("ConfigurationItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("LineItem"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.DiscountEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Discounts") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("Discounts") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Discounts") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Discounts") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.FeeDetailEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("FeeDetails") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("FeeDetails") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("FeeDetails") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("FeeDetails") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Items") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.OrderDynamicPropertyObjectValueEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", "Capture") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("CaptureId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", "Refund") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("RefundId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Capture"); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Refund"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentGatewayTransactionEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Transactions") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PaymentIn"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("InPayments") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("InPayments") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CustomerOrder"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany() + .HasForeignKey("CustomerOrderId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "Payment") + .WithMany("Refunds") + .HasForeignKey("PaymentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("Payment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("RefundItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", "Refund") + .WithMany("Items") + .HasForeignKey("RefundId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("LineItem"); + + b.Navigation("Refund"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Shipments") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomerOrder"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("ShipmentItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Items") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", "ShipmentPackage") + .WithMany("Items") + .HasForeignKey("ShipmentPackageId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("LineItem"); + + b.Navigation("Shipment"); + + b.Navigation("ShipmentPackage"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Packages") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.TaxDetailEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("TaxDetails") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("TaxDetails") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("TaxDetails") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("TaxDetails") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("Items"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("InPayments"); + + b.Navigation("Items"); + + b.Navigation("Shipments"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.Navigation("CaptureItems"); + + b.Navigation("ConfigurationItems"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("RefundItems"); + + b.Navigation("ShipmentItems"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Captures"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("Refunds"); + + b.Navigation("TaxDetails"); + + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("Items"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("InPayments"); + + b.Navigation("Items"); + + b.Navigation("Packages"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.Navigation("Items"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/20241205094652_AddIsDiscountAmountRounded.cs b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/20241205094652_AddIsDiscountAmountRounded.cs new file mode 100644 index 00000000..adbe4965 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/20241205094652_AddIsDiscountAmountRounded.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.OrdersModule.Data.PostgreSql.Migrations +{ + /// + public partial class AddIsDiscountAmountRounded : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsDiscountAmountRounded", + table: "OrderLineItem", + type: "boolean", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDiscountAmountRounded", + table: "OrderLineItem"); + } + } +} diff --git a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/OrderDbContextModelSnapshot.cs b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/OrderDbContextModelSnapshot.cs index 88dda8b0..f4a7edf9 100644 --- a/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/OrderDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.OrdersModule.Data.PostgreSql/Migrations/OrderDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "8.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -709,6 +709,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsConfigured") .HasColumnType("boolean"); + b.Property("IsDiscountAmountRounded") + .HasColumnType("boolean"); + b.Property("IsGift") .HasColumnType("boolean"); diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/20241205094527_AddIsDiscountAmountRounded.Designer.cs b/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/20241205094527_AddIsDiscountAmountRounded.Designer.cs new file mode 100644 index 00000000..9595ebc5 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/20241205094527_AddIsDiscountAmountRounded.Designer.cs @@ -0,0 +1,2099 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using VirtoCommerce.OrdersModule.Data.Repositories; + +#nullable disable + +namespace VirtoCommerce.OrdersModule.Data.SqlServer.Migrations +{ + [DbContext(typeof(OrderDbContext))] + [Migration("20241205094527_AddIsDiscountAmountRounded")] + partial class AddIsDiscountAmountRounded + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.AddressEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("AddressType") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CountryCode") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CountryName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("FirstName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("LastName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Line1") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("Line2") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("Name") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("Organization") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("PaymentInId") + .HasColumnType("nvarchar(128)"); + + b.Property("Phone") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("PostalCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("RegionId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("RegionName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderAddress", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime2"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("CloseTransaction") + .HasColumnType("bit"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("IsApproved") + .HasColumnType("bit"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("PaymentId") + .HasColumnType("nvarchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("VendorId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("TransactionId", "CustomerOrderId") + .IsUnique() + .HasFilter("[CustomerOrderId] IS NOT NULL"); + + b.ToTable("OrderCapture", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CaptureId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaptureId"); + + b.HasIndex("LineItemId"); + + b.ToTable("OrderCaptureItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ConfigurationItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CatalogId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CategoryId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("ImageUrl") + .HasMaxLength(1028) + .HasColumnType("nvarchar(1028)"); + + b.Property("LineItemId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("ProductId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("Sku") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.ToTable("OrderConfigurationItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime2"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("ChannelId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CustomerName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountTotal") + .HasColumnType("Money"); + + b.Property("DiscountTotalWithTax") + .HasColumnType("Money"); + + b.Property("EmployeeId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("EmployeeName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Fee") + .HasColumnType("Money"); + + b.Property("FeeTotal") + .HasColumnType("Money"); + + b.Property("FeeTotalWithTax") + .HasColumnType("Money"); + + b.Property("FeeWithTax") + .HasColumnType("Money"); + + b.Property("HandlingTotal") + .HasColumnType("Money"); + + b.Property("HandlingTotalWithTax") + .HasColumnType("Money"); + + b.Property("IsAnonymous") + .HasColumnType("bit"); + + b.Property("IsApproved") + .HasColumnType("bit"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("IsPrototype") + .HasColumnType("bit"); + + b.Property("LanguageCode") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("PaymentTotal") + .HasColumnType("Money"); + + b.Property("PaymentTotalWithTax") + .HasColumnType("Money"); + + b.Property("PurchaseOrderNumber") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("rowversion"); + + b.Property("ShippingTotal") + .HasColumnType("Money"); + + b.Property("ShippingTotalWithTax") + .HasColumnType("Money"); + + b.Property("ShoppingCartId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("StoreId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("StoreName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("SubTotal") + .HasColumnType("Money"); + + b.Property("SubTotalWithTax") + .HasColumnType("Money"); + + b.Property("SubscriptionId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("SubscriptionNumber") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("Total") + .HasColumnType("Money"); + + b.HasKey("Id"); + + b.ToTable("CustomerOrder", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.DiscountEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CouponCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CouponInvalidDescription") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("LineItemId") + .HasColumnType("nvarchar(128)"); + + b.Property("PaymentInId") + .HasColumnType("nvarchar(128)"); + + b.Property("PromotionDescription") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("PromotionId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("PromotionName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderDiscount", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.FeeDetailEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("Currency") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("FeeId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("LineItemId") + .HasColumnType("nvarchar(128)"); + + b.Property("PaymentInId") + .HasColumnType("nvarchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderFeeDetail", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime2"); + + b.Property("CatalogId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CategoryId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("Fee") + .HasColumnType("Money"); + + b.Property("FeeWithTax") + .HasColumnType("Money"); + + b.Property("FulfillmentCenterId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("FulfillmentCenterName") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("FulfillmentLocationCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("ImageUrl") + .HasMaxLength(1028) + .HasColumnType("nvarchar(1028)"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("IsConfigured") + .HasColumnType("bit"); + + b.Property("IsDiscountAmountRounded") + .HasColumnType("bit"); + + b.Property("IsGift") + .HasColumnType("bit"); + + b.Property("IsReccuring") + .HasColumnType("bit"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("Money"); + + b.Property("PriceId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("PriceWithTax") + .HasColumnType("Money"); + + b.Property("ProductId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProductOuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ProductType") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("ShippingMethodCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Sku") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("VendorId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.ToTable("OrderLineItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.OrderDynamicPropertyObjectValueEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("BooleanValue") + .HasColumnType("bit"); + + b.Property("CaptureId") + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("DateTimeValue") + .HasColumnType("datetime2"); + + b.Property("DecimalValue") + .HasColumnType("decimal(18,5)"); + + b.Property("DictionaryItemId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("IntegerValue") + .HasColumnType("int"); + + b.Property("LineItemId") + .HasColumnType("nvarchar(128)"); + + b.Property("Locale") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("LongTextValue") + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("ObjectId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ObjectType") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PaymentInId") + .HasColumnType("nvarchar(128)"); + + b.Property("PropertyId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("PropertyName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("RefundId") + .HasColumnType("nvarchar(128)"); + + b.Property("ShipmentId") + .HasColumnType("nvarchar(128)"); + + b.Property("ShortTextValue") + .HasMaxLength(512) + .HasColumnType("nvarchar(512)"); + + b.Property("ValueType") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("CaptureId"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("RefundId"); + + b.HasIndex("ShipmentId"); + + b.HasIndex("ObjectType", "CustomerOrderId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_CustomerOrderId"); + + b.HasIndex("ObjectType", "LineItemId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_LineItemId"); + + b.HasIndex("ObjectType", "ObjectId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_ObjectId"); + + b.HasIndex("ObjectType", "PaymentInId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_PaymentInId"); + + b.HasIndex("ObjectType", "RefundId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_RefundId"); + + b.HasIndex("ObjectType", "ShipmentId") + .HasDatabaseName("IX_OrderDynamicProperty_ObjectType_ShipmentId"); + + b.ToTable("OrderDynamicPropertyObjectValue", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentGatewayTransactionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("GatewayIpAddress") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("IsProcessed") + .HasColumnType("bit"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Note") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("PaymentInId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("ProcessAttemptCount") + .HasColumnType("int"); + + b.Property("ProcessError") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("ProcessedDate") + .HasColumnType("datetime2"); + + b.Property("RequestData") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ResponseData") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Type") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("PaymentInId"); + + b.ToTable("OrderPaymentGatewayTransaction", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("AuthorizedDate") + .HasColumnType("datetime2"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime2"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("CapturedDate") + .HasColumnType("datetime2"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CustomerName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("GatewayCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("IncomingDate") + .HasColumnType("datetime2"); + + b.Property("IsApproved") + .HasColumnType("bit"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("Money"); + + b.Property("PriceWithTax") + .HasColumnType("Money"); + + b.Property("Purpose") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("ShipmentId") + .HasColumnType("nvarchar(128)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Total") + .HasColumnType("Money"); + + b.Property("TotalWithTax") + .HasColumnType("Money"); + + b.Property("VendorId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("VoidedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderPaymentIn", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime2"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("IsApproved") + .HasColumnType("bit"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("PaymentId") + .HasColumnType("nvarchar(128)"); + + b.Property("ReasonCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ReasonMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RejectReasonMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("VendorId") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("TransactionId", "CustomerOrderId") + .IsUnique() + .HasFilter("[CustomerOrderId] IS NOT NULL"); + + b.ToTable("OrderRefund", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("RefundId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.HasIndex("RefundId"); + + b.ToTable("OrderRefundItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CancelReason") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CancelledDate") + .HasColumnType("datetime2"); + + b.Property("CancelledState") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("Comment") + .HasMaxLength(2048) + .HasColumnType("nvarchar(2048)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Currency") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CustomerOrderId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("DeliveryDate") + .HasColumnType("datetime2"); + + b.Property("DiscountAmount") + .HasColumnType("Money"); + + b.Property("DiscountAmountWithTax") + .HasColumnType("Money"); + + b.Property("EmployeeId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("EmployeeName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Fee") + .HasColumnType("Money"); + + b.Property("FeeWithTax") + .HasColumnType("Money"); + + b.Property("FulfillmentCenterId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("FulfillmentCenterName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("IsApproved") + .HasColumnType("bit"); + + b.Property("IsCancelled") + .HasColumnType("bit"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("Number") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OrganizationId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("OrganizationName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ParentOperationId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Price") + .HasColumnType("Money"); + + b.Property("PriceWithTax") + .HasColumnType("Money"); + + b.Property("ShipmentMethodCode") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ShipmentMethodOption") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Status") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Sum") + .HasColumnType("Money"); + + b.Property("TaxPercentRate") + .HasColumnType("decimal(18,4)"); + + b.Property("TaxTotal") + .HasColumnType("Money"); + + b.Property("TaxType") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("Total") + .HasColumnType("Money"); + + b.Property("TotalWithTax") + .HasColumnType("Money"); + + b.Property("TrackingNumber") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("TrackingUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("VendorId") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("VolumetricWeight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.ToTable("OrderShipment", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentItemEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("BarCode") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("LineItemId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("OuterId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("ShipmentId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("ShipmentPackageId") + .HasColumnType("nvarchar(128)"); + + b.Property("Status") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("LineItemId"); + + b.HasIndex("ShipmentId"); + + b.HasIndex("ShipmentPackageId"); + + b.ToTable("OrderShipmentItem", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("BarCode") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("CreatedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Height") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("Length") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("MeasureUnit") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("ModifiedBy") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ModifiedDate") + .HasColumnType("datetime2"); + + b.Property("PackageType") + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("ShipmentId") + .IsRequired() + .HasColumnType("nvarchar(128)"); + + b.Property("Weight") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.Property("WeightUnit") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("Width") + .HasPrecision(18, 4) + .HasColumnType("decimal(18,4)"); + + b.HasKey("Id"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderShipmentPackage", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.TaxDetailEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("Amount") + .HasColumnType("Money"); + + b.Property("CustomerOrderId") + .HasColumnType("nvarchar(128)"); + + b.Property("LineItemId") + .HasColumnType("nvarchar(128)"); + + b.Property("Name") + .HasMaxLength(1024) + .HasColumnType("nvarchar(1024)"); + + b.Property("PaymentInId") + .HasColumnType("nvarchar(128)"); + + b.Property("Rate") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("ShipmentId") + .HasColumnType("nvarchar(128)"); + + b.HasKey("Id"); + + b.HasIndex("CustomerOrderId"); + + b.HasIndex("LineItemId"); + + b.HasIndex("PaymentInId"); + + b.HasIndex("ShipmentId"); + + b.ToTable("OrderTaxDetail", (string)null); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.AddressEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Addresses") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Addresses") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Addresses") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany() + .HasForeignKey("CustomerOrderId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "Payment") + .WithMany("Captures") + .HasForeignKey("PaymentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("Payment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", "Capture") + .WithMany("Items") + .HasForeignKey("CaptureId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("CaptureItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Capture"); + + b.Navigation("LineItem"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ConfigurationItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("ConfigurationItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("LineItem"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.DiscountEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Discounts") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("Discounts") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Discounts") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Discounts") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.FeeDetailEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("FeeDetails") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("FeeDetails") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("FeeDetails") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("FeeDetails") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Items") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.OrderDynamicPropertyObjectValueEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", "Capture") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("CaptureId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", "Refund") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("RefundId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("DynamicPropertyObjectValues") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Capture"); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Refund"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentGatewayTransactionEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("Transactions") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PaymentIn"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("InPayments") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("InPayments") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("CustomerOrder"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany() + .HasForeignKey("CustomerOrderId"); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "Payment") + .WithMany("Refunds") + .HasForeignKey("PaymentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("Payment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("RefundItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", "Refund") + .WithMany("Items") + .HasForeignKey("RefundId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("LineItem"); + + b.Navigation("Refund"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("Shipments") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomerOrder"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentItemEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("ShipmentItems") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Items") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", "ShipmentPackage") + .WithMany("Items") + .HasForeignKey("ShipmentPackageId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("LineItem"); + + b.Navigation("Shipment"); + + b.Navigation("ShipmentPackage"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("Packages") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.TaxDetailEntity", b => + { + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", "CustomerOrder") + .WithMany("TaxDetails") + .HasForeignKey("CustomerOrderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", "LineItem") + .WithMany("TaxDetails") + .HasForeignKey("LineItemId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", "PaymentIn") + .WithMany("TaxDetails") + .HasForeignKey("PaymentInId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", "Shipment") + .WithMany("TaxDetails") + .HasForeignKey("ShipmentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("CustomerOrder"); + + b.Navigation("LineItem"); + + b.Navigation("PaymentIn"); + + b.Navigation("Shipment"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CaptureEntity", b => + { + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("Items"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.CustomerOrderEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("InPayments"); + + b.Navigation("Items"); + + b.Navigation("Shipments"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.LineItemEntity", b => + { + b.Navigation("CaptureItems"); + + b.Navigation("ConfigurationItems"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("RefundItems"); + + b.Navigation("ShipmentItems"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.PaymentInEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Captures"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("Refunds"); + + b.Navigation("TaxDetails"); + + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.RefundEntity", b => + { + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("Items"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentEntity", b => + { + b.Navigation("Addresses"); + + b.Navigation("Discounts"); + + b.Navigation("DynamicPropertyObjectValues"); + + b.Navigation("FeeDetails"); + + b.Navigation("InPayments"); + + b.Navigation("Items"); + + b.Navigation("Packages"); + + b.Navigation("TaxDetails"); + }); + + modelBuilder.Entity("VirtoCommerce.OrdersModule.Data.Model.ShipmentPackageEntity", b => + { + b.Navigation("Items"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/20241205094527_AddIsDiscountAmountRounded.cs b/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/20241205094527_AddIsDiscountAmountRounded.cs new file mode 100644 index 00000000..febed786 --- /dev/null +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/20241205094527_AddIsDiscountAmountRounded.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VirtoCommerce.OrdersModule.Data.SqlServer.Migrations +{ + /// + public partial class AddIsDiscountAmountRounded : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsDiscountAmountRounded", + table: "OrderLineItem", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDiscountAmountRounded", + table: "OrderLineItem"); + } + } +} diff --git a/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/OrderDbContextModelSnapshot.cs b/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/OrderDbContextModelSnapshot.cs index db9db2a5..3aa5461b 100644 --- a/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/OrderDbContextModelSnapshot.cs +++ b/src/VirtoCommerce.OrdersModule.Data.SqlServer/Migrations/OrderDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "8.0.11") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -709,6 +709,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsConfigured") .HasColumnType("bit"); + b.Property("IsDiscountAmountRounded") + .HasColumnType("bit"); + b.Property("IsGift") .HasColumnType("bit"); diff --git a/src/VirtoCommerce.OrdersModule.Data/Model/LineItemEntity.cs b/src/VirtoCommerce.OrdersModule.Data/Model/LineItemEntity.cs index b4fad3c3..309402b2 100644 --- a/src/VirtoCommerce.OrdersModule.Data/Model/LineItemEntity.cs +++ b/src/VirtoCommerce.OrdersModule.Data/Model/LineItemEntity.cs @@ -25,6 +25,7 @@ public class LineItemEntity : AuditableEntity, IHasOuterId public decimal PriceWithTax { get; set; } [Column(TypeName = "Money")] public decimal DiscountAmount { get; set; } + public bool IsDiscountAmountRounded { get; set; } [Column(TypeName = "Money")] public decimal DiscountAmountWithTax { get; set; } [Column(TypeName = "Money")] @@ -160,6 +161,7 @@ public virtual LineItem ToModel(LineItem lineItem) lineItem.Price = Price; lineItem.PriceWithTax = PriceWithTax; lineItem.DiscountAmount = DiscountAmount; + lineItem.IsDiscountAmountRounded = IsDiscountAmountRounded; lineItem.DiscountAmountWithTax = DiscountAmountWithTax; lineItem.Quantity = Quantity; lineItem.TaxTotal = TaxTotal; @@ -234,6 +236,7 @@ public virtual LineItemEntity FromModel(LineItem lineItem, PrimaryKeyResolvingMa Price = lineItem.Price; PriceWithTax = lineItem.PriceWithTax; DiscountAmount = lineItem.DiscountAmount; + IsDiscountAmountRounded = lineItem.IsDiscountAmountRounded; DiscountAmountWithTax = lineItem.DiscountAmountWithTax; Fee = lineItem.Fee; FeeWithTax = lineItem.FeeWithTax; @@ -318,6 +321,7 @@ public virtual void Patch(LineItemEntity target) target.FulfillmentCenterName = FulfillmentCenterName; target.VendorId = VendorId; target.IsConfigured = IsConfigured; + target.IsDiscountAmountRounded = IsDiscountAmountRounded; // Patch prices if there are non 0 prices in the patching entity, or all patched entity prices are 0 var isNeedPatch = GetNonCalculatablePrices().Any(x => x != 0m) || target.GetNonCalculatablePrices().All(x => x == 0m); diff --git a/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderBuilder.cs b/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderBuilder.cs index 607c56cc..90dd2bf0 100644 --- a/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderBuilder.cs +++ b/src/VirtoCommerce.OrdersModule.Data/Services/CustomerOrderBuilder.cs @@ -269,6 +269,7 @@ protected virtual LineItem ToOrderModel(CartModule.Core.Model.LineItem lineItem) retVal.FeeWithTax = lineItem.FeeWithTax; retVal.DiscountAmount = lineItem.DiscountAmount; + retVal.IsDiscountAmountRounded = lineItem.IsDiscountAmountRounded; retVal.Price = lineItem.ListPrice; retVal.FulfillmentLocationCode = lineItem.FulfillmentLocationCode; diff --git a/src/VirtoCommerce.OrdersModule.Data/Services/DefaultCustomerOrderTotalsCalculator.cs b/src/VirtoCommerce.OrdersModule.Data/Services/DefaultCustomerOrderTotalsCalculator.cs index 0584d2e0..b5c4fd77 100644 --- a/src/VirtoCommerce.OrdersModule.Data/Services/DefaultCustomerOrderTotalsCalculator.cs +++ b/src/VirtoCommerce.OrdersModule.Data/Services/DefaultCustomerOrderTotalsCalculator.cs @@ -70,8 +70,8 @@ public virtual void CalculateTotals(CustomerOrder order) if (order.Items != null) { - order.SubTotal = order.Items.Sum(x => x.Price * x.Quantity); - order.SubTotalWithTax = order.Items.Sum(x => x.PriceWithTax * x.Quantity); + order.SubTotal = order.Items.Sum(x => x.ListTotal); + order.SubTotalWithTax = order.Items.Sum(x => x.ListTotalWithTax); order.SubTotalTaxTotal += order.Items.Sum(x => x.TaxTotal); order.SubTotalDiscount = order.Items.Sum(x => x.DiscountTotal); order.SubTotalDiscountWithTax = order.Items.Sum(x => x.DiscountTotalWithTax); @@ -200,20 +200,26 @@ protected virtual void CalculateShipmentTotals(Shipment shipment) protected virtual void CalculateLineItemTotals(LineItem lineItem) { - if (lineItem == null) - { - throw new ArgumentNullException(nameof(lineItem)); - } + ArgumentNullException.ThrowIfNull(lineItem); + + var quantity = Math.Max(1, lineItem.Quantity); + var currency = _currencyService.GetAllCurrenciesAsync().GetAwaiter().GetResult().First(c => c.Code == lineItem.Currency); + + lineItem.ListTotal = lineItem.Price * quantity; + lineItem.PlacedPrice = lineItem.Price - lineItem.DiscountAmount; + lineItem.DiscountTotal = currency.RoundingPolicy.RoundMoney(lineItem.DiscountAmount * quantity, currency); + lineItem.ExtendedPrice = lineItem.ListTotal - lineItem.DiscountTotal; + var taxFactor = 1 + lineItem.TaxPercentRate; + lineItem.PriceWithTax = lineItem.Price * taxFactor; - lineItem.PlacedPrice = lineItem.Price - lineItem.DiscountAmount; - lineItem.ExtendedPrice = lineItem.PlacedPrice * lineItem.Quantity; + lineItem.ListTotalWithTax = lineItem.ListTotal * taxFactor; + lineItem.PlacedPriceWithTax = lineItem.PlacedPrice * taxFactor; + lineItem.ExtendedPriceWithTax = lineItem.ExtendedPrice * taxFactor; lineItem.DiscountAmountWithTax = lineItem.DiscountAmount * taxFactor; - lineItem.DiscountTotal = lineItem.DiscountAmount * Math.Max(1, lineItem.Quantity); + lineItem.DiscountTotalWithTax = lineItem.DiscountTotal * taxFactor; lineItem.FeeWithTax = lineItem.Fee * taxFactor; - lineItem.PlacedPriceWithTax = lineItem.PlacedPrice * taxFactor; - lineItem.ExtendedPriceWithTax = lineItem.PlacedPriceWithTax * lineItem.Quantity; - lineItem.DiscountTotalWithTax = lineItem.DiscountAmountWithTax * Math.Max(1, lineItem.Quantity); + lineItem.TaxTotal = lineItem.ExtendedPrice * lineItem.TaxPercentRate; } } diff --git a/src/VirtoCommerce.OrdersModule.Web/module.manifest b/src/VirtoCommerce.OrdersModule.Web/module.manifest index 3c8915fc..f61b6fcf 100644 --- a/src/VirtoCommerce.OrdersModule.Web/module.manifest +++ b/src/VirtoCommerce.OrdersModule.Web/module.manifest @@ -1,12 +1,12 @@ VirtoCommerce.Orders - 3.837.0 + 3.838.0 3.867.0 - + diff --git a/tests/VirtoCommerce.OrdersModule.Tests/OrderTotalsCalculationTest.cs b/tests/VirtoCommerce.OrdersModule.Tests/OrderTotalsCalculationTest.cs index 5ac1d95b..7804c627 100644 --- a/tests/VirtoCommerce.OrdersModule.Tests/OrderTotalsCalculationTest.cs +++ b/tests/VirtoCommerce.OrdersModule.Tests/OrderTotalsCalculationTest.cs @@ -1,15 +1,80 @@ +using System; using System.Collections.Generic; using Moq; +using VirtoCommerce.CoreModule.Core.Common; using VirtoCommerce.CoreModule.Core.Currency; using VirtoCommerce.OrdersModule.Core.Model; using VirtoCommerce.OrdersModule.Data.Services; using Xunit; +using LineItem = VirtoCommerce.OrdersModule.Core.Model.LineItem; +using Shipment = VirtoCommerce.OrdersModule.Core.Model.Shipment; namespace VirtoCommerce.OrdersModule.Tests { [Trait("Category", "CI")] public class OrderTotalsCalculationTest { + public static IEnumerable Data => + [ + // Expected Expected Expected + // MidpointRounding, ListPrice, DiscountAmount, Quantity, SubTotal, DiscountTotal, Total + [MidpointRounding.AwayFromZero, 49.95m, 4.9950m, 1, 49.95m, 5.00m, 44.95m], + [MidpointRounding.ToZero, 49.95m, 4.9950m, 1, 49.95m, 4.99m, 44.96m], + [MidpointRounding.AwayFromZero, 26.25m, 1.3125m, 1, 26.25m, 1.31m, 24.94m], + [MidpointRounding.ToZero, 26.25m, 1.3125m, 1, 26.25m, 1.31m, 24.94m], + [MidpointRounding.AwayFromZero, 26.25m, 1.3125m, 3, 78.75m, 3.94m, 74.81m], + [MidpointRounding.ToZero, 26.25m, 1.3125m, 3, 78.75m, 3.93m, 74.82m], + [MidpointRounding.AwayFromZero, 422.50m, 190.1250m, 1, 422.50m, 190.13m, 232.37m], + [MidpointRounding.ToZero, 422.50m, 190.1250m, 1, 422.50m, 190.12m, 232.38m], + [MidpointRounding.AwayFromZero, 422.50m, 190.1250m, 10, 4225.00m, 1901.25m, 2323.75m], + [MidpointRounding.ToZero, 422.50m, 190.1250m, 10, 4225.00m, 1901.25m, 2323.75m], + ]; + + [Theory] + [MemberData(nameof(Data))] + public void CalculateTotals_LineItemDiscountTotal_MustBeRounded( + MidpointRounding midpointRounding, + decimal listPrice, + decimal discountAmount, + int quantity, + decimal expectedSubTotal, + decimal expectedDiscountTotal, + decimal expectedTotal) + { + // Arrange + var lineItem = new LineItem + { + Price = listPrice, + DiscountAmount = discountAmount, + Quantity = quantity, + }; + + var order = new CustomerOrder + { + Items = [lineItem], + }; + + var currency = new Currency(new Language("en-US"), code: null) + { + MidpointRounding = midpointRounding.ToString(), + RoundingPolicy = new DefaultMoneyRoundingPolicy() + }; + + var totalsCalculator = GetTotalsCalculator(currency); + + // Act + totalsCalculator.CalculateTotals(order); + + // Assert + Assert.Equal(expectedSubTotal, order.SubTotal); + Assert.Equal(expectedDiscountTotal, order.DiscountTotal); + Assert.Equal(expectedTotal, order.Total); + + Assert.Equal(expectedSubTotal, lineItem.ListTotal); + Assert.Equal(expectedDiscountTotal, lineItem.DiscountTotal); + Assert.Equal(expectedTotal, lineItem.ExtendedPrice); + } + private DefaultCustomerOrderTotalsCalculator GetTotalsCalculator(Currency currency) { var currencyServiceMock = new Mock();