From bb088225a27d04c8237bfcdc7658a5564e838082 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 4 Dec 2023 14:55:24 +0530 Subject: added endpoint to get an invoice's items only --- invoice/service.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'invoice/service.go') diff --git a/invoice/service.go b/invoice/service.go index 91e2707..91579c6 100644 --- a/invoice/service.go +++ b/invoice/service.go @@ -81,6 +81,21 @@ func getInvoices(invoices *[]Invoice, userId uint, isDraft bool) error { return nil } +func getInvoiceItems(items *[]InvoiceItem, invoiceId uint) error { + res := db.Where("invoice_id = ?", invoiceId).Find(&items) + + // TODO: handle potential errors + if res.Error != nil { + return res.Error + } + + if res.RowsAffected == 0 { + return e.ErrEmptyResponse + } + + return nil +} + // TODO: route to only get the invouce's items func (i *Invoice) upsert() error { -- cgit v1.2.3