package booking

import (
	"fmt"
	"strconv"
	"time"

	"github.com/rjNemo/rentease/internal/config"
)

type Line struct {
	From         time.Time
	To           time.Time
	CustomerName string
	Platform     string
	Id           int
	Total        float64
	PlatformFees float64
	Canceled     bool
}

func (l Line) InvoiceNumber(hc *config.Host) string {
	return fmt.Sprintf("%s%04s", hc.InvoicePrefix, strconv.Itoa(l.Id+hc.CustomerSeed))
}

func (l Line) Fee() float64 {
	if l.Platform == "Other" {
		return l.Total * 5 / 100
	}
	return l.Total * 10 / 100
}

func (l Line) Profit() float64 {
	return l.Total - l.PlatformFees - l.Fee()
}
