-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathShipment.cs
More file actions
179 lines (143 loc) · 6 KB
/
Shipment.cs
File metadata and controls
179 lines (143 loc) · 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using System;
using System.Collections.Generic;
using System.Linq;
using VirtoCommerce.CoreModule.Core.Common;
using VirtoCommerce.CoreModule.Core.Tax;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.Swagger;
using VirtoCommerce.ShippingModule.Core.Model;
namespace VirtoCommerce.OrdersModule.Core.Model
{
[SwaggerSchemaId("OrderShipment")]
public class Shipment : OrderOperation, IHasTaxDetalization, ISupportCancellation, ITaxable, IHasDiscounts, ICloneable, IHasFeesDetalization
{
public string OrganizationId { get; set; }
public string OrganizationName { get; set; }
public string FulfillmentCenterId { get; set; }
public string FulfillmentCenterName { get; set; }
public string EmployeeId { get; set; }
public string EmployeeName { get; set; }
/// <summary>
/// Current shipment method code
/// </summary>
public string ShipmentMethodCode { get; set; }
/// <summary>
/// Current shipment option code
/// </summary>
public string ShipmentMethodOption { get; set; }
/// <summary>
/// Shipment method contains additional shipment method information
/// </summary>
public ShippingMethod ShippingMethod { get; set; }
public string CustomerOrderId { get; set; }
public CustomerOrder CustomerOrder { get; set; }
public ICollection<ShipmentItem> Items { get; set; }
public ICollection<ShipmentPackage> Packages { get; set; }
public ICollection<PaymentIn> InPayments { get; set; }
public ICollection<FeeDetail> FeeDetails { get; set; }
[Auditable]
public string WeightUnit { get; set; }
[Auditable]
public decimal? Weight { get; set; }
[Auditable]
public string MeasureUnit { get; set; }
[Auditable]
public decimal? Height { get; set; }
[Auditable]
public decimal? Length { get; set; }
[Auditable]
public decimal? Width { get; set; }
#region IHasDiscounts
public ICollection<Discount> Discounts { get; set; }
#endregion
public Address DeliveryAddress { get; set; }
public virtual decimal Price { get; set; }
public virtual decimal PriceWithTax { get; set; }
[Auditable]
public virtual decimal Total { get; set; }
public virtual decimal TotalWithTax { get; set; }
[Auditable]
public virtual decimal DiscountAmount { get; set; }
public virtual decimal DiscountAmountWithTax { get; set; }
public string PickupLocationId { get; set; }
//Any extra Fee
[Auditable]
public virtual decimal Fee { get; set; }
public virtual decimal FeeWithTax { get; set; }
/// <summary>
/// Tracking information
/// </summary>
public string TrackingNumber { get; set; }
public string TrackingUrl { get; set; }
public DateTime? DeliveryDate { get; set; }
public override string ObjectType { get; set; } = typeof(Shipment).FullName;
public string VendorId { get; set; }
#region ITaxable Members
/// <summary>
/// Tax category or type
/// </summary>
[Auditable]
public string TaxType { get; set; }
[Auditable]
public decimal TaxTotal { get; set; }
[Auditable]
public decimal TaxPercentRate { get; set; }
#endregion
#region ITaxDetailSupport Members
public ICollection<TaxDetail> TaxDetails { get; set; }
#endregion
public virtual void ReduceDetails(string responseGroup)
{
//Reduce details according to response group
var orderResponseGroup = EnumUtility.SafeParseFlags(responseGroup, CustomerOrderResponseGroup.Full);
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithAddresses))
{
DeliveryAddress = null;
}
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithDiscounts))
{
Discounts = null;
}
if (!orderResponseGroup.HasFlag(CustomerOrderResponseGroup.WithPrices))
{
Price = 0m;
PriceWithTax = 0m;
DiscountAmount = 0m;
DiscountAmountWithTax = 0m;
Total = 0m;
TotalWithTax = 0m;
TaxTotal = 0m;
TaxPercentRate = 0m;
Sum = 0m;
}
}
public virtual void RestoreDetails(Shipment shipment)
{
Price = shipment.Price;
PriceWithTax = shipment.PriceWithTax;
DiscountAmount = shipment.DiscountAmount;
DiscountAmountWithTax = shipment.DiscountAmountWithTax;
Total = shipment.Total;
TotalWithTax = shipment.TotalWithTax;
TaxTotal = shipment.TaxTotal;
TaxPercentRate = shipment.TaxPercentRate;
Sum = shipment.Sum;
}
#region ICloneable members
public override object Clone()
{
var result = base.Clone() as Shipment;
result.DeliveryAddress = DeliveryAddress?.Clone() as Address;
result.ShippingMethod = ShippingMethod?.Clone() as ShippingMethod;
result.CustomerOrder = CustomerOrder?.Clone() as CustomerOrder;
result.Items = Items?.Select(x => x.Clone()).OfType<ShipmentItem>().ToList();
result.Packages = Packages?.Select(x => x.Clone()).OfType<ShipmentPackage>().ToList();
result.InPayments = InPayments?.Select(x => x.Clone()).OfType<PaymentIn>().ToList();
result.Discounts = Discounts?.Select(x => x.Clone()).OfType<Discount>().ToList();
result.TaxDetails = TaxDetails?.Select(x => x.Clone()).OfType<TaxDetail>().ToList();
result.FeeDetails = FeeDetails?.Select(x => x.Clone()).OfType<FeeDetail>().ToList();
return result;
}
#endregion
}
}