Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAL Accounting System

🧾 Modern Accounting System for F&B Suppliers

A MYOB-like accounting system with Invoicing, Inventory, and Reporting


✨ Features

📊 Sales & Invoicing

  • Create draft invoices with multi-line items
  • Post invoices with automatic stock deduction
  • Moving average cost calculation
  • Payment allocation (partial/full)
  • Credit notes for returns

📦 Inventory Management

  • Real-time stock tracking
  • Moving average costing (perpetual)
  • Stock ledger with full history
  • Stock adjustments & opname
  • Negative stock prevention

🛒 Purchasing

  • Receive items from suppliers
  • Bill management
  • Payment processing
  • Debit notes for returns

📈 Reporting

  • Sales summary by period
  • AR/AP aging reports
  • Inventory valuation
  • Profit & Loss statement
  • Balance Sheet
  • Trial Balance

🔐 Security

  • Role-based access control (RBAC)
  • Permission-based UI
  • Audit trail for all actions
  • Period locking

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • Docker & Docker Compose
  • npm or yarn

1. Start Database (Docker)

# Start MySQL and phpMyAdmin
make docker-up

# Or manually:
cd docker && docker-compose up -d

Services:

  • MySQL: localhost:3306

2. Install Dependencies

make install

# Or manually:
cd apps/web && npm install

3. Start Development Server

make dev

# Or manually:
cd apps/web && npm run dev

Open http://localhost:3000 in your browser.

4. Login

Use the default admin credentials:

  • Email: admin@sal-system.local
  • Password: admin123

📁 Project Structure

sal-system/
├── apps/
│   └── web/                    # Next.js application
│       ├── app/
│       │   ├── api/v1/         # API Route Handlers
│       │   ├── (ui)/           # UI Pages
│       │   └── layout.tsx
│       └── src/
│           ├── lib/            # Client utilities
│           └── ui/             # React components
├── packages/
│   ├── shared/
│   │   ├── types/              # TypeScript types
│   │   ├── schemas/            # Zod validation schemas
│   │   └── constants/          # Error codes, permissions
│   └── server/
│       ├── db/                 # Database connection
│       ├── auth/               # Authentication
│       └── services/           # Business logic
└── docker/
    ├── docker-compose.yml
    └── mysql/
        ├── init/               # SQL init scripts (schema + seed)
        └── conf.d/             # MySQL configuration

🔑 Default Roles & Permissions

Role Description
Admin Full system access
Owner Reports & approvals
Finance Post transactions, payments, reports
Sales Create invoices, manage customers
Warehouse Inventory management
Purchasing Purchase orders, receiving

🛠️ Tech Stack

  • Frontend: Next.js 14 (App Router), React 18
  • State Management: TanStack Query v5
  • Validation: Zod
  • Database: MySQL 8.0 (InnoDB)
  • Authentication: JWT (jose)
  • Styling: Vanilla CSS with design system
  • Icons: Lucide React

📡 API Endpoints

Authentication

POST /api/auth/login
POST /api/auth/logout
GET  /api/me

Sales

GET  /api/sales/invoices
POST /api/sales/invoices
GET  /api/sales/invoices/:id
POST /api/sales/invoices/:id/post
POST /api/sales/payments

Inventory

GET  /api/inventory/stock-on-hand
GET  /api/inventory/ledger
POST /api/inventory/adjustments

Reports

GET  /api/reports/sales-summary
GET  /api/reports/ar-aging
GET  /api/reports/inventory-valuation

🐳 Docker Services

Service Port Description
MySQL 3306 Database server

Environment Variables

Copy docker/.env and modify as needed:

MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=sal_accounting
MYSQL_USER=sal_user
MYSQL_PASSWORD=sal_password
MYSQL_PORT=3306
PMA_PORT=8080

📋 Commands

# Docker
make docker-up      # Start containers
make docker-down    # Stop containers
make docker-logs    # View logs
make db-reset       # Reset database

# Development
make install        # Install dependencies
make dev            # Start dev server
make build          # Production build
make start          # Start production
make clean          # Clean artifacts

🔄 Transaction Flow

Sales Invoice Posting

  1. ✅ Check period lock (invoice date)
  2. ✅ Validate invoice status = DRAFT
  3. ✅ Check stock availability (if no_negative_stock enabled)
  4. ✅ Lock item_stock rows (FOR UPDATE)
  5. ✅ Update stock (deduct qty, calculate value)
  6. ✅ Insert stock ledger entries
  7. ✅ Create journal entries (AR, Sales, Tax, COGS, Inventory)
  8. ✅ Update invoice status to POSTED
  9. ✅ Update customer AR balance
  10. ✅ Create audit log

📝 License

MIT License - feel free to use for personal or commercial projects.


Built with ❤️ for F&B Suppliers

About

A Complete Accounting Software for Supplier Company

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages