diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-12-04 14:55:24 +0530 | 
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-12-04 14:55:24 +0530 | 
| commit | bb088225a27d04c8237bfcdc7658a5564e838082 (patch) | |
| tree | 9f79491a6b3f136863d0a92683fb4dd35ba4c612 /invoice/service.go | |
| parent | a6087d0a4f177973b9d27e544f85736d90039089 (diff) | |
added endpoint to get an invoice's items only
Diffstat (limited to 'invoice/service.go')
| -rw-r--r-- | invoice/service.go | 15 | 
1 files changed, 15 insertions, 0 deletions
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 {  |