From fb9ba155438100f295fdb563ad955151ee038ad3 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 13 Oct 2025 00:37:30 +0530 Subject: flattened out the invoice schema, was overengineered --- invoice/service.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'invoice/service.go') diff --git a/invoice/service.go b/invoice/service.go index 55b1319..20cf767 100644 --- a/invoice/service.go +++ b/invoice/service.go @@ -1,5 +1,5 @@ /* openbills - Server for web based Libre Billing Software - * Copyright (C) 2023 Vidhu Kant Sharma + * Copyright (C) 2023-2025 Vidhu Kant Sharma * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ func getNewInvoiceNumber() (uint, error) { } func getInvoice(invoice *Invoice, id uint) error { - res := db.Preload("BillingAddress").Preload("ShippingAddress").Preload("Items").Preload("CustomFields").Find(&invoice, id) + res := db.Preload("Items").Preload("CustomFields").Find(&invoice, id) // TODO: handle potential errors if res.Error != nil { @@ -61,6 +61,8 @@ func getInvoice(invoice *Invoice, id uint) error { return nil } +// TODO: rather than returning all invoices, always require a filter, maybe +// so we're actually searching invoices func getInvoices(invoices *[]Invoice, isDraft bool) error { res := db.Where("is_draft = ?", isDraft).Find(&invoices) -- cgit v1.2.3