Skip to content

Instantly share code, notes, and snippets.

@marvinhosea
Last active October 7, 2022 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marvinhosea/fb97267e294d85e947dc2cbae37435b8 to your computer and use it in GitHub Desktop.
Save marvinhosea/fb97267e294d85e947dc2cbae37435b8 to your computer and use it in GitHub Desktop.
invoice.go
package internal
type Invoice struct {
Name string
Address string
InvoiceItems []*InvoiceData
}
func CreateInvoice(name string, address string, invoiceItems []*InvoiceData) *Invoice {
return &Invoice{
Name: name,
Address: address,
InvoiceItems: invoiceItems,
}
}
func (i *Invoice) CalculateInvoiceTotalAmount() float64 {
var invoiceTotalAmount int64 = 0
for _, data := range i.InvoiceItems {
amount := data.CalculateTotalAmount()
invoiceTotalAmount += amount
}
totalAmount := float64(invoiceTotalAmount) / 100
return totalAmount
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment