Skip to content

Instantly share code, notes, and snippets.

@marvinhosea
Created October 6, 2022 23:12
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/61e2bcafb1ec7d3cfdfd79e3429543a2 to your computer and use it in GitHub Desktop.
Save marvinhosea/61e2bcafb1ec7d3cfdfd79e3429543a2 to your computer and use it in GitHub Desktop.
final.main.go
package main
import (
"fmt"
internal "marvinhosea/invoices/internal"
)
func main() {
// Generate sample invoice data
ecommerceInvoiceData, err := internal.NewInvoiceData("Ecommerce application", 1, 3000.50)
if err != nil {
panic(err)
}
laptopInvoiceData, err := internal.NewInvoiceData("Macbook Pro", 1, 200.70)
if err != nil {
panic(err)
}
// Invoice Items collection
invoiceItems := []*internal.InvoiceData{ecommerceInvoiceData, laptopInvoiceData}
// Create single invoice
invoice := internal.CreateInvoice("Example Shop1", "Example address", invoiceItems)
err = internal.GenerateInvoicePdf(*invoice)
fmt.Printf("The Total Invoice Amount is: %f", invoice.CalculateInvoiceTotalAmount())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment