Browse Source

Release v0.3.1 - billing, exports, reporting, email audit log

main
def 2 weeks ago
parent
commit
409360f98a
  1. 40
      PROJECT_STATE.md
  2. 26
      README.md
  3. 69
      backend/app.py
  4. 2591
      backend/app.py.bak_accounting_builder
  5. 2581
      backend/app.py.bak_report_email_fix

40
PROJECT_STATE.md

@ -16,7 +16,7 @@ OTB Billing is a contractor-focused billing system designed to be:
- deployable on fresh Linux systems
- suitable for managed hosting or client-installed deployments
The system is being built as a practical alternative to overly restrictive SaaS billing tools, with emphasis on ownership, simplicity, and contractor workflow.
The system is being built as a practical alternative to restrictive SaaS billing tools, with emphasis on ownership, simplicity, portability, and contractor/operator workflow.
Tagline direction:
@ -86,7 +86,6 @@ This remains a core project rule.
- invoice lock after payment activity
- invoice statuses
- invoice email sending with PDF attachment
- latest invoice email activity display
Current invoice statuses:
- draft
@ -122,7 +121,7 @@ Current payment statuses:
- PDF invoice generation
- client details on invoice
- status badge on invoice
- totals, paid, remaining display
- totals / paid / remaining display
- branding/logo support on HTML and PDF
## Exports
@ -131,7 +130,7 @@ Current payment statuses:
- payments CSV export
- filtered invoice CSV export
- filtered invoice PDF ZIP export
- monthly/quarterly/yearly accounting package ZIP export
- accounting package ZIP export
- revenue report JSON export
## Batch / Print
@ -185,6 +184,11 @@ app_settings
- SSL flag
- report delivery email
## Email Delivery
- invoice email with PDF attachment
- revenue report JSON email
- accounting package email
## Email Logging
Stored in:
email_log
@ -216,7 +220,6 @@ Confirmed working:
- invoice view
- invoice PDF generation
- invoice email with PDF attachment
- invoice email log display
- payment entry
- payment overpayment prevention
- payment reversal / void
@ -233,6 +236,7 @@ Confirmed working:
- revenue report email
- accounting package ZIP export
- accounting package email
- email audit logging
---
@ -251,14 +255,14 @@ This file must remain complete so installer-driven deployment works in one shot.
# Business / Product Direction
This system is intended to grow into a deployable billing product for small contractors and related service businesses.
This system is intended to grow into a deployable billing product for small operators, hosting providers, and service businesses.
Target strengths versus typical SaaS billing tools:
- simpler workflow
- data ownership
- exportability
- portability
- contractor-first design
- operator-first design
- no hostage-style software design
Long-term success goal:
@ -286,7 +290,7 @@ build something users are happy to use and proud to own.
- client portal
- role-based access
- accountant/export workflows
- job-tracking integration with related contractor platform modules
- integration paths for vertical forks such as HVAC/customer-service variants
---
@ -324,23 +328,3 @@ python3 backend/app.py
During active development, run in a visible terminal so logs stay visible.
Do not rely on hidden/background launch during normal debug workflow.
=================================================
Version: v0.3.1
Date: 2026-03-09
=================================================
Release milestone reached.
System now supports:
- client/service/invoice/payment workflow
- invoice PDF and email
- settings/config with branding and SMTP
- CSV / JSON / ZIP exports
- batch print
- revenue reporting
- accounting package export and email
Deferred to next release:
- email send logging / audit trail

26
README.md

@ -47,3 +47,29 @@ Notes
- Core billing/export/report workflow is now operational.
- Email logging/audit trail is planned for a future release.
## v0.3.1 — 2026-03-10
Milestone release.
Features included
-----------------
- Invoice PDF generation
- Invoice email sending
- Settings/config system
- Branding/logo support
- CSV exports
- Filtered invoice export
- Batch PDF ZIP export
- Batch print
- Revenue report
- Revenue JSON export
- Accounting package ZIP export
- Email delivery for reports and accounting package
- Email audit logging
Notes
-----
- Core billing/export/report workflow is now operational.
- Email log table records invoice, revenue report, and accounting package sends.

69
backend/app.py

@ -300,6 +300,57 @@ def get_report_period_bounds(frequency):
return start_utc, end_utc, label
def build_accounting_package_bytes():
import json
import zipfile
from io import BytesIO
report = get_revenue_report_data()
conn = get_db_connection()
cursor = conn.cursor(dictionary=True)
cursor.execute("""
SELECT
i.id,
i.invoice_number,
i.status,
i.total_amount,
i.amount_paid,
i.created_at,
c.company_name,
c.contact_name
FROM invoices i
JOIN clients c ON i.client_id = c.id
ORDER BY i.created_at DESC
""")
invoices = cursor.fetchall()
conn.close()
payload = {
"report": report,
"invoices": invoices
}
json_bytes = json.dumps(payload, indent=2, default=str).encode()
zip_buffer = BytesIO()
with zipfile.ZipFile(zip_buffer, "w", zipfile.ZIP_DEFLATED) as z:
z.writestr("revenue_report.json", json.dumps(report, indent=2))
z.writestr("invoices.json", json.dumps(invoices, indent=2, default=str))
zip_buffer.seek(0)
filename = f"accounting_package_{report.get('period_label','report')}.zip"
return zip_buffer.read(), filename
def get_revenue_report_data():
settings = get_app_settings()
frequency = (settings.get("report_frequency") or "monthly").strip().lower()
@ -470,6 +521,18 @@ def settings():
return render_template("settings.html", settings=settings)
@app.route("/reports/accounting-package.zip")
def accounting_package_zip():
package_bytes, filename = build_accounting_package_bytes()
return send_file(
BytesIO(package_bytes),
mimetype="application/zip",
as_attachment=True,
download_name=filename
)
@app.route("/reports/revenue")
def revenue_report():
report = get_revenue_report_data()
@ -579,8 +642,7 @@ def email_revenue_report_json():
recipient,
subject,
body,
email_type="invoice",
invoice_id=invoice_id,
email_type="revenue_report",
attachments=[{
"filename": "revenue_report.json",
"mime_type": "application/json",
@ -612,8 +674,7 @@ def email_accounting_package():
recipient,
subject,
body,
email_type="invoice",
invoice_id=invoice_id,
email_type="accounting_package",
attachments=[{
"filename": "accounting_package.zip",
"mime_type": "application/zip",

2591
backend/app.py.bak_accounting_builder

File diff suppressed because it is too large Load Diff

2581
backend/app.py.bak_report_email_fix

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save