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 decimal FocValue { get; set; }
|
||||
public decimal DiscountValue { get; set; }
|
||||
public decimal? TotalVatValue { get; set; }
|
||||
public decimal GrossValue { get; set; }
|
||||
public decimal NetValue { get; set; }
|
||||
public OrderStatusEnum OrderStatus { get; set; }
|
||||
|
|
@ -51,6 +52,7 @@ public class SaveOrderItemRequest
|
|||
public decimal DiscountAmount { get; set; }
|
||||
public bool IsFocItem { get; set; }
|
||||
public decimal LineTotalValue { get; set; }
|
||||
public decimal? VatValue { get; set; }
|
||||
}
|
||||
|
||||
public class SaveOrderPromotionRequest
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public class GetSalesOrderResponse
|
|||
public string FocCode { get; set; }
|
||||
public decimal DiscountValue { get; set; }
|
||||
public decimal GrossValue { get; set; }
|
||||
public decimal? TotalVatValue { get; set; }
|
||||
public decimal NetValue { get; set; }
|
||||
public int OrderStatus { get; set; }
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ public class GetSalesOrderItemResponse
|
|||
public decimal? ApprovedQuantity { get; set; }
|
||||
public decimal? DiscountPercentage { get; set; }
|
||||
public decimal? DiscountAmount { get; set; }
|
||||
public decimal? VatValue { get; set; }
|
||||
public bool IsFocItem { get; set; }
|
||||
public decimal LineTotalValue { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,22 +74,22 @@ public class OrderService : IOrderService
|
|||
item.OrderId = request.OrderId;
|
||||
}
|
||||
|
||||
var materialStock = await _httpService.GetMaterialStockAsync(request.PlantCode);
|
||||
if(materialStock is null || materialStock?.Count==0)
|
||||
{
|
||||
throw new Exception($"Material Stocks not found against this Plant Code-{request.PlantCode}");
|
||||
}
|
||||
//var materialStock = await _httpService.GetMaterialStockAsync(request.PlantCode);
|
||||
//if(materialStock is null || materialStock?.Count==0)
|
||||
//{
|
||||
// throw new Exception($"Material Stocks not found against this Plant Code-{request.PlantCode}");
|
||||
//}
|
||||
|
||||
|
||||
foreach (var item in request.Items)
|
||||
{
|
||||
decimal currentStock = materialStock.FirstOrDefault(x => x.MaterialCode == item.MaterialCode)?.AvailableStock ?? 0;
|
||||
//foreach (var item in request.Items)
|
||||
//{
|
||||
// decimal currentStock = materialStock.FirstOrDefault(x => x.MaterialCode == item.MaterialCode)?.AvailableStock ?? 0;
|
||||
|
||||
if(currentStock<item.ApprovedQuantity)
|
||||
{
|
||||
throw new Exception($"Insufficient stock is available for Material Code '{item.MaterialCode}' in Plant Code '{request.PlantCode}'.");
|
||||
}
|
||||
}
|
||||
// if(currentStock<item.ApprovedQuantity)
|
||||
// {
|
||||
// throw new Exception($"Insufficient stock is available for Material Code '{item.MaterialCode}' in Plant Code '{request.PlantCode}'.");
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
// 2. Insert vs update decision
|
||||
|
|
@ -552,6 +552,7 @@ public class OrderService : IOrderService
|
|||
table.Columns.Add("DiscountAmount", typeof(decimal));
|
||||
table.Columns.Add("IsFocItem", typeof(bool));
|
||||
table.Columns.Add("LineTotalValue", typeof(decimal));
|
||||
table.Columns.Add("VatValue", typeof(decimal));
|
||||
table.Columns.Add("OrderStatus", typeof(int));
|
||||
|
||||
foreach (SaveOrderItemRequest item in items)
|
||||
|
|
@ -574,6 +575,7 @@ public class OrderService : IOrderService
|
|||
item.DiscountAmount,
|
||||
item.IsFocItem,
|
||||
item.LineTotalValue,
|
||||
item.VatValue,
|
||||
orderStatus);
|
||||
}
|
||||
|
||||
|
|
@ -657,6 +659,7 @@ public class OrderService : IOrderService
|
|||
SqlHelperExtension.CreateInParam(pName: "@ReferenceTxtNo", pType: SqlDbType.VarChar, pValue: request.ReferenceTxtNo ),
|
||||
SqlHelperExtension.CreateInParam(pName: "@GrossValue", pType: SqlDbType.Decimal, pValue: request.GrossValue),
|
||||
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: "@NetValue", pType: SqlDbType.Decimal, pValue: request.NetValue),
|
||||
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: "@GrossValue", pType: SqlDbType.Decimal, pValue: request.GrossValue),
|
||||
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: "@NetValue", pType: SqlDbType.Decimal, pValue: request.NetValue),
|
||||
SqlHelperExtension.CreateInParam(pName: "@OrderStatus", pType: SqlDbType.Int, pValue: (int)request.OrderStatus),
|
||||
|
|
@ -772,7 +776,8 @@ public class OrderService : IOrderService
|
|||
DiscountValue = dr.GetDecimal(12),
|
||||
GrossValue = dr.GetDecimal(13),
|
||||
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),
|
||||
DiscountAmount = dr.IsDBNull(11) ? null : dr.GetDecimal(11),
|
||||
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