Compare commits
57 Commits
sales-ui-fixers
...
UI
| Author | SHA1 | Date | |
|---|---|---|---|
| cb6b92d221 | |||
| 3f10ae3bca | |||
| 61fe1a0e0c | |||
| 941f20d4c5 | |||
| b06d20e649 | |||
| 445d323bed | |||
| 9028255800 | |||
| 1b2f244853 | |||
| 475bcfec1a | |||
| 85db26ec82 | |||
| baee987d26 | |||
| f45a59f20d | |||
| 32304cbaff | |||
| 2b64bb0ebc | |||
| ffe5251236 | |||
| d04a7fb3bc | |||
| d76595085e | |||
| bad33a8492 | |||
| b0216fca30 | |||
| 49c112d188 | |||
| c836b57d54 | |||
| 3a583f80e5 | |||
| 83e0335504 | |||
| 513343b62a | |||
| 256e39ccff | |||
| efb37fce7a | |||
| 01fc2582b6 | |||
| 39a2dc60be | |||
| 3b87a6e421 | |||
| 2a7a44cc27 | |||
| c7cf63e7de | |||
| d1044e4728 | |||
| 821e96e011 | |||
| d6f973202d | |||
| 1d5a5cf68e | |||
| 8e472ac996 | |||
| 666979cf22 | |||
| eb36e0acfa | |||
| 0ff39e9e58 | |||
| cbb610fc8b | |||
| afa9928dcc | |||
| 99aa395fb1 | |||
| cb41d503c4 | |||
| 629f3d1f44 | |||
| b3b6a25ce8 | |||
| f664961fce | |||
| bebec10eb3 | |||
| 160c687db3 | |||
| d413ad4064 | |||
| 9b8c2493ad | |||
| 99b669395e | |||
| 4cc6a546c7 | |||
| 8835ba9500 | |||
| 251b23f4b5 | |||
| 283a56723f | |||
| 1c5b05e315 | |||
| b4993b202d |
+1
Submodule .claude/worktrees/agent-a98805dc618e0f67c added at b4993b202d
@@ -0,0 +1,106 @@
|
|||||||
|
# test
|
||||||
|
name: CI/CD - ERP Core Monorepo
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- production
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
backend-build-and-deploy:
|
||||||
|
name: Build & Deploy ERP Core Backend
|
||||||
|
runs-on: linux
|
||||||
|
if: github.event.pull_request.merged == true
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
run: |
|
||||||
|
git clone \
|
||||||
|
--depth 1 \
|
||||||
|
--branch production \
|
||||||
|
https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Restore backend
|
||||||
|
working-directory: .gitea/workflows
|
||||||
|
run: dotnet restore ../../Backend/ERPCore.sln
|
||||||
|
|
||||||
|
- name: Publish backend
|
||||||
|
working-directory: .gitea/workflows
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/erpcore-deploy
|
||||||
|
mkdir -p /tmp/erpcore-deploy
|
||||||
|
dotnet publish ../../Backend/ERPCore/ERPCore.csproj \
|
||||||
|
-c Release \
|
||||||
|
-r linux-x64 \
|
||||||
|
--self-contained true \
|
||||||
|
-o /tmp/erpcore-deploy
|
||||||
|
|
||||||
|
- name: Stop backend service
|
||||||
|
run: systemctl stop erpcore.service
|
||||||
|
|
||||||
|
- name: Copy backend to deploy folder
|
||||||
|
run: |
|
||||||
|
mkdir -p /home/erp/core/publish
|
||||||
|
rm -rf /home/erp/core/publish/*
|
||||||
|
cp -r /tmp/erpcore-deploy/* /home/erp/core/publish/
|
||||||
|
|
||||||
|
- name: Fix backend ownership and permissions
|
||||||
|
run: |
|
||||||
|
chown -R erpuser:erpuser /home/erp/core/publish
|
||||||
|
find /home/erp/core/publish -type d -exec chmod 755 {} +
|
||||||
|
find /home/erp/core/publish -type f -exec chmod 644 {} +
|
||||||
|
chmod +x /home/erp/core/publish/ERPCore
|
||||||
|
|
||||||
|
- name: Restart backend service
|
||||||
|
run: systemctl restart erpcore.service
|
||||||
|
|
||||||
|
- name: Verify backend
|
||||||
|
run: |
|
||||||
|
systemctl is-active erpcore.service && echo "Backend service running" || echo "Backend service failed"
|
||||||
|
|
||||||
|
frontend-build-and-deploy:
|
||||||
|
name: Build & Deploy ERP Core Frontend
|
||||||
|
runs-on: linux
|
||||||
|
needs: backend-build-and-deploy
|
||||||
|
if: github.event.pull_request.merged == true
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
run: |
|
||||||
|
git clone \
|
||||||
|
--depth 1 \
|
||||||
|
--branch Production \
|
||||||
|
https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Build frontend Docker image
|
||||||
|
working-directory: .gitea/workflows
|
||||||
|
run: docker build -t erpcore-frontend:latest ../../Frontend/erp-system
|
||||||
|
|
||||||
|
- name: Stop & remove existing frontend container
|
||||||
|
run: |
|
||||||
|
docker stop erpcore-frontend 2>/dev/null || true
|
||||||
|
docker rm erpcore-frontend 2>/dev/null || true
|
||||||
|
|
||||||
|
- name: Start frontend container
|
||||||
|
run: |
|
||||||
|
docker run -d \
|
||||||
|
--name erpcore-frontend \
|
||||||
|
-p 6702:6702 \
|
||||||
|
--add-host=host.docker.internal:host-gateway \
|
||||||
|
-e BACKEND_ORIGIN=http://host.docker.internal:6701 \
|
||||||
|
--restart unless-stopped \
|
||||||
|
--memory="512m" \
|
||||||
|
--cpus="1.0" \
|
||||||
|
--cap-drop ALL \
|
||||||
|
--security-opt no-new-privileges \
|
||||||
|
erpcore-frontend:latest
|
||||||
|
|
||||||
|
- name: Remove old frontend images
|
||||||
|
run: docker image prune -f
|
||||||
|
|
||||||
|
- name: Verify frontend
|
||||||
|
run: |
|
||||||
|
docker ps --filter name=erpcore-frontend --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" \
|
||||||
|
| grep erpcore-frontend && echo "Frontend container running" || echo "Frontend container failed"
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.9" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||||
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ERPCore\ERPCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="Xunit" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using ERPCore.Domain.Notifications;
|
||||||
|
using ERPCore.Repositories;
|
||||||
|
using ERPCore.Services;
|
||||||
|
using ERPCore.System.Errors;
|
||||||
|
using ERPCore.Tests.TestSupport;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace ERPCore.Tests;
|
||||||
|
|
||||||
|
public class NotificationConfigServiceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task GetAsync_MergesSavedValuesWithDiscoveredModules()
|
||||||
|
{
|
||||||
|
var dbName = Guid.NewGuid().ToString("N");
|
||||||
|
await using var db = NotificationConfigTestSupport.CreateContext(dbName);
|
||||||
|
await NotificationConfigTestSupport.SeedAsync(db, new[]
|
||||||
|
{
|
||||||
|
new NotificationConfigModule
|
||||||
|
{
|
||||||
|
ModuleKey = "sale.create",
|
||||||
|
EmailEnabled = true,
|
||||||
|
SmsEnabled = false,
|
||||||
|
InAppEnabled = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var service = CreateService(db);
|
||||||
|
|
||||||
|
var result = await service.GetAsync();
|
||||||
|
|
||||||
|
Assert.Equal(7u, result.RowVersion);
|
||||||
|
Assert.Contains(result.Value.Modules, m => m.ModuleKey == "sale.create" && m.EmailEnabled && !m.SmsEnabled && m.InAppEnabled);
|
||||||
|
Assert.Contains(result.Value.Modules, m => m.ModuleKey == "grn.confirmed" && !m.EmailEnabled && !m.SmsEnabled && !m.InAppEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateAsync_PersistsEmptyAndMultiChannelSelections()
|
||||||
|
{
|
||||||
|
var dbName = Guid.NewGuid().ToString("N");
|
||||||
|
await using var db = NotificationConfigTestSupport.CreateContext(dbName);
|
||||||
|
await NotificationConfigTestSupport.SeedAsync(db);
|
||||||
|
|
||||||
|
var service = CreateService(db);
|
||||||
|
var catalog = new NotificationModuleCatalog();
|
||||||
|
var request = new ERPCore.Dtos.Notifications.UpdateNotificationConfigRequest
|
||||||
|
{
|
||||||
|
Modules = catalog.GetAll().Select((module, index) => new ERPCore.Dtos.Notifications.UpdateNotificationModuleRequest
|
||||||
|
{
|
||||||
|
ModuleKey = module.Key,
|
||||||
|
EmailEnabled = index == 0,
|
||||||
|
SmsEnabled = index == 1,
|
||||||
|
InAppEnabled = index == 1
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
var updated = await service.UpdateAsync(request, 7);
|
||||||
|
|
||||||
|
Assert.Equal(7u, updated.RowVersion);
|
||||||
|
Assert.Contains(updated.Value.Modules, m => m.ModuleKey == catalog.GetAll()[0].Key && m.EmailEnabled && !m.SmsEnabled && !m.InAppEnabled);
|
||||||
|
Assert.Contains(updated.Value.Modules, m => m.ModuleKey == catalog.GetAll()[1].Key && !m.EmailEnabled && m.SmsEnabled && m.InAppEnabled);
|
||||||
|
|
||||||
|
await using var verifyDb = NotificationConfigTestSupport.CreateContext(dbName);
|
||||||
|
var persisted = await verifyDb.NotificationConfigModules.AsNoTracking().ToListAsync();
|
||||||
|
Assert.Contains(persisted, m => m.ModuleKey == catalog.GetAll()[0].Key && m.EmailEnabled && !m.SmsEnabled && !m.InAppEnabled);
|
||||||
|
Assert.Contains(persisted, m => m.ModuleKey == catalog.GetAll()[1].Key && !m.EmailEnabled && m.SmsEnabled && m.InAppEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ResolveEnabledChannelsAsync_ReturnsEmptyWhenNothingEnabled()
|
||||||
|
{
|
||||||
|
var dbName = Guid.NewGuid().ToString("N");
|
||||||
|
await using var db = NotificationConfigTestSupport.CreateContext(dbName);
|
||||||
|
await NotificationConfigTestSupport.SeedAsync(db, new[]
|
||||||
|
{
|
||||||
|
new NotificationConfigModule
|
||||||
|
{
|
||||||
|
ModuleKey = "sale.create",
|
||||||
|
EmailEnabled = false,
|
||||||
|
SmsEnabled = false,
|
||||||
|
InAppEnabled = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var service = CreateService(db);
|
||||||
|
|
||||||
|
var channels = await service.ResolveEnabledChannelsAsync("sale.create");
|
||||||
|
|
||||||
|
Assert.Empty(channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ResolveEnabledChannelsAsync_ReturnsMultipleChannels()
|
||||||
|
{
|
||||||
|
var dbName = Guid.NewGuid().ToString("N");
|
||||||
|
await using var db = NotificationConfigTestSupport.CreateContext(dbName);
|
||||||
|
await NotificationConfigTestSupport.SeedAsync(db, new[]
|
||||||
|
{
|
||||||
|
new NotificationConfigModule
|
||||||
|
{
|
||||||
|
ModuleKey = "sale.create",
|
||||||
|
EmailEnabled = true,
|
||||||
|
SmsEnabled = true,
|
||||||
|
InAppEnabled = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var service = CreateService(db);
|
||||||
|
|
||||||
|
var channels = await service.ResolveEnabledChannelsAsync("sale.create");
|
||||||
|
|
||||||
|
Assert.Equal(new[] { NotificationChannel.Email, NotificationChannel.Sms }, channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdateAsync_MapsConcurrencyFailuresToDomainException()
|
||||||
|
{
|
||||||
|
var dbName = Guid.NewGuid().ToString("N");
|
||||||
|
await using var db = NotificationConfigTestSupport.CreateContext(dbName);
|
||||||
|
await NotificationConfigTestSupport.SeedAsync(db);
|
||||||
|
|
||||||
|
var service = CreateService(db, new ThrowingUnitOfWork());
|
||||||
|
var catalog = new NotificationModuleCatalog();
|
||||||
|
var request = new ERPCore.Dtos.Notifications.UpdateNotificationConfigRequest
|
||||||
|
{
|
||||||
|
Modules = catalog.GetAll().Select(module => new ERPCore.Dtos.Notifications.UpdateNotificationModuleRequest
|
||||||
|
{
|
||||||
|
ModuleKey = module.Key,
|
||||||
|
EmailEnabled = false,
|
||||||
|
SmsEnabled = false,
|
||||||
|
InAppEnabled = false
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
var ex = await Assert.ThrowsAsync<DomainException>(() => service.UpdateAsync(request, 7));
|
||||||
|
Assert.Equal(ErrorCodes.ConcurrencyConflict, ex.Code);
|
||||||
|
Assert.Equal(412, ex.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static NotificationConfigService CreateService(ERPCore.Infra.Persistence.ErpDbContext db, ERPCore.Infra.UoW.IUnitOfWork? uow = null)
|
||||||
|
{
|
||||||
|
var configRepo = new Repository<NotificationConfig>(db);
|
||||||
|
var moduleRepo = new Repository<NotificationConfigModule>(db);
|
||||||
|
return new NotificationConfigService(
|
||||||
|
configRepo,
|
||||||
|
moduleRepo,
|
||||||
|
new NotificationModuleCatalog(),
|
||||||
|
new TestCurrentUser(),
|
||||||
|
uow ?? new ERPCore.Infra.UoW.UnitOfWork(db));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using ERPCore.Services;
|
||||||
|
|
||||||
|
namespace ERPCore.Tests;
|
||||||
|
|
||||||
|
public class NotificationModuleCatalogTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void GetAll_ReturnsStableUniqueModuleKeys()
|
||||||
|
{
|
||||||
|
var catalog = new NotificationModuleCatalog();
|
||||||
|
|
||||||
|
Assert.NotEmpty(catalog.GetAll());
|
||||||
|
Assert.Contains(catalog.GetAll(), m => m.Key == "sale.create");
|
||||||
|
Assert.Contains(catalog.GetAll(), m => m.Key == "grn.confirmed");
|
||||||
|
Assert.Equal(catalog.GetAll().Count, catalog.GetAll().Select(m => m.Key).Distinct(StringComparer.OrdinalIgnoreCase).Count());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using ERPCore.Infra.Auth;
|
||||||
|
using ERPCore.Infra.Persistence;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
|
|
||||||
|
namespace ERPCore.Tests.TestSupport;
|
||||||
|
|
||||||
|
internal sealed class TestCurrentUser : ICurrentUser
|
||||||
|
{
|
||||||
|
public string UserId => "system";
|
||||||
|
public int AuditUserId => User.SystemUserId;
|
||||||
|
public bool IsAuthenticated => false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class ThrowingUnitOfWork : ERPCore.Infra.UoW.IUnitOfWork
|
||||||
|
{
|
||||||
|
public Task<int> SaveChangesAsync(CancellationToken ct = default)
|
||||||
|
=> throw new DbUpdateConcurrencyException("Test concurrency conflict.");
|
||||||
|
|
||||||
|
public Task ExecuteInTransactionAsync(Func<CancellationToken, Task> action, CancellationToken ct = default)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
|
||||||
|
public Task<T> ExecuteInTransactionAsync<T>(Func<CancellationToken, Task<T>> action, CancellationToken ct = default)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class NotificationConfigTestSupport
|
||||||
|
{
|
||||||
|
private static readonly InMemoryDatabaseRoot Root = new();
|
||||||
|
|
||||||
|
public static ErpDbContext CreateContext(string name)
|
||||||
|
{
|
||||||
|
var options = new DbContextOptionsBuilder<ErpDbContext>()
|
||||||
|
.UseInMemoryDatabase(name, Root)
|
||||||
|
.Options;
|
||||||
|
|
||||||
|
return new ErpDbContext(options, new TestCurrentUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task SeedAsync(ErpDbContext db, IEnumerable<NotificationConfigModule>? modules = null)
|
||||||
|
{
|
||||||
|
db.Users.Add(new User
|
||||||
|
{
|
||||||
|
UserId = User.SystemUserId,
|
||||||
|
Username = "system",
|
||||||
|
DisplayName = "System"
|
||||||
|
});
|
||||||
|
|
||||||
|
var config = new NotificationConfig
|
||||||
|
{
|
||||||
|
NotificationConfigId = NotificationConfig.SingletonId,
|
||||||
|
UpdatedBy = User.SystemUserId,
|
||||||
|
UpdatedAt = DateTime.UtcNow,
|
||||||
|
RowVersion = 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (modules is not null)
|
||||||
|
{
|
||||||
|
foreach (var module in modules)
|
||||||
|
{
|
||||||
|
module.NotificationConfigId = NotificationConfig.SingletonId;
|
||||||
|
config.Modules.Add(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db.NotificationConfig.Add(config);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,13 +27,15 @@ public sealed class AuthController : ControllerBase
|
|||||||
private readonly IAuthRecoveryService _recovery;
|
private readonly IAuthRecoveryService _recovery;
|
||||||
private readonly IAuthAltService _alt;
|
private readonly IAuthAltService _alt;
|
||||||
private readonly IRoleService _roles;
|
private readonly IRoleService _roles;
|
||||||
|
private readonly IAuditService _audit;
|
||||||
|
|
||||||
public AuthController(IAuthUserService users, IAuthRecoveryService recovery, IAuthAltService alt, IRoleService roles)
|
public AuthController(IAuthUserService users, IAuthRecoveryService recovery, IAuthAltService alt, IRoleService roles, IAuditService audit)
|
||||||
{
|
{
|
||||||
_users = users;
|
_users = users;
|
||||||
_recovery = recovery;
|
_recovery = recovery;
|
||||||
_alt = alt;
|
_alt = alt;
|
||||||
_roles = roles;
|
_roles = roles;
|
||||||
|
_audit = audit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -68,6 +70,7 @@ public sealed class AuthController : ControllerBase
|
|||||||
{
|
{
|
||||||
var result = await _users.LoginAsync(request, ct);
|
var result = await _users.LoginAsync(request, ct);
|
||||||
AuthCookieWriter.WriteSession(Response, result.AccessToken, result.RefreshToken, result.Body.ExpiresIn);
|
AuthCookieWriter.WriteSession(Response, result.AccessToken, result.RefreshToken, result.Body.ExpiresIn);
|
||||||
|
if (result.Body.User?.UserId is Guid authUserId) await _audit.RecordLoginAsync(authUserId, ClientIp(), ClientUserAgent(), ct);
|
||||||
return Ok(result.Body);
|
return Ok(result.Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,9 +81,13 @@ public sealed class AuthController : ControllerBase
|
|||||||
{
|
{
|
||||||
var result = await _users.VerifyOtpForLoginAsync(request, ct);
|
var result = await _users.VerifyOtpForLoginAsync(request, ct);
|
||||||
AuthCookieWriter.WriteSession(Response, result.AccessToken, result.RefreshToken, result.Body.ExpiresIn);
|
AuthCookieWriter.WriteSession(Response, result.AccessToken, result.RefreshToken, result.Body.ExpiresIn);
|
||||||
|
if (result.Body.User?.UserId is Guid authUserId) await _audit.RecordLoginAsync(authUserId, ClientIp(), ClientUserAgent(), ct);
|
||||||
return Ok(result.Body);
|
return Ok(result.Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string? ClientIp() => HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||||
|
private string? ClientUserAgent() => Request.Headers.UserAgent.ToString() is { Length: > 0 } ua ? ua : null;
|
||||||
|
|
||||||
[HttpPost("refresh-token")]
|
[HttpPost("refresh-token")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(AuthSessionResponse), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(AuthSessionResponse), StatusCodes.Status200OK)]
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using ERPCore.Dtos.Config;
|
||||||
|
using ERPCore.Services.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ERPCore.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Branch configuration endpoints — the singleton toggle for whether this deployment
|
||||||
|
/// requires a branch on Employee/Warehouse records at all.
|
||||||
|
/// <para>
|
||||||
|
/// <b>Authorization:</b> writes are admitted by the inherited ERP door policy only, same
|
||||||
|
/// Phase-1 posture as <see cref="ProductConfigController"/> — any ERP-admitted user can
|
||||||
|
/// flip this flag until per-endpoint RBAC lands.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/v1/branch-config")]
|
||||||
|
public sealed class BranchConfigController : ApiControllerBase
|
||||||
|
{
|
||||||
|
private readonly IBranchConfigService _config;
|
||||||
|
|
||||||
|
public BranchConfigController(IBranchConfigService config) => _config = config;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(BranchConfigDto), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult<BranchConfigDto>> Get(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var result = await _config.GetAsync(ct);
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Ok(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
[ProducesResponseType(typeof(BranchConfigDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status412PreconditionFailed)]
|
||||||
|
public async Task<ActionResult<BranchConfigDto>> Update(
|
||||||
|
[FromBody] UpdateBranchConfigRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var expected = RequireIfMatch();
|
||||||
|
var result = await _config.UpdateAsync(request, expected, ct);
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Ok(result.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,14 @@ public sealed class BundleSalesController : ApiControllerBase
|
|||||||
return result is null ? NotFound() : Ok(result);
|
return result is null ? NotFound() : Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("templates")]
|
||||||
|
[ProducesResponseType(typeof(BundleSaleTemplateDto), StatusCodes.Status201Created)]
|
||||||
|
public async Task<ActionResult<BundleSaleTemplateDto>> CreateTemplate([FromBody] CreateBundleSaleTemplateRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var result = await _bundles.CreateTemplateAsync(request, ct);
|
||||||
|
return Created($"/api/v1/bundle-sales/templates/{result.BundleSaleTemplateId}", result);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PagedResponse<BundleSaleSummaryDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<BundleSaleSummaryDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<BundleSaleSummaryDto>>> List(
|
public async Task<ActionResult<PagedResponse<BundleSaleSummaryDto>>> List(
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ public sealed class DashboardController : ApiControllerBase
|
|||||||
/// <summary>Aggregate counts for stock, GRN, and procurement.</summary>
|
/// <summary>Aggregate counts for stock, GRN, and procurement.</summary>
|
||||||
[HttpGet("stats")]
|
[HttpGet("stats")]
|
||||||
[ProducesResponseType(typeof(DashboardStatsDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(DashboardStatsDto), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<DashboardStatsDto>> GetStats(CancellationToken ct)
|
public async Task<ActionResult<DashboardStatsDto>> GetStats([FromQuery] int? branchId, CancellationToken ct)
|
||||||
=> Ok(await _dashboard.GetStatsAsync(ct));
|
=> Ok(await _dashboard.GetStatsAsync(branchId, ct));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ namespace ERPCore.Controllers;
|
|||||||
public sealed class GrnsController : ApiControllerBase
|
public sealed class GrnsController : ApiControllerBase
|
||||||
{
|
{
|
||||||
private readonly IGrnService _grns;
|
private readonly IGrnService _grns;
|
||||||
private readonly IGrnPaymentService _payments;
|
|
||||||
|
|
||||||
public GrnsController(IGrnService grns, IGrnPaymentService payments)
|
public GrnsController(IGrnService grns)
|
||||||
{
|
{
|
||||||
_grns = grns;
|
_grns = grns;
|
||||||
_payments = payments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>List GRNs, newest first.</summary>
|
/// <summary>List GRNs, newest first.</summary>
|
||||||
@@ -24,8 +22,8 @@ public sealed class GrnsController : ApiControllerBase
|
|||||||
[ProducesResponseType(typeof(PagedResponse<GrnSummaryDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<GrnSummaryDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<GrnSummaryDto>>> List(
|
public async Task<ActionResult<PagedResponse<GrnSummaryDto>>> List(
|
||||||
[FromQuery] PageQuery query, [FromQuery] GrnStatus? status, [FromQuery] int? poId,
|
[FromQuery] PageQuery query, [FromQuery] GrnStatus? status, [FromQuery] int? poId,
|
||||||
[FromQuery] int? vendorId, [FromQuery] int? warehouseId, CancellationToken ct)
|
[FromQuery] int? vendorId, [FromQuery] int? warehouseId, [FromQuery] int? branchId, CancellationToken ct)
|
||||||
=> Ok(await _grns.ListAsync(query, status, poId, vendorId, warehouseId, ct));
|
=> Ok(await _grns.ListAsync(query, status, poId, vendorId, warehouseId, branchId, ct));
|
||||||
|
|
||||||
[HttpGet("{grnId:int}")]
|
[HttpGet("{grnId:int}")]
|
||||||
[ProducesResponseType(typeof(GrnDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(GrnDto), StatusCodes.Status200OK)]
|
||||||
@@ -64,23 +62,4 @@ public sealed class GrnsController : ApiControllerBase
|
|||||||
public async Task<ActionResult<ReleaseLineResultDto>> Release(
|
public async Task<ActionResult<ReleaseLineResultDto>> Release(
|
||||||
int grnId, int grnLineId, [FromBody] ReleaseLineRequest request, CancellationToken ct)
|
int grnId, int grnLineId, [FromBody] ReleaseLineRequest request, CancellationToken ct)
|
||||||
=> Ok(await _grns.ReleaseLineAsync(grnId, grnLineId, request.Action, ct));
|
=> Ok(await _grns.ReleaseLineAsync(grnId, grnLineId, request.Action, ct));
|
||||||
|
|
||||||
/// <summary>Pay the vendor against this GRN's balance, in full or in installments; posts a real GL journal entry.</summary>
|
|
||||||
[HttpPost("{grnId:int}/payments")]
|
|
||||||
[ProducesResponseType(typeof(GrnPaymentDto), StatusCodes.Status201Created)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
|
||||||
public async Task<ActionResult<GrnPaymentDto>> Pay(int grnId, [FromBody] CreateGrnPaymentRequest request, CancellationToken ct)
|
|
||||||
{
|
|
||||||
var dto = await _payments.PayAsync(grnId, request, ct);
|
|
||||||
return Created($"/api/v1/grns/{grnId}/payments/{dto.GrnPaymentId}", dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Payment history for this GRN, newest first.</summary>
|
|
||||||
[HttpGet("{grnId:int}/payments")]
|
|
||||||
[ProducesResponseType(typeof(IReadOnlyList<GrnPaymentDto>), StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
||||||
public async Task<ActionResult<IReadOnlyList<GrnPaymentDto>>> ListPayments(int grnId, CancellationToken ct)
|
|
||||||
=> Ok(await _payments.ListAsync(grnId, ct));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class BranchesController : ApiControllerBase
|
|||||||
await _branches.SetStatusAsync(branchId, request.Status, ct);
|
await _branches.SetStatusAsync(branchId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{branchId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int branchId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _branches.DeleteAsync(branchId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,14 @@ public sealed class DepartmentsController : ApiControllerBase
|
|||||||
await _departments.SetStatusAsync(departmentId, request.Status, ct);
|
await _departments.SetStatusAsync(departmentId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{departmentId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int departmentId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _departments.DeleteAsync(departmentId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class DesignationsController : ApiControllerBase
|
|||||||
await _designations.SetStatusAsync(designationId, request.Status, ct);
|
await _designations.SetStatusAsync(designationId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{designationId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int designationId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _designations.DeleteAsync(designationId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ public sealed class EmployeesController : ApiControllerBase
|
|||||||
return Ok(result.Value);
|
return Ok(result.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Never a hard delete — Employee is retained forever (docs/12-BACKEND-HRM.md C.2).</summary>
|
|
||||||
[HttpPatch("{employeeId:int}/status")]
|
[HttpPatch("{employeeId:int}/status")]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
@@ -93,6 +92,17 @@ public sealed class EmployeesController : ApiControllerBase
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Permanently deletes the employee and all dependent HR records. Blocked (409) if payroll history exists.</summary>
|
||||||
|
[HttpDelete("{employeeId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int employeeId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _employees.DeleteAsync(employeeId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("{employeeId:int}/link-user")]
|
[HttpPost("{employeeId:int}/link-user")]
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class EmploymentTypesController : ApiControllerBase
|
|||||||
await _employmentTypes.SetStatusAsync(employmentTypeId, request.Status, ct);
|
await _employmentTypes.SetStatusAsync(employmentTypeId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{employmentTypeId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int employmentTypeId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _employmentTypes.DeleteAsync(employmentTypeId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class HrDocumentTypesController : ApiControllerBase
|
|||||||
await _types.SetStatusAsync(hrDocumentTypeId, request.Status, ct);
|
await _types.SetStatusAsync(hrDocumentTypeId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{hrDocumentTypeId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int hrDocumentTypeId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _types.DeleteAsync(hrDocumentTypeId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class LeaveTypesController : ApiControllerBase
|
|||||||
await _leaveTypes.SetStatusAsync(leaveTypeId, request.Status, ct);
|
await _leaveTypes.SetStatusAsync(leaveTypeId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{leaveTypeId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int leaveTypeId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _leaveTypes.DeleteAsync(leaveTypeId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class SalaryComponentsController : ApiControllerBase
|
|||||||
await _components.SetStatusAsync(salaryComponentId, request.Status, ct);
|
await _components.SetStatusAsync(salaryComponentId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{salaryComponentId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int salaryComponentId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _components.DeleteAsync(salaryComponentId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,14 @@ public sealed class WorkShiftsController : ApiControllerBase
|
|||||||
await _shifts.SetStatusAsync(workShiftId, request.Status, ct);
|
await _shifts.SetStatusAsync(workShiftId, request.Status, ct);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{workShiftId:int}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<IActionResult> Delete(int workShiftId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _shifts.DeleteAsync(workShiftId, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using ERPCore.Dtos.Notifications;
|
||||||
|
using ERPCore.Services.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ERPCore.Controllers;
|
||||||
|
|
||||||
|
[Route("api/v1/notification-config")]
|
||||||
|
public sealed class NotificationConfigController : ApiControllerBase
|
||||||
|
{
|
||||||
|
private readonly INotificationConfigService _config;
|
||||||
|
|
||||||
|
public NotificationConfigController(INotificationConfigService config) => _config = config;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(NotificationConfigDto), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult<NotificationConfigDto>> Get(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var result = await _config.GetAsync(ct);
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Ok(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
[ProducesResponseType(typeof(NotificationConfigDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status412PreconditionFailed)]
|
||||||
|
public async Task<ActionResult<NotificationConfigDto>> Update([FromBody] UpdateNotificationConfigRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var expected = RequireIfMatch();
|
||||||
|
var result = await _config.UpdateAsync(request, expected, ct);
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Ok(result.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,19 @@ public sealed class ProductionRunsController : ApiControllerBase
|
|||||||
CancellationToken ct)
|
CancellationToken ct)
|
||||||
=> Ok(await _runs.ListAsync(query, status, templateId, warehouseId, ct));
|
=> Ok(await _runs.ListAsync(query, status, templateId, warehouseId, ct));
|
||||||
|
|
||||||
|
/// <summary>Produced-items report (FR-MFG-13): one row per run that has produced
|
||||||
|
/// something, plus a summary total over every filtered row.</summary>
|
||||||
|
[HttpGet("produced")]
|
||||||
|
[ProducesResponseType(typeof(ProducedListResponseDto), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult<ProducedListResponseDto>> ListProduced(
|
||||||
|
[FromQuery] DateOnly? from,
|
||||||
|
[FromQuery] DateOnly? to,
|
||||||
|
[FromQuery] int? templateId,
|
||||||
|
[FromQuery] int? warehouseId,
|
||||||
|
[FromQuery] ProductionRunStatus? status,
|
||||||
|
CancellationToken ct)
|
||||||
|
=> Ok(await _runs.ListProducedAsync(from, to, templateId, warehouseId, status, ct));
|
||||||
|
|
||||||
[HttpGet("{runId:int}")]
|
[HttpGet("{runId:int}")]
|
||||||
[ProducesResponseType(typeof(RunGraphDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(RunGraphDto), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
using ERPCore.Dtos.Common;
|
||||||
|
using ERPCore.Dtos.Grn;
|
||||||
|
using ERPCore.Dtos.Procurement;
|
||||||
|
using ERPCore.Services.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ERPCore.Controllers;
|
||||||
|
|
||||||
|
/// <summary>Purchase invoice endpoints — vendor invoices consolidating Confirmed GRNs.</summary>
|
||||||
|
[Route("api/v1/purchase-invoices")]
|
||||||
|
public sealed class PurchaseInvoicesController : ApiControllerBase
|
||||||
|
{
|
||||||
|
private readonly IPurchaseInvoiceService _invoices;
|
||||||
|
private readonly IPurchaseInvoicePaymentService _payments;
|
||||||
|
|
||||||
|
public PurchaseInvoicesController(IPurchaseInvoiceService invoices, IPurchaseInvoicePaymentService payments)
|
||||||
|
{
|
||||||
|
_invoices = invoices;
|
||||||
|
_payments = payments;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(PagedResponse<PurchaseInvoiceSummaryDto>), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult<PagedResponse<PurchaseInvoiceSummaryDto>>> List(
|
||||||
|
[FromQuery] PageQuery query, [FromQuery] PurchaseInvoiceStatus? status, [FromQuery] int? vendorId, CancellationToken ct)
|
||||||
|
=> Ok(await _invoices.ListAsync(query, status, vendorId, ct));
|
||||||
|
|
||||||
|
/// <summary>Confirmed, not-yet-invoiced GRNs for a vendor — candidates for a new/edited invoice.</summary>
|
||||||
|
[HttpGet("eligible-grns")]
|
||||||
|
[ProducesResponseType(typeof(IReadOnlyList<GrnEligibleForInvoiceDto>), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult<IReadOnlyList<GrnEligibleForInvoiceDto>>> EligibleGrns([FromQuery] int vendorId, CancellationToken ct)
|
||||||
|
=> Ok(await _invoices.ListEligibleGrnsAsync(vendorId, ct));
|
||||||
|
|
||||||
|
[HttpGet("{purchaseInvoiceId:int}")]
|
||||||
|
[ProducesResponseType(typeof(PurchaseInvoiceDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult<PurchaseInvoiceDto>> GetById(int purchaseInvoiceId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var result = await _invoices.GetAsync(purchaseInvoiceId, ct);
|
||||||
|
if (result is null) return NotFound();
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Ok(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[ProducesResponseType(typeof(PurchaseInvoiceDto), StatusCodes.Status201Created)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status422UnprocessableEntity)]
|
||||||
|
public async Task<ActionResult<PurchaseInvoiceDto>> Create([FromBody] CreatePurchaseInvoiceRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var result = await _invoices.CreateAsync(request, ct);
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Created($"/api/v1/purchase-invoices/{result.Value.PurchaseInvoiceId}", result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPut("{purchaseInvoiceId:int}")]
|
||||||
|
[ProducesResponseType(typeof(PurchaseInvoiceDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status412PreconditionFailed)]
|
||||||
|
public async Task<ActionResult<PurchaseInvoiceDto>> Update(int purchaseInvoiceId, [FromBody] UpdatePurchaseInvoiceRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var expected = RequireIfMatch();
|
||||||
|
var result = await _invoices.UpdateAsync(purchaseInvoiceId, request, expected, ct);
|
||||||
|
SetETag(result.RowVersion);
|
||||||
|
return Ok(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("{purchaseInvoiceId:int}/post")]
|
||||||
|
[ProducesResponseType(typeof(PurchaseInvoiceDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<ActionResult<PurchaseInvoiceDto>> Post(int purchaseInvoiceId, CancellationToken ct)
|
||||||
|
=> Ok(await _invoices.PostAsync(purchaseInvoiceId, ct));
|
||||||
|
|
||||||
|
[HttpPost("{purchaseInvoiceId:int}/cancel")]
|
||||||
|
[ProducesResponseType(typeof(PurchaseInvoiceDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<ActionResult<PurchaseInvoiceDto>> Cancel(int purchaseInvoiceId, CancellationToken ct)
|
||||||
|
=> Ok(await _invoices.CancelAsync(purchaseInvoiceId, ct));
|
||||||
|
|
||||||
|
/// <summary>Pay the vendor against this invoice's balance, in full or in installments; posts a real GL journal entry.</summary>
|
||||||
|
[HttpPost("{purchaseInvoiceId:int}/payments")]
|
||||||
|
[ProducesResponseType(typeof(PurchaseInvoicePaymentDto), StatusCodes.Status201Created)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
|
public async Task<ActionResult<PurchaseInvoicePaymentDto>> Pay(int purchaseInvoiceId, [FromBody] CreatePurchaseInvoicePaymentRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var dto = await _payments.PayAsync(purchaseInvoiceId, request, ct);
|
||||||
|
return Created($"/api/v1/purchase-invoices/{purchaseInvoiceId}/payments/{dto.PurchaseInvoicePaymentId}", dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Payment history for this invoice, newest first.</summary>
|
||||||
|
[HttpGet("{purchaseInvoiceId:int}/payments")]
|
||||||
|
[ProducesResponseType(typeof(IReadOnlyList<PurchaseInvoicePaymentDto>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult<IReadOnlyList<PurchaseInvoicePaymentDto>>> ListPayments(int purchaseInvoiceId, CancellationToken ct)
|
||||||
|
=> Ok(await _payments.ListAsync(purchaseInvoiceId, ct));
|
||||||
|
}
|
||||||
@@ -25,8 +25,9 @@ public sealed class SalesInvoicesController : ApiControllerBase
|
|||||||
[FromQuery] SalesInvoiceStatus? status,
|
[FromQuery] SalesInvoiceStatus? status,
|
||||||
[FromQuery] int? customerId,
|
[FromQuery] int? customerId,
|
||||||
[FromQuery] int? warehouseId,
|
[FromQuery] int? warehouseId,
|
||||||
|
[FromQuery] int? branchId,
|
||||||
CancellationToken ct)
|
CancellationToken ct)
|
||||||
=> Ok(await _invoices.ListAsync(query, status, customerId, warehouseId, ct));
|
=> Ok(await _invoices.ListAsync(query, status, customerId, warehouseId, branchId, ct));
|
||||||
|
|
||||||
[HttpGet("{salesInvoiceId:int}")]
|
[HttpGet("{salesInvoiceId:int}")]
|
||||||
[ProducesResponseType(typeof(SalesInvoiceDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(SalesInvoiceDto), StatusCodes.Status200OK)]
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public sealed class StockAdjustmentsController : ApiControllerBase
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PagedResponse<AdjustmentSummaryDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<AdjustmentSummaryDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<AdjustmentSummaryDto>>> List(
|
public async Task<ActionResult<PagedResponse<AdjustmentSummaryDto>>> List(
|
||||||
[FromQuery] PageQuery query, [FromQuery] int? warehouseId, [FromQuery] int? reasonCodeId, CancellationToken ct)
|
[FromQuery] PageQuery query, [FromQuery] int? warehouseId, [FromQuery] int? branchId, [FromQuery] int? reasonCodeId, CancellationToken ct)
|
||||||
=> Ok(await _adjustments.ListAsync(query, warehouseId, reasonCodeId, ct));
|
=> Ok(await _adjustments.ListAsync(query, warehouseId, branchId, reasonCodeId, ct));
|
||||||
|
|
||||||
/// <summary>Get one adjustment with its lines and the ledger entries it posted.</summary>
|
/// <summary>Get one adjustment with its lines and the ledger entries it posted.</summary>
|
||||||
[HttpGet("{adjustmentId:int}")]
|
[HttpGet("{adjustmentId:int}")]
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ public sealed class StockController : ApiControllerBase
|
|||||||
[HttpGet("on-hand/list")]
|
[HttpGet("on-hand/list")]
|
||||||
[ProducesResponseType(typeof(PagedResponse<StockOnHandDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<StockOnHandDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<StockOnHandDto>>> OnHandList(
|
public async Task<ActionResult<PagedResponse<StockOnHandDto>>> OnHandList(
|
||||||
[FromQuery] int? itemId, [FromQuery] int? warehouseId, [FromQuery] PageQuery query, CancellationToken ct)
|
[FromQuery] int? itemId, [FromQuery] int? warehouseId, [FromQuery] int? branchId, [FromQuery] PageQuery query, CancellationToken ct)
|
||||||
=> Ok(await _stock.GetOnHandListAsync(itemId, warehouseId, query, ct));
|
=> Ok(await _stock.GetOnHandListAsync(itemId, warehouseId, branchId, query, ct));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Immutable movement history. <c>sourceDocType</c>/<c>sourceDocId</c> answer "what did
|
/// Immutable movement history. <c>sourceDocType</c>/<c>sourceDocId</c> answer "what did
|
||||||
@@ -39,11 +39,11 @@ public sealed class StockController : ApiControllerBase
|
|||||||
[HttpGet("ledger")]
|
[HttpGet("ledger")]
|
||||||
[ProducesResponseType(typeof(PagedResponse<StockLedgerRowDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<StockLedgerRowDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<StockLedgerRowDto>>> Ledger(
|
public async Task<ActionResult<PagedResponse<StockLedgerRowDto>>> Ledger(
|
||||||
[FromQuery] int? itemId, [FromQuery] int? warehouseId,
|
[FromQuery] int? itemId, [FromQuery] int? warehouseId, [FromQuery] int? branchId,
|
||||||
[FromQuery] DateOnly? from, [FromQuery] DateOnly? to,
|
[FromQuery] DateOnly? from, [FromQuery] DateOnly? to,
|
||||||
[FromQuery] string? sourceDocType, [FromQuery] int? sourceDocId,
|
[FromQuery] string? sourceDocType, [FromQuery] int? sourceDocId,
|
||||||
[FromQuery] PageQuery query, CancellationToken ct)
|
[FromQuery] PageQuery query, CancellationToken ct)
|
||||||
=> Ok(await _stock.GetLedgerAsync(itemId, warehouseId, from, to, sourceDocType, sourceDocId, query, ct));
|
=> Ok(await _stock.GetLedgerAsync(itemId, warehouseId, branchId, from, to, sourceDocType, sourceDocId, query, ct));
|
||||||
|
|
||||||
[HttpGet("valuation")]
|
[HttpGet("valuation")]
|
||||||
[ProducesResponseType(typeof(StockValuationDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(StockValuationDto), StatusCodes.Status200OK)]
|
||||||
@@ -54,8 +54,8 @@ public sealed class StockController : ApiControllerBase
|
|||||||
[HttpGet("reorder-alerts")]
|
[HttpGet("reorder-alerts")]
|
||||||
[ProducesResponseType(typeof(PagedResponse<ReorderAlertDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<ReorderAlertDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<ReorderAlertDto>>> ReorderAlerts(
|
public async Task<ActionResult<PagedResponse<ReorderAlertDto>>> ReorderAlerts(
|
||||||
[FromQuery] int? warehouseId, [FromQuery] PageQuery query, CancellationToken ct)
|
[FromQuery] int? warehouseId, [FromQuery] int? branchId, [FromQuery] PageQuery query, CancellationToken ct)
|
||||||
=> Ok(await _reorder.GetAlertsAsync(warehouseId, query, ct));
|
=> Ok(await _reorder.GetAlertsAsync(warehouseId, branchId, query, ct));
|
||||||
|
|
||||||
/// <summary>Create a draft requisition for an item's suggested reorder quantity.</summary>
|
/// <summary>Create a draft requisition for an item's suggested reorder quantity.</summary>
|
||||||
[HttpPost("reorder-alerts/{itemId:int}/requisition")]
|
[HttpPost("reorder-alerts/{itemId:int}/requisition")]
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public sealed class StockCountsController : ApiControllerBase
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PagedResponse<CountSummaryDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<CountSummaryDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<CountSummaryDto>>> List(
|
public async Task<ActionResult<PagedResponse<CountSummaryDto>>> List(
|
||||||
[FromQuery] PageQuery query, [FromQuery] CountStatus? status, [FromQuery] int? warehouseId, CancellationToken ct)
|
[FromQuery] PageQuery query, [FromQuery] CountStatus? status, [FromQuery] int? warehouseId, [FromQuery] int? branchId, CancellationToken ct)
|
||||||
=> Ok(await _counts.ListAsync(query, status, warehouseId, ct));
|
=> Ok(await _counts.ListAsync(query, status, warehouseId, branchId, ct));
|
||||||
|
|
||||||
[HttpGet("{countId:int}")]
|
[HttpGet("{countId:int}")]
|
||||||
[ProducesResponseType(typeof(CountDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(CountDto), StatusCodes.Status200OK)]
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ public sealed class StockTransfersController : ApiControllerBase
|
|||||||
[ProducesResponseType(typeof(PagedResponse<TransferSummaryDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<TransferSummaryDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<TransferSummaryDto>>> List(
|
public async Task<ActionResult<PagedResponse<TransferSummaryDto>>> List(
|
||||||
[FromQuery] PageQuery query, [FromQuery] TransferStatus? status,
|
[FromQuery] PageQuery query, [FromQuery] TransferStatus? status,
|
||||||
[FromQuery] int? srcWarehouseId, [FromQuery] int? destWarehouseId, CancellationToken ct)
|
[FromQuery] int? srcWarehouseId, [FromQuery] int? destWarehouseId, [FromQuery] int? branchId, CancellationToken ct)
|
||||||
=> Ok(await _transfers.ListAsync(query, status, srcWarehouseId, destWarehouseId, ct));
|
=> Ok(await _transfers.ListAsync(query, status, srcWarehouseId, destWarehouseId, branchId, ct));
|
||||||
|
|
||||||
[HttpGet("{transferId:int}")]
|
[HttpGet("{transferId:int}")]
|
||||||
[ProducesResponseType(typeof(TransferDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(TransferDto), StatusCodes.Status200OK)]
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using ERPCore.Domain.Enums;
|
||||||
using ERPCore.Dtos.Common;
|
using ERPCore.Dtos.Common;
|
||||||
using ERPCore.Dtos.Uoms;
|
using ERPCore.Dtos.Uoms;
|
||||||
using ERPCore.Services.Interfaces;
|
using ERPCore.Services.Interfaces;
|
||||||
@@ -15,8 +16,9 @@ public sealed class UomsController : ApiControllerBase
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PagedResponse<UomDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<UomDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<UomDto>>> List([FromQuery] PageQuery query, CancellationToken ct)
|
public async Task<ActionResult<PagedResponse<UomDto>>> List(
|
||||||
=> Ok(await _uoms.ListAsync(query, ct));
|
[FromQuery] PageQuery query, [FromQuery] EntityStatus? status, CancellationToken ct)
|
||||||
|
=> Ok(await _uoms.ListAsync(query, status, ct));
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(UomDto), StatusCodes.Status201Created)]
|
[ProducesResponseType(typeof(UomDto), StatusCodes.Status201Created)]
|
||||||
@@ -26,4 +28,14 @@ public sealed class UomsController : ApiControllerBase
|
|||||||
var dto = await _uoms.CreateAsync(request, ct);
|
var dto = await _uoms.CreateAsync(request, ct);
|
||||||
return Created($"/api/v1/uoms/{dto.UomId}", dto);
|
return Created($"/api/v1/uoms/{dto.UomId}", dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Deactivate/reactivate. Masters are never hard-deleted (FR-MD-08).</summary>
|
||||||
|
[HttpPatch("{uomId:int}/status")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<IActionResult> SetStatus(int uomId, [FromBody] UpdateUomStatusRequest request, CancellationToken ct)
|
||||||
|
{
|
||||||
|
await _uoms.SetStatusAsync(uomId, request.Status, ct);
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
using ERPCore.Dtos.Audit;
|
||||||
using ERPCore.Dtos.Common;
|
using ERPCore.Dtos.Common;
|
||||||
using ERPCore.Dtos.Hrm;
|
using ERPCore.Dtos.Hrm;
|
||||||
using ERPCore.Dtos.Users;
|
using ERPCore.Dtos.Users;
|
||||||
|
using ERPCore.Infra.Auth;
|
||||||
using ERPCore.Services.Interfaces;
|
using ERPCore.Services.Interfaces;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -15,11 +18,15 @@ public sealed class UsersController : ApiControllerBase
|
|||||||
{
|
{
|
||||||
private readonly IUserManagementService _users;
|
private readonly IUserManagementService _users;
|
||||||
private readonly IEmployeeUserLinkService _links;
|
private readonly IEmployeeUserLinkService _links;
|
||||||
|
private readonly IAuditService _audit;
|
||||||
|
private readonly ICurrentUser _currentUser;
|
||||||
|
|
||||||
public UsersController(IUserManagementService users, IEmployeeUserLinkService links)
|
public UsersController(IUserManagementService users, IEmployeeUserLinkService links, IAuditService audit, ICurrentUser currentUser)
|
||||||
{
|
{
|
||||||
_users = users;
|
_users = users;
|
||||||
_links = links;
|
_links = links;
|
||||||
|
_audit = audit;
|
||||||
|
_currentUser = currentUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Advisory forward-direction lookup: does a Staff record already exist with this email? (docs/12-BACKEND-HRM.md A.5)</summary>
|
/// <summary>Advisory forward-direction lookup: does a Staff record already exist with this email? (docs/12-BACKEND-HRM.md A.5)</summary>
|
||||||
@@ -30,8 +37,8 @@ public sealed class UsersController : ApiControllerBase
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PagedResponse<ManagedUserDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<ManagedUserDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<ManagedUserDto>>> List([FromQuery] PageQuery query, CancellationToken ct)
|
public async Task<ActionResult<PagedResponse<ManagedUserDto>>> List([FromQuery] PageQuery query, [FromQuery] EntityStatus? status, [FromQuery] string? roleCode, CancellationToken ct)
|
||||||
=> Ok(await _users.ListAsync(query, ct));
|
=> Ok(await _users.ListAsync(query, status, roleCode, ct));
|
||||||
|
|
||||||
/// <summary>AuthHex UserType options for the create-user form's select.</summary>
|
/// <summary>AuthHex UserType options for the create-user form's select.</summary>
|
||||||
[HttpGet("user-types")]
|
[HttpGet("user-types")]
|
||||||
@@ -53,7 +60,7 @@ public sealed class UsersController : ApiControllerBase
|
|||||||
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
[ProducesResponseType(StatusCodes.Status409Conflict)]
|
||||||
public async Task<ActionResult<ManagedUserDto>> Create([FromBody] CreateUserRequest request, CancellationToken ct)
|
public async Task<ActionResult<ManagedUserDto>> Create([FromBody] CreateUserRequest request, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var result = await _users.CreateAsync(request, ct);
|
var result = await _users.CreateAsync(request, _currentUser.AuditUserId, ct);
|
||||||
return Created($"/api/v1/users/{result.UserId}", result);
|
return Created($"/api/v1/users/{result.UserId}", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,4 +69,18 @@ public sealed class UsersController : ApiControllerBase
|
|||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult<ManagedUserDto>> UpdateRole(int userId, [FromBody] UpdateUserRoleRequest request, CancellationToken ct)
|
public async Task<ActionResult<ManagedUserDto>> UpdateRole(int userId, [FromBody] UpdateUserRoleRequest request, CancellationToken ct)
|
||||||
=> Ok(await _users.UpdateRoleAsync(userId, request, ct));
|
=> Ok(await _users.UpdateRoleAsync(userId, request, ct));
|
||||||
|
|
||||||
|
/// <summary>Revokes/restores standing inside ERPCore only — see <see cref="IUserManagementService.SetStatusAsync"/>.</summary>
|
||||||
|
[HttpPatch("{userId:int}/status")]
|
||||||
|
[ProducesResponseType(typeof(ManagedUserDto), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
public async Task<ActionResult<ManagedUserDto>> UpdateStatus(int userId, [FromBody] UpdateUserStatusRequest request, CancellationToken ct)
|
||||||
|
=> Ok(await _users.SetStatusAsync(userId, request.Status, ct));
|
||||||
|
|
||||||
|
/// <summary>Device/login history ERPCore captures itself — not AuthHex's "currently active sessions"
|
||||||
|
/// (which only ever reports the caller's own). See <see cref="IAuditService.ListLoginDevicesAsync"/>.</summary>
|
||||||
|
[HttpGet("{userId:int}/login-devices")]
|
||||||
|
[ProducesResponseType(typeof(PagedResponse<LoginActivityDto>), StatusCodes.Status200OK)]
|
||||||
|
public async Task<ActionResult<PagedResponse<LoginActivityDto>>> ListLoginDevices(int userId, [FromQuery] PageQuery query, CancellationToken ct)
|
||||||
|
=> Ok(await _audit.ListLoginDevicesAsync(userId, query, ct));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ public sealed class WarehousesController : ApiControllerBase
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(PagedResponse<WarehouseDto>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PagedResponse<WarehouseDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PagedResponse<WarehouseDto>>> List([FromQuery] PageQuery query, CancellationToken ct)
|
public async Task<ActionResult<PagedResponse<WarehouseDto>>> List(
|
||||||
=> Ok(await _warehouses.ListAsync(query, ct));
|
[FromQuery] PageQuery query, [FromQuery] int? branchId, CancellationToken ct)
|
||||||
|
=> Ok(await _warehouses.ListAsync(query, branchId, ct));
|
||||||
|
|
||||||
[HttpGet("{warehouseId:int}")]
|
[HttpGet("{warehouseId:int}")]
|
||||||
[ProducesResponseType(typeof(WarehouseDto), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(WarehouseDto), StatusCodes.Status200OK)]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public static class DocumentTypes
|
|||||||
public const string Rfq = "RFQ";
|
public const string Rfq = "RFQ";
|
||||||
public const string PurchaseOrder = "PO";
|
public const string PurchaseOrder = "PO";
|
||||||
public const string Grn = "GRN";
|
public const string Grn = "GRN";
|
||||||
|
public const string PurchaseInvoice = "PINV";
|
||||||
public const string Transfer = "TRF";
|
public const string Transfer = "TRF";
|
||||||
public const string Adjustment = "ADJ";
|
public const string Adjustment = "ADJ";
|
||||||
public const string Count = "CNT";
|
public const string Count = "CNT";
|
||||||
@@ -20,6 +21,7 @@ public static class DocumentTypes
|
|||||||
public const string SalesInvoice = "SI";
|
public const string SalesInvoice = "SI";
|
||||||
public const string SalesSlip = "SSL";
|
public const string SalesSlip = "SSL";
|
||||||
public const string BundleSale = "BND";
|
public const string BundleSale = "BND";
|
||||||
|
public const string BundleSaleTemplate = "TPL";
|
||||||
public const string SalesReturn = "SRET";
|
public const string SalesReturn = "SRET";
|
||||||
|
|
||||||
/// <summary>Cashier day-end close-out (Sales) — <c>DEND-2026-00001</c>.</summary>
|
/// <summary>Cashier day-end close-out (Sales) — <c>DEND-2026-00001</c>.</summary>
|
||||||
|
|||||||
@@ -3,16 +3,19 @@ using ERPCore.Domain.Enums;
|
|||||||
namespace ERPCore.Domain.Entities;
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Branch/location master (FR-HR-MD-01) — multi-branch readiness. Referenced
|
/// Branch/location master (FR-HR-MD-01) — multi-branch readiness. Required by
|
||||||
/// optionally by <see cref="Employee.BranchId"/> and <see cref="PayrollRun.BranchId"/>.
|
/// <see cref="Employee.BranchId"/>, optionally referenced by <see cref="PayrollRun.BranchId"/>.
|
||||||
/// Deactivated, not deleted, when referenced. Model: docs/12-BACKEND-HRM.md Part C.1.
|
/// Deactivated, not deleted, when referenced. Model: docs/12-BACKEND-HRM.md Part C.1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Branch
|
public class Branch
|
||||||
{
|
{
|
||||||
public int BranchId { get; set; }
|
public int BranchId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Server-generated on create ("BR-001", "BR-002", ...) — never accepted from the client.</summary>
|
||||||
public string Code { get; set; } = string.Empty;
|
public string Code { get; set; } = string.Empty;
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
public string? PhoneNumber { get; set; }
|
||||||
public EntityStatus Status { get; set; } = EntityStatus.Active;
|
public EntityStatus Status { get; set; } = EntityStatus.Active;
|
||||||
|
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Branch configuration — a singleton row (single-tenant, docs/00-CORE §1) gating whether
|
||||||
|
/// this deployment uses branches at all. When <see cref="BranchingEnabled"/> is off, the
|
||||||
|
/// Employee/Warehouse create forms stop asking for a branch and every new record is
|
||||||
|
/// silently assigned to the deployment's one default branch instead — schema-wise
|
||||||
|
/// <c>Employee.BranchId</c>/<c>Warehouse.BranchId</c> stay <c>NOT NULL</c> either way, only
|
||||||
|
/// the UI/UX requirement toggles. See <see cref="Services.BranchConfigService.ResolveBranchIdAsync"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class BranchConfig
|
||||||
|
{
|
||||||
|
/// <summary>Always 1 - the singleton row's id.</summary>
|
||||||
|
public const int SingletonId = 1;
|
||||||
|
|
||||||
|
public int ConfigId { get; set; }
|
||||||
|
|
||||||
|
public bool BranchingEnabled { get; set; } = true;
|
||||||
|
|
||||||
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
public int? UpdatedBy { get; set; }
|
||||||
|
public User? UpdatedByUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>PostgreSQL xmin-backed optimistic concurrency token (ETag source).</summary>
|
||||||
|
public uint RowVersion { get; set; }
|
||||||
|
}
|
||||||
@@ -6,8 +6,10 @@ namespace ERPCore.Domain.Entities;
|
|||||||
/// Staff record (FR-HR-MD-02) — distinct from <see cref="User"/> (the system login
|
/// Staff record (FR-HR-MD-02) — distinct from <see cref="User"/> (the system login
|
||||||
/// account): not every employee has a login, and not every login belongs to an
|
/// account): not every employee has a login, and not every login belongs to an
|
||||||
/// employee. <see cref="UserId"/> is the optional, explicit, human-confirmed link
|
/// employee. <see cref="UserId"/> is the optional, explicit, human-confirmed link
|
||||||
/// between the two (docs/12-BACKEND-HRM.md A.5/C.2, Part B.3.2). Never hard-deleted —
|
/// between the two (docs/12-BACKEND-HRM.md A.5/C.2, Part B.3.2). Normal separation is
|
||||||
/// separation is recorded via <see cref="Status"/> + <see cref="LastWorkingDate"/>.
|
/// recorded via <see cref="Status"/> + <see cref="LastWorkingDate"/> rather than deletion;
|
||||||
|
/// an explicit hard delete is also available (<see cref="Services.Interfaces.IEmployeeService.DeleteAsync"/>)
|
||||||
|
/// and cascades to every dependent HR record, blocked only if payroll history exists.
|
||||||
/// <see cref="EmployeeCode"/> is user-entered (not <see cref="NumberSequence"/>-issued):
|
/// <see cref="EmployeeCode"/> is user-entered (not <see cref="NumberSequence"/>-issued):
|
||||||
/// HR departments keep their own legacy numbering scheme, and NumberSequence's
|
/// HR departments keep their own legacy numbering scheme, and NumberSequence's
|
||||||
/// year-scoping is the wrong shape for an identifier that must never look "reset".
|
/// year-scoping is the wrong shape for an identifier that must never look "reset".
|
||||||
@@ -50,7 +52,7 @@ public class Employee
|
|||||||
public Designation? Designation { get; set; }
|
public Designation? Designation { get; set; }
|
||||||
public int EmploymentTypeId { get; set; }
|
public int EmploymentTypeId { get; set; }
|
||||||
public EmploymentType? EmploymentType { get; set; }
|
public EmploymentType? EmploymentType { get; set; }
|
||||||
public int? BranchId { get; set; }
|
public int BranchId { get; set; }
|
||||||
public Branch? Branch { get; set; }
|
public Branch? Branch { get; set; }
|
||||||
public int WorkShiftId { get; set; }
|
public int WorkShiftId { get; set; }
|
||||||
public WorkShift? WorkShift { get; set; }
|
public WorkShift? WorkShift { get; set; }
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ public class Grn
|
|||||||
public int WarehouseId { get; set; }
|
public int WarehouseId { get; set; }
|
||||||
public Warehouse? Warehouse { get; set; }
|
public Warehouse? Warehouse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Owning branch, set explicitly at creation — warehouses are shared across
|
||||||
|
/// branches, so branch scope can no longer be derived from <see cref="Warehouse"/>.</summary>
|
||||||
|
public int BranchId { get; set; }
|
||||||
|
public Branch? Branch { get; set; }
|
||||||
|
|
||||||
public GrnStatus Status { get; set; } = GrnStatus.Draft;
|
public GrnStatus Status { get; set; } = GrnStatus.Draft;
|
||||||
|
|
||||||
public int CreatedBy { get; set; }
|
public int CreatedBy { get; set; }
|
||||||
@@ -34,14 +39,14 @@ public class Grn
|
|||||||
public string? GlJournalNo { get; set; }
|
public string? GlJournalNo { get; set; }
|
||||||
public DateTime? GlPostedAt { get; set; }
|
public DateTime? GlPostedAt { get; set; }
|
||||||
|
|
||||||
/// <summary>Sum of vendor payments made against this GRN's total payable (<see cref="GrnLine.LineTotal"/>).</summary>
|
/// <summary>The Purchase Invoice this GRN has been consolidated into, if any (null until
|
||||||
public decimal PaidAmount { get; set; }
|
/// invoiced). Vendor settlement is tracked on the invoice, not per-GRN — see
|
||||||
/// <summary>Total payable minus <see cref="PaidAmount"/>; installments accrue against this until it reaches zero.</summary>
|
/// <see cref="PurchaseInvoice"/>.</summary>
|
||||||
public decimal BalanceAmount { get; set; }
|
public int? PurchaseInvoiceId { get; set; }
|
||||||
|
public PurchaseInvoice? PurchaseInvoice { get; set; }
|
||||||
|
|
||||||
/// <summary>PostgreSQL xmin-backed optimistic concurrency token.</summary>
|
/// <summary>PostgreSQL xmin-backed optimistic concurrency token.</summary>
|
||||||
public uint RowVersion { get; set; }
|
public uint RowVersion { get; set; }
|
||||||
|
|
||||||
public ICollection<GrnLine> Lines { get; set; } = new List<GrnLine>();
|
public ICollection<GrnLine> Lines { get; set; } = new List<GrnLine>();
|
||||||
public ICollection<GrnPayment> Payments { get; set; } = new List<GrnPayment>();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,11 +44,12 @@ public class Item
|
|||||||
public string? TaxClass { get; set; }
|
public string? TaxClass { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional fixed selling price used by Sales only. <c>null</c> means "use stock value"
|
/// Optional selling price range and flat price used by Sales only.
|
||||||
/// (the item is sold at its FIFO stock cost at sale time); a value is the fixed sale price.
|
/// <c>null</c> values mean the field is not set. These values never enter costing/GRN/FIFO.
|
||||||
/// Never enters costing/GRN/FIFO (docs/10 Part C.1, C.9).
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? SalePrice { get; set; }
|
public decimal? SellingMinPrice { get; set; }
|
||||||
|
public decimal? SellingMaxPrice { get; set; }
|
||||||
|
public decimal? SellingFlatPrice { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How much one pack holds, as the user entered it — <c>500</c> with
|
/// How much one pack holds, as the user entered it — <c>500</c> with
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// One row per successful sign-in, captured directly by ERPCore (not AuthHex) so an
|
||||||
|
/// admin can see a user's device/login history — AuthHex's own session listing only
|
||||||
|
/// ever reports the currently-authenticated caller's own sessions, with no admin-scoped
|
||||||
|
/// call to inspect anyone else's. This is a history of past logins, not a live "currently
|
||||||
|
/// active sessions" view (that would need AuthHex to expose one).
|
||||||
|
/// </summary>
|
||||||
|
public class LoginActivity
|
||||||
|
{
|
||||||
|
public int LoginActivityId { get; set; }
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public User? User { get; set; }
|
||||||
|
|
||||||
|
public string? IpAddress { get; set; }
|
||||||
|
public string? UserAgent { get; set; }
|
||||||
|
/// <summary>Best-effort "Browser on OS" label parsed from <see cref="UserAgent"/> for display.</summary>
|
||||||
|
public string? DeviceLabel { get; set; }
|
||||||
|
|
||||||
|
public DateTime LoginAt { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notification configuration (new settings module) - singleton root row.
|
||||||
|
/// </summary>
|
||||||
|
public class NotificationConfig
|
||||||
|
{
|
||||||
|
public const int SingletonId = 1;
|
||||||
|
|
||||||
|
public int NotificationConfigId { get; set; }
|
||||||
|
|
||||||
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
public int? UpdatedBy { get; set; }
|
||||||
|
public User? UpdatedByUser { get; set; }
|
||||||
|
|
||||||
|
public uint RowVersion { get; set; }
|
||||||
|
|
||||||
|
public ICollection<NotificationConfigModule> Modules { get; set; } = new List<NotificationConfigModule>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
|
public class NotificationConfigModule
|
||||||
|
{
|
||||||
|
public int NotificationConfigModuleId { get; set; }
|
||||||
|
|
||||||
|
public int NotificationConfigId { get; set; }
|
||||||
|
public NotificationConfig? NotificationConfig { get; set; }
|
||||||
|
|
||||||
|
public string ModuleKey { get; set; } = string.Empty;
|
||||||
|
public bool EmailEnabled { get; set; }
|
||||||
|
public bool SmsEnabled { get; set; }
|
||||||
|
public bool InAppEnabled { get; set; }
|
||||||
|
}
|
||||||
@@ -1,22 +1,24 @@
|
|||||||
namespace ERPCore.Domain.Entities;
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Product configuration (FR-MD-11) — a <b>singleton row</b> (single-tenant, docs/00-CORE §1)
|
/// Product configuration (FR-MD-11) - a singleton row (single-tenant, docs/00-CORE §1)
|
||||||
/// gating optional product master-data features.
|
/// gating optional product master-data features.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// <see cref="SubcategoriesEnabled"/> and <see cref="BrandsEnabled"/> are enforced
|
/// <see cref="SubcategoriesEnabled"/> and <see cref="BrandsEnabled"/> are enforced
|
||||||
/// server-side: an Item write carrying a subcategory/brand while the flag is off is
|
/// server-side: an Item write carrying a subcategory/brand while the flag is off is
|
||||||
/// rejected with <c>CONFIG_DISABLED</c>. <see cref="ItemTypesEnabled"/> is
|
/// rejected with <c>CONFIG_DISABLED</c>. <see cref="ItemTypesEnabled"/> is advisory only
|
||||||
/// <b>advisory only</b> — items carry no item-type reference (see <see cref="ItemType"/>),
|
/// - items carry no item-type reference (see <see cref="ItemType"/>), so there is nothing
|
||||||
/// so there is nothing on a write to reject; the frontend honours it by hiding the
|
/// on a write to reject; the frontend honours it by hiding the variant builder.
|
||||||
/// builder's type section. Reads are never gated, so existing data stays visible after a
|
/// <see cref="SellingPricesEnabled"/>, <see cref="SerialNumbersEnabled"/>,
|
||||||
/// flag is switched off.
|
/// <see cref="BatchListsEnabled"/> and <see cref="WarrantyPeriodsEnabled"/> are enforced
|
||||||
|
/// on item writes and drive the create/edit screens. Reads are never gated, so existing
|
||||||
|
/// data stays visible after a flag is switched off.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// Model: docs/10-BACKEND-PHASE1.md Part C.1.
|
/// Model: docs/10-BACKEND-PHASE1.md Part C.1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProductConfig
|
public class ProductConfig
|
||||||
{
|
{
|
||||||
/// <summary>Always 1 — the singleton row's id.</summary>
|
/// <summary>Always 1 - the singleton row's id.</summary>
|
||||||
public const int SingletonId = 1;
|
public const int SingletonId = 1;
|
||||||
|
|
||||||
public int ConfigId { get; set; }
|
public int ConfigId { get; set; }
|
||||||
@@ -24,6 +26,10 @@ public class ProductConfig
|
|||||||
public bool SubcategoriesEnabled { get; set; } = true;
|
public bool SubcategoriesEnabled { get; set; } = true;
|
||||||
public bool BrandsEnabled { get; set; } = true;
|
public bool BrandsEnabled { get; set; } = true;
|
||||||
public bool ItemTypesEnabled { get; set; } = true;
|
public bool ItemTypesEnabled { get; set; } = true;
|
||||||
|
public bool SellingPricesEnabled { get; set; } = true;
|
||||||
|
public bool SerialNumbersEnabled { get; set; } = true;
|
||||||
|
public bool BatchListsEnabled { get; set; } = true;
|
||||||
|
public bool WarrantyPeriodsEnabled { get; set; } = true;
|
||||||
|
|
||||||
public DateTime? UpdatedAt { get; set; }
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
|
||||||
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vendor invoice consolidating one or more Confirmed GRNs for the same vendor
|
||||||
|
/// (each linked GRN becomes one <see cref="PurchaseInvoiceLine"/>, not re-itemized).
|
||||||
|
/// Draft is editable (GRNs can be re-selected); Posted reclassifies the GRN clearing
|
||||||
|
/// balance to Accounts Payable (see PurchaseInvoiceService.PostAsync); vendor payments
|
||||||
|
/// are then recorded against this aggregate rather than against the individual GRNs.
|
||||||
|
/// </summary>
|
||||||
|
public class PurchaseInvoice
|
||||||
|
{
|
||||||
|
public int PurchaseInvoiceId { get; set; }
|
||||||
|
public string DocNo { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string VendorInvoiceNo { get; set; } = string.Empty;
|
||||||
|
public DateTime VendorInvoiceDate { get; set; }
|
||||||
|
|
||||||
|
public int VendorId { get; set; }
|
||||||
|
public Vendor? Vendor { get; set; }
|
||||||
|
|
||||||
|
public string VendorSnapshotName { get; set; } = string.Empty;
|
||||||
|
public string? VendorSnapshotTaxNo { get; set; }
|
||||||
|
|
||||||
|
public PurchaseInvoiceStatus Status { get; set; } = PurchaseInvoiceStatus.Draft;
|
||||||
|
|
||||||
|
public decimal Subtotal { get; set; }
|
||||||
|
public decimal VatTotal { get; set; }
|
||||||
|
public decimal GrandTotal { get; set; }
|
||||||
|
public decimal PaidAmount { get; set; }
|
||||||
|
public decimal BalanceAmount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Journal number of the AP-recognition GL journal entry posted when this
|
||||||
|
/// invoice is Posted (Debit GRN Clearing / Credit Accounts Payable) — see
|
||||||
|
/// PurchaseInvoiceService.PostAsync.</summary>
|
||||||
|
public string? GlJournalNo { get; set; }
|
||||||
|
public DateTime? GlPostedAt { get; set; }
|
||||||
|
|
||||||
|
public int CreatedBy { get; set; }
|
||||||
|
public User? Creator { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
|
||||||
|
public uint RowVersion { get; set; }
|
||||||
|
|
||||||
|
public ICollection<PurchaseInvoiceLine> Lines { get; set; } = new List<PurchaseInvoiceLine>();
|
||||||
|
public ICollection<PurchaseInvoicePayment> Payments { get; set; } = new List<PurchaseInvoicePayment>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// One row per consolidated GRN on a <see cref="PurchaseInvoice"/> — a straight
|
||||||
|
/// consolidation of that GRN's line totals, not a re-itemization (docs: Purchase
|
||||||
|
/// Invoice consolidates GRNs, it does not re-enter item lines).
|
||||||
|
/// </summary>
|
||||||
|
public class PurchaseInvoiceLine
|
||||||
|
{
|
||||||
|
public int PurchaseInvoiceLineId { get; set; }
|
||||||
|
|
||||||
|
public int PurchaseInvoiceId { get; set; }
|
||||||
|
public PurchaseInvoice? PurchaseInvoice { get; set; }
|
||||||
|
|
||||||
|
public int GrnId { get; set; }
|
||||||
|
public Grn? Grn { get; set; }
|
||||||
|
|
||||||
|
public decimal Subtotal { get; set; }
|
||||||
|
public decimal VatTotal { get; set; }
|
||||||
|
public decimal LineTotal { get; set; }
|
||||||
|
}
|
||||||
+8
-7
@@ -1,16 +1,17 @@
|
|||||||
namespace ERPCore.Domain.Entities;
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A vendor payment made against a confirmed GRN's balance (installments allowed —
|
/// A vendor payment made against a Posted purchase invoice's balance (installments
|
||||||
/// see GrnPaymentService.PayAsync). Posts its own real GL journal entry (Debit GRN
|
/// allowed — see PurchaseInvoicePaymentService.PayAsync). Posts its own real GL
|
||||||
/// Clearing / Credit the selected bank-or-cash account) before being recorded here.
|
/// journal entry (Debit Accounts Payable / Credit the selected bank-or-cash account)
|
||||||
|
/// before being recorded here.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GrnPayment
|
public class PurchaseInvoicePayment
|
||||||
{
|
{
|
||||||
public int GrnPaymentId { get; set; }
|
public int PurchaseInvoicePaymentId { get; set; }
|
||||||
|
|
||||||
public int GrnId { get; set; }
|
public int PurchaseInvoiceId { get; set; }
|
||||||
public Grn? Grn { get; set; }
|
public PurchaseInvoice? PurchaseInvoice { get; set; }
|
||||||
|
|
||||||
public decimal Amount { get; set; }
|
public decimal Amount { get; set; }
|
||||||
public DateTime PaymentDate { get; set; }
|
public DateTime PaymentDate { get; set; }
|
||||||
@@ -17,6 +17,11 @@ public class SalesInvoice
|
|||||||
public int WarehouseId { get; set; }
|
public int WarehouseId { get; set; }
|
||||||
public Warehouse? Warehouse { get; set; }
|
public Warehouse? Warehouse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Owning branch, set explicitly at creation — warehouses are shared across
|
||||||
|
/// branches, so branch scope can no longer be derived from <see cref="Warehouse"/>.</summary>
|
||||||
|
public int BranchId { get; set; }
|
||||||
|
public Branch? Branch { get; set; }
|
||||||
|
|
||||||
public SalesInvoiceType InvoiceType { get; set; } = SalesInvoiceType.B2C;
|
public SalesInvoiceType InvoiceType { get; set; } = SalesInvoiceType.B2C;
|
||||||
public SalesInvoiceStatus Status { get; set; } = SalesInvoiceStatus.Draft;
|
public SalesInvoiceStatus Status { get; set; } = SalesInvoiceStatus.Draft;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace ERPCore.Domain.Entities;
|
|||||||
/// A customer payment made against a Posted sales invoice's balance (installments
|
/// A customer payment made against a Posted sales invoice's balance (installments
|
||||||
/// allowed — see SalesInvoicePaymentService.PayAsync). Posts its own real GL journal
|
/// allowed — see SalesInvoicePaymentService.PayAsync). Posts its own real GL journal
|
||||||
/// entry (Debit the selected bank-or-cash account / Credit Accounts Receivable) before
|
/// entry (Debit the selected bank-or-cash account / Credit Accounts Receivable) before
|
||||||
/// being recorded here — the mirror image of <see cref="GrnPayment"/>.
|
/// being recorded here — the mirror image of <see cref="PurchaseInvoicePayment"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SalesInvoicePayment
|
public class SalesInvoicePayment
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public class StockAdjustment
|
|||||||
public int ReasonCodeId { get; set; }
|
public int ReasonCodeId { get; set; }
|
||||||
public ReasonCode? ReasonCode { get; set; }
|
public ReasonCode? ReasonCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Owning branch, set explicitly at creation — warehouses are shared across
|
||||||
|
/// branches, so branch scope can no longer be derived from <see cref="Warehouse"/>.</summary>
|
||||||
|
public int BranchId { get; set; }
|
||||||
|
public Branch? Branch { get; set; }
|
||||||
|
|
||||||
public AdjustmentStatus Status { get; set; } = AdjustmentStatus.Posted;
|
public AdjustmentStatus Status { get; set; } = AdjustmentStatus.Posted;
|
||||||
|
|
||||||
public int CreatedBy { get; set; }
|
public int CreatedBy { get; set; }
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ public class StockCount
|
|||||||
public int WarehouseId { get; set; }
|
public int WarehouseId { get; set; }
|
||||||
public Warehouse? Warehouse { get; set; }
|
public Warehouse? Warehouse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Owning branch, set explicitly at creation — warehouses are shared across
|
||||||
|
/// branches, so branch scope can no longer be derived from <see cref="Warehouse"/>.</summary>
|
||||||
|
public int BranchId { get; set; }
|
||||||
|
public Branch? Branch { get; set; }
|
||||||
|
|
||||||
public CountType CountType { get; set; }
|
public CountType CountType { get; set; }
|
||||||
public CountStatus Status { get; set; } = CountStatus.Draft;
|
public CountStatus Status { get; set; } = CountStatus.Draft;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ public class StockTransfer
|
|||||||
public int DestWarehouseId { get; set; }
|
public int DestWarehouseId { get; set; }
|
||||||
public Warehouse? DestWarehouse { get; set; }
|
public Warehouse? DestWarehouse { get; set; }
|
||||||
|
|
||||||
|
/// <summary>Owning branch, set explicitly at creation — warehouses are shared across
|
||||||
|
/// branches, so branch scope can no longer be derived from src/dest warehouse.</summary>
|
||||||
|
public int BranchId { get; set; }
|
||||||
|
public Branch? Branch { get; set; }
|
||||||
|
|
||||||
public TransferStatus Status { get; set; } = TransferStatus.Draft;
|
public TransferStatus Status { get; set; } = TransferStatus.Draft;
|
||||||
|
|
||||||
public int CreatedBy { get; set; }
|
public int CreatedBy { get; set; }
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
|
||||||
namespace ERPCore.Domain.Entities;
|
namespace ERPCore.Domain.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -10,4 +12,8 @@ public class Uom
|
|||||||
{
|
{
|
||||||
public int UomId { get; set; }
|
public int UomId { get; set; }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public EntityStatus Status { get; set; } = EntityStatus.Active;
|
||||||
|
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public DateTime? UpdatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ public class Warehouse
|
|||||||
public int WarehouseId { get; set; }
|
public int WarehouseId { get; set; }
|
||||||
public string Code { get; set; } = string.Empty;
|
public string Code { get; set; } = string.Empty;
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
public int BranchId { get; set; }
|
||||||
|
public Branch? Branch { get; set; }
|
||||||
|
|
||||||
public ICollection<Bin> Bins { get; set; } = new List<Bin>();
|
public ICollection<Bin> Bins { get; set; } = new List<Bin>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,8 @@ public enum AuditAction
|
|||||||
{
|
{
|
||||||
Create,
|
Create,
|
||||||
Update,
|
Update,
|
||||||
Delete
|
Delete,
|
||||||
|
/// <summary>A successful sign-in — written explicitly (not via ErpDbContext's automatic
|
||||||
|
/// entity-change capture, since a login mutates nothing) by AuthController.</summary>
|
||||||
|
Login
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace ERPCore.Domain.Enums;
|
||||||
|
|
||||||
|
public enum PurchaseInvoiceStatus
|
||||||
|
{
|
||||||
|
Draft,
|
||||||
|
Posted,
|
||||||
|
Cancelled
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
namespace ERPCore.Domain.Notifications.Modules;
|
||||||
|
|
||||||
|
[NotificationModule("sale.create", "Sale Created", "Raised when a sales document is created.", 10)]
|
||||||
|
public sealed class SaleCreateNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("sale.posted", "Sale Posted", "Raised when a sales document is posted.", 20)]
|
||||||
|
public sealed class SalePostedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("grn.created", "GRN Created", "Raised when a goods receipt note is created.", 30)]
|
||||||
|
public sealed class GrnCreatedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("grn.confirmed", "GRN Confirmed", "Raised when a goods receipt note is confirmed.", 40)]
|
||||||
|
public sealed class GrnConfirmedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("purchase.order.created", "Purchase Order Created", "Raised when a purchase order is created.", 50)]
|
||||||
|
public sealed class PurchaseOrderCreatedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("purchase.order.approved", "Purchase Order Approved", "Raised when a purchase order is approved.", 60)]
|
||||||
|
public sealed class PurchaseOrderApprovedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("purchase.return.created", "Purchase Return Created", "Raised when a purchase return is created.", 70)]
|
||||||
|
public sealed class PurchaseReturnCreatedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("stock.adjustment.created", "Stock Adjustment Created", "Raised when a stock adjustment is created.", 80)]
|
||||||
|
public sealed class StockAdjustmentCreatedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("stock.transfer.created", "Stock Transfer Created", "Raised when a stock transfer is created.", 90)]
|
||||||
|
public sealed class StockTransferCreatedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("item.created", "Item Created", "Raised when an item master record is created.", 100)]
|
||||||
|
public sealed class ItemCreatedNotificationModule;
|
||||||
|
|
||||||
|
[NotificationModule("item.updated", "Item Updated", "Raised when an item master record is updated.", 110)]
|
||||||
|
public sealed class ItemUpdatedNotificationModule;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace ERPCore.Domain.Notifications;
|
||||||
|
|
||||||
|
public enum NotificationChannel
|
||||||
|
{
|
||||||
|
Email,
|
||||||
|
Sms,
|
||||||
|
InApp
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
namespace ERPCore.Domain.Notifications;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
|
||||||
|
public sealed class NotificationModuleAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Key { get; }
|
||||||
|
public string Label { get; }
|
||||||
|
public string Description { get; }
|
||||||
|
public int SortOrder { get; }
|
||||||
|
|
||||||
|
public NotificationModuleAttribute(string key, string label, string description, int sortOrder)
|
||||||
|
{
|
||||||
|
Key = key;
|
||||||
|
Label = label;
|
||||||
|
Description = description;
|
||||||
|
SortOrder = sortOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace ERPCore.Domain.Notifications;
|
||||||
|
|
||||||
|
public sealed record NotificationModuleDefinition(
|
||||||
|
string Key,
|
||||||
|
string Label,
|
||||||
|
string Description,
|
||||||
|
int SortOrder);
|
||||||
@@ -10,3 +10,7 @@ public sealed record AuditLogDto(
|
|||||||
/// <summary>A GL-ready journal stub emitted per stock movement (FR-STK-13).</summary>
|
/// <summary>A GL-ready journal stub emitted per stock movement (FR-STK-13).</summary>
|
||||||
public sealed record JournalEntryStubDto(
|
public sealed record JournalEntryStubDto(
|
||||||
int JournalId, string SourceDocType, int SourceDocId, string DebitAccount, string CreditAccount, decimal Amount);
|
int JournalId, string SourceDocType, int SourceDocId, string DebitAccount, string CreditAccount, decimal Amount);
|
||||||
|
|
||||||
|
/// <summary>A captured past sign-in — device history, not a live "currently active sessions" view.</summary>
|
||||||
|
public sealed record LoginActivityDto(
|
||||||
|
int LoginActivityId, string? IpAddress, string? DeviceLabel, DateTime LoginAt);
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ERPCore.Dtos.Config;
|
||||||
|
|
||||||
|
/// <summary>Branch configuration resource — the singleton toggle for whether this deployment
|
||||||
|
/// requires a branch on Employee/Warehouse records at all.</summary>
|
||||||
|
public sealed record BranchConfigDto(bool BranchingEnabled, DateTime? UpdatedAt, int? UpdatedBy);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Full replacement of the flag. <c>UpdatedBy</c> is derived from the token, never posted.
|
||||||
|
/// <para>
|
||||||
|
/// <see cref="BranchingEnabled"/> is <see cref="bool"/>? deliberately: <c>[Required]</c> on a
|
||||||
|
/// non-nullable bool is a no-op, so an omitted flag would otherwise silently bind to
|
||||||
|
/// <c>false</c>. Nullable makes the requirement actually bind — an omitted flag is a 400.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
public sealed class UpdateBranchConfigRequest
|
||||||
|
{
|
||||||
|
[Required] public bool? BranchingEnabled { get; set; }
|
||||||
|
}
|
||||||
@@ -4,10 +4,14 @@ namespace ERPCore.Dtos.Config;
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Product configuration resource (docs/11-BACKEND-PHASE1.md §2.8). Singleton.
|
/// Product configuration resource (docs/11-BACKEND-PHASE1.md §2.8). Singleton.
|
||||||
/// <see cref="ItemTypesEnabled"/> is advisory (frontend-honoured) — see the entity docs.
|
/// <see cref="ItemTypesEnabled"/> is advisory (frontend-honoured) - see the entity docs.
|
||||||
|
/// <see cref="SellingPricesEnabled"/>, <see cref="SerialNumbersEnabled"/>,
|
||||||
|
/// <see cref="BatchListsEnabled"/> and <see cref="WarrantyPeriodsEnabled"/> are enforced
|
||||||
|
/// when items are written.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record ProductConfigDto(
|
public sealed record ProductConfigDto(
|
||||||
bool SubcategoriesEnabled, bool BrandsEnabled, bool ItemTypesEnabled,
|
bool SubcategoriesEnabled, bool BrandsEnabled, bool ItemTypesEnabled,
|
||||||
|
bool SellingPricesEnabled, bool SerialNumbersEnabled, bool BatchListsEnabled, bool WarrantyPeriodsEnabled,
|
||||||
DateTime? UpdatedAt, int? UpdatedBy);
|
DateTime? UpdatedAt, int? UpdatedBy);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -15,8 +19,8 @@ public sealed record ProductConfigDto(
|
|||||||
/// <para>
|
/// <para>
|
||||||
/// The flags are <see cref="bool"/>? deliberately: <c>[Required]</c> on a non-nullable bool
|
/// The flags are <see cref="bool"/>? deliberately: <c>[Required]</c> on a non-nullable bool
|
||||||
/// is a no-op (it always has a value), so a body of <c>{}</c> would bind every flag to
|
/// is a no-op (it always has a value), so a body of <c>{}</c> would bind every flag to
|
||||||
/// <c>false</c> and silently switch all three features off. Nullable makes the requirement
|
/// <c>false</c> and silently switch everything off. Nullable makes the requirement actually
|
||||||
/// actually bind — an omitted flag is a 400, not an accidental disable.
|
/// bind - an omitted flag is a 400, not an accidental disable.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class UpdateProductConfigRequest
|
public sealed class UpdateProductConfigRequest
|
||||||
@@ -24,4 +28,8 @@ public sealed class UpdateProductConfigRequest
|
|||||||
[Required] public bool? SubcategoriesEnabled { get; set; }
|
[Required] public bool? SubcategoriesEnabled { get; set; }
|
||||||
[Required] public bool? BrandsEnabled { get; set; }
|
[Required] public bool? BrandsEnabled { get; set; }
|
||||||
[Required] public bool? ItemTypesEnabled { get; set; }
|
[Required] public bool? ItemTypesEnabled { get; set; }
|
||||||
|
[Required] public bool? SellingPricesEnabled { get; set; }
|
||||||
|
[Required] public bool? SerialNumbersEnabled { get; set; }
|
||||||
|
[Required] public bool? BatchListsEnabled { get; set; }
|
||||||
|
[Required] public bool? WarrantyPeriodsEnabled { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,36 +15,30 @@ public sealed record GrnLineDto(
|
|||||||
HoldStatus HoldStatus, int? BatchId, IReadOnlyList<GrnLineWarrantyNumberDto> WarrantyNumbers);
|
HoldStatus HoldStatus, int? BatchId, IReadOnlyList<GrnLineWarrantyNumberDto> WarrantyNumbers);
|
||||||
|
|
||||||
public sealed record GrnDto(
|
public sealed record GrnDto(
|
||||||
int GrnId, string DocNo, int? PoId, int VendorId, int WarehouseId, GrnStatus Status,
|
int GrnId, string DocNo, int? PoId, int VendorId, int WarehouseId, int BranchId, GrnStatus Status,
|
||||||
int CreatedBy, DateTime CreatedAt, DateTime? PostedAt, string? GlJournalNo,
|
int CreatedBy, DateTime CreatedAt, DateTime? PostedAt, string? GlJournalNo,
|
||||||
decimal PaidAmount, decimal BalanceAmount, IReadOnlyList<GrnLineDto> Lines);
|
int? PurchaseInvoiceId, string? PurchaseInvoiceNo, IReadOnlyList<GrnLineDto> Lines);
|
||||||
|
|
||||||
/// <summary>Row shape for <c>GET /grns</c> — line count instead of the lines themselves.</summary>
|
/// <summary>Row shape for <c>GET /grns</c> — line count instead of the lines themselves.</summary>
|
||||||
public sealed record GrnSummaryDto(
|
public sealed record GrnSummaryDto(
|
||||||
int GrnId, string DocNo, int? PoId, int VendorId, int WarehouseId, GrnStatus Status,
|
int GrnId, string DocNo, int? PoId, int VendorId, int WarehouseId, int BranchId, GrnStatus Status,
|
||||||
int CreatedBy, DateTime CreatedAt, DateTime? PostedAt, int LineCount,
|
int CreatedBy, DateTime CreatedAt, DateTime? PostedAt, int LineCount,
|
||||||
decimal PaidAmount, decimal BalanceAmount);
|
int? PurchaseInvoiceId, string? PurchaseInvoiceNo);
|
||||||
|
|
||||||
public sealed record CreatedLayerDto(
|
public sealed record CreatedLayerDto(
|
||||||
int LayerId, int ItemId, int WarehouseId, int? BatchId,
|
int LayerId, int ItemId, int WarehouseId, int? BatchId,
|
||||||
decimal QtyReceived, decimal QtyRemaining, decimal UnitCost, DateTime ReceiptDate);
|
decimal QtyReceived, decimal QtyRemaining, decimal UnitCost, DateTime ReceiptDate);
|
||||||
|
|
||||||
public sealed record GrnConfirmResultDto(
|
public sealed record GrnConfirmResultDto(
|
||||||
int GrnId, GrnStatus Status, DateTime PostedAt, string GlJournalNo, decimal BalanceAmount,
|
int GrnId, GrnStatus Status, DateTime PostedAt, string GlJournalNo,
|
||||||
IReadOnlyList<CreatedLayerDto> CreatedLayers, IReadOnlyList<int> LedgerRefs, PurchaseOrderStatus? PoStatus);
|
IReadOnlyList<CreatedLayerDto> CreatedLayers, IReadOnlyList<int> LedgerRefs, PurchaseOrderStatus? PoStatus);
|
||||||
|
|
||||||
public sealed record ReleaseLineResultDto(int GrnLineId, HoldStatus HoldStatus);
|
public sealed record ReleaseLineResultDto(int GrnLineId, HoldStatus HoldStatus);
|
||||||
|
|
||||||
public sealed record GrnPaymentDto(
|
/// <summary>A Confirmed, not-yet-invoiced GRN eligible to be consolidated onto a Purchase Invoice.</summary>
|
||||||
int GrnPaymentId, int GrnId, decimal Amount, DateTime PaymentDate,
|
public sealed record GrnEligibleForInvoiceDto(
|
||||||
long GlBankAccountId, string BankAccountName, string? Reference, string? GlJournalNo, DateTime CreatedAt);
|
int GrnId, string DocNo, DateTime PostedAt, int WarehouseId,
|
||||||
|
int LineCount, decimal Subtotal, decimal VatTotal, decimal GrandTotal);
|
||||||
public sealed class CreateGrnPaymentRequest
|
|
||||||
{
|
|
||||||
[Range(0.01, double.MaxValue)] public decimal Amount { get; set; }
|
|
||||||
[Required] public long GlBankAccountId { get; set; }
|
|
||||||
[StringLength(100)] public string? Reference { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Requests ----------------------------------------------------------------------
|
// Requests ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -87,6 +81,9 @@ public sealed class CreateGrnRequest
|
|||||||
/// <summary>Required for a direct receipt (no PO); ignored otherwise (vendor derives from the PO).</summary>
|
/// <summary>Required for a direct receipt (no PO); ignored otherwise (vendor derives from the PO).</summary>
|
||||||
public int? VendorId { get; set; }
|
public int? VendorId { get; set; }
|
||||||
[Required] public int WarehouseId { get; set; }
|
[Required] public int WarehouseId { get; set; }
|
||||||
|
/// <summary>Owning branch for this GRN — warehouses are shared, so this is what actually
|
||||||
|
/// scopes the document (resolved via IBranchConfigService; required when branching is enabled).</summary>
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
[Required, MinLength(1)] public List<CreateGrnLineInput> Lines { get; set; } = new();
|
[Required, MinLength(1)] public List<CreateGrnLineInput> Lines { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace ERPCore.Dtos.Hrm;
|
|||||||
public sealed record EmployeeListItemDto(
|
public sealed record EmployeeListItemDto(
|
||||||
int EmployeeId, string EmployeeCode, string FullName, string? Email,
|
int EmployeeId, string EmployeeCode, string FullName, string? Email,
|
||||||
int DepartmentId, string? DepartmentName, int DesignationId, string? DesignationName,
|
int DepartmentId, string? DepartmentName, int DesignationId, string? DesignationName,
|
||||||
int EmploymentTypeId, string? EmploymentTypeName, int? BranchId, string? BranchName,
|
int EmploymentTypeId, string? EmploymentTypeName, int BranchId, string? BranchName,
|
||||||
EmployeeStatus Status, bool HasUserLink, DateTime HireDate);
|
EmployeeStatus Status, bool HasUserLink, DateTime HireDate);
|
||||||
|
|
||||||
public sealed record EmployeeDetailDto(
|
public sealed record EmployeeDetailDto(
|
||||||
@@ -16,7 +16,7 @@ public sealed record EmployeeDetailDto(
|
|||||||
string? City, string? PostalCode, string? Country,
|
string? City, string? PostalCode, string? Country,
|
||||||
string? EmergencyContactName, string? EmergencyContactRelationship, string? EmergencyContactPhone,
|
string? EmergencyContactName, string? EmergencyContactRelationship, string? EmergencyContactPhone,
|
||||||
DateTime HireDate, DateTime? ConfirmationDate, DateTime? LastWorkingDate,
|
DateTime HireDate, DateTime? ConfirmationDate, DateTime? LastWorkingDate,
|
||||||
int DepartmentId, int DesignationId, int EmploymentTypeId, int? BranchId, int WorkShiftId,
|
int DepartmentId, int DesignationId, int EmploymentTypeId, int BranchId, int WorkShiftId,
|
||||||
int? ReportingManagerId, string? EpfNumber, string? EtfNumber, string? TaxIdentificationNumber,
|
int? ReportingManagerId, string? EpfNumber, string? EtfNumber, string? TaxIdentificationNumber,
|
||||||
int? UserId, EmployeeStatus Status, DateTime CreatedAt, DateTime? UpdatedAt);
|
int? UserId, EmployeeStatus Status, DateTime CreatedAt, DateTime? UpdatedAt);
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public sealed class CreateEmployeeRequest
|
|||||||
[Required] public int DepartmentId { get; set; }
|
[Required] public int DepartmentId { get; set; }
|
||||||
[Required] public int DesignationId { get; set; }
|
[Required] public int DesignationId { get; set; }
|
||||||
[Required] public int EmploymentTypeId { get; set; }
|
[Required] public int EmploymentTypeId { get; set; }
|
||||||
public int? BranchId { get; set; }
|
[Required] public int BranchId { get; set; }
|
||||||
[Required] public int WorkShiftId { get; set; }
|
[Required] public int WorkShiftId { get; set; }
|
||||||
public int? ReportingManagerId { get; set; }
|
public int? ReportingManagerId { get; set; }
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ public sealed class UpdateEmployeeRequest
|
|||||||
[Required] public int DepartmentId { get; set; }
|
[Required] public int DepartmentId { get; set; }
|
||||||
[Required] public int DesignationId { get; set; }
|
[Required] public int DesignationId { get; set; }
|
||||||
[Required] public int EmploymentTypeId { get; set; }
|
[Required] public int EmploymentTypeId { get; set; }
|
||||||
public int? BranchId { get; set; }
|
[Required] public int BranchId { get; set; }
|
||||||
[Required] public int WorkShiftId { get; set; }
|
[Required] public int WorkShiftId { get; set; }
|
||||||
public int? ReportingManagerId { get; set; }
|
public int? ReportingManagerId { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -7,20 +7,22 @@ namespace ERPCore.Dtos.Hrm;
|
|||||||
// ids, timestamps) excluded from create/update requests (02-SECURITY B.6/C.1).
|
// ids, timestamps) excluded from create/update requests (02-SECURITY B.6/C.1).
|
||||||
|
|
||||||
public sealed record BranchDto(
|
public sealed record BranchDto(
|
||||||
int BranchId, string Code, string Name, string? Address, EntityStatus Status,
|
int BranchId, string Code, string Name, string? Address, string? PhoneNumber, EntityStatus Status,
|
||||||
DateTime CreatedAt, DateTime? UpdatedAt);
|
DateTime CreatedAt, DateTime? UpdatedAt);
|
||||||
|
|
||||||
|
// Code is server-generated (BranchService.GenerateCodeAsync) — never accepted from the client.
|
||||||
public sealed class CreateBranchRequest
|
public sealed class CreateBranchRequest
|
||||||
{
|
{
|
||||||
[Required, StringLength(20)] public string Code { get; set; } = string.Empty;
|
|
||||||
[Required, StringLength(200)] public string Name { get; set; } = string.Empty;
|
[Required, StringLength(200)] public string Name { get; set; } = string.Empty;
|
||||||
[StringLength(500)] public string? Address { get; set; }
|
[StringLength(500)] public string? Address { get; set; }
|
||||||
|
[StringLength(30)] public string? PhoneNumber { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class UpdateBranchRequest
|
public sealed class UpdateBranchRequest
|
||||||
{
|
{
|
||||||
[Required, StringLength(200)] public string Name { get; set; } = string.Empty;
|
[Required, StringLength(200)] public string Name { get; set; } = string.Empty;
|
||||||
[StringLength(500)] public string? Address { get; set; }
|
[StringLength(500)] public string? Address { get; set; }
|
||||||
|
[StringLength(30)] public string? PhoneNumber { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed record DepartmentDto(
|
public sealed record DepartmentDto(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public sealed record ItemListItemDto(
|
|||||||
int ItemId, string Sku, string Name, int CategoryId, int? SubCategoryId, int? BrandId,
|
int ItemId, string Sku, string Name, int CategoryId, int? SubCategoryId, int? BrandId,
|
||||||
int BaseUomId, int? DefaultVendorId, StockNature StockNature, TrackingMode TrackingMode,
|
int BaseUomId, int? DefaultVendorId, StockNature StockNature, TrackingMode TrackingMode,
|
||||||
Warranty Warranty, int? WarrantyPeriodMonths,
|
Warranty Warranty, int? WarrantyPeriodMonths,
|
||||||
string? TaxClass, decimal? SalePrice,
|
string? TaxClass, decimal? SellingMinPrice, decimal? SellingMaxPrice, decimal? SellingFlatPrice,
|
||||||
decimal? ContentQty, MeasureUnit? ContentUnit,
|
decimal? ContentQty, MeasureUnit? ContentUnit,
|
||||||
decimal? ContentBaseQty, MeasureUnit? ContentBaseUnit,
|
decimal? ContentBaseQty, MeasureUnit? ContentBaseUnit,
|
||||||
EntityStatus Status);
|
EntityStatus Status);
|
||||||
@@ -31,7 +31,7 @@ public sealed record ItemDetailDto(
|
|||||||
int? SubCategoryId, int? BrandId, int BaseUomId, int? DefaultVendorId,
|
int? SubCategoryId, int? BrandId, int BaseUomId, int? DefaultVendorId,
|
||||||
StockNature StockNature, TrackingMode TrackingMode,
|
StockNature StockNature, TrackingMode TrackingMode,
|
||||||
Warranty Warranty, int? WarrantyPeriodMonths,
|
Warranty Warranty, int? WarrantyPeriodMonths,
|
||||||
string? TaxClass, decimal? SalePrice,
|
string? TaxClass, decimal? SellingMinPrice, decimal? SellingMaxPrice, decimal? SellingFlatPrice,
|
||||||
decimal? ContentQty, MeasureUnit? ContentUnit,
|
decimal? ContentQty, MeasureUnit? ContentUnit,
|
||||||
decimal? ContentBaseQty, MeasureUnit? ContentBaseUnit,
|
decimal? ContentBaseQty, MeasureUnit? ContentBaseUnit,
|
||||||
EntityStatus Status, IReadOnlyList<ItemReorderDto> Reorder,
|
EntityStatus Status, IReadOnlyList<ItemReorderDto> Reorder,
|
||||||
@@ -66,7 +66,9 @@ public sealed class CreateItemRequest
|
|||||||
public int? WarrantyPeriodMonths { get; set; }
|
public int? WarrantyPeriodMonths { get; set; }
|
||||||
[StringLength(20)] public string? TaxClass { get; set; }
|
[StringLength(20)] public string? TaxClass { get; set; }
|
||||||
/// <summary>Optional fixed sale price (Sales only). Null ⇒ sell at stock/FIFO value.</summary>
|
/// <summary>Optional fixed sale price (Sales only). Null ⇒ sell at stock/FIFO value.</summary>
|
||||||
[Range(0, double.MaxValue)] public decimal? SalePrice { get; set; }
|
[Range(0, double.MaxValue)] public decimal? SellingMinPrice { get; set; }
|
||||||
|
[Range(0, double.MaxValue)] public decimal? SellingMaxPrice { get; set; }
|
||||||
|
[Range(0, double.MaxValue)] public decimal? SellingFlatPrice { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How much one pack holds. Supply with <see cref="ContentUnit"/> or leave both null
|
/// How much one pack holds. Supply with <see cref="ContentUnit"/> or leave both null
|
||||||
@@ -96,7 +98,9 @@ public sealed class UpdateItemRequest
|
|||||||
public int? WarrantyPeriodMonths { get; set; }
|
public int? WarrantyPeriodMonths { get; set; }
|
||||||
[StringLength(20)] public string? TaxClass { get; set; }
|
[StringLength(20)] public string? TaxClass { get; set; }
|
||||||
/// <summary>Optional fixed sale price (Sales only). Null ⇒ sell at stock/FIFO value.</summary>
|
/// <summary>Optional fixed sale price (Sales only). Null ⇒ sell at stock/FIFO value.</summary>
|
||||||
[Range(0, double.MaxValue)] public decimal? SalePrice { get; set; }
|
[Range(0, double.MaxValue)] public decimal? SellingMinPrice { get; set; }
|
||||||
|
[Range(0, double.MaxValue)] public decimal? SellingMaxPrice { get; set; }
|
||||||
|
[Range(0, double.MaxValue)] public decimal? SellingFlatPrice { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How much one pack holds. Supply with <see cref="ContentUnit"/> or leave both null
|
/// How much one pack holds. Supply with <see cref="ContentUnit"/> or leave both null
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace ERPCore.Dtos.Notifications;
|
||||||
|
|
||||||
|
public sealed record NotificationModuleConfigDto(
|
||||||
|
string ModuleKey,
|
||||||
|
string Label,
|
||||||
|
string Description,
|
||||||
|
bool EmailEnabled,
|
||||||
|
bool SmsEnabled,
|
||||||
|
bool InAppEnabled);
|
||||||
|
|
||||||
|
public sealed record NotificationConfigDto(
|
||||||
|
IReadOnlyList<NotificationModuleConfigDto> Modules,
|
||||||
|
DateTime? UpdatedAt,
|
||||||
|
int? UpdatedBy);
|
||||||
|
|
||||||
|
public sealed class UpdateNotificationModuleRequest
|
||||||
|
{
|
||||||
|
[Required, StringLength(100)] public string ModuleKey { get; set; } = string.Empty;
|
||||||
|
[Required] public bool? EmailEnabled { get; set; }
|
||||||
|
[Required] public bool? SmsEnabled { get; set; }
|
||||||
|
[Required] public bool? InAppEnabled { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class UpdateNotificationConfigRequest
|
||||||
|
{
|
||||||
|
[Required, MinLength(0)] public List<UpdateNotificationModuleRequest> Modules { get; set; } = new();
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
|
||||||
|
namespace ERPCore.Dtos.Procurement;
|
||||||
|
|
||||||
|
public sealed record PurchaseInvoiceLineDto(
|
||||||
|
int PurchaseInvoiceLineId, int GrnId, string GrnDocNo, DateTime GrnPostedAt,
|
||||||
|
decimal Subtotal, decimal VatTotal, decimal LineTotal);
|
||||||
|
|
||||||
|
public sealed record PurchaseInvoiceTotalsDto(
|
||||||
|
decimal Subtotal, decimal VatTotal, decimal GrandTotal, decimal PaidAmount, decimal BalanceAmount);
|
||||||
|
|
||||||
|
public sealed record PurchaseInvoiceDto(
|
||||||
|
int PurchaseInvoiceId, string DocNo, string VendorInvoiceNo, DateTime VendorInvoiceDate,
|
||||||
|
int VendorId, string VendorSnapshotName, string? VendorSnapshotTaxNo,
|
||||||
|
PurchaseInvoiceStatus Status, int GrnCount, int CreatedBy, DateTime CreatedAt, DateTime? UpdatedAt,
|
||||||
|
string? GlJournalNo, DateTime? GlPostedAt,
|
||||||
|
PurchaseInvoiceTotalsDto Totals, IReadOnlyList<PurchaseInvoiceLineDto> Lines);
|
||||||
|
|
||||||
|
public sealed record PurchaseInvoiceSummaryDto(
|
||||||
|
int PurchaseInvoiceId, string DocNo, string VendorInvoiceNo, DateTime VendorInvoiceDate,
|
||||||
|
int VendorId, string VendorSnapshotName, PurchaseInvoiceStatus Status, int GrnCount,
|
||||||
|
PurchaseInvoiceTotalsDto Totals, DateTime CreatedAt, string? GlJournalNo);
|
||||||
|
|
||||||
|
public sealed record PurchaseInvoicePaymentDto(
|
||||||
|
int PurchaseInvoicePaymentId, int PurchaseInvoiceId, decimal Amount, DateTime PaymentDate,
|
||||||
|
long GlBankAccountId, string BankAccountName, string? Reference, string? GlJournalNo, DateTime CreatedAt);
|
||||||
|
|
||||||
|
public sealed class CreatePurchaseInvoicePaymentRequest
|
||||||
|
{
|
||||||
|
[Range(0.01, double.MaxValue)] public decimal Amount { get; set; }
|
||||||
|
[Required] public long GlBankAccountId { get; set; }
|
||||||
|
[StringLength(100)] public string? Reference { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class CreatePurchaseInvoiceRequest
|
||||||
|
{
|
||||||
|
[Required] public int VendorId { get; set; }
|
||||||
|
[Required, StringLength(50)] public string VendorInvoiceNo { get; set; } = string.Empty;
|
||||||
|
[Required] public DateTime VendorInvoiceDate { get; set; }
|
||||||
|
[Required, MinLength(1)] public List<int> GrnIds { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class UpdatePurchaseInvoiceRequest
|
||||||
|
{
|
||||||
|
[Required] public int VendorId { get; set; }
|
||||||
|
[Required, StringLength(50)] public string VendorInvoiceNo { get; set; } = string.Empty;
|
||||||
|
[Required] public DateTime VendorInvoiceDate { get; set; }
|
||||||
|
[Required, MinLength(1)] public List<int> GrnIds { get; set; } = new();
|
||||||
|
}
|
||||||
@@ -70,6 +70,35 @@ public sealed record RunEventDto(
|
|||||||
int EventId, int? RunStageId, RunStageEventType EventType, string? Note,
|
int EventId, int? RunStageId, RunStageEventType EventType, string? Note,
|
||||||
JsonElement? Payload, int UserId, DateTime CreatedAt);
|
JsonElement? Payload, int UserId, DateTime CreatedAt);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// One row of the produced-items report (<c>GET /production-runs/produced</c>) — the
|
||||||
|
/// terminal output of a run that has produced something, costed the same way
|
||||||
|
/// <c>PostReceiptAsync</c> costs the finished layer at approve (FR-MFG-13):
|
||||||
|
/// <c>unitCost = (Σ ConsumedValue − Σ ReturnedValue) / (ProducedQty − ScrappedQty)</c>.
|
||||||
|
/// One row per run — server validation (<see cref="ProductionGraphValidator"/> via
|
||||||
|
/// FR-MFG-05) guarantees exactly one item-bearing output per run, always the terminal
|
||||||
|
/// one, so run and produced line coincide 1:1.
|
||||||
|
/// <para><c>UnitCost</c>/<c>TotalCost</c> are final only once <c>Status</c> is
|
||||||
|
/// <c>Completed</c> — a leftover return can still shrink the pool between the terminal
|
||||||
|
/// stage's Done and its Approve, same caveat as <see cref="CostPoolDto"/>.</para>
|
||||||
|
/// </summary>
|
||||||
|
public sealed record ProducedLineDto(
|
||||||
|
int RunId, string DocNo, ProductionRunStatus Status,
|
||||||
|
int TemplateId, string TemplateName,
|
||||||
|
int WarehouseId, string WarehouseName,
|
||||||
|
int ItemId, string ItemName,
|
||||||
|
decimal ProducedQty, decimal ScrappedQty, decimal GoodQty,
|
||||||
|
decimal UnitCost, decimal TotalCost,
|
||||||
|
DateTime CreatedAt, DateTime? CompletedAt);
|
||||||
|
|
||||||
|
/// <summary>Aggregate footer for the produced-items report — totals over every row the filter
|
||||||
|
/// matched, not just the current page (there is no pagination here, matching the Sales report
|
||||||
|
/// convention of flat, filter-bounded rows).</summary>
|
||||||
|
public sealed record ProducedSummaryDto(
|
||||||
|
int RunCount, decimal TotalProducedQty, decimal TotalScrappedQty, decimal TotalGoodQty, decimal TotalCost);
|
||||||
|
|
||||||
|
public sealed record ProducedListResponseDto(IReadOnlyList<ProducedLineDto> Items, ProducedSummaryDto Summary);
|
||||||
|
|
||||||
/// <summary>Full run graph (docs/30 §D.2 <c>GET /production-runs/{id}</c>).</summary>
|
/// <summary>Full run graph (docs/30 §D.2 <c>GET /production-runs/{id}</c>).</summary>
|
||||||
public sealed record RunGraphDto(
|
public sealed record RunGraphDto(
|
||||||
int RunId, string DocNo, int TemplateId, string TemplateName,
|
int RunId, string DocNo, int TemplateId, string TemplateName,
|
||||||
@@ -99,8 +128,10 @@ public sealed class CreateRunRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Per-run scaling override (FR-MFG-08). Only accepted while the stage has not started
|
/// Per-run scaling override (FR-MFG-08). Accepted before the stage starts, and — for a Stock
|
||||||
/// (<c>409 STAGE_NOT_EDITABLE</c>).
|
/// input only — while it is running too: raising <see cref="StageQuantityLine.PlannedQty"/>
|
||||||
|
/// draws the extra amount from FIFO, lowering it returns the excess (<c>409
|
||||||
|
/// STAGE_NOT_EDITABLE</c> for every other status).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class UpdateStageQuantitiesRequest
|
public sealed class UpdateStageQuantitiesRequest
|
||||||
{
|
{
|
||||||
@@ -116,4 +147,11 @@ public sealed class StageQuantityLine
|
|||||||
|
|
||||||
[Range(0.0001, double.MaxValue)]
|
[Range(0.0001, double.MaxValue)]
|
||||||
public decimal PlannedQty { get; set; }
|
public decimal PlannedQty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required only when this line lowers a running Stock input below what it has already
|
||||||
|
/// consumed — the excess is returned to stock the same way <c>ReturnLeftoverAsync</c>
|
||||||
|
/// does, and that always needs a reason (FR-MFG-14). Ignored otherwise.
|
||||||
|
/// </summary>
|
||||||
|
public int? ReasonCodeId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,13 @@ namespace ERPCore.Dtos.Rbac;
|
|||||||
|
|
||||||
/// <summary>Response for `GET /api/v1/auth/me` — the frontend's authoritative source
|
/// <summary>Response for `GET /api/v1/auth/me` — the frontend's authoritative source
|
||||||
/// for the current user's role and permitted sidebar nav codes (replaces trusting
|
/// for the current user's role and permitted sidebar nav codes (replaces trusting
|
||||||
/// the stale, client-only `roleId` cached in localStorage).</summary>
|
/// the stale, client-only `roleId` cached in localStorage). <see cref="BranchId"/>/
|
||||||
public sealed record MeResponseDto(string? RoleCode, string? RoleName, IReadOnlyList<string> NavCodes);
|
/// <see cref="BranchName"/> come from the caller's linked <c>Employee</c> record, when
|
||||||
|
/// one exists — null for a login with no Employee link. <see cref="IsAdmin"/> gates
|
||||||
|
/// branch pickers client-side only (no server-side branch enforcement exists yet,
|
||||||
|
/// see docs/BRANCH_ISOLATION_PLAN.md). <see cref="BranchingEnabled"/> mirrors the
|
||||||
|
/// singleton <c>BranchConfig</c> toggle — when false the frontend hides branch pickers
|
||||||
|
/// entirely rather than merely restricting them by role.</summary>
|
||||||
|
public sealed record MeResponseDto(
|
||||||
|
string? RoleCode, string? RoleName, IReadOnlyList<string> NavCodes,
|
||||||
|
bool IsAdmin, int? BranchId, string? BranchName, bool BranchingEnabled);
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public sealed class CreateBundleSaleTemplateLineRequest
|
|||||||
|
|
||||||
public sealed class CreateBundleSaleTemplateRequest
|
public sealed class CreateBundleSaleTemplateRequest
|
||||||
{
|
{
|
||||||
[Required] public string TemplateCode { get; set; } = string.Empty;
|
|
||||||
[Required] public string TemplateName { get; set; } = string.Empty;
|
[Required] public string TemplateName { get; set; } = string.Empty;
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
[Required, MinLength(1)] public List<CreateBundleSaleTemplateLineRequest> Lines { get; set; } = new();
|
[Required, MinLength(1)] public List<CreateBundleSaleTemplateLineRequest> Lines { get; set; } = new();
|
||||||
|
|||||||
@@ -8,11 +8,21 @@ namespace ERPCore.Dtos.Sales;
|
|||||||
/// Merges sales-slip and bundle-sale lines for the same item into one row.</summary>
|
/// Merges sales-slip and bundle-sale lines for the same item into one row.</summary>
|
||||||
public sealed record SalesDayEndItemLineDto(int ItemId, string Sku, string Name, decimal Qty, decimal Revenue);
|
public sealed record SalesDayEndItemLineDto(int ItemId, string Sku, string Name, decimal Qty, decimal Revenue);
|
||||||
|
|
||||||
|
/// <summary>Read-only visibility into that cashier's Sales Invoices for the date — informational
|
||||||
|
/// only, appended to <see cref="SalesDayEndDto"/> and <see cref="SalesDayEndPreviewDto"/>.
|
||||||
|
/// Invoices post their own GL entry on Confirm (SalesPostingService.PostInvoiceAsync) and have no
|
||||||
|
/// DayEndId, so they're never locked against a close: these fields are computed live from current
|
||||||
|
/// data on every read, unlike the frozen Slip/Bundle totals alongside them.</summary>
|
||||||
|
public sealed record SalesDayEndInvoiceSummaryDto(
|
||||||
|
int InvoiceCount, decimal InvoiceSubtotal, decimal InvoiceDiscountTotal, decimal InvoiceTaxTotal,
|
||||||
|
decimal InvoiceGrandTotal, IReadOnlyList<string> InvoiceNumbers);
|
||||||
|
|
||||||
public sealed record SalesDayEndDto(
|
public sealed record SalesDayEndDto(
|
||||||
int SalesDayEndId, string DocNo, int CashierUserId, DateOnly BusinessDate,
|
int SalesDayEndId, string DocNo, int CashierUserId, DateOnly BusinessDate,
|
||||||
int SlipCount, int BundleCount, decimal Subtotal, decimal DiscountTotal, decimal TaxTotal, decimal GrandTotal,
|
int SlipCount, int BundleCount, decimal Subtotal, decimal DiscountTotal, decimal TaxTotal, decimal GrandTotal,
|
||||||
decimal CostOfGoodsSold, string? GlJournalNo, DateTime? GlPostedAt, int ClosedBy, DateTime ClosedAt,
|
decimal CostOfGoodsSold, string? GlJournalNo, DateTime? GlPostedAt, int ClosedBy, DateTime ClosedAt,
|
||||||
IReadOnlyList<string> SlipNumbers, IReadOnlyList<string> BundleNumbers, IReadOnlyList<SalesDayEndItemLineDto> ItemBreakdown);
|
IReadOnlyList<string> SlipNumbers, IReadOnlyList<string> BundleNumbers, IReadOnlyList<SalesDayEndItemLineDto> ItemBreakdown,
|
||||||
|
SalesDayEndInvoiceSummaryDto Invoices);
|
||||||
|
|
||||||
public sealed record SalesDayEndSummaryDto(
|
public sealed record SalesDayEndSummaryDto(
|
||||||
int SalesDayEndId, string DocNo, int CashierUserId, DateOnly BusinessDate,
|
int SalesDayEndId, string DocNo, int CashierUserId, DateOnly BusinessDate,
|
||||||
@@ -25,7 +35,8 @@ public sealed record SalesDayEndPreviewDto(
|
|||||||
int SlipCount, int BundleCount, decimal Subtotal, decimal DiscountTotal, decimal TaxTotal, decimal GrandTotal,
|
int SlipCount, int BundleCount, decimal Subtotal, decimal DiscountTotal, decimal TaxTotal, decimal GrandTotal,
|
||||||
IReadOnlyList<string> SlipNumbers, IReadOnlyList<string> BundleNumbers,
|
IReadOnlyList<string> SlipNumbers, IReadOnlyList<string> BundleNumbers,
|
||||||
IReadOnlyList<DraftSlipBlockingCloseDto> DraftSlipsBlockingClose,
|
IReadOnlyList<DraftSlipBlockingCloseDto> DraftSlipsBlockingClose,
|
||||||
IReadOnlyList<DraftBundleBlockingCloseDto> DraftBundleSalesBlockingClose);
|
IReadOnlyList<DraftBundleBlockingCloseDto> DraftBundleSalesBlockingClose,
|
||||||
|
SalesDayEndInvoiceSummaryDto Invoices);
|
||||||
|
|
||||||
public sealed record DraftSlipBlockingCloseDto(int SalesSlipId, string SlipNo, decimal GrandTotal);
|
public sealed record DraftSlipBlockingCloseDto(int SalesSlipId, string SlipNo, decimal GrandTotal);
|
||||||
public sealed record DraftBundleBlockingCloseDto(int BundleSaleId, string BundleNo, decimal GrandTotal);
|
public sealed record DraftBundleBlockingCloseDto(int BundleSaleId, string BundleNo, decimal GrandTotal);
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ public sealed record SalesInvoiceTotalsDto(
|
|||||||
|
|
||||||
public sealed record SalesInvoiceDto(
|
public sealed record SalesInvoiceDto(
|
||||||
int SalesInvoiceId, string InvoiceNo, DateTime InvoiceDate, int CustomerId,
|
int SalesInvoiceId, string InvoiceNo, DateTime InvoiceDate, int CustomerId,
|
||||||
string CustomerSnapshotName, string? CustomerSnapshotTaxNo, int WarehouseId,
|
string CustomerSnapshotName, string? CustomerSnapshotTaxNo, int WarehouseId, int BranchId,
|
||||||
SalesInvoiceType InvoiceType, SalesInvoiceStatus Status, int CreatedBy, DateTime CreatedAt,
|
SalesInvoiceType InvoiceType, SalesInvoiceStatus Status, int CreatedBy, DateTime CreatedAt,
|
||||||
DateTime? UpdatedAt, string? GlJournalNo, DateTime? GlPostedAt,
|
DateTime? UpdatedAt, string? GlJournalNo, DateTime? GlPostedAt,
|
||||||
SalesInvoiceTotalsDto Totals, IReadOnlyList<SalesInvoiceLineDto> Lines);
|
SalesInvoiceTotalsDto Totals, IReadOnlyList<SalesInvoiceLineDto> Lines);
|
||||||
|
|
||||||
public sealed record SalesInvoiceSummaryDto(
|
public sealed record SalesInvoiceSummaryDto(
|
||||||
int SalesInvoiceId, string InvoiceNo, DateTime InvoiceDate, int CustomerId,
|
int SalesInvoiceId, string InvoiceNo, DateTime InvoiceDate, int CustomerId,
|
||||||
string CustomerSnapshotName, int WarehouseId, SalesInvoiceType InvoiceType,
|
string CustomerSnapshotName, int WarehouseId, int BranchId, SalesInvoiceType InvoiceType,
|
||||||
SalesInvoiceStatus Status, SalesInvoiceTotalsDto Totals, DateTime CreatedAt, string? GlJournalNo);
|
SalesInvoiceStatus Status, SalesInvoiceTotalsDto Totals, DateTime CreatedAt, string? GlJournalNo);
|
||||||
|
|
||||||
public sealed record SalesInvoicePaymentDto(
|
public sealed record SalesInvoicePaymentDto(
|
||||||
@@ -65,6 +65,9 @@ public sealed class CreateSalesInvoiceRequest
|
|||||||
{
|
{
|
||||||
[Required] public int CustomerId { get; set; }
|
[Required] public int CustomerId { get; set; }
|
||||||
[Required] public int WarehouseId { get; set; }
|
[Required] public int WarehouseId { get; set; }
|
||||||
|
/// <summary>Owning branch — warehouses are shared, so this is what actually scopes the
|
||||||
|
/// document (resolved via IBranchConfigService).</summary>
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
[Required, EnumDataType(typeof(SalesInvoiceType))] public SalesInvoiceType InvoiceType { get; set; } = SalesInvoiceType.B2C;
|
[Required, EnumDataType(typeof(SalesInvoiceType))] public SalesInvoiceType InvoiceType { get; set; } = SalesInvoiceType.B2C;
|
||||||
[Required, MinLength(1)] public List<CreateSalesInvoiceLineRequest> Lines { get; set; } = new();
|
[Required, MinLength(1)] public List<CreateSalesInvoiceLineRequest> Lines { get; set; } = new();
|
||||||
}
|
}
|
||||||
@@ -73,6 +76,9 @@ public sealed class UpdateSalesInvoiceRequest
|
|||||||
{
|
{
|
||||||
[Required] public int CustomerId { get; set; }
|
[Required] public int CustomerId { get; set; }
|
||||||
[Required] public int WarehouseId { get; set; }
|
[Required] public int WarehouseId { get; set; }
|
||||||
|
/// <summary>Owning branch — warehouses are shared, so this is what actually scopes the
|
||||||
|
/// document (resolved via IBranchConfigService).</summary>
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
[Required, EnumDataType(typeof(SalesInvoiceType))] public SalesInvoiceType InvoiceType { get; set; } = SalesInvoiceType.B2C;
|
[Required, EnumDataType(typeof(SalesInvoiceType))] public SalesInvoiceType InvoiceType { get; set; } = SalesInvoiceType.B2C;
|
||||||
[Required, MinLength(1)] public List<CreateSalesInvoiceLineRequest> Lines { get; set; } = new();
|
[Required, MinLength(1)] public List<CreateSalesInvoiceLineRequest> Lines { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ public sealed record SalesFreeIssueRewardOptionDto(
|
|||||||
int ItemId,
|
int ItemId,
|
||||||
string Sku,
|
string Sku,
|
||||||
string Name,
|
string Name,
|
||||||
decimal? SalePrice);
|
decimal? SellingFlatPrice);
|
||||||
|
|
||||||
public sealed record SalesFreeIssueSuggestionLineDto(
|
public sealed record SalesFreeIssueSuggestionLineDto(
|
||||||
int SalesSlipLineId,
|
int SalesSlipLineId,
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ namespace ERPCore.Dtos.Stock;
|
|||||||
public sealed record AdjustmentLineDto(int AdjLineId, int ItemId, int? BinId, int? BatchId, decimal QtyDelta);
|
public sealed record AdjustmentLineDto(int AdjLineId, int ItemId, int? BinId, int? BatchId, decimal QtyDelta);
|
||||||
|
|
||||||
public sealed record AdjustmentDto(
|
public sealed record AdjustmentDto(
|
||||||
int AdjustmentId, string DocNo, int WarehouseId, int ReasonCodeId, AdjustmentStatus Status,
|
int AdjustmentId, string DocNo, int WarehouseId, int BranchId, int ReasonCodeId, AdjustmentStatus Status,
|
||||||
int CreatedBy, DateTime CreatedAt, string? GlJournalNo, DateTime? GlPostedAt,
|
int CreatedBy, DateTime CreatedAt, string? GlJournalNo, DateTime? GlPostedAt,
|
||||||
IReadOnlyList<AdjustmentLineDto> Lines, IReadOnlyList<int> LedgerRefs);
|
IReadOnlyList<AdjustmentLineDto> Lines, IReadOnlyList<int> LedgerRefs);
|
||||||
|
|
||||||
/// <summary>Row shape for <c>GET /stock-adjustments</c> — no lines/ledgerRefs (those need a per-row query).</summary>
|
/// <summary>Row shape for <c>GET /stock-adjustments</c> — no lines/ledgerRefs (those need a per-row query).</summary>
|
||||||
public sealed record AdjustmentSummaryDto(
|
public sealed record AdjustmentSummaryDto(
|
||||||
int AdjustmentId, string DocNo, int WarehouseId, int ReasonCodeId, AdjustmentStatus Status,
|
int AdjustmentId, string DocNo, int WarehouseId, int BranchId, int ReasonCodeId, AdjustmentStatus Status,
|
||||||
int CreatedBy, DateTime CreatedAt, int LineCount, string? GlJournalNo);
|
int CreatedBy, DateTime CreatedAt, int LineCount, string? GlJournalNo);
|
||||||
|
|
||||||
// Requests ----------------------------------------------------------------------
|
// Requests ----------------------------------------------------------------------
|
||||||
@@ -31,6 +31,9 @@ public sealed class CreateAdjustmentLineInput
|
|||||||
public sealed class CreateAdjustmentRequest
|
public sealed class CreateAdjustmentRequest
|
||||||
{
|
{
|
||||||
[Required] public int WarehouseId { get; set; }
|
[Required] public int WarehouseId { get; set; }
|
||||||
|
/// <summary>Owning branch — warehouses are shared, so this is what actually scopes the
|
||||||
|
/// document (resolved via IBranchConfigService).</summary>
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
/// <summary>Nullable so an omitted value is a distinct <c>REASON_CODE_REQUIRED</c> error, not 0.</summary>
|
/// <summary>Nullable so an omitted value is a distinct <c>REASON_CODE_REQUIRED</c> error, not 0.</summary>
|
||||||
public int? ReasonCodeId { get; set; }
|
public int? ReasonCodeId { get; set; }
|
||||||
[Required, MinLength(1)] public List<CreateAdjustmentLineInput> Lines { get; set; } = new();
|
[Required, MinLength(1)] public List<CreateAdjustmentLineInput> Lines { get; set; } = new();
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ namespace ERPCore.Dtos.Stock;
|
|||||||
public sealed record CountLineDto(int CountLineId, int ItemId, int? BinId, decimal SystemQty, decimal? CountedQty, decimal? Variance);
|
public sealed record CountLineDto(int CountLineId, int ItemId, int? BinId, decimal SystemQty, decimal? CountedQty, decimal? Variance);
|
||||||
|
|
||||||
public sealed record CountDto(
|
public sealed record CountDto(
|
||||||
int CountId, string DocNo, int WarehouseId, CountType CountType, CountStatus Status,
|
int CountId, string DocNo, int WarehouseId, int BranchId, CountType CountType, CountStatus Status,
|
||||||
int CreatedBy, DateTime CreatedAt, IReadOnlyList<CountLineDto> Lines);
|
int CreatedBy, DateTime CreatedAt, IReadOnlyList<CountLineDto> Lines);
|
||||||
|
|
||||||
/// <summary>Row shape for <c>GET /stock-counts</c> — line count instead of the lines themselves.</summary>
|
/// <summary>Row shape for <c>GET /stock-counts</c> — line count instead of the lines themselves.</summary>
|
||||||
public sealed record CountSummaryDto(
|
public sealed record CountSummaryDto(
|
||||||
int CountId, string DocNo, int WarehouseId, CountType CountType, CountStatus Status,
|
int CountId, string DocNo, int WarehouseId, int BranchId, CountType CountType, CountStatus Status,
|
||||||
int CreatedBy, DateTime CreatedAt, int LineCount);
|
int CreatedBy, DateTime CreatedAt, int LineCount);
|
||||||
|
|
||||||
public sealed record CountPostResultDto(int CountId, CountStatus Status, int? AdjustmentId, string? GlJournalNo, IReadOnlyList<int> LedgerRefs);
|
public sealed record CountPostResultDto(int CountId, CountStatus Status, int? AdjustmentId, string? GlJournalNo, IReadOnlyList<int> LedgerRefs);
|
||||||
@@ -23,6 +23,9 @@ public sealed record CountPostResultDto(int CountId, CountStatus Status, int? Ad
|
|||||||
public sealed class CreateCountRequest
|
public sealed class CreateCountRequest
|
||||||
{
|
{
|
||||||
[Required] public int WarehouseId { get; set; }
|
[Required] public int WarehouseId { get; set; }
|
||||||
|
/// <summary>Owning branch — warehouses are shared, so this is what actually scopes the
|
||||||
|
/// document (resolved via IBranchConfigService).</summary>
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
[Required, EnumDataType(typeof(CountType))] public CountType CountType { get; set; }
|
[Required, EnumDataType(typeof(CountType))] public CountType CountType { get; set; }
|
||||||
[Required, MinLength(1)] public List<int> ItemIds { get; set; } = new();
|
[Required, MinLength(1)] public List<int> ItemIds { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ public sealed record TransferLineDto(
|
|||||||
int TransferLineId, int ItemId, int? SrcBinId, int? DestBinId, int? BatchId, decimal Qty, decimal QtyReceived);
|
int TransferLineId, int ItemId, int? SrcBinId, int? DestBinId, int? BatchId, decimal Qty, decimal QtyReceived);
|
||||||
|
|
||||||
public sealed record TransferDto(
|
public sealed record TransferDto(
|
||||||
int TransferId, string DocNo, int SrcWarehouseId, int DestWarehouseId,
|
int TransferId, string DocNo, int SrcWarehouseId, int DestWarehouseId, int BranchId,
|
||||||
TransferStatus Status, int CreatedBy, DateTime CreatedAt, IReadOnlyList<TransferLineDto> Lines);
|
TransferStatus Status, int CreatedBy, DateTime CreatedAt, IReadOnlyList<TransferLineDto> Lines);
|
||||||
|
|
||||||
/// <summary>Row shape for <c>GET /stock-transfers</c> — line count instead of the lines themselves.</summary>
|
/// <summary>Row shape for <c>GET /stock-transfers</c> — line count instead of the lines themselves.</summary>
|
||||||
public sealed record TransferSummaryDto(
|
public sealed record TransferSummaryDto(
|
||||||
int TransferId, string DocNo, int SrcWarehouseId, int DestWarehouseId,
|
int TransferId, string DocNo, int SrcWarehouseId, int DestWarehouseId, int BranchId,
|
||||||
TransferStatus Status, int CreatedBy, DateTime CreatedAt, int LineCount);
|
TransferStatus Status, int CreatedBy, DateTime CreatedAt, int LineCount);
|
||||||
|
|
||||||
public sealed record ConsumedLayerDto(int LayerId, decimal QtyConsumed, decimal UnitCost);
|
public sealed record ConsumedLayerDto(int LayerId, decimal QtyConsumed, decimal UnitCost);
|
||||||
@@ -42,6 +42,9 @@ public sealed class CreateTransferRequest
|
|||||||
{
|
{
|
||||||
[Required] public int SrcWarehouseId { get; set; }
|
[Required] public int SrcWarehouseId { get; set; }
|
||||||
[Required] public int DestWarehouseId { get; set; }
|
[Required] public int DestWarehouseId { get; set; }
|
||||||
|
/// <summary>Owning branch for this transfer — warehouses are shared, so this is what
|
||||||
|
/// actually scopes the document (resolved via IBranchConfigService).</summary>
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
[Required, MinLength(1)] public List<CreateTransferLineInput> Lines { get; set; } = new();
|
[Required, MinLength(1)] public List<CreateTransferLineInput> Lines { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
|
||||||
namespace ERPCore.Dtos.Uoms;
|
namespace ERPCore.Dtos.Uoms;
|
||||||
|
|
||||||
/// <summary>UOM resource (docs/11-BACKEND-PHASE1.md §2.2).</summary>
|
/// <summary>UOM resource (docs/11-BACKEND-PHASE1.md §2.2).</summary>
|
||||||
public sealed record UomDto(int UomId, string Name);
|
public sealed record UomDto(int UomId, string Name, EntityStatus Status, DateTime CreatedAt, DateTime? UpdatedAt);
|
||||||
|
|
||||||
public sealed class CreateUomRequest
|
public sealed class CreateUomRequest
|
||||||
{
|
{
|
||||||
[Required, StringLength(50)] public string Name { get; set; } = string.Empty;
|
[Required, StringLength(50)] public string Name { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class UpdateUomStatusRequest
|
||||||
|
{
|
||||||
|
[Required, EnumDataType(typeof(EntityStatus))] public EntityStatus Status { get; set; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,22 @@ public sealed class CreateUserRequest
|
|||||||
/// email-lookup — never automatic, even on an exact email match (docs/12-BACKEND-HRM.md A.5).
|
/// email-lookup — never automatic, even on an exact email match (docs/12-BACKEND-HRM.md A.5).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? LinkEmployeeId { get; set; }
|
public int? LinkEmployeeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required, together with <see cref="DepartmentId"/>/<see cref="DesignationId"/>/
|
||||||
|
/// <see cref="EmploymentTypeId"/>/<see cref="WorkShiftId"/>/<see cref="BranchId"/>, whenever
|
||||||
|
/// the assigned Role is not Admin and <see cref="LinkEmployeeId"/> is not supplied: creates
|
||||||
|
/// the linked Employee record whose BranchId is what actually scopes this account to one
|
||||||
|
/// branch (see BranchAccessService.EnsureBranchVisibleAsync).
|
||||||
|
/// </summary>
|
||||||
|
public string? EmployeeCode { get; set; }
|
||||||
|
public int? BranchId { get; set; }
|
||||||
|
public int? DepartmentId { get; set; }
|
||||||
|
public int? DesignationId { get; set; }
|
||||||
|
public int? EmploymentTypeId { get; set; }
|
||||||
|
public int? WorkShiftId { get; set; }
|
||||||
|
/// <summary>Defaults to today when omitted.</summary>
|
||||||
|
public DateTime? HireDate { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class UpdateUserRoleRequest
|
public sealed class UpdateUserRoleRequest
|
||||||
@@ -37,5 +53,10 @@ public sealed class UpdateUserRoleRequest
|
|||||||
[Required] public int RoleId { get; set; }
|
[Required] public int RoleId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class UpdateUserStatusRequest
|
||||||
|
{
|
||||||
|
[Required, EnumDataType(typeof(EntityStatus))] public EntityStatus Status { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>AuthHex UserType lookup, for populating the create-user form's select (no local shadow — read-only passthrough).</summary>
|
/// <summary>AuthHex UserType lookup, for populating the create-user form's select (no local shadow — read-only passthrough).</summary>
|
||||||
public sealed record UserTypeOptionDto(Guid UserTypeId, string? Code, string? Description);
|
public sealed record UserTypeOptionDto(Guid UserTypeId, string? Code, string? Description);
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace ERPCore.Dtos.Warehouses;
|
namespace ERPCore.Dtos.Warehouses;
|
||||||
|
|
||||||
/// <summary>Warehouse resource (docs/11-BACKEND-PHASE1.md §2.5).</summary>
|
/// <summary>Warehouse resource (docs/11-BACKEND-PHASE1.md §2.5). <see cref="BranchId"/> is
|
||||||
public sealed record WarehouseDto(int WarehouseId, string Code, string Name);
|
/// the anchor `docs/BRANCH_ISOLATION_PLAN.md` uses to branch-scope everything that carries
|
||||||
|
/// a `warehouseId` (Sales, GRN, stock, ...) without a column on every one of those entities.</summary>
|
||||||
|
public sealed record WarehouseDto(int WarehouseId, string Code, string Name, int BranchId, string? BranchName);
|
||||||
|
|
||||||
/// <summary>Bin/location resource (docs/11 §2.5).</summary>
|
/// <summary>Bin/location resource (docs/11 §2.5).</summary>
|
||||||
public sealed record BinDto(int BinId, int WarehouseId, string Code, string? BinType);
|
public sealed record BinDto(int BinId, int WarehouseId, string Code, string? BinType);
|
||||||
@@ -12,6 +14,7 @@ public sealed class CreateWarehouseRequest
|
|||||||
{
|
{
|
||||||
[Required, StringLength(50)] public string Code { get; set; } = string.Empty;
|
[Required, StringLength(50)] public string Code { get; set; } = string.Empty;
|
||||||
[Required, StringLength(200)] public string Name { get; set; } = string.Empty;
|
[Required, StringLength(200)] public string Name { get; set; } = string.Empty;
|
||||||
|
[Required] public int BranchId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class CreateBinRequest
|
public sealed class CreateBinRequest
|
||||||
|
|||||||
@@ -31,4 +31,8 @@ public sealed class CurrentUser : ICurrentUser
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int AuditUserId => int.TryParse(UserId, out var id) ? id : User.SystemUserId;
|
public int AuditUserId => int.TryParse(UserId, out var id) ? id : User.SystemUserId;
|
||||||
|
|
||||||
|
public string? RoleCode => _accessor.HttpContext?.User?.FindFirstValue(AuthHexClaims.RoleCode);
|
||||||
|
|
||||||
|
public bool IsAdmin => string.Equals(RoleCode?.Trim(), "Admin", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,4 +19,14 @@ public interface ICurrentUser
|
|||||||
|
|
||||||
/// <summary>True when the request carries an authenticated principal.</summary>
|
/// <summary>True when the request carries an authenticated principal.</summary>
|
||||||
bool IsAuthenticated { get; }
|
bool IsAuthenticated { get; }
|
||||||
|
|
||||||
|
/// <summary>The AuthHex <c>RoleCode</c> claim verbatim, or null if absent/unauthenticated.</summary>
|
||||||
|
string? RoleCode { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True when <see cref="RoleCode"/> is "Admin" (case-insensitive — AuthHex mints the claim
|
||||||
|
/// independently of ERPCore's stored casing). Mirrors <c>RoleService.GetMeAsync</c>'s check;
|
||||||
|
/// the only role that bypasses branch-scoping (see <see cref="Services.Interfaces.IBranchAccessService"/>).
|
||||||
|
/// </summary>
|
||||||
|
bool IsAdmin { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
namespace ERPCore.Infra.Auth;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Best-effort "Browser on OS" label from a raw User-Agent string, for display in the
|
||||||
|
/// login-device history — not a full parsing library, just enough to be readable
|
||||||
|
/// (docs call this out: exact device model detection is out of scope).
|
||||||
|
/// </summary>
|
||||||
|
public static class UserAgentLabeler
|
||||||
|
{
|
||||||
|
public static string Label(string? userAgent)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(userAgent)) return "Unknown device";
|
||||||
|
|
||||||
|
var os = DetectOs(userAgent);
|
||||||
|
var browser = DetectBrowser(userAgent);
|
||||||
|
return $"{browser} on {os}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string DetectOs(string ua)
|
||||||
|
{
|
||||||
|
if (ua.Contains("Windows", StringComparison.OrdinalIgnoreCase)) return "Windows";
|
||||||
|
if (ua.Contains("Mac OS X", StringComparison.OrdinalIgnoreCase) || ua.Contains("Macintosh", StringComparison.OrdinalIgnoreCase)) return "macOS";
|
||||||
|
if (ua.Contains("Android", StringComparison.OrdinalIgnoreCase)) return "Android";
|
||||||
|
if (ua.Contains("iPhone", StringComparison.OrdinalIgnoreCase) || ua.Contains("iPad", StringComparison.OrdinalIgnoreCase)) return "iOS";
|
||||||
|
if (ua.Contains("Linux", StringComparison.OrdinalIgnoreCase)) return "Linux";
|
||||||
|
return "an unknown OS";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string DetectBrowser(string ua)
|
||||||
|
{
|
||||||
|
// Order matters: Edge/OPR/Chrome all also contain "Safari"/"Chrome" tokens.
|
||||||
|
if (ua.Contains("Edg/", StringComparison.OrdinalIgnoreCase)) return "Edge";
|
||||||
|
if (ua.Contains("OPR/", StringComparison.OrdinalIgnoreCase) || ua.Contains("Opera", StringComparison.OrdinalIgnoreCase)) return "Opera";
|
||||||
|
if (ua.Contains("Firefox", StringComparison.OrdinalIgnoreCase)) return "Firefox";
|
||||||
|
if (ua.Contains("CriOS", StringComparison.OrdinalIgnoreCase) || ua.Contains("Chrome", StringComparison.OrdinalIgnoreCase)) return "Chrome";
|
||||||
|
if (ua.Contains("Safari", StringComparison.OrdinalIgnoreCase)) return "Safari";
|
||||||
|
return "an unknown browser";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ public static class AuditScribe
|
|||||||
private static readonly HashSet<Type> Excluded =
|
private static readonly HashSet<Type> Excluded =
|
||||||
[
|
[
|
||||||
typeof(AuditLog), typeof(JournalEntryStub), typeof(NumberSequence),
|
typeof(AuditLog), typeof(JournalEntryStub), typeof(NumberSequence),
|
||||||
typeof(StockLedger), typeof(StockLayer),
|
typeof(StockLedger), typeof(StockLayer), typeof(LoginActivity),
|
||||||
];
|
];
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions Json = new()
|
private static readonly JsonSerializerOptions Json = new()
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace ERPCore.Infra.Persistence.Configurations;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the singleton branch-configuration row. The check constraint is what makes
|
||||||
|
/// "singleton" a database guarantee rather than a convention (mirrors ProductConfig).
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BranchConfigConfiguration : IEntityTypeConfiguration<BranchConfig>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<BranchConfig> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("branch_config", t =>
|
||||||
|
t.HasCheckConstraint("ck_branch_config_singleton", $"\"ConfigId\" = {BranchConfig.SingletonId}"));
|
||||||
|
|
||||||
|
builder.HasKey(c => c.ConfigId);
|
||||||
|
|
||||||
|
// The id is fixed, never generated — there is exactly one row, seeded by DataSeeder.
|
||||||
|
builder.Property(c => c.ConfigId).ValueGeneratedNever();
|
||||||
|
|
||||||
|
builder.Property(c => c.BranchingEnabled).IsRequired().HasDefaultValue(true);
|
||||||
|
|
||||||
|
// PostgreSQL xmin system column as the optimistic concurrency token (ETag).
|
||||||
|
builder.Property(c => c.RowVersion).IsRowVersion();
|
||||||
|
|
||||||
|
builder.HasOne(c => c.UpdatedByUser)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(c => c.UpdatedBy)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ public sealed class BranchConfiguration : IEntityTypeConfiguration<Branch>
|
|||||||
builder.HasIndex(b => b.Code).IsUnique();
|
builder.HasIndex(b => b.Code).IsUnique();
|
||||||
builder.Property(b => b.Name).IsRequired().HasMaxLength(200);
|
builder.Property(b => b.Name).IsRequired().HasMaxLength(200);
|
||||||
builder.Property(b => b.Address).HasMaxLength(500);
|
builder.Property(b => b.Address).HasMaxLength(500);
|
||||||
|
builder.Property(b => b.PhoneNumber).HasMaxLength(30);
|
||||||
|
|
||||||
builder.Property(b => b.Status)
|
builder.Property(b => b.Status)
|
||||||
.HasConversion<string>().HasMaxLength(20).IsRequired()
|
.HasConversion<string>().HasMaxLength(20).IsRequired()
|
||||||
|
|||||||
@@ -17,38 +17,18 @@ public sealed class GrnConfiguration : IEntityTypeConfiguration<Grn>
|
|||||||
builder.Property(g => g.Status).HasConversion<string>().HasMaxLength(20).IsRequired();
|
builder.Property(g => g.Status).HasConversion<string>().HasMaxLength(20).IsRequired();
|
||||||
builder.Property(g => g.CreatedAt).IsRequired();
|
builder.Property(g => g.CreatedAt).IsRequired();
|
||||||
builder.Property(g => g.GlJournalNo).HasMaxLength(30);
|
builder.Property(g => g.GlJournalNo).HasMaxLength(30);
|
||||||
builder.Property(g => g.PaidAmount).HasPrecision(18, 4);
|
|
||||||
builder.Property(g => g.BalanceAmount).HasPrecision(18, 4);
|
|
||||||
builder.Property(g => g.RowVersion).IsRowVersion();
|
builder.Property(g => g.RowVersion).IsRowVersion();
|
||||||
|
|
||||||
builder.HasOne(g => g.PurchaseOrder).WithMany().HasForeignKey(g => g.PoId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(g => g.PurchaseOrder).WithMany().HasForeignKey(g => g.PoId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(g => g.Vendor).WithMany().HasForeignKey(g => g.VendorId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(g => g.Vendor).WithMany().HasForeignKey(g => g.VendorId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(g => g.Warehouse).WithMany().HasForeignKey(g => g.WarehouseId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(g => g.Warehouse).WithMany().HasForeignKey(g => g.WarehouseId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasOne(g => g.Branch).WithMany().HasForeignKey(g => g.BranchId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(g => g.Creator).WithMany().HasForeignKey(g => g.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(g => g.Creator).WithMany().HasForeignKey(g => g.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasOne(g => g.PurchaseInvoice).WithMany().HasForeignKey(g => g.PurchaseInvoiceId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
builder.HasIndex(g => g.Status);
|
builder.HasIndex(g => g.Status);
|
||||||
builder.HasIndex(g => g.PoId);
|
builder.HasIndex(g => g.PoId);
|
||||||
}
|
builder.HasIndex(g => g.BranchId);
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class GrnPaymentConfiguration : IEntityTypeConfiguration<GrnPayment>
|
|
||||||
{
|
|
||||||
public void Configure(EntityTypeBuilder<GrnPayment> builder)
|
|
||||||
{
|
|
||||||
builder.ToTable("grn_payments");
|
|
||||||
builder.HasKey(p => p.GrnPaymentId);
|
|
||||||
|
|
||||||
builder.Property(p => p.Amount).HasPrecision(18, 4);
|
|
||||||
builder.Property(p => p.PaymentDate).IsRequired();
|
|
||||||
builder.Property(p => p.BankAccountName).IsRequired().HasMaxLength(200);
|
|
||||||
builder.Property(p => p.Reference).HasMaxLength(100);
|
|
||||||
builder.Property(p => p.GlJournalNo).HasMaxLength(30);
|
|
||||||
builder.Property(p => p.CreatedAt).IsRequired();
|
|
||||||
|
|
||||||
builder.HasOne(p => p.Grn).WithMany(g => g.Payments).HasForeignKey(p => p.GrnId).OnDelete(DeleteBehavior.Restrict);
|
|
||||||
builder.HasOne(p => p.Creator).WithMany().HasForeignKey(p => p.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
|
||||||
|
|
||||||
builder.HasIndex(p => p.GrnId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ public sealed class ItemConfiguration : IEntityTypeConfiguration<Item>
|
|||||||
builder.Property(i => i.TaxClass).HasMaxLength(20);
|
builder.Property(i => i.TaxClass).HasMaxLength(20);
|
||||||
|
|
||||||
// Sales-only fixed selling price; nullable (null ⇒ sell at stock/FIFO value).
|
// Sales-only fixed selling price; nullable (null ⇒ sell at stock/FIFO value).
|
||||||
builder.Property(i => i.SalePrice).HasPrecision(18, 4);
|
builder.Property(i => i.SellingMinPrice).HasPrecision(18, 4);
|
||||||
|
builder.Property(i => i.SellingMaxPrice).HasPrecision(18, 4);
|
||||||
|
builder.Property(i => i.SellingFlatPrice).HasPrecision(18, 4);
|
||||||
|
|
||||||
// Optional content size (how much one stocked pack holds). All four are nullable
|
// Optional content size (how much one stocked pack holds). All four are nullable
|
||||||
// together: null ⇒ the item has no measurable content. The base pair is derived
|
// together: null ⇒ the item has no measurable content. The base pair is derived
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace ERPCore.Infra.Persistence.Configurations;
|
||||||
|
|
||||||
|
public sealed class LoginActivityConfiguration : IEntityTypeConfiguration<LoginActivity>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<LoginActivity> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("login_activities");
|
||||||
|
builder.HasKey(l => l.LoginActivityId);
|
||||||
|
|
||||||
|
builder.Property(l => l.IpAddress).HasMaxLength(64);
|
||||||
|
builder.Property(l => l.UserAgent).HasMaxLength(500);
|
||||||
|
builder.Property(l => l.DeviceLabel).HasMaxLength(200);
|
||||||
|
builder.Property(l => l.LoginAt).IsRequired();
|
||||||
|
|
||||||
|
builder.HasOne(l => l.User).WithMany().HasForeignKey(l => l.UserId).OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
builder.HasIndex(l => new { l.UserId, l.LoginAt });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,8 @@ public sealed class NavItemConfiguration : IEntityTypeConfiguration<NavItem>
|
|||||||
builder.HasData(
|
builder.HasData(
|
||||||
new NavItem { NavItemId = 1, Code = "dashboard", Label = "Dashboard", Href = "/dashboard", SortOrder = 1 },
|
new NavItem { NavItemId = 1, Code = "dashboard", Label = "Dashboard", Href = "/dashboard", SortOrder = 1 },
|
||||||
new NavItem { NavItemId = 2, Code = "products", Label = "Products", Href = "/dashboard/products", SortOrder = 2 },
|
new NavItem { NavItemId = 2, Code = "products", Label = "Products", Href = "/dashboard/products", SortOrder = 2 },
|
||||||
new NavItem { NavItemId = 3, Code = "vendors", Label = "Vendors", Href = "/dashboard/vendors", SortOrder = 3 },
|
// NavItemId 3 ("vendors") retired 2026-09-09 — Vendors moved under Procurement as a
|
||||||
|
// sub-item (see SubNavItemConfiguration/PermissionConfiguration), matching the sidebar.
|
||||||
new NavItem { NavItemId = 4, Code = "procurement", Label = "Procurement", Href = "/dashboard/procurement", SortOrder = 4 },
|
new NavItem { NavItemId = 4, Code = "procurement", Label = "Procurement", Href = "/dashboard/procurement", SortOrder = 4 },
|
||||||
new NavItem { NavItemId = 5, Code = "receiving", Label = "Receiving", Href = "/dashboard/receiving/grn", SortOrder = 5 },
|
new NavItem { NavItemId = 5, Code = "receiving", Label = "Receiving", Href = "/dashboard/receiving/grn", SortOrder = 5 },
|
||||||
new NavItem { NavItemId = 6, Code = "stock", Label = "Stock", Href = "/dashboard/stock", SortOrder = 6 },
|
new NavItem { NavItemId = 6, Code = "stock", Label = "Stock", Href = "/dashboard/stock", SortOrder = 6 },
|
||||||
@@ -39,7 +40,8 @@ public sealed class NavItemConfiguration : IEntityTypeConfiguration<NavItem>
|
|||||||
new NavItem { NavItemId = 10, Code = "help", Label = "Help", Href = "/dashboard/help", SortOrder = 10 },
|
new NavItem { NavItemId = 10, Code = "help", Label = "Help", Href = "/dashboard/help", SortOrder = 10 },
|
||||||
new NavItem { NavItemId = 11, Code = "ledgers", Label = "Ledgers", Href = "/dashboard/ledgers", SortOrder = 11 },
|
new NavItem { NavItemId = 11, Code = "ledgers", Label = "Ledgers", Href = "/dashboard/ledgers", SortOrder = 11 },
|
||||||
new NavItem { NavItemId = 12, Code = "accounts", Label = "Accounts", Href = "/dashboard/accounts", SortOrder = 12 },
|
new NavItem { NavItemId = 12, Code = "accounts", Label = "Accounts", Href = "/dashboard/accounts", SortOrder = 12 },
|
||||||
new NavItem { NavItemId = 13, Code = "sales", Label = "Sales", Href = "/dashboard/sales", SortOrder = 13 }
|
new NavItem { NavItemId = 13, Code = "sales", Label = "Sales", Href = "/dashboard/sales", SortOrder = 13 },
|
||||||
|
new NavItem { NavItemId = 14, Code = "production", Label = "Production", Href = "/dashboard/production", SortOrder = 14 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace ERPCore.Infra.Persistence.Configurations;
|
||||||
|
|
||||||
|
public sealed class NotificationConfigConfiguration : IEntityTypeConfiguration<NotificationConfig>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<NotificationConfig> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("notification_config", t =>
|
||||||
|
t.HasCheckConstraint("ck_notification_config_singleton", $"\"NotificationConfigId\" = {NotificationConfig.SingletonId}"));
|
||||||
|
|
||||||
|
builder.HasKey(c => c.NotificationConfigId);
|
||||||
|
builder.Property(c => c.NotificationConfigId).ValueGeneratedNever();
|
||||||
|
|
||||||
|
builder.Property(c => c.RowVersion).IsRowVersion();
|
||||||
|
|
||||||
|
builder.HasMany(c => c.Modules)
|
||||||
|
.WithOne(m => m.NotificationConfig)
|
||||||
|
.HasForeignKey(m => m.NotificationConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
builder.HasOne(c => c.UpdatedByUser)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(c => c.UpdatedBy)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace ERPCore.Infra.Persistence.Configurations;
|
||||||
|
|
||||||
|
public sealed class NotificationConfigModuleConfiguration : IEntityTypeConfiguration<NotificationConfigModule>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<NotificationConfigModule> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("notification_config_modules");
|
||||||
|
builder.HasKey(m => m.NotificationConfigModuleId);
|
||||||
|
|
||||||
|
builder.Property(m => m.ModuleKey).IsRequired().HasMaxLength(100);
|
||||||
|
builder.HasIndex(m => m.ModuleKey).IsUnique();
|
||||||
|
|
||||||
|
builder.Property(m => m.EmailEnabled).IsRequired().HasDefaultValue(false);
|
||||||
|
builder.Property(m => m.SmsEnabled).IsRequired().HasDefaultValue(false);
|
||||||
|
builder.Property(m => m.InAppEnabled).IsRequired().HasDefaultValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,9 @@ public sealed class PermissionConfiguration : IEntityTypeConfiguration<Permissio
|
|||||||
builder.HasData(
|
builder.HasData(
|
||||||
new Permission { PermissionId = 1, Code = "NAV:dashboard", NavItemId = 1 },
|
new Permission { PermissionId = 1, Code = "NAV:dashboard", NavItemId = 1 },
|
||||||
new Permission { PermissionId = 2, Code = "NAV:products", NavItemId = 2 },
|
new Permission { PermissionId = 2, Code = "NAV:products", NavItemId = 2 },
|
||||||
new Permission { PermissionId = 3, Code = "NAV:vendors", NavItemId = 3 },
|
// Moved under Procurement as a sub-item (2026-09-09) — same PermissionId (3), just
|
||||||
|
// repointed to the new SubNavItem, so any role already granted this permission keeps it.
|
||||||
|
new Permission { PermissionId = 3, Code = "NAV:procurement.vendors", SubNavItemId = 30 },
|
||||||
new Permission { PermissionId = 4, Code = "NAV:procurement", NavItemId = 4 },
|
new Permission { PermissionId = 4, Code = "NAV:procurement", NavItemId = 4 },
|
||||||
new Permission { PermissionId = 5, Code = "NAV:receiving", NavItemId = 5 },
|
new Permission { PermissionId = 5, Code = "NAV:receiving", NavItemId = 5 },
|
||||||
new Permission { PermissionId = 6, Code = "NAV:stock", NavItemId = 6 },
|
new Permission { PermissionId = 6, Code = "NAV:stock", NavItemId = 6 },
|
||||||
@@ -61,7 +63,27 @@ public sealed class PermissionConfiguration : IEntityTypeConfiguration<Permissio
|
|||||||
new Permission { PermissionId = 26, Code = "NAV:accounts.bank-accounts", SubNavItemId = 15 },
|
new Permission { PermissionId = 26, Code = "NAV:accounts.bank-accounts", SubNavItemId = 15 },
|
||||||
new Permission { PermissionId = 32, Code = "NAV:accounts", NavItemId = 12 },
|
new Permission { PermissionId = 32, Code = "NAV:accounts", NavItemId = 12 },
|
||||||
new Permission { PermissionId = 33, Code = "NAV:accounts.cheque-books", SubNavItemId = 21 },
|
new Permission { PermissionId = 33, Code = "NAV:accounts.cheque-books", SubNavItemId = 21 },
|
||||||
new Permission { PermissionId = 34, Code = "NAV:accounts.received-cheques", SubNavItemId = 22 }
|
new Permission { PermissionId = 34, Code = "NAV:accounts.received-cheques", SubNavItemId = 22 },
|
||||||
|
new Permission { PermissionId = 35, Code = "NAV:production", NavItemId = 14 },
|
||||||
|
new Permission { PermissionId = 36, Code = "NAV:production.templates", SubNavItemId = 27 },
|
||||||
|
new Permission { PermissionId = 37, Code = "NAV:production.runs", SubNavItemId = 25 },
|
||||||
|
new Permission { PermissionId = 38, Code = "NAV:production.produced", SubNavItemId = 26 },
|
||||||
|
new Permission { PermissionId = 39, Code = "NAV:procurement.purchase-invoices", SubNavItemId = 28 },
|
||||||
|
new Permission { PermissionId = 40, Code = "NAV:settings.branches", SubNavItemId = 29 },
|
||||||
|
new Permission { PermissionId = 41, Code = "NAV:stock.ledger", SubNavItemId = 31 },
|
||||||
|
new Permission { PermissionId = 42, Code = "NAV:stock.enquiry", SubNavItemId = 32 },
|
||||||
|
new Permission { PermissionId = 43, Code = "NAV:stock.valuation", SubNavItemId = 33 },
|
||||||
|
new Permission { PermissionId = 44, Code = "NAV:stock.transfers", SubNavItemId = 34 },
|
||||||
|
new Permission { PermissionId = 45, Code = "NAV:stock.adjustments", SubNavItemId = 35 },
|
||||||
|
new Permission { PermissionId = 46, Code = "NAV:stock.counts", SubNavItemId = 36 },
|
||||||
|
new Permission { PermissionId = 47, Code = "NAV:stock.reorder-alerts", SubNavItemId = 37 },
|
||||||
|
new Permission { PermissionId = 48, Code = "NAV:stock.wastage", SubNavItemId = 38 },
|
||||||
|
// Sales (NavItemId 13) children — SubNavItemId 23 had no permission row before now
|
||||||
|
// (mirrors SubNavItemConfiguration's rename of that row to sales.bundle-templates).
|
||||||
|
new Permission { PermissionId = 49, Code = "NAV:sales.bundle-templates", SubNavItemId = 23 },
|
||||||
|
new Permission { PermissionId = 50, Code = "NAV:sales.invoices", SubNavItemId = 40 },
|
||||||
|
new Permission { PermissionId = 51, Code = "NAV:sales.free-issues", SubNavItemId = 41 },
|
||||||
|
new Permission { PermissionId = 52, Code = "NAV:sales.day-end", SubNavItemId = 42 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ public sealed class ProductConfigConfiguration : IEntityTypeConfiguration<Produc
|
|||||||
builder.Property(c => c.SubcategoriesEnabled).IsRequired().HasDefaultValue(true);
|
builder.Property(c => c.SubcategoriesEnabled).IsRequired().HasDefaultValue(true);
|
||||||
builder.Property(c => c.BrandsEnabled).IsRequired().HasDefaultValue(true);
|
builder.Property(c => c.BrandsEnabled).IsRequired().HasDefaultValue(true);
|
||||||
builder.Property(c => c.ItemTypesEnabled).IsRequired().HasDefaultValue(true);
|
builder.Property(c => c.ItemTypesEnabled).IsRequired().HasDefaultValue(true);
|
||||||
|
builder.Property(c => c.SellingPricesEnabled).IsRequired().HasDefaultValue(true);
|
||||||
|
builder.Property(c => c.SerialNumbersEnabled).IsRequired().HasDefaultValue(true);
|
||||||
|
builder.Property(c => c.BatchListsEnabled).IsRequired().HasDefaultValue(true);
|
||||||
|
builder.Property(c => c.WarrantyPeriodsEnabled).IsRequired().HasDefaultValue(true);
|
||||||
|
|
||||||
// PostgreSQL xmin system column as the optimistic concurrency token (ETag).
|
// PostgreSQL xmin system column as the optimistic concurrency token (ETag).
|
||||||
builder.Property(c => c.RowVersion).IsRowVersion();
|
builder.Property(c => c.RowVersion).IsRowVersion();
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
using ERPCore.Domain.Entities;
|
||||||
|
using ERPCore.Domain.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace ERPCore.Infra.Persistence.Configurations;
|
||||||
|
|
||||||
|
public sealed class PurchaseInvoiceConfiguration : IEntityTypeConfiguration<PurchaseInvoice>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PurchaseInvoice> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("purchase_invoices");
|
||||||
|
builder.HasKey(x => x.PurchaseInvoiceId);
|
||||||
|
|
||||||
|
builder.Property(x => x.DocNo).IsRequired().HasMaxLength(30);
|
||||||
|
builder.HasIndex(x => x.DocNo).IsUnique();
|
||||||
|
|
||||||
|
builder.Property(x => x.VendorInvoiceNo).IsRequired().HasMaxLength(50);
|
||||||
|
builder.Property(x => x.VendorInvoiceDate).IsRequired();
|
||||||
|
// A vendor invoice number is only meaningful per-vendor; the service also excludes
|
||||||
|
// Cancelled invoices from the duplicate check, so this composite index is a coarse
|
||||||
|
// backstop (it does not distinguish Cancelled rows) rather than the sole enforcement.
|
||||||
|
builder.HasIndex(x => new { x.VendorId, x.VendorInvoiceNo });
|
||||||
|
|
||||||
|
builder.HasOne(x => x.Vendor)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.VendorId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.Property(x => x.VendorSnapshotName).IsRequired().HasMaxLength(200);
|
||||||
|
builder.Property(x => x.VendorSnapshotTaxNo).HasMaxLength(50);
|
||||||
|
|
||||||
|
builder.Property(x => x.Status)
|
||||||
|
.HasConversion<string>().HasMaxLength(20).IsRequired()
|
||||||
|
.HasDefaultValue(PurchaseInvoiceStatus.Draft);
|
||||||
|
|
||||||
|
foreach (var p in new[] { nameof(PurchaseInvoice.Subtotal), nameof(PurchaseInvoice.VatTotal), nameof(PurchaseInvoice.GrandTotal), nameof(PurchaseInvoice.PaidAmount), nameof(PurchaseInvoice.BalanceAmount) })
|
||||||
|
builder.Property<decimal>(p).HasPrecision(18, 4);
|
||||||
|
builder.Property(x => x.GlJournalNo).HasMaxLength(30);
|
||||||
|
|
||||||
|
builder.HasOne(x => x.Creator).WithMany().HasForeignKey(x => x.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.Property(x => x.CreatedAt).IsRequired();
|
||||||
|
builder.Property(x => x.RowVersion).IsRowVersion();
|
||||||
|
|
||||||
|
builder.HasIndex(x => x.Status);
|
||||||
|
builder.HasIndex(x => x.VendorId);
|
||||||
|
|
||||||
|
builder.HasMany(x => x.Lines)
|
||||||
|
.WithOne(x => x.PurchaseInvoice)
|
||||||
|
.HasForeignKey(x => x.PurchaseInvoiceId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class PurchaseInvoiceLineConfiguration : IEntityTypeConfiguration<PurchaseInvoiceLine>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PurchaseInvoiceLine> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("purchase_invoice_lines");
|
||||||
|
builder.HasKey(x => x.PurchaseInvoiceLineId);
|
||||||
|
|
||||||
|
builder.Property(x => x.Subtotal).HasPrecision(18, 4);
|
||||||
|
builder.Property(x => x.VatTotal).HasPrecision(18, 4);
|
||||||
|
builder.Property(x => x.LineTotal).HasPrecision(18, 4);
|
||||||
|
|
||||||
|
builder.HasOne(x => x.Grn)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.GrnId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
// A GRN can be consolidated onto at most one active line at a time — cancelling the
|
||||||
|
// invoice removes its lines and frees the GRN (PurchaseInvoiceService.CancelAsync), so
|
||||||
|
// this stays enforceable rather than blocking a later re-invoice of the same GRN.
|
||||||
|
builder.HasIndex(x => x.GrnId).IsUnique();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class PurchaseInvoicePaymentConfiguration : IEntityTypeConfiguration<PurchaseInvoicePayment>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PurchaseInvoicePayment> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("purchase_invoice_payments");
|
||||||
|
builder.HasKey(p => p.PurchaseInvoicePaymentId);
|
||||||
|
|
||||||
|
builder.Property(p => p.Amount).HasPrecision(18, 4);
|
||||||
|
builder.Property(p => p.PaymentDate).IsRequired();
|
||||||
|
builder.Property(p => p.BankAccountName).IsRequired().HasMaxLength(200);
|
||||||
|
builder.Property(p => p.Reference).HasMaxLength(100);
|
||||||
|
builder.Property(p => p.GlJournalNo).HasMaxLength(30);
|
||||||
|
builder.Property(p => p.CreatedAt).IsRequired();
|
||||||
|
|
||||||
|
builder.HasOne(p => p.PurchaseInvoice).WithMany(x => x.Payments).HasForeignKey(p => p.PurchaseInvoiceId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasOne(p => p.Creator).WithMany().HasForeignKey(p => p.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasIndex(p => p.PurchaseInvoiceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,11 @@ public sealed class SalesInvoiceConfiguration : IEntityTypeConfiguration<SalesIn
|
|||||||
.HasForeignKey(x => x.WarehouseId)
|
.HasForeignKey(x => x.WarehouseId)
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasOne(x => x.Branch)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(x => x.BranchId)
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
builder.Property(x => x.InvoiceType)
|
builder.Property(x => x.InvoiceType)
|
||||||
.HasConversion<string>().HasMaxLength(20).IsRequired()
|
.HasConversion<string>().HasMaxLength(20).IsRequired()
|
||||||
.HasDefaultValue(SalesInvoiceType.B2C);
|
.HasDefaultValue(SalesInvoiceType.B2C);
|
||||||
@@ -47,6 +52,7 @@ public sealed class SalesInvoiceConfiguration : IEntityTypeConfiguration<SalesIn
|
|||||||
|
|
||||||
builder.HasIndex(x => x.Status);
|
builder.HasIndex(x => x.Status);
|
||||||
builder.HasIndex(x => x.InvoiceDate);
|
builder.HasIndex(x => x.InvoiceDate);
|
||||||
|
builder.HasIndex(x => x.BranchId);
|
||||||
|
|
||||||
builder.HasMany(x => x.Lines)
|
builder.HasMany(x => x.Lines)
|
||||||
.WithOne(x => x.SalesInvoice)
|
.WithOne(x => x.SalesInvoice)
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ public sealed class StockAdjustmentConfiguration : IEntityTypeConfiguration<Stoc
|
|||||||
|
|
||||||
builder.HasOne(a => a.Warehouse).WithMany().HasForeignKey(a => a.WarehouseId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(a => a.Warehouse).WithMany().HasForeignKey(a => a.WarehouseId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(a => a.ReasonCode).WithMany().HasForeignKey(a => a.ReasonCodeId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(a => a.ReasonCode).WithMany().HasForeignKey(a => a.ReasonCodeId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasOne(a => a.Branch).WithMany().HasForeignKey(a => a.BranchId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(a => a.Creator).WithMany().HasForeignKey(a => a.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(a => a.Creator).WithMany().HasForeignKey(a => a.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasIndex(a => a.BranchId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ public sealed class StockCountConfiguration : IEntityTypeConfiguration<StockCoun
|
|||||||
builder.Property(c => c.RowVersion).IsRowVersion();
|
builder.Property(c => c.RowVersion).IsRowVersion();
|
||||||
|
|
||||||
builder.HasOne(c => c.Warehouse).WithMany().HasForeignKey(c => c.WarehouseId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(c => c.Warehouse).WithMany().HasForeignKey(c => c.WarehouseId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasOne(c => c.Branch).WithMany().HasForeignKey(c => c.BranchId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(c => c.Creator).WithMany().HasForeignKey(c => c.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(c => c.Creator).WithMany().HasForeignKey(c => c.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
builder.HasIndex(c => c.Status);
|
builder.HasIndex(c => c.Status);
|
||||||
|
builder.HasIndex(c => c.BranchId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ public sealed class StockTransferConfiguration : IEntityTypeConfiguration<StockT
|
|||||||
|
|
||||||
builder.HasOne(t => t.SrcWarehouse).WithMany().HasForeignKey(t => t.SrcWarehouseId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(t => t.SrcWarehouse).WithMany().HasForeignKey(t => t.SrcWarehouseId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(t => t.DestWarehouse).WithMany().HasForeignKey(t => t.DestWarehouseId).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(t => t.DestWarehouse).WithMany().HasForeignKey(t => t.DestWarehouseId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasOne(t => t.Branch).WithMany().HasForeignKey(t => t.BranchId).OnDelete(DeleteBehavior.Restrict);
|
||||||
builder.HasOne(t => t.Creator).WithMany().HasForeignKey(t => t.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
builder.HasOne(t => t.Creator).WithMany().HasForeignKey(t => t.CreatedBy).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
builder.HasIndex(t => t.Status);
|
builder.HasIndex(t => t.Status);
|
||||||
|
builder.HasIndex(t => t.BranchId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,16 +31,28 @@ public sealed class SubNavItemConfiguration : IEntityTypeConfiguration<SubNavIte
|
|||||||
new SubNavItem { SubNavItemId = 4, NavItemId = 2, Code = "products.item-type", Label = "Item Type", Href = "/dashboard/products/item-types", SortOrder = 4 },
|
new SubNavItem { SubNavItemId = 4, NavItemId = 2, Code = "products.item-type", Label = "Item Type", Href = "/dashboard/products/item-types", SortOrder = 4 },
|
||||||
new SubNavItem { SubNavItemId = 5, NavItemId = 2, Code = "products.uom", Label = "UOM", Href = "/dashboard/products/uoms", SortOrder = 5 },
|
new SubNavItem { SubNavItemId = 5, NavItemId = 2, Code = "products.uom", Label = "UOM", Href = "/dashboard/products/uoms", SortOrder = 5 },
|
||||||
new SubNavItem { SubNavItemId = 6, NavItemId = 2, Code = "products.configuration", Label = "Configuration", Href = "/dashboard/products/settings", SortOrder = 6 },
|
new SubNavItem { SubNavItemId = 6, NavItemId = 2, Code = "products.configuration", Label = "Configuration", Href = "/dashboard/products/settings", SortOrder = 6 },
|
||||||
|
new SubNavItem { SubNavItemId = 29, NavItemId = 9, Code = "settings.branches", Label = "Branches", Href = "/dashboard/settings/branches", SortOrder = 0 },
|
||||||
new SubNavItem { SubNavItemId = 7, NavItemId = 9, Code = "settings.roles", Label = "Roles", Href = "/dashboard/settings/roles", SortOrder = 1 },
|
new SubNavItem { SubNavItemId = 7, NavItemId = 9, Code = "settings.roles", Label = "Roles", Href = "/dashboard/settings/roles", SortOrder = 1 },
|
||||||
new SubNavItem { SubNavItemId = 8, NavItemId = 9, Code = "settings.users", Label = "Users", Href = "/dashboard/settings/users", SortOrder = 2 },
|
new SubNavItem { SubNavItemId = 8, NavItemId = 9, Code = "settings.users", Label = "Users", Href = "/dashboard/settings/users", SortOrder = 2 },
|
||||||
new SubNavItem { SubNavItemId = 23, NavItemId = 13, Code = "sales.bundle-sales", Label = "Bundle Sales", Href = "/dashboard/sales/bundles", SortOrder = 1 },
|
new SubNavItem { SubNavItemId = 24, NavItemId = 9, Code = "settings.notification-config", Label = "Notification Config", Href = "/dashboard/settings/notification-config", SortOrder = 3 },
|
||||||
|
// Sales (NavItemId 13) children — mirror the sidebar order (AppSidebar.tsx). SubNavItemId
|
||||||
|
// 23 is renamed in place (was "sales.bundle-sales" / Bundle Sales) rather than
|
||||||
|
// delete+recreate, so any role already granted this permission keeps it; the rest are new.
|
||||||
|
new SubNavItem { SubNavItemId = 40, NavItemId = 13, Code = "sales.invoices", Label = "Sales", Href = "/dashboard/sales/invoices", SortOrder = 1 },
|
||||||
|
new SubNavItem { SubNavItemId = 23, NavItemId = 13, Code = "sales.bundle-templates", Label = "Bundle Templates", Href = "/dashboard/sales/bundles/templates", SortOrder = 2 },
|
||||||
|
new SubNavItem { SubNavItemId = 41, NavItemId = 13, Code = "sales.free-issues", Label = "Free Issues", Href = "/dashboard/sales/free-issues", SortOrder = 3 },
|
||||||
|
new SubNavItem { SubNavItemId = 42, NavItemId = 13, Code = "sales.day-end", Label = "Day End", Href = "/dashboard/sales/day-end", SortOrder = 4 },
|
||||||
// Procurement (NavItemId 4) children — mirror the hub page order.
|
// Procurement (NavItemId 4) children — mirror the hub page order.
|
||||||
// IDs 17-20 (not 9-12): 9-12 were already claimed by the Ledgers sub-items below;
|
// IDs 17-20 (not 9-12): 9-12 were already claimed by the Ledgers sub-items below;
|
||||||
// these procurement rows were never actually migrated into the database before now.
|
// these procurement rows were never actually migrated into the database before now.
|
||||||
|
// Vendors (SubNavItemId 30) reuses PermissionId 3, which used to point at the retired
|
||||||
|
// top-level "vendors" NavItem — so any role already granted this permission keeps it.
|
||||||
|
new SubNavItem { SubNavItemId = 30, NavItemId = 4, Code = "procurement.vendors", Label = "Vendors", Href = "/dashboard/vendors", SortOrder = 0 },
|
||||||
new SubNavItem { SubNavItemId = 17, NavItemId = 4, Code = "procurement.requisitions", Label = "Requisitions", Href = "/dashboard/procurement/requisitions", SortOrder = 1 },
|
new SubNavItem { SubNavItemId = 17, NavItemId = 4, Code = "procurement.requisitions", Label = "Requisitions", Href = "/dashboard/procurement/requisitions", SortOrder = 1 },
|
||||||
new SubNavItem { SubNavItemId = 18, NavItemId = 4, Code = "procurement.rfqs", Label = "RFQs", Href = "/dashboard/procurement/rfqs", SortOrder = 2 },
|
new SubNavItem { SubNavItemId = 18, NavItemId = 4, Code = "procurement.rfqs", Label = "RFQs", Href = "/dashboard/procurement/rfqs", SortOrder = 2 },
|
||||||
new SubNavItem { SubNavItemId = 19, NavItemId = 4, Code = "procurement.purchase-orders", Label = "Purchase Orders", Href = "/dashboard/procurement/purchase-orders", SortOrder = 3 },
|
new SubNavItem { SubNavItemId = 19, NavItemId = 4, Code = "procurement.purchase-orders", Label = "Purchase Orders", Href = "/dashboard/procurement/purchase-orders", SortOrder = 3 },
|
||||||
new SubNavItem { SubNavItemId = 20, NavItemId = 4, Code = "procurement.purchase-returns", Label = "Purchase Returns", Href = "/dashboard/procurement/purchase-returns", SortOrder = 4 },
|
new SubNavItem { SubNavItemId = 20, NavItemId = 4, Code = "procurement.purchase-returns", Label = "Purchase Returns", Href = "/dashboard/procurement/purchase-returns", SortOrder = 4 },
|
||||||
|
new SubNavItem { SubNavItemId = 28, NavItemId = 4, Code = "procurement.purchase-invoices", Label = "Purchase Invoices", Href = "/dashboard/procurement/purchase-invoices", SortOrder = 5 },
|
||||||
new SubNavItem { SubNavItemId = 9, NavItemId = 11, Code = "ledgers.trial-balance", Label = "Trial Balance", Href = "/dashboard/ledgers/trial-balance", SortOrder = 1 },
|
new SubNavItem { SubNavItemId = 9, NavItemId = 11, Code = "ledgers.trial-balance", Label = "Trial Balance", Href = "/dashboard/ledgers/trial-balance", SortOrder = 1 },
|
||||||
new SubNavItem { SubNavItemId = 10, NavItemId = 11, Code = "ledgers.balance-sheet", Label = "Balance Sheet", Href = "/dashboard/ledgers/balance-sheet", SortOrder = 2 },
|
new SubNavItem { SubNavItemId = 10, NavItemId = 11, Code = "ledgers.balance-sheet", Label = "Balance Sheet", Href = "/dashboard/ledgers/balance-sheet", SortOrder = 2 },
|
||||||
new SubNavItem { SubNavItemId = 11, NavItemId = 11, Code = "ledgers.general-ledger", Label = "General Ledger", Href = "/dashboard/ledgers/general-ledger", SortOrder = 3 },
|
new SubNavItem { SubNavItemId = 11, NavItemId = 11, Code = "ledgers.general-ledger", Label = "General Ledger", Href = "/dashboard/ledgers/general-ledger", SortOrder = 3 },
|
||||||
@@ -53,7 +65,26 @@ public sealed class SubNavItemConfiguration : IEntityTypeConfiguration<SubNavIte
|
|||||||
// doesn't silently lose it just because the section it lives under changed.
|
// doesn't silently lose it just because the section it lives under changed.
|
||||||
new SubNavItem { SubNavItemId = 15, NavItemId = 12, Code = "accounts.bank-accounts", Label = "Cash / Bank Accounts", Href = "/dashboard/accounts/bank-accounts", SortOrder = 1 },
|
new SubNavItem { SubNavItemId = 15, NavItemId = 12, Code = "accounts.bank-accounts", Label = "Cash / Bank Accounts", Href = "/dashboard/accounts/bank-accounts", SortOrder = 1 },
|
||||||
new SubNavItem { SubNavItemId = 21, NavItemId = 12, Code = "accounts.cheque-books", Label = "Cheque Books", Href = "/dashboard/accounts/cheque-books", SortOrder = 2 },
|
new SubNavItem { SubNavItemId = 21, NavItemId = 12, Code = "accounts.cheque-books", Label = "Cheque Books", Href = "/dashboard/accounts/cheque-books", SortOrder = 2 },
|
||||||
new SubNavItem { SubNavItemId = 22, NavItemId = 12, Code = "accounts.received-cheques", Label = "Received Cheques", Href = "/dashboard/accounts/received-cheques", SortOrder = 3 }
|
new SubNavItem { SubNavItemId = 22, NavItemId = 12, Code = "accounts.received-cheques", Label = "Received Cheques", Href = "/dashboard/accounts/received-cheques", SortOrder = 3 },
|
||||||
|
// Production (NavItemId 14) children — mirror the sidebar order (AppSidebar.tsx).
|
||||||
|
// ID 27 (not 24): 24 collides with settings.notification-config above — that ID was
|
||||||
|
// reused by mistake in migration 20260820100345, which upserts row 24 to become the
|
||||||
|
// notification-config item and silently overwrites this one. See migration
|
||||||
|
// FixProductionTemplatesSubNavItemIdConflict for the data repair.
|
||||||
|
new SubNavItem { SubNavItemId = 27, NavItemId = 14, Code = "production.templates", Label = "Templates", Href = "/dashboard/production/templates", SortOrder = 1 },
|
||||||
|
new SubNavItem { SubNavItemId = 25, NavItemId = 14, Code = "production.runs", Label = "Runs", Href = "/dashboard/production/runs", SortOrder = 2 },
|
||||||
|
new SubNavItem { SubNavItemId = 26, NavItemId = 14, Code = "production.produced", Label = "Produced", Href = "/dashboard/production/produced", SortOrder = 3 },
|
||||||
|
// Stock (NavItemId 6) children — mirror the sidebar order (AppSidebar.tsx). These rows
|
||||||
|
// never existed in the database before now, so "stock" is still bypassed frontend-side
|
||||||
|
// in AppSidebar.tsx until roles are actually granted these permissions.
|
||||||
|
new SubNavItem { SubNavItemId = 31, NavItemId = 6, Code = "stock.ledger", Label = "Stock Ledger", Href = "/dashboard/stock/ledger", SortOrder = 1 },
|
||||||
|
new SubNavItem { SubNavItemId = 32, NavItemId = 6, Code = "stock.enquiry", Label = "Stock Enquiry", Href = "/dashboard/stock/enquiry", SortOrder = 2 },
|
||||||
|
new SubNavItem { SubNavItemId = 33, NavItemId = 6, Code = "stock.valuation", Label = "Valuation", Href = "/dashboard/stock/valuation", SortOrder = 3 },
|
||||||
|
new SubNavItem { SubNavItemId = 34, NavItemId = 6, Code = "stock.transfers", Label = "Transfers", Href = "/dashboard/stock/transfers", SortOrder = 4 },
|
||||||
|
new SubNavItem { SubNavItemId = 35, NavItemId = 6, Code = "stock.adjustments", Label = "Adjustments", Href = "/dashboard/stock/adjustments", SortOrder = 5 },
|
||||||
|
new SubNavItem { SubNavItemId = 36, NavItemId = 6, Code = "stock.counts", Label = "Counts", Href = "/dashboard/stock/counts", SortOrder = 6 },
|
||||||
|
new SubNavItem { SubNavItemId = 37, NavItemId = 6, Code = "stock.reorder-alerts", Label = "Reorder Alerts", Href = "/dashboard/stock/reorder-alerts", SortOrder = 7 },
|
||||||
|
new SubNavItem { SubNavItemId = 38, NavItemId = 6, Code = "stock.wastage", Label = "Wastage", Href = "/dashboard/stock/wastage", SortOrder = 8 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ERPCore.Domain.Entities;
|
using ERPCore.Domain.Entities;
|
||||||
|
using ERPCore.Domain.Enums;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
@@ -13,5 +14,13 @@ public sealed class UomConfiguration : IEntityTypeConfiguration<Uom>
|
|||||||
|
|
||||||
builder.Property(u => u.Name).IsRequired().HasMaxLength(50);
|
builder.Property(u => u.Name).IsRequired().HasMaxLength(50);
|
||||||
builder.HasIndex(u => u.Name).IsUnique();
|
builder.HasIndex(u => u.Name).IsUnique();
|
||||||
|
|
||||||
|
builder.Property(u => u.Status)
|
||||||
|
.HasConversion<string>().HasMaxLength(20).IsRequired()
|
||||||
|
.HasDefaultValue(EntityStatus.Active);
|
||||||
|
|
||||||
|
builder.Property(u => u.CreatedAt).IsRequired();
|
||||||
|
|
||||||
|
builder.HasIndex(u => u.Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,9 @@ public sealed class WarehouseConfiguration : IEntityTypeConfiguration<Warehouse>
|
|||||||
builder.HasIndex(w => w.Code).IsUnique();
|
builder.HasIndex(w => w.Code).IsUnique();
|
||||||
|
|
||||||
builder.Property(w => w.Name).IsRequired().HasMaxLength(200);
|
builder.Property(w => w.Name).IsRequired().HasMaxLength(200);
|
||||||
|
|
||||||
|
builder.HasOne(w => w.Branch).WithMany()
|
||||||
|
.HasForeignKey(w => w.BranchId).OnDelete(DeleteBehavior.Restrict);
|
||||||
|
builder.HasIndex(w => w.BranchId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user