Complete FOC for Integration
This commit is contained in:
parent
769e973f48
commit
93be7ab99c
|
|
@ -9,14 +9,14 @@ public class IntegrationMaterialFreeGoodsResponse : ResponseBase
|
||||||
public string DistributionChannel { get; set; }
|
public string DistributionChannel { get; set; }
|
||||||
public string? CustomerNumber { get; set; } // nullable
|
public string? CustomerNumber { get; set; } // nullable
|
||||||
public string? CustomerPriceGroup { get; set; }
|
public string? CustomerPriceGroup { get; set; }
|
||||||
public string MaterialCode { get; set; }
|
public string? MaterialCode { get; set; }
|
||||||
public decimal MinOrderQuantity { get; set; }
|
public decimal? MinOrderQuantity { get; set; }
|
||||||
public decimal ForQuantity { get; set; }
|
public decimal? ForQuantity { get; set; }
|
||||||
public string UnitOfMeasure { get; set; }
|
public string? UnitOfMeasure { get; set; }
|
||||||
public decimal FreeQuantity { get; set; }
|
public decimal? FreeQuantity { get; set; }
|
||||||
public string FocUnitOfMeasure { get; set; }
|
public string? FocUnitOfMeasure { get; set; }
|
||||||
public DateTime ValidFrom { get; set; }
|
public DateTime? ValidFrom { get; set; }
|
||||||
public DateTime ValidTo { get; set; }
|
public DateTime? ValidTo { get; set; }
|
||||||
public string? Status { get; set; }
|
public string? Status { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -370,32 +370,12 @@ public class IntegrationService : IIntegrationService
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime? fromValid = null;
|
IntegrationMaterialFreeGoodsResponse meterialFreeGoods = await GetMaterialFreeGoodsByRecordNoAsync(tc, request.ConditionRecNo);
|
||||||
DateTime? toValid = null;
|
|
||||||
|
|
||||||
if (request.Slabs != null && request.Slabs.Count > 0)
|
if (meterialFreeGoods != null && meterialFreeGoods.FreeGoodsId >0)
|
||||||
{
|
{
|
||||||
fromValid =request.Slabs.Max(x => x.ValidFrom);
|
DeleteMaterialFreeGoodsByRecordNoAsync(tc, request.ConditionRecNo);
|
||||||
toValid = request.Slabs.Max(x => x.ValidTo);
|
CreateMaterialFreeGoods(tc, request);
|
||||||
}
|
|
||||||
|
|
||||||
IntegrationMaterialFreeGoodsResponse meterialFreeGoods = await GetMaterialFreeGoodsByFilterAsync(tc,
|
|
||||||
new GetMaterialFreeGoodsByFilterRequest() { SalesOrg = request.SalesOrg, DistributionChannel = request.DistributionChannel,
|
|
||||||
CustomerPriceGroup = request.CustomerPriceGroup,MaterialCode = request.MaterialCode, CustomerNumber = request.CustomerNumber,
|
|
||||||
ValidFrom = fromValid, ValidTo= toValid});
|
|
||||||
|
|
||||||
InActiveMaterialFreeGoodsByFilter(tc,
|
|
||||||
new GetMaterialFreeGoodsByFilterRequest()
|
|
||||||
{
|
|
||||||
SalesOrg = request.SalesOrg,
|
|
||||||
DistributionChannel = request.DistributionChannel,
|
|
||||||
CustomerPriceGroup = request.CustomerPriceGroup,
|
|
||||||
MaterialCode = request.MaterialCode,
|
|
||||||
CustomerNumber = request.CustomerNumber
|
|
||||||
});
|
|
||||||
if (meterialFreeGoods != null && !string.IsNullOrWhiteSpace(meterialFreeGoods.MaterialCode))
|
|
||||||
{
|
|
||||||
UpdateMaterialFreeGoods(tc, request);
|
|
||||||
response.IsUpdated = true;
|
response.IsUpdated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1488,6 +1468,51 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<IntegrationMaterialFreeGoodsResponse> GetMaterialFreeGoodsByRecordNoAsync(
|
||||||
|
TransactionContext tc, int recordNo)
|
||||||
|
{
|
||||||
|
IntegrationMaterialFreeGoodsResponse response = new IntegrationMaterialFreeGoodsResponse();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionRecordNo", SqlDbType.NVarChar, recordNo),
|
||||||
|
];
|
||||||
|
|
||||||
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetAllMaterialFreeGoodsByRecordNo", parameterValues: p))
|
||||||
|
{
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
response = new IntegrationMaterialFreeGoodsResponse()
|
||||||
|
{
|
||||||
|
FreeGoodsId = dr.GetInt32(0),
|
||||||
|
SalesOrg = dr.GetString(1),
|
||||||
|
DistributionChannel = dr.GetString(2),
|
||||||
|
CustomerNumber = dr.IsDBNull(3) ? null : dr.GetString(3),
|
||||||
|
CustomerPriceGroup = dr.IsDBNull(4) ? null : dr.GetString(4),
|
||||||
|
MaterialCode = dr.IsDBNull(5) ? null : dr.GetString(5),
|
||||||
|
MinOrderQuantity = dr.IsDBNull(6) ? null : dr.GetDecimal(6),
|
||||||
|
ForQuantity = dr.IsDBNull(7) ? null : dr.GetDecimal(7),
|
||||||
|
UnitOfMeasure = dr.IsDBNull(8) ? null : dr.GetString(8),
|
||||||
|
FreeQuantity = dr.IsDBNull(9) ? null : dr.GetDecimal(9),
|
||||||
|
FocUnitOfMeasure = dr.IsDBNull(10) ? null : dr.GetString(10),
|
||||||
|
ValidFrom = dr.IsDBNull(11) ? null : dr.GetDateTime(11),
|
||||||
|
ValidTo = dr.IsDBNull(12) ? null : dr.GetDateTime(12),
|
||||||
|
Status = dr.IsDBNull(13) ? null : dr.GetString(13)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw DBCustomError.GenerateCustomError(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool DeleteMaterialFreeGoodsByFilter(
|
private bool DeleteMaterialFreeGoodsByFilter(
|
||||||
TransactionContext tc, GetMaterialFreeGoodsByFilterRequest request)
|
TransactionContext tc, GetMaterialFreeGoodsByFilterRequest request)
|
||||||
|
|
@ -1515,6 +1540,28 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool DeleteMaterialFreeGoodsByRecordNoAsync(
|
||||||
|
TransactionContext tc, int conditionRecNo)
|
||||||
|
{
|
||||||
|
bool response = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionRecNo", SqlDbType.Int, conditionRecNo)
|
||||||
|
];
|
||||||
|
_ = tc.ExecuteNonQuerySp("dbo.DeleteMaterialFOCByRecordNo", parameterValues: p);
|
||||||
|
response = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw DBCustomError.GenerateCustomError(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
private bool InActiveMaterialFreeGoodsByFilter(
|
private bool InActiveMaterialFreeGoodsByFilter(
|
||||||
TransactionContext tc, GetMaterialFreeGoodsByFilterRequest request)
|
TransactionContext tc, GetMaterialFreeGoodsByFilterRequest request)
|
||||||
{
|
{
|
||||||
|
|
@ -1564,6 +1611,7 @@ public class IntegrationService : IIntegrationService
|
||||||
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.Date, item.ValidFrom),
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.Date, item.ValidFrom),
|
||||||
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.Date, item.ValidTo),
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.Date, item.ValidTo),
|
||||||
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, item.Status),
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, item.Status),
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionRecNo", SqlDbType.Int, request.ConditionRecNo),
|
||||||
];
|
];
|
||||||
|
|
||||||
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertIntegrationMaterialFreeGoods", parameterValues: p);
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertIntegrationMaterialFreeGoods", parameterValues: p);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user