displaying button complete, incomplete in receving for finance department

This commit is contained in:
rowell_m_soriano 2026-02-09 14:53:57 +08:00
parent eb7223d47e
commit e5e4f315ac
13 changed files with 95 additions and 93 deletions

View File

@ -39,22 +39,14 @@ namespace CPRNIMS.Domain.Services.Finance
}
public async Task<List<ReceivingDetail>> GetRRDetailByPO(RRDetailsDto itemDto)
{
try
{
var allItems = await _dbContext.ReceivingDetails
.FromSqlRaw($"EXEC GetRRDetailByPO @PONo,@POTypeId,@UserId",
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
var allItems = await _dbContext.ReceivingDetails
.FromSqlRaw($"EXEC GetRRDetailByPOFinance @PONo,@POTypeId,@UserId",
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<ReceivingDetail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
return allItems ?? new List<ReceivingDetail>();
}
public async Task<RRDetail> PostPutPayment(RRDetailsDto itemDto)

View File

@ -18,6 +18,7 @@ namespace CPRNIMS.Domain.UIContracts.Account
Task<List<RegisterVM>> GetAllUserAsync(User user);
Task<List<UserRoleVM>> GetAllRoleAsync(User user);
Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user);
Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user,string token);
Task<List<string>> GetRoles(User user);
Task<List<RegisterVM>> GetUserProfileById(User user);
Task<EmailMessageDetailsVM> GetUserByEmail(string email, EmailMessageDetailsVM forgotPassword);

View File

@ -439,42 +439,31 @@ namespace CPRNIMS.Domain.UIServices.Account
// Handle token retrieval failure
return null;
}
public async Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user)
public async Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user, string token)
{
try
{
var token = await _tokenHelper.GetValidTokenAsync();
if (string.IsNullOrEmpty(token))
return null;
if (!string.IsNullOrEmpty(token))
var jsonContent = JsonSerializer.Serialize(user);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var jsonContent = JsonSerializer.Serialize(user);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
var response = await httpClient.PostAsync(_configuration["Account:GetLandingPageByUserId"], content);
if (response.IsSuccessStatusCode)
{
var response = await httpClient.PostAsync(_configuration["Account:GetLandingPageByUserId"], content);
if (response.IsSuccessStatusCode)
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myAccess = JsonSerializer.Deserialize<List<ControllerAccessVM>>(jsonResponse, options);
return myAccess;
}
else
{
// Handle API request failure
}
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myAccess = JsonSerializer.Deserialize<List<ControllerAccessVM>>(jsonResponse, options);
return myAccess;
}
}
// Handle token retrieval failure
return null;
}
catch (Exception ex)
@ -483,6 +472,17 @@ namespace CPRNIMS.Domain.UIServices.Account
throw;
}
}
public async Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user)
{
var token = await _tokenHelper.GetValidTokenAsync();
if (!string.IsNullOrEmpty(token))
{
// Call the overload
return await GetLandingPageByUserId(user, token);
}
return null;
}
public async Task<List<DepartmentVM>> GetDepartment(User user)
{
var token = await _tokenHelper.GetValidTokenAsync();

View File

@ -9,4 +9,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@ -28,34 +28,16 @@ namespace CPRNIMS.WebApi.Controllers.Finance
[HttpPost("GetAllClosedPO")]
public async Task<IActionResult> GetAllClosedPO(RRDetailsDto itemCodeDto)
{
try
{
var allPR = await _rr.GetAllClosedPO(itemCodeDto);
var allPR = await _rr.GetAllClosedPO(itemCodeDto);
return Ok(allPR);
}
catch (Exception ex)
{
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
await PostErrorMessage(message, "WebApi");
throw;
}
return Ok(allPR);
}
[HttpPost("GetRRDetailByPO")]
public async Task<IActionResult> GetRRDetailByPO(RRDetailsDto itemDto)
{
try
{
var myPR = await _rr.GetRRDetailByPO(itemDto);
var myPR = await _rr.GetRRDetailByPO(itemDto);
return Ok(myPR);
}
catch (Exception ex)
{
var message = ex.InnerException?.ToString() ?? ex.Message.ToString();
await PostErrorMessage(message, "WebApi");
throw;
}
return Ok(myPR);
}
#endregion

View File

@ -1,6 +1,5 @@
using CPRNIMS.Domain.Contracts.Items;
using CPRNIMS.Domain.Contracts.Receiving;
using CPRNIMS.Domain.Contracts.SMTP;
using CPRNIMS.Domain.Services;
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Helper;

View File

@ -6,10 +6,13 @@
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<View_SelectedScaffolderID>RazorViewEmptyScaffolder</View_SelectedScaffolderID>
<View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
<NameOfLastUsedPublishProfile>D:\sourcecode\CPRNIMS\CPRNIMS.WebApps\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
<NameOfLastUsedPublishProfile>D:\sourcecode\NonInventPurchasing\CPRNIMS.WebApps\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
<WebStackScaffolding_ViewDialogWidth>650.4</WebStackScaffolding_ViewDialogWidth>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@ -260,8 +260,7 @@ namespace CPRNIMS.WebApps.Controllers.Account
#region Views
public async Task<IActionResult> Index()
{
await IsAuthenTicated();
return View();
return await IsAuthenTicated();
}
#endregion
}

View File

@ -88,7 +88,7 @@ namespace CPRNIMS.WebApps.Controllers.Base
ViewBag.UserCompany = User.FindFirst("Company")?.Value;
ViewBag.UserRoles = string.Join(",",
User.FindAll(ClaimTypes.Role).Select(c => c.Value));
ViewBag.URLAttachment = User.FindFirst("URLAttachment")?.Value;
ViewBag.URLAttachment = User.FindFirst("URLAttachment")?.Value ?? "Content/Images/UserProfile/404userImage.jpg";
}
protected IActionResult GetResponse<T>(T response)

View File

@ -158,23 +158,6 @@ namespace CPRNIMS.WebApps.Controllers
var handler = new JwtSecurityTokenHandler();
var jwtToken = handler.ReadJwtToken(login.token);
if (login.expiresInSeconds > 0)
{
expirationTime = DateTime.UtcNow.AddSeconds(login.expiresInSeconds);
}
else if (!string.IsNullOrEmpty(login.token))
{
try
{
if (jwtToken.ValidTo > DateTime.MinValue)
{
expirationTime = jwtToken.ValidTo;
}
}
catch { }
}
var claims = new List<Claim>
{
@ -212,8 +195,19 @@ namespace CPRNIMS.WebApps.Controllers
new ClaimsPrincipal(identity),
authProperties
);
var currentUser = new Infrastructure.Models.Account.User
{
UserId = login.userId,
UserName = login.userName,
FullName = login.fullName,
Company = login.company,
Token = login.token,
MyAccess = string.Join(",", jwtToken.Claims
.Where(c => c.Type == ClaimTypes.Role)
.Select(c => c.Value))
};
var userAccess = await _account.GetLandingPageByUserId(GetUser());
var userAccess = await _account.GetLandingPageByUserId(currentUser, login.token);
var landingAction = userAccess?.FirstOrDefault(u => u.AccessTypeId == 1);

View File

@ -1,7 +1,5 @@
using CPRNIMS.Domain.UIServices.Updater;
using CPRNIMS.WebApps.Common;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Options;
var builder = WebApplication.CreateBuilder(args);
@ -18,7 +16,6 @@ if (!app.Environment.IsDevelopment())
//app.UseRewriter(options);
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCors("AllowAll");
app.UseRouting();
app.UseSession();

View File

@ -142,3 +142,37 @@ var colDefForReceivingSKU = [
}
},
];
var colRRFinance = [
{ data: 'prNo' },
{ data: 'itemNo' },
{ data: 'itemDescription' },
{ data: 'itemCategoryName' },
{
data: 'quantity',
render: function (data, type, row, meta) {
return numberWithCommas(data);
}
},
{
data: 'remainingQty',
render: function (data, type, row, meta) {
return numberWithCommas(data);
}
},
{
data: 'quantityReceived',
render: function (data, type, row, meta) {
return numberWithCommas(data);
}
},
{ data: 'uomName' },
{
data: 'unitPrice',
render: function (data, type, row, meta) {
return numberWithCommas(data);
}
},
{ data: 'prDetailsId', visible: false },
{ data: 'emailAddress', visible: false },
{ data: 'supplierName', visible: false },
];

View File

@ -32,13 +32,11 @@
vatRate.style.display = 'none';
amountPHP.style.display = 'none';
}
let btnComplete = document.getElementById('btnComplete');
let btnIncomplete = document.getElementById('btnIncomplete');
//let btnComplete = document.getElementById('btnComplete');
//let btnIncomplete = document.getElementById('btnIncomplete');
let btnClosePO = document.getElementById('btnClosePO');
btnPayment.style.display = 'none';
if (UserRights == 'POApprover' || UserRights == 'LLIFINANCE' || UserRights == 'CnvssAppver') {
btnComplete.style.display = 'none';
btnIncomplete.style.display = 'none';
btnSubmit.style.display = 'none';
btnReject.style.display = 'none';
dynamicColumn = colRRFinance;