Add price lists capability for foils

This commit is contained in:
Florian Baumann 2023-04-20 12:05:14 +02:00
parent e0d90ae12d
commit 2ed9467f6a
4 changed files with 18 additions and 8 deletions

View File

@ -152,7 +152,7 @@ func show_card_details(card *Card) error {
}
fmt.Printf("\n%sHistory%s\n", Green, Reset)
print_price_history(card.SerraPrices, "* ")
print_price_history(card.SerraPrices, "* ", false)
fmt.Println()
return nil
}

View File

@ -163,15 +163,23 @@ func convert_rarities(rar []primitive.M) Rarities {
}
func print_price_history(prices []PriceEntry, prefix string) {
func print_price_history(prices []PriceEntry, prefix string, total bool) {
var before float64
for _, e := range prices {
value := e.Usd
var value float64
if total {
value = e.Usd + e.UsdFoil + e.UsdEtched
if getCurrency() == "EUR" {
value = e.Eur + e.EurFoil
}
} else {
value = e.Usd
if getCurrency() == "EUR" {
value = e.Eur
}
}
if value > before && before != 0 {
fmt.Printf("%s%s%s %.2f %s%s (%+.2f%%, %+.2f %s)\n", prefix, stringToTime(e.Date), Green, value, getCurrency(), Reset, (value/before*100)-100, value-before, getCurrency())

View File

@ -162,7 +162,7 @@ func ShowSet(setname string) error {
LogMessage(fmt.Sprintf("Uncommons: %.0f", ri.Uncommons), "normal")
LogMessage(fmt.Sprintf("Commons: %.0f", ri.Commons), "normal")
fmt.Printf("\n%sPrice History:%s\n", Pink, Reset)
print_price_history(sets[0].SerraPrices, "* ")
print_price_history(sets[0].SerraPrices, "* ", true)
fmt.Printf("\n%sMost valuable cards%s\n", Pink, Reset)

View File

@ -120,11 +120,13 @@ var statsCmd = &cobra.Command{
foil_value = 0
}
total_value := nf_value + foil_value
fmt.Printf("Current: %s%.2f %s%s\n", Pink, total_value, getCurrency(), Reset)
fmt.Printf("Total: %s%.2f %s%s\n", Pink, total_value, getCurrency(), Reset)
fmt.Printf("Normal: %s%.2f %s%s\n", Pink, nf_value, getCurrency(), Reset)
fmt.Printf("Foils: %s%.2f %s%s\n", Pink, foil_value, getCurrency(), Reset)
total, _ := totalcoll.storage_find_total()
fmt.Printf("History: \n")
print_price_history(total.Value, "* ")
print_price_history(total.Value, "* ", true)
return nil
},
}