All projects

Internship project · ESBİ

Mini Bookkeeping App

A web-based bookkeeping app for small businesses: customer and supplier accounts, inventory, sales and purchase invoices, collections and payments, stock counts and reports. I built it end to end during my internship at ESBİ, following a requirements document and its five-week plan.

  • ASP.NET Core MVC
  • .NET 10
  • Clean Architecture
  • EF Core 10
  • SQL Server
  • Bootstrap 5
  • xUnit
  • GitHub Actions

No live demo: the app needs a .NET server and SQL Server, so the screenshots below come from a local run with sample data.

New sales invoice with three line items; subtotal, VAT and total are calculated automatically

What it does

Every module in the requirements document, each one checked against the database.

Customer & supplier accounts

Customers, suppliers or both. Balances aren't stored; they're calculated from account movements, and the statement shows the opening balance, period totals and a running balance for any date range.

Inventory

Stock cards with purchase and sales prices, VAT rate and a critical level. Quantities come from stock movements; items at or below the critical level are flagged on the list and the dashboard.

Sales & purchase invoices

A header plus line items with VAT per line; totals update as you type. Saving writes the invoice, its stock movements and the account entry together, and deleting the invoice reverses all of them.

Stock movements & counts

Every stock movement in one filterable list. Count surplus and shortage slips change stock only and never touch an account, as the spec requires.

Collections & payments

Cash, bank transfer or cheque. A collection credits the account, a payment debits it, and each gets its own document number.

Reports

Account balances, stock status, critical stock and sales by salesperson, plus invoice and movement lists. Reports are printable and match the movement records.

Parameters

Company details, default VAT, currency, decimal places (0–2), negative-stock control, critical-stock warnings and document number formats such as SAT-{yyyy}-{0000}.

Users & roles

Admin and standard roles; only admins manage users and parameters. The session is checked on every request, so deactivating a user or changing a role takes effect immediately.

Screens

Captured from the running app with sample data. The interface is in Turkish; click to enlarge.

How it works

An MVC app on Clean Architecture: the rules sit in the inner layers, while the database and the web stay at the edges.

WebControllers, views, view models, filters and login security. Registers every service at startup.
InfrastructureEF Core DbContext, one configuration per table, five migrations and the PBKDF2 password hasher
ApplicationServices, form DTOs and business-rule exceptions, plus the interfaces for the database and password hashing
DomainEleven entities, constants and pure rules for document numbers and rounding. Depends on nothing.
tests/Unit, architecture and integration tests; GitHub Actions runs them on every push

Each layer is its own project, and dependencies only point inward. Application reaches the database through an interface that Infrastructure implements, controllers never see the DbContext, and architecture tests keep it that way.

Tested on every push

Unit tests cover the pure rules, password hashing, login lockout and the layer rules. Integration tests run the whole app in memory against a real SQL Server, on a fresh database each time. GitHub Actions also checks formatting and that the migrations match the model.

Balances are calculated, not stored

Stock quantities and account balances are derived from the movement tables. The formula is defined once as an expression and reused inside queries, so the sum runs in SQL instead of loading every movement into memory.

C#
.Select(s => new StokBakiyesi {
    Stok   = s,
    Mevcut = s.StokHareketleri.AsQueryable().Sum(Etki)
})

One transaction per document

An invoice, its stock movements and its account entry are saved with a single SaveChanges call, so either all of them are written or none. When an invoice is deleted, its movements are found by document number and type and removed the same way.

History can't disappear

Links from accounts, stock cards, salespeople and users to documents are Restrict, not Cascade. With negative-stock control on, deleting a purchase invoice that would push stock below zero is blocked, and the app names the item.

Amounts don't depend on the server

Amounts are typed with a decimal comma. The request culture is pinned to tr-TR, so 12,50 can't turn into 1250 on an English server, and rounding follows the decimal-places parameter, half away from zero.

Forms only carry what they show

Forms bind to DTOs instead of entities, and the record ID is read from the URL only. A field added to the form can't change another record or a server-calculated total; an integration test tries exactly that.

Security

Custom cookie authentication on the project's own user table, hardened after a security review.

Password storage

PBKDF2-SHA256 with a 16-byte random salt and 600,000 iterations. Hashes are compared in constant time.

Login limits

By default, at most 10 login attempts per minute from one IP, and five wrong passwords lock the account for five minutes. The limits are read from appsettings.json and checked at startup; logins and lockouts are logged with user name and IP.

Browser protection

A nonce-based Content Security Policy, X-Frame-Options, nosniff and a strict referrer policy. Every POST checks an anti-forgery token, and third-party scripts are served from the app itself.

Live session checks

Each request re-reads the signed-in user, so deleted, deactivated or changed users are signed out. Admins can't remove themselves or the last active admin.

Problems I ran into

Six of the twelve issues documented in the README, and how each was solved.

Invoices silently failed validation

With nullable reference types on, MVC treated non-nullable properties as required, including the invoice number and navigation properties that never come from the form. ModelState was always invalid, with no visible error.

Fix: server-filled fields were removed from validation, and a test confirmed that bad input such as an empty customer was still rejected. Moving the forms to DTOs later made this workaround unnecessary.

Lists showed zero stock

Quantities and balances come from movements, but the queries didn't load them, so every sum was 0 and the edit screen showed a false critical-stock warning.

Fix: loading the movements fixed the numbers; later the lists were rewritten to sum in SQL so they don't pull every movement into memory.

One formula in six places

The stock and balance formulas were written by hand in six views each. Changing the critical-stock rule meant finding all of them, and missing one made two screens disagree.

Fix: the formulas moved into services behind interfaces, and views now get ready values through ViewModels, so the compiler keeps business logic out of the views.

Identity didn't fit the spec

ASP.NET Core Identity adds seven tables and its own user class, while the spec asked for an 11-table schema with its own user table.

Fix: Identity was removed in favour of cookie authentication on the existing table and a PBKDF2 password helper; the seed data hashes were regenerated with it.

Amounts depended on the server language

Model binding reads 12,50 using the server's culture. It worked on a Turkish machine, but an English server would have saved 1250.

Fix: the app culture is pinned to tr-TR, and the English model binding messages were replaced with Turkish ones.

Open sessions outlived deactivation

A deactivated user couldn't sign in again, but a session that was already open kept its old rights for up to eight hours.

Fix: the cookie is validated against the database on every request, and removing yourself or the last active admin is blocked.

Read all twelve in the README →

Five-week plan

The order of work set by the requirements document.

  1. Week 1Database design, project skeleton, login, user management and salespeople
  2. Week 2Customer and supplier accounts, stock cards
  3. Week 3Sales and purchase invoices that update stock and accounts
  4. Week 4Stock movements, count slips, collections and payments
  5. Week 5Parameters, reports, testing and delivery

Run it locally

You need the .NET 10 SDK and SQL Server. Run these from the repository root.

  1. Create the database

    The UTF-8 code page flag keeps Turkish characters intact.

    Shell
    sqlcmd -S "localhost\MSSQLSERVER01" -E -f i:65001 -i database/create_database.sql
  2. Load the sample data (optional)

    Shell
    sqlcmd -S "localhost\MSSQLSERVER01" -E -f i:65001 -i database/seed_data.sql
  3. Start the app

    It opens at http://localhost:5029.

    Shell
    dotnet run --project src/OnMuhasebe.Web
  4. Run the tests (optional)

    Unit tests need nothing else. Integration tests run when ONMUHASEBE_TEST_SQL points at a SQL Server; each run creates its own database and drops it afterwards.

    PowerShell
    $env:ONMUHASEBE_TEST_SQL = "Server=localhost\MSSQLSERVER01;Trusted_Connection=True;TrustServerCertificate=True"
    dotnet test

Different SQL Server name?

The commands use the localhost\MSSQLSERVER01 instance. If yours is localhost or .\SQLEXPRESS, change the server name in the commands and in DefaultConnection inside src/OnMuhasebe.Web/appsettings.json.

Sample users

admin (admin) and ayse.yilmaz (standard), both with the password 123456. They exist for testing only and must not be loaded on a live server.

Not included

More projects