wip: improve invoice generation logic

This commit is contained in:
2025-08-14 20:00:21 +01:00
parent a85e13e17d
commit 7f4da2f606
10 changed files with 165 additions and 42 deletions
+19
View File
@@ -1,6 +1,7 @@
package models
import (
"errors"
"time"
"github.com/google/uuid"
@@ -170,6 +171,24 @@ func (db *DB) UpdateInvoice(userId, id uuid.UUID, body types.UpdateInvoiceReques
return nil
}
func (db *DB) UpdateInvoicePDF(userId, id uuid.UUID, pdf string, invoice *types.Invoice) error {
if pdf == "" {
return errors.New("PDF path is empty!")
}
result := db.instance.Where("user_id = ?", userId).Where("id = ?", id).First(invoice)
if result.Error != nil {
return result.Error
}
result = db.instance.Model(invoice).Updates(types.Invoice{
PDF: pdf,
})
return nil
}
func (db *DB) DeleteItem(userId, id uuid.UUID) error {
result := db.instance.Unscoped().Where("user_id = ?", userId).Where("id = ?", id).Delete(&types.Item{})