Compare commits
2 Commits
8bf59da423
...
376af6828e
| Author | SHA1 | Date | |
|---|---|---|---|
| 376af6828e | |||
| b094c7ca75 |
|
|
@ -736,4 +736,5 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models
|
|||
[Description("SAP User")]
|
||||
SapUser = 4 ,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -169,3 +169,11 @@ public class GetFOCMaterialRequest : PagedRequest
|
|||
public string? FOCCode { get; set; }
|
||||
}
|
||||
|
||||
public class GetPaymentTermRequest : PagedRequest
|
||||
{
|
||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||
public string SalesOrgCode { get; set; }
|
||||
|
||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "PayementTerm Code must be between 3 and 10 characters.")]
|
||||
public string? PayementTermCode { get; set; }
|
||||
}
|
||||
|
|
@ -207,4 +207,16 @@ public class GetFOCMaterialResponse
|
|||
public string FOCUnitOfMeasurement { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class GetPaymentTermResponse
|
||||
{
|
||||
public int PaymentTermId { get; set; }
|
||||
public string PaymentTermCode { get; set; }
|
||||
public string PaymentTermDescription { get; set; }
|
||||
public string SalesOrgCode { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public string PaymentTermType { get; set; }
|
||||
}
|
||||
|
|
@ -19,4 +19,5 @@ public interface IMobileMasterDataService
|
|||
Task<PagedResult<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request);
|
||||
Task<PagedResult<GetFOCResponse>> GetFOCsAsync(GetFOCRequest request);
|
||||
Task<PagedResult<GetFOCMaterialResponse>> GetFOCMaterialsAsync(GetFOCMaterialRequest request);
|
||||
Task<PagedResult<GetPaymentTermResponse>> GetPaymentTermsAsync(GetPaymentTermRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ public class IntegrationService : IIntegrationService
|
|||
response.IsUpdated = false;
|
||||
}
|
||||
|
||||
int roleTypeId = GetRegionAreaTerritoryLevel(request);
|
||||
bool isUserExist = await IsUserExistByEmployeeNumberAsync(tc, request.EmployeeVendorCode);
|
||||
|
||||
if (!isUserExist)
|
||||
|
|
@ -164,7 +165,7 @@ public class IntegrationService : IIntegrationService
|
|||
EmailAddress = request.Mail,
|
||||
IsLocked = 0,
|
||||
Password ="12345",
|
||||
UserRoleType = request.Designation == "01"? (int)UserRoleTypeEnum.OrderCollector : null,
|
||||
UserRoleType = roleTypeId,
|
||||
UserPlatformId = (int)UserPlatFormType.AppUser,
|
||||
EmployeeNumber = request.EmployeeVendorCode
|
||||
};
|
||||
|
|
@ -191,6 +192,29 @@ public class IntegrationService : IIntegrationService
|
|||
return response;
|
||||
}
|
||||
|
||||
private int GetRegionAreaTerritoryLevel(IntegrationEmployeeRequest request)
|
||||
{
|
||||
bool hasRegion = !string.IsNullOrWhiteSpace(request.RegionAreaCode);
|
||||
bool hasArea = !string.IsNullOrWhiteSpace(request.AreaAVSalesUnitCode);
|
||||
bool hasTerritory = !string.IsNullOrWhiteSpace(request.Territory);
|
||||
|
||||
if (hasRegion && hasArea && hasTerritory)
|
||||
{
|
||||
return (int)UserRoleTypeEnum.OrderCollector;
|
||||
}
|
||||
|
||||
if (hasRegion && hasArea && !hasTerritory)
|
||||
{
|
||||
return (int)UserRoleTypeEnum.OrderValidator;
|
||||
}
|
||||
|
||||
if (hasRegion && !hasArea && !hasTerritory)
|
||||
{
|
||||
return (int)UserRoleTypeEnum.OrderApprover;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public async Task<MaterialIntegrationReqResponse> UpsertMaterialAsync(IntegrationMaterialRequest request)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -877,5 +877,59 @@ public class MobileMasterDataService : IMobileMasterDataService
|
|||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<PagedResult<GetPaymentTermResponse>> GetPaymentTermsAsync(GetPaymentTermRequest request)
|
||||
{
|
||||
PagedResult<GetPaymentTermResponse> response = new();
|
||||
try
|
||||
{
|
||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||
try
|
||||
{
|
||||
SqlParameter[] p =
|
||||
[
|
||||
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.VarChar, pValue: request.SalesOrgCode),
|
||||
SqlHelperExtension.CreateInParam(pName: "@PaymentTermCode", pType: SqlDbType.VarChar, pValue: request.PayementTermCode),
|
||||
SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber),
|
||||
SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize)
|
||||
];
|
||||
|
||||
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetPaymentTermsPaginated", parameterValues: p))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
response.Items.Add(new GetPaymentTermResponse
|
||||
{
|
||||
PaymentTermId = dr.GetInt32(0),
|
||||
PaymentTermCode = dr.GetString(1),
|
||||
PaymentTermDescription = dr.GetString(2),
|
||||
SalesOrgCode = dr.GetString(3),
|
||||
StartDate = dr.GetDateTime(4),
|
||||
EndDate = dr.GetDateTime(5),
|
||||
PaymentTermType = dr.GetString(6),
|
||||
});
|
||||
}
|
||||
dr.Close();
|
||||
|
||||
response.TotalCount = response.Items.Count;
|
||||
response.PageNumber = request.PageNumber;
|
||||
response.PageSize = request.PageSize;
|
||||
}
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception ie)
|
||||
{
|
||||
tc?.HandleError();
|
||||
|
||||
throw DBCustomError.GenerateCustomError(ie);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
|||
/// </remarks>
|
||||
/// <param name="request"></param>
|
||||
/// <response code="200">If login successful Return Attendance List</response>
|
||||
[HttpGet("MaterialFOCs")]
|
||||
[HttpGet("FOCs")]
|
||||
[IgnoreAntiforgeryToken]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetFOCResponse))]
|
||||
public async Task<IActionResult> GetMaterialFOCs([FromQuery] GetFOCRequest request)
|
||||
|
|
@ -333,5 +333,31 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
|||
return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase<AppAuthUserResponse>.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Login using your credential data retrieve from SqlServer
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// </remarks>
|
||||
/// <param name="request"></param>
|
||||
/// <response code="200">If login successful Return Attendance List</response>
|
||||
[HttpGet("PaymentTerms")]
|
||||
[IgnoreAntiforgeryToken]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetPaymentTermResponse))]
|
||||
public async Task<IActionResult> GetPaymentTerms([FromQuery] GetPaymentTermRequest request)
|
||||
{
|
||||
PagedResult<GetPaymentTermResponse> response = new();
|
||||
try
|
||||
{
|
||||
response = await _service.GetPaymentTermsAsync(request);
|
||||
return Ok(MobileResponseBase<PagedResult<GetPaymentTermResponse>>.Success(response));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string msg = $"Exception occur on Get PaymentTerms endpoint with request - {request?.SalesOrgCode} -{request?.PayementTermCode}";
|
||||
_logger.LogError(exception: ex, message: msg);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase<AppAuthUserResponse>.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user