A invoice management system built with ASP.NET Core 8.0, featuring dynamic invoice creation, real-time inventory checking, and hybrid database architecture.
- Dynamic Invoice Creation: Real-time product selection with auto-complete
- Inventory Management: Stock level checking across multiple stores
- Hybrid Database Architecture: Local PostgreSQL + Supabase integration
- JSONB Support: Flexible additional charges storage
- Responsive UI: Modern web interface with JavaScript/jQuery
- Invoice Slip Generation: Printable invoice views
- Framework: ASP.NET Core 8.0 (MVC)
- Database: PostgreSQL (local + Supabase)
- ORM: Entity Framework Core with Npgsql
- Frontend: Razor views with JavaScript/jQuery
- JSON Handling: Newtonsoft.Json
- InvoiceHeader: Main invoice records with JSONB additional charges
- InvoiceItem: Individual line items with product details
- External Integration: Product catalog and inventory from Supabase
- .NET 8.0 SDK
- PostgreSQL database (local or cloud)
- Supabase account (for product catalog)
git clone <repository-url>
cd InvoicePOC- Install PostgreSQL on your machine
- Create a new database for the application
- Update the connection string in
appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "postgresql://username:password@localhost:5432/your_database"
}
}- Create a Supabase project
- Run the database seed script:
psql -h db.bbclercdvyoupgrepjvi.supabase.co -U postgres -d postgres -f db_seed_products_stores.sql# Install EF Core tools (if not already installed)
dotnet tool install --global dotnet-ef
# Create and apply migrations
dotnet ef migrations add InitialCreate
dotnet ef database updateUpdate the Supabase connection string in Controllers/InvoiceController.cs:
private string _supabaseConnString = "Host=your-supabase-host;Port=5432;Database=postgres;Username=postgres;Password=your-password;SSL Mode=Require;Trust Server Certificate=true";dotnet restore
dotnet build
dotnet runThe application will be available at https://localhost:5001 or http://localhost:5000.
-- InvoiceHeaders table
CREATE TABLE InvoiceHeaders (
InvoiceId SERIAL PRIMARY KEY,
CreatedDate TIMESTAMP NOT NULL,
NetTotal DECIMAL(12,2) NOT NULL,
GrandTotal DECIMAL(12,2) NOT NULL,
AdditionalCharges JSONB
);
-- InvoiceItems table
CREATE TABLE InvoiceItems (
ItemId SERIAL PRIMARY KEY,
InvoiceId INTEGER REFERENCES InvoiceHeaders(InvoiceId),
ProductName TEXT NOT NULL,
Store TEXT NOT NULL,
Quantity INTEGER NOT NULL,
Price DECIMAL(12,2) NOT NULL,
Total DECIMAL(12,2) NOT NULL
);- Product: Product names and prices
- Store: Store locations
- ProductStock: Inventory levels per product/store
- Navigate to the application homepage
- Select products from the dropdown (auto-populated from Supabase)
- Choose store location
- Enter quantity (stock levels are checked automatically)
- Add additional charges if needed
- Save the invoice
- Generated invoices are stored locally
- Access invoice slips via
/Invoice/Slip/{id}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "your-local-postgresql-connection-string"
}
}ASPNETCORE_ENVIRONMENT: Set toDevelopmentfor local development- Database connection strings can be overridden via environment variables
InvoicePOC/
βββ Controllers/
β βββ HomeController.cs
β βββ InvoiceController.cs
βββ Models/
β βββ InvoiceDbContext.cs
β βββ InvoiceHeaders.cs
β βββ InvoiceItem.cs
β βββ ErrorViewModel.cs
βββ Views/
β βββ Home/
β βββ Invoice/
β βββ Index.cshtml
β βββ Slip.cshtml
βββ Migrations/
βββ wwwroot/
βββ Program.cs
βββ appsettings.json
βββ db_seed_products_stores.sql
dotnet run --environment Developmentdotnet publish -c Release
dotnet run --environment ProductionGET /Invoice/Index- Invoice creation formPOST /Invoice/SaveInvoice- Save new invoiceGET /Invoice/Slip/{id}- View invoice slip
GET /Invoice/GetProducts- Get all productsGET /Invoice/GetProductPrice- Get product priceGET /Invoice/GetStores- Get all storesGET /Invoice/GetStock- Get stock level
- Update default connection strings
- Use environment variables for sensitive data
- Implement proper authentication/authorization for production
- Enable HTTPS in production
- Validate all user inputs
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is a proof of concept for invoice management.
For issues and questions:
- Check the existing issues
- Create a new issue with detailed information
- Include error messages and steps to reproduce
Note: This is a invoice application. For production use, implement proper security measures, error handling, and comprehensive testing.