add vat value in save order endpoint
This commit is contained in:
parent
e9500278cd
commit
399590a904
|
|
@ -28,6 +28,7 @@ public class SaveOrderRequest
|
||||||
public string FocCode { get; set; }
|
public string FocCode { get; set; }
|
||||||
public decimal FocValue { get; set; }
|
public decimal FocValue { get; set; }
|
||||||
public decimal DiscountValue { get; set; }
|
public decimal DiscountValue { get; set; }
|
||||||
|
public decimal? TotalVatValue { get; set; }
|
||||||
public decimal GrossValue { get; set; }
|
public decimal GrossValue { get; set; }
|
||||||
public decimal NetValue { get; set; }
|
public decimal NetValue { get; set; }
|
||||||
public OrderStatusEnum OrderStatus { get; set; }
|
public OrderStatusEnum OrderStatus { get; set; }
|
||||||
|
|
@ -51,6 +52,7 @@ public class SaveOrderItemRequest
|
||||||
public decimal DiscountAmount { get; set; }
|
public decimal DiscountAmount { get; set; }
|
||||||
public bool IsFocItem { get; set; }
|
public bool IsFocItem { get; set; }
|
||||||
public decimal LineTotalValue { get; set; }
|
public decimal LineTotalValue { get; set; }
|
||||||
|
public decimal? VatValue { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SaveOrderPromotionRequest
|
public class SaveOrderPromotionRequest
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public class GetSalesOrderResponse
|
||||||
public string FocCode { get; set; }
|
public string FocCode { get; set; }
|
||||||
public decimal DiscountValue { get; set; }
|
public decimal DiscountValue { get; set; }
|
||||||
public decimal GrossValue { get; set; }
|
public decimal GrossValue { get; set; }
|
||||||
|
public decimal? TotalVatValue { get; set; }
|
||||||
public decimal NetValue { get; set; }
|
public decimal NetValue { get; set; }
|
||||||
public int OrderStatus { get; set; }
|
public int OrderStatus { get; set; }
|
||||||
|
|
||||||
|
|
@ -58,6 +59,7 @@ public class GetSalesOrderItemResponse
|
||||||
public decimal? ApprovedQuantity { get; set; }
|
public decimal? ApprovedQuantity { get; set; }
|
||||||
public decimal? DiscountPercentage { get; set; }
|
public decimal? DiscountPercentage { get; set; }
|
||||||
public decimal? DiscountAmount { get; set; }
|
public decimal? DiscountAmount { get; set; }
|
||||||
|
public decimal? VatValue { get; set; }
|
||||||
public bool IsFocItem { get; set; }
|
public bool IsFocItem { get; set; }
|
||||||
public decimal LineTotalValue { get; set; }
|
public decimal LineTotalValue { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,22 +74,22 @@ public class OrderService : IOrderService
|
||||||
item.OrderId = request.OrderId;
|
item.OrderId = request.OrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
var materialStock = await _httpService.GetMaterialStockAsync(request.PlantCode);
|
//var materialStock = await _httpService.GetMaterialStockAsync(request.PlantCode);
|
||||||
if(materialStock is null || materialStock?.Count==0)
|
//if(materialStock is null || materialStock?.Count==0)
|
||||||
{
|
//{
|
||||||
throw new Exception($"Material Stocks not found against this Plant Code-{request.PlantCode}");
|
// throw new Exception($"Material Stocks not found against this Plant Code-{request.PlantCode}");
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
foreach (var item in request.Items)
|
//foreach (var item in request.Items)
|
||||||
{
|
//{
|
||||||
decimal currentStock = materialStock.FirstOrDefault(x => x.MaterialCode == item.MaterialCode)?.AvailableStock ?? 0;
|
// decimal currentStock = materialStock.FirstOrDefault(x => x.MaterialCode == item.MaterialCode)?.AvailableStock ?? 0;
|
||||||
|
|
||||||
if(currentStock<item.ApprovedQuantity)
|
// if(currentStock<item.ApprovedQuantity)
|
||||||
{
|
// {
|
||||||
throw new Exception($"Insufficient stock is available for Material Code '{item.MaterialCode}' in Plant Code '{request.PlantCode}'.");
|
// throw new Exception($"Insufficient stock is available for Material Code '{item.MaterialCode}' in Plant Code '{request.PlantCode}'.");
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
// 2. Insert vs update decision
|
// 2. Insert vs update decision
|
||||||
|
|
@ -552,6 +552,7 @@ public class OrderService : IOrderService
|
||||||
table.Columns.Add("DiscountAmount", typeof(decimal));
|
table.Columns.Add("DiscountAmount", typeof(decimal));
|
||||||
table.Columns.Add("IsFocItem", typeof(bool));
|
table.Columns.Add("IsFocItem", typeof(bool));
|
||||||
table.Columns.Add("LineTotalValue", typeof(decimal));
|
table.Columns.Add("LineTotalValue", typeof(decimal));
|
||||||
|
table.Columns.Add("VatValue", typeof(decimal));
|
||||||
table.Columns.Add("OrderStatus", typeof(int));
|
table.Columns.Add("OrderStatus", typeof(int));
|
||||||
|
|
||||||
foreach (SaveOrderItemRequest item in items)
|
foreach (SaveOrderItemRequest item in items)
|
||||||
|
|
@ -574,6 +575,7 @@ public class OrderService : IOrderService
|
||||||
item.DiscountAmount,
|
item.DiscountAmount,
|
||||||
item.IsFocItem,
|
item.IsFocItem,
|
||||||
item.LineTotalValue,
|
item.LineTotalValue,
|
||||||
|
item.VatValue,
|
||||||
orderStatus);
|
orderStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -652,11 +654,12 @@ public class OrderService : IOrderService
|
||||||
SqlHelperExtension.CreateInParam(pName: "@EmployeeCode", pType: SqlDbType.VarChar, pValue: request.EmployeeCode ),
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeCode", pType: SqlDbType.VarChar, pValue: request.EmployeeCode ),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@EmployeeName", pType: SqlDbType.VarChar, pValue: request.EmployeeCode ),
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeName", pType: SqlDbType.VarChar, pValue: request.EmployeeCode ),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@PaymentTermCode", pType: SqlDbType.VarChar, pValue: request.PaymentTermCode),
|
SqlHelperExtension.CreateInParam(pName: "@PaymentTermCode", pType: SqlDbType.VarChar, pValue: request.PaymentTermCode),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@DiscountCode", pType: SqlDbType.VarChar, pValue: request.DiscountCode),
|
SqlHelperExtension.CreateInParam(pName: "@DiscountCode", pType: SqlDbType.VarChar, pValue: request.DiscountCode),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@FOCCode", pType: SqlDbType.VarChar, pValue: request.FocCode),
|
SqlHelperExtension.CreateInParam(pName: "@FOCCode", pType: SqlDbType.VarChar, pValue: request.FocCode),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@ReferenceTxtNo", pType: SqlDbType.VarChar, pValue: request.ReferenceTxtNo ),
|
SqlHelperExtension.CreateInParam(pName: "@ReferenceTxtNo", pType: SqlDbType.VarChar, pValue: request.ReferenceTxtNo ),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@GrossValue", pType: SqlDbType.Decimal, pValue: request.GrossValue),
|
SqlHelperExtension.CreateInParam(pName: "@GrossValue", pType: SqlDbType.Decimal, pValue: request.GrossValue),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@DiscountValue", pType: SqlDbType.Decimal, pValue: request.DiscountValue),
|
SqlHelperExtension.CreateInParam(pName: "@DiscountValue", pType: SqlDbType.Decimal, pValue: request.DiscountValue),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@TotalVatValue", pType: SqlDbType.VarChar, pValue: request.TotalVatValue),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@FOCValue", pType: SqlDbType.Decimal, pValue: request.FocCode),
|
SqlHelperExtension.CreateInParam(pName: "@FOCValue", pType: SqlDbType.Decimal, pValue: request.FocCode),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@NetValue", pType: SqlDbType.Decimal, pValue: request.NetValue),
|
SqlHelperExtension.CreateInParam(pName: "@NetValue", pType: SqlDbType.Decimal, pValue: request.NetValue),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@OrderStatus", pType: SqlDbType.Int, pValue: (int)request.OrderStatus),
|
SqlHelperExtension.CreateInParam(pName: "@OrderStatus", pType: SqlDbType.Int, pValue: (int)request.OrderStatus),
|
||||||
|
|
@ -707,6 +710,7 @@ public class OrderService : IOrderService
|
||||||
SqlHelperExtension.CreateInParam(pName: "@ReferenceTxtNo", pType: SqlDbType.VarChar, pValue: request.ReferenceTxtNo ),
|
SqlHelperExtension.CreateInParam(pName: "@ReferenceTxtNo", pType: SqlDbType.VarChar, pValue: request.ReferenceTxtNo ),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@GrossValue", pType: SqlDbType.Decimal, pValue: request.GrossValue),
|
SqlHelperExtension.CreateInParam(pName: "@GrossValue", pType: SqlDbType.Decimal, pValue: request.GrossValue),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@DiscountValue", pType: SqlDbType.Decimal, pValue: request.DiscountValue),
|
SqlHelperExtension.CreateInParam(pName: "@DiscountValue", pType: SqlDbType.Decimal, pValue: request.DiscountValue),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@TotalVatValue", pType: SqlDbType.VarChar, pValue: request.TotalVatValue),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@FOCValue", pType: SqlDbType.Decimal, pValue: request.FocCode),
|
SqlHelperExtension.CreateInParam(pName: "@FOCValue", pType: SqlDbType.Decimal, pValue: request.FocCode),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@NetValue", pType: SqlDbType.Decimal, pValue: request.NetValue),
|
SqlHelperExtension.CreateInParam(pName: "@NetValue", pType: SqlDbType.Decimal, pValue: request.NetValue),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@OrderStatus", pType: SqlDbType.Int, pValue: (int)request.OrderStatus),
|
SqlHelperExtension.CreateInParam(pName: "@OrderStatus", pType: SqlDbType.Int, pValue: (int)request.OrderStatus),
|
||||||
|
|
@ -772,7 +776,8 @@ public class OrderService : IOrderService
|
||||||
DiscountValue = dr.GetDecimal(12),
|
DiscountValue = dr.GetDecimal(12),
|
||||||
GrossValue = dr.GetDecimal(13),
|
GrossValue = dr.GetDecimal(13),
|
||||||
NetValue = dr.GetDecimal(14),
|
NetValue = dr.GetDecimal(14),
|
||||||
OrderStatus = dr.GetInt32(15)
|
OrderStatus = dr.GetInt32(15),
|
||||||
|
TotalVatValue = dr.IsDBNull(17)? null: dr.GetDecimal(17)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -796,7 +801,8 @@ public class OrderService : IOrderService
|
||||||
DiscountPercentage = dr.IsDBNull(10) ? null : dr.GetDecimal(10),
|
DiscountPercentage = dr.IsDBNull(10) ? null : dr.GetDecimal(10),
|
||||||
DiscountAmount = dr.IsDBNull(11) ? null : dr.GetDecimal(11),
|
DiscountAmount = dr.IsDBNull(11) ? null : dr.GetDecimal(11),
|
||||||
IsFocItem = dr.GetInt32(12) > 0,
|
IsFocItem = dr.GetInt32(12) > 0,
|
||||||
LineTotalValue = dr.GetDecimal(13)
|
LineTotalValue = dr.GetDecimal(13),
|
||||||
|
VatValue = dr.IsDBNull(14) ? null : dr.GetDecimal(14)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user