Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
name: Pull Request Build Check
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-check:
quality:
permissions:
contents: read
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install JS dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Type check
run: npm run typecheck

- name: Unit tests
run: npm run test

build:
permissions:
contents: read
needs: quality
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -36,7 +68,7 @@ jobs:
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev

- name: Install JS dependencies
run: npm install
run: npm ci

- name: Build Check
uses: tauri-apps/tauri-action@v0
Expand Down
32 changes: 31 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,40 @@ on:
required: true
default: '1.0.0'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
quality:
permissions:
contents: read
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install JS dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Type check
run: npm run typecheck

- name: Unit tests
run: npm run test

publish:
permissions:
contents: write
needs: quality
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -40,7 +70,7 @@ jobs:
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev

- name: Install JS dependencies
run: npm install
run: npm ci

- name: Update Version
shell: pwsh
Expand Down
3 changes: 0 additions & 3 deletions .vscode/extensions.json

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 kilObit

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
117 changes: 48 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,69 @@
# 🧾 KB Invoice Generator
# KB Invoice Generator

A premium, lightning-fast native desktop application for generating professional invoice PDFs, built using **Tauri v2**, **Vite**, and **Vanilla TypeScript**.
![build](https://img.shields.io/github/actions/workflow/status/Mohammad-Faiz-Cloud-Engineer/KB-Invoice-Generator/build-check.yml?branch=main&style=flat-square&label=build)
![Version](https://img.shields.io/badge/version-0.1.0-18181b?style=flat-square)
![TypeScript](https://img.shields.io/badge/TypeScript-5.6-3178C6?style=flat-square)
![Tauri](https://img.shields.io/badge/Tauri-2-FFC131?style=flat-square)
![Vite](https://img.shields.io/badge/Vite-6-646CFF?style=flat-square)
![Vitest](https://img.shields.io/badge/Vitest-4-6E9F18?style=flat-square)
![ESLint](https://img.shields.io/badge/ESLint-10-4B32C3?style=flat-square)
![Tests](https://img.shields.io/badge/tests-73%20passing-22c55e?style=flat-square)
![License](https://img.shields.io/badge/license-MIT-3da639?style=flat-square)
![Platform](https://img.shields.io/badge/platform-Win%20|%20Mac%20|%20Linux-8b8cf7?style=flat-square)

KB Invoice Generator allows users to design, edit, and export beautiful, print-ready invoices directly from a clean desktop interface. It is designed to run completely offline with no external tracking or cloud requirements.
A offline-first desktop app for generating clean, print-ready invoice PDFs. Built on Tauri v2 + Vite + TypeScript. No cloud, no tracking, no BS.

---
## What it does

## ✨ Key Features
You pick a template, fill in your details directly on the invoice (click anything and type), and hit Export PDF. That's it. Everything happens locally.

* ✍️ **Direct Inline Editing**: Click and type directly on the live A4 paper invoice preview. Layout dimensions, margins, and alignments adjust dynamically.
* 📈 **Auto-Growing Text Fields**: Address and notes areas grow automatically as you type to prevent scrollbars or text cutting off in the final PDF.
* 🎨 **Dynamic Accent Color Picker**: Choose a brand theme color from swatches or a custom color picker. Table columns, titles, borders, and totals style colors adapt instantly.
* 🛠️ **Deep Customization Toggles**: Hide or show individual sections (e.g. Logo, Client Address, Shipping Charge, Bank Block, Routing Codes, Payment Terms, Notes) via simple sidebar checkboxes.
* ↕️ **Drag-and-Drop Reordering**: Rearrange invoice line items dynamically using visual drag handles (`⋮⋮`). Totals are recalculated instantly.
* 💾 **Local Backups (JSON)**: Export your invoice settings and drafts to a local `.json` file and import it back at any time to resume editing.
* 🔄 **Calculations Engine**: Real-time calculations of subtotal, tax %, discount %, shipping, and grand totals.
* 🖨️ **Print-to-PDF Ready**: Strips away all editor panels, action buttons, drag handles, and borders on print. Suppresses default browser print headers (date/time/title) and footers (URL/page numbers) automatically for a clean, clean PDF document.
The invoice preview is live. Change a quantity, the total updates. Toggle a section off, it disappears. Switch accent color, the whole invoice recolors instantly. No save button, no form submits.

---
## Features worth knowing

## 🚀 Tech Stack
- **Click-to-edit everything** every field on the invoice paper is an input. Nothing is behind a form modal.
- **Live calculations** subtotal, discount %, tax %, shipping recalculate on every keystroke. Discount and tax inputs exist both on the invoice and in the sidebar and stay in sync.
- **Auto due date** set an invoice date + payment terms like "Net 30" and the due date fills itself.
- **Drag to reorder line items** grab the `⋮⋮` handle, drop anywhere.
- **Visibility toggles** 16 checkboxes to show/hide sections (logo, bank block, routing codes, client address, etc). You can also hit the `×` that appears on hover directly on the invoice.
- **Brand color** 6 presets + custom picker. Applies via CSS variable instantly, no re-render.
- **Logo upload** reads as base64, embeds directly. No external file dependency.
- **Drafts** save named drafts to `localStorage`, load or delete anytime.
- **JSON backup** export the full invoice state to a `.json` file, import it back later. The logo data is included.
- **Clean PDF output** `Ctrl+P` or Export PDF. The print stylesheet strips all editor chrome. `@page { margin: 0 }` kills browser headers/footers. The document title is set to the invoice number so the save dialog defaults to the right filename.

* **Frontend**: HTML5, Vanilla TypeScript, CSS3 Custom Variables (Vanilla CSS)
* **Desktop Container**: [Tauri v2](https://tauri.app/) (Rust-backed native wrapper)
* **Build Tool**: [Vite](https://vite.dev/)
## Templates

---
Two templates ship currently:

## 📂 Project Structure
- **Template 1 (Modern)** company on top left, invoice number top right, footer has company info + bank details side by side
- **Template 2 (Classic)** same structure but with a bold accent-colored rule under the header

```
├── .gitignore # Files ignored by git (dist, node_modules, etc.)
├── index.html # Main application template viewport
├── package.json # NPM package scripts and dependencies
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite bundler configurations
├── icon.png # App icon source image
├── src/
│ ├── assets/ # Static frontend assets (icons, images)
│ ├── data.ts # Default invoice data and calculations
│ ├── main.ts # DOM Controller, Event Bindings & State Sync
│ ├── styles.css # UI layout and print media style rules
│ ├── templates.ts # Invoice structural rendering templates (Modern & Classic)
│ ├── types.ts # TypeScript interface definitions
│ └── vite-env.d.ts # Vite environment asset declarations
└── src-tauri/
├── Cargo.toml # Rust package manifest
├── tauri.conf.json # Tauri app configuration (Window settings, bundle, icons)
├── build.rs # Tauri compilation builder
├── capabilities/ # Desktop window permission sets
└── icons/ # Generated desktop launcher app icons
```

---
Both share the same items table, calculation block, and footer logic.

## 🛠️ Installation & Setup
## Stack

To run or build this application locally, you will need to set up the [Tauri Prerequisites](https://v2.tauri.app/start/prerequisites/).
| | |
|---|---|
| Desktop | Tauri v2 (Rust) |
| Build | Vite 6 |
| Language | TypeScript 5.6 |
| Styling | Vanilla CSS + custom properties |
| PDF | `window.print()` + print stylesheet |
| Storage | localStorage + JSON file export |

### 1. Prerequisites (Windows)
* Install **[Node.js](https://nodejs.org/)** (LTS recommended)
* Install **[Rust](https://www.rust-lang.org/)** (via rustup)
* Install **Build Tools for Visual Studio** (with the C++ build tools workload)
No framework. No component library. The whole UI is a single `invoiceData` state object that gets rendered to an HTML string via `renderTemplate()` and injected with `innerHTML`. Fast, tiny bundle, zero overhead.

### 2. Install Dependencies
Clone the repository and run:
```bash
npm install
```
## Getting started

### 3. Development Server
To launch the frontend live-reload server alongside the Tauri native desktop window:
```bash
npm run tauri dev
```
You need the [Tauri v2 prerequisites](https://v2.tauri.app/start/prerequisites/). Node.js, Rust, and on Windows the MSVC build tools.

### 4. Build Production Installer
To clean compile and package the application into a standalone Windows installer (`.exe` and `.msi` setup bundles):
```bash
npm run tauri build
npm install
npm run tauri dev # dev window with hot reload
npm run tauri build # produces .exe + .msi in src-tauri/target/release/bundle/
```
Once complete, the built installers will be located at:
`src-tauri/target/release/bundle/`

---

## 📄 License
## License

This project is licensed under the MIT License.
MIT
32 changes: 32 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import globals from "globals";

export default tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.es2020,
},
},
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"@typescript-eslint/no-explicit-any": [
"warn",
{ ignoreRestArgs: true },
],
"no-restricted-globals": ["error", "event"],
"prefer-const": "error",
"no-var": "error",
},
},
{
ignores: ["dist/", "node_modules/", "src-tauri/"],
},
);
Loading