Skip to content

ekynug2/sal-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages