Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
10a9136
feat: finance accounts, categories and transfers (Phase 3 stage 3, F1)
Vishnu90Coreinn Nov 24, 2026
de0c650
feat: expenses with mandatory receipts (Phase 3 stage 3, F2)
Vishnu90Coreinn Nov 24, 2026
6e23dd6
feat: income, void/correct and month lock (Phase 3 stage 3, F3 + F4)
Vishnu90Coreinn Nov 25, 2026
165e428
feat: finance overview dashboard (Phase 3 stage 3, F5)
Vishnu90Coreinn Nov 25, 2026
e49cd27
fix: guard finance corrections against double submit, ignore stale da…
Vishnu90Coreinn Nov 25, 2026
35c570b
feat: finance reports with Excel, PDF and CSV export (Phase 3 stage 3…
Vishnu90Coreinn Nov 25, 2026
20a14f3
docs: drop the Daftra import (F4b) from the finance plan
Vishnu90Coreinn Nov 25, 2026
14c9983
feat: partners and their capital (Phase 3 stage 3, F5b)
Vishnu90Coreinn Nov 25, 2026
06f81e1
feat: month-by-month comparison in the finance report
Vishnu90Coreinn Nov 25, 2026
d36bca6
feat: polish the finance pages (quick actions, sorting, CSV, drill-do…
Vishnu90Coreinn Nov 25, 2026
783bfd0
fix: clean receipt file names the same way on Windows and Linux
Vishnu90Coreinn Nov 25, 2026
1314345
feat: refine the app-wide design (Solid buttons, Inter and Plus Jakar…
Vishnu90Coreinn Nov 25, 2026
7932ce7
fix: make finance shares add up and show capital on the overview
Vishnu90Coreinn Nov 25, 2026
c699dfc
feat: clear visual hierarchy across the finance list cards and pages
Vishnu90Coreinn Nov 25, 2026
5c59a33
feat: finance gaps from the Daftra review (cheques, payees, split exp…
Vishnu90Coreinn Nov 25, 2026
8989eaa
docs: plan for a double-entry ledger so the client can leave Daftra
Vishnu90Coreinn Nov 25, 2026
ca841a1
feat: double-entry ledger foundation (chart of accounts, automatic jo…
Vishnu90Coreinn Nov 25, 2026
7077802
feat: chart editing, record mapping, manual journals and downloads fo…
Vishnu90Coreinn Nov 25, 2026
5a53696
feat: Profit & Loss and Balance Sheet from the ledger (L4)
Vishnu90Coreinn Nov 25, 2026
22993d3
feat: VAT on entries and the VAT return; cheques held in payable/rece…
Vishnu90Coreinn Nov 25, 2026
b68b3f1
feat: year-end close for the books (31 December)
Vishnu90Coreinn Nov 25, 2026
25ead65
feat: receivables for tax invoices (L6, first half)
Vishnu90Coreinn Nov 25, 2026
af86664
docs: finance cut-over runbook (Daftra to this app)
Vishnu90Coreinn Nov 25, 2026
9798af2
feat: supplier bills / payables (L6, second half)
Vishnu90Coreinn Nov 25, 2026
19aef13
chore: take unrelated client documents back out of the branch; runboo…
Vishnu90Coreinn Nov 25, 2026
00d4049
feat: standard chart of accounts and monthly (recurring) journals
Vishnu90Coreinn Nov 25, 2026
a49922d
feat: attach the supplier's invoice to a bill; standard chart is ensu…
Vishnu90Coreinn Nov 25, 2026
0caa7cb
docs: cut-over agreed for 1 January 2027 (cut-off 31 December 2026), …
Vishnu90Coreinn Nov 25, 2026
f7cd989
feat: categories for paying VAT to the tax authority and receiving re…
Vishnu90Coreinn Nov 25, 2026
1e682e6
docs: dry-run day checklist for the finance cut-over
Vishnu90Coreinn Nov 25, 2026
83989ed
fix: review findings (linked cheques respect month locks, empty years…
Vishnu90Coreinn Nov 25, 2026
f951b06
fix: remaining review findings (migration id collision, bill list cap…
Vishnu90Coreinn Nov 25, 2026
b5d6ffa
feat(ux): ask for the VAT type instead of assuming it, mark invoice a…
Vishnu90Coreinn Nov 25, 2026
6be4afc
feat(ux): Books sections, lock-through months, safer mapping lists
Vishnu90Coreinn Nov 25, 2026
239d7ad
feat(ux): Finance setup page and a "Needs attention" panel
Vishnu90Coreinn Nov 25, 2026
1d5eeb2
feat(ux): VAT by quarter with the due date; a faster expense form
Vishnu90Coreinn Nov 26, 2026
44b918a
feat(ux): phone menu headings and shorter entry header; bills summary…
Vishnu90Coreinn Nov 26, 2026
a9c783b
fix(ux): keep the expense form's footer to a line or two on a phone
Vishnu90Coreinn Nov 26, 2026
a9fe5b1
feat(ux): the top bar finds finance records, not only screens
Vishnu90Coreinn Nov 26, 2026
a9421b6
feat(ux): remaining polish from the finance screen review
Vishnu90Coreinn Nov 26, 2026
7b2fb4c
fix(auth): a password change renews sessions; staff expense options c…
Vishnu90Coreinn Nov 26, 2026
136dea6
fix(finance): correct accounting reports and transaction controls
Vishnu90Coreinn Nov 26, 2026
2168567
test(settings): expect the VAT period columns
Vishnu90Coreinn Nov 26, 2026
2d71633
fix(finance): correct the VAT export note and bring the cut-over docu…
Vishnu90Coreinn Nov 26, 2026
039b7fe
fix(finance): only a Manager sets the VAT recovery percentage
Vishnu90Coreinn Nov 26, 2026
6be53ae
fix(finance): align the finance screens and keep the app's own catego…
Vishnu90Coreinn Nov 26, 2026
ad349e6
fix(ui): level page actions with the title and tidy the rows under he…
Vishnu90Coreinn Nov 26, 2026
2036dfd
feat(ui): rework Accounts, Dashboard and Staff Leave; move New reques…
Vishnu90Coreinn Nov 26, 2026
5f258b8
fix(web): guard VAT entry and unsaved edits
Vishnu90Coreinn Nov 27, 2026
ec7178f
fix(finance): protect imports and keep ledger reads read-only
Vishnu90Coreinn Nov 27, 2026
763329c
feat(invoices): choose VAT per invoice and share one client list with…
Vishnu90Coreinn Nov 28, 2026
c3a4819
feat(web): add toasts and motion to money and chart screens
Vishnu90Coreinn Nov 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ appsettings.*.local.json
publish/
.DS_Store
Thumbs.db

# Expense receipts when no receipts path is configured (development)
App_Data/
101 changes: 101 additions & 0 deletions apps/api.tests/Helpers/TestFinance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using HrPayroll.Api.Data;
using HrPayroll.Api.Data.Entities;
using Microsoft.EntityFrameworkCore;

namespace HrPayroll.Api.Tests.Helpers;

/// <summary>Creates finance rows directly in the test database.</summary>
public static class TestFinance
{
/// <summary>Today on UAE time, which is what the API treats as "today".</summary>
public static DateOnly Today => DateOnly.FromDateTime(DateTime.UtcNow.AddHours(4));

public static string Unique(string prefix = "Acct") => $"{prefix} {Guid.NewGuid():N}"[..30];

public static async Task<FinAccount> AddAccountAsync(
string connectionString, string? name = null, decimal opening = 1000m, DateOnly? openingDate = null,
string kind = FinAccountKinds.Bank, bool isActive = true, string? accountNumber = null, string? iban = null)
{
var now = DateTime.UtcNow;
var account = new FinAccount
{
Name = name ?? Unique(), Kind = kind, OpeningBalance = opening, OpeningDate = openingDate ?? Today.AddDays(-60),
IsActive = isActive, AccountNumber = accountNumber, Iban = iban, CreatedUtc = now, UpdatedUtc = now,
};
await using var db = TestUsers.NewContext(connectionString);
db.FinAccounts.Add(account);
await db.SaveChangesAsync();
return account;
}

public static async Task<FinEntry> AddEntryAsync(
string connectionString, int accountId, string kind, decimal amount, DateOnly? date = null,
string status = FinStatuses.Active, int? categoryId = null, string party = "Test party", string createdBy = "tester")
{
var now = DateTime.UtcNow;
var entry = new FinEntry
{
Kind = kind, EntryNo = (kind == FinEntryKinds.Income ? "INC-" : "EXP-") + Guid.NewGuid().ToString("N")[..12],
EntryDate = date ?? Today.AddDays(-5), CategoryId = categoryId ?? (kind == FinEntryKinds.Income ? 10 : 1),
Party = party, AccountId = accountId, Amount = amount, Status = status,
VoidedUtc = status == FinStatuses.Voided ? now : null, VoidedBy = status == FinStatuses.Voided ? "tester" : null,
CreatedBy = createdBy, CreatedUtc = now,
};
entry.Lines.Add(new FinEntryLine { CategoryId = entry.CategoryId, Amount = amount }); // an ordinary entry is one line
await using var db = TestUsers.NewContext(connectionString);
db.FinEntries.Add(entry);
await db.SaveChangesAsync();
return entry;
}

public static async Task<FinTransfer> AddTransferAsync(
string connectionString, int fromId, int toId, decimal amount, DateOnly? date = null, string status = FinStatuses.Active)
{
var now = DateTime.UtcNow;
var transfer = new FinTransfer
{
TransferNo = "TRF-" + Guid.NewGuid().ToString("N")[..12], TransferDate = date ?? Today.AddDays(-3),
FromAccountId = fromId, ToAccountId = toId, Amount = amount, Status = status,
VoidedUtc = status == FinStatuses.Voided ? now : null, CreatedBy = "tester", CreatedUtc = now,
};
await using var db = TestUsers.NewContext(connectionString);
db.FinTransfers.Add(transfer);
await db.SaveChangesAsync();
return transfer;
}

public static async Task<FinPartner> AddPartnerAsync(string connectionString, string? name = null, decimal opening = 0m, bool isActive = true)
{
var now = DateTime.UtcNow;
var partner = new FinPartner { Name = name ?? Unique("Partner"), OpeningCapital = opening, IsActive = isActive, CreatedUtc = now, UpdatedUtc = now };
await using var db = TestUsers.NewContext(connectionString);
db.FinPartners.Add(partner);
await db.SaveChangesAsync();
return partner;
}

/// <summary>Capital put in (<see cref="FinEntryKinds.Capital"/>) or paid back (<see cref="FinEntryKinds.CapitalOut"/>) by a partner.</summary>
public static async Task<FinEntry> AddCapitalAsync(
string connectionString, int accountId, int partnerId, decimal amount, DateOnly? date = null, string kind = FinEntryKinds.Capital, string status = FinStatuses.Active)
{
var now = DateTime.UtcNow;
await using var db = TestUsers.NewContext(connectionString);
var partner = await db.FinPartners.AsNoTracking().SingleAsync(p => p.Id == partnerId);
var entry = new FinEntry
{
Kind = kind, EntryNo = (kind == FinEntryKinds.Capital ? "CAP-" : "RTN-") + Guid.NewGuid().ToString("N")[..12],
EntryDate = date ?? Today.AddDays(-5), CategoryId = kind == FinEntryKinds.Capital ? 11 : 12, Party = partner.Name, PartnerId = partnerId,
AccountId = accountId, Amount = amount, Status = status,
VoidedUtc = status == FinStatuses.Voided ? now : null, VoidedBy = status == FinStatuses.Voided ? "tester" : null, CreatedBy = "tester", CreatedUtc = now,
};
db.FinEntries.Add(entry);
await db.SaveChangesAsync();
return entry;
}

public static async Task<List<AuditLog>> AuditAsync(string connectionString, string action, string? entityId = null)
{
await using var db = TestUsers.NewContext(connectionString);
return await db.AuditLogs.AsNoTracking().Where(a => a.Action == action && (entityId == null || a.EntityId == entityId)).ToListAsync();
}
}
1 change: 1 addition & 0 deletions apps/api.tests/HrPayroll.Api.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ItemGroup>
<Using Include="Xunit" />
<None Include="../../docs/payroll-test-vectors.json" Link="payroll-test-vectors.json" CopyToOutputDirectory="PreserveNewest" />
<None Include="../../docs/finance-test-vectors.json" Link="finance-test-vectors.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
31 changes: 24 additions & 7 deletions apps/api.tests/Integration/ChangePasswordEndpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,15 @@ public async Task ChangePassword_WithOversizedFields_IsABadRequest()
// --- success -------------------------------------------------------------------------------------------

[Fact]
public async Task ChangePassword_Success_IsNoContent_AndOnlyTheNewPasswordSignsInAfterwards()
public async Task ChangePassword_Success_ReturnsANewSession_AndOnlyTheNewPasswordSignsInAfterwards()
{
var (user, token) = await SignedInUserAsync();

var response = await PostChange(token, new { currentPassword = TestUsers.DefaultPassword, newPassword = NewPassword });

Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
Assert.Empty(await response.Content.ReadAsStringAsync());
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var session = JsonDocument.Parse(await response.Content.ReadAsStringAsync()).RootElement;
Assert.Equal(user.Username, session.GetProperty("user").GetProperty("username").GetString());

Assert.Equal(HttpStatusCode.Unauthorized, (await PostLogin(user.Username, TestUsers.DefaultPassword)).StatusCode);
Assert.Equal(HttpStatusCode.OK, (await PostLogin(user.Username, NewPassword)).StatusCode);
Expand All @@ -189,13 +190,29 @@ public async Task ChangePassword_Success_IsNoContent_AndOnlyTheNewPasswordSignsI
}

[Fact]
public async Task ChangePassword_Success_KeepsTheExistingTokenValid()
public async Task ChangePassword_Success_EndsEveryEarlierSignIn_AndTheReturnedTokenWorks()
{
var (_, token) = await SignedInUserAsync();
var (user, token) = await SignedInUserAsync();
var elsewhere = await TestUsers.LoginAsync(api.Client, user.Username, TestUsers.DefaultPassword);

await PostChange(token, new { currentPassword = TestUsers.DefaultPassword, newPassword = NewPassword });
var response = await PostChange(token, new { currentPassword = TestUsers.DefaultPassword, newPassword = NewPassword });
var renewed = JsonDocument.Parse(await response.Content.ReadAsStringAsync()).RootElement.GetProperty("token").GetString();

Assert.Equal(HttpStatusCode.Unauthorized, (await api.GetAsync("/api/auth/me", token)).StatusCode);
Assert.Equal(HttpStatusCode.Unauthorized, (await api.GetAsync("/api/auth/me", elsewhere)).StatusCode);
Assert.Equal(HttpStatusCode.OK, (await api.GetAsync("/api/auth/me", renewed)).StatusCode);
}

[Fact]
public async Task ATokenWithoutAStamp_WorksUntilThePasswordFirstChanges()
{
var user = await TestUsers.CreateAsync(api.ConnectionString);
var old = TestTokens.Forge(user.Id, user.Username, user.Role); // as issued before stamps existed
Assert.Equal(HttpStatusCode.OK, (await api.GetAsync("/api/auth/me", old)).StatusCode);

await PostChange(old, new { currentPassword = TestUsers.DefaultPassword, newPassword = NewPassword });

Assert.Equal(HttpStatusCode.OK, (await api.GetAsync("/api/auth/me", token)).StatusCode);
Assert.Equal(HttpStatusCode.Unauthorized, (await api.GetAsync("/api/auth/me", old)).StatusCode);
}

[Fact]
Expand Down
Loading
Loading