You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.6 KiB
70 lines
1.6 KiB
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"marmic/servicetrade-toolbox/internal/api"
|
|
"marmic/servicetrade-toolbox/internal/ui"
|
|
"marmic/servicetrade-toolbox/internal/utils"
|
|
)
|
|
|
|
func HandleInvoices(session *api.Session) {
|
|
for {
|
|
ui.ClearScreen()
|
|
fmt.Println("Invoices Menu:")
|
|
fmt.Println("1. Search Invoice")
|
|
fmt.Println("2. List Recent Invoices")
|
|
fmt.Println("3. Create Invoice")
|
|
fmt.Println("4. Back to Main Menu")
|
|
|
|
choice, err := utils.GetUserChoice(4)
|
|
if err != nil {
|
|
ui.DisplayError("Invalid input:", err)
|
|
utils.PressEnterToContinue()
|
|
continue
|
|
}
|
|
switch choice {
|
|
case 1:
|
|
searchInvoice(session)
|
|
case 2:
|
|
listRecentInvoices(session)
|
|
case 3:
|
|
createInvoice(session)
|
|
case 4:
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func searchInvoice(session *api.Session) {
|
|
ui.ClearScreen()
|
|
fmt.Println("Search Invoice:")
|
|
identifier := utils.PromptForInput("Enter Invoice Number or ID: ")
|
|
|
|
invoice, err := session.GetInvoice(identifier)
|
|
if err != nil {
|
|
fmt.Printf("Error fetching invoice: %v\n", err)
|
|
utils.PressEnterToContinue()
|
|
return
|
|
}
|
|
|
|
fmt.Println("Invoice Details:")
|
|
fmt.Printf("Invoice Number: %v\n", invoice["invoiceNumber"])
|
|
fmt.Printf("Total Price: $%v\n", invoice["totalPrice"])
|
|
fmt.Printf("Status: %v\n", invoice["status"])
|
|
|
|
utils.PressEnterToContinue()
|
|
}
|
|
|
|
func listRecentInvoices(session *api.Session) {
|
|
ui.ClearScreen()
|
|
fmt.Println("Listing recent invoices...")
|
|
// TODO: Implement recent invoices listing logic using the API
|
|
utils.PressEnterToContinue()
|
|
}
|
|
|
|
func createInvoice(session *api.Session) {
|
|
ui.ClearScreen()
|
|
fmt.Println("Creating a new invoice...")
|
|
// TODO: Implement invoice creation logic using the API
|
|
utils.PressEnterToContinue()
|
|
}
|
|
|