-
-
Save marvinhosea/fb97267e294d85e947dc2cbae37435b8 to your computer and use it in GitHub Desktop.
invoice.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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