add coverpage to price calculation

This commit is contained in:
2025-07-02 00:28:13 +02:00
parent 9e638dcfc2
commit 6c0440f06d

View File

@@ -133,6 +133,11 @@ func (p *PrintJob) Execute() error {
func (p *PrintJob) CalculatePrintCosts() (float64, error) {
pageCount := utils.CountPagesAtPath(p.ShopItem.Pdf)
if pageCount == 0 {
return 0, fmt.Errorf("Cant calculate price, pdf seems to be empty")
}
printMode := GetPrintMode(p.ShopItem.PrintMode)
//Get actual pagecount depending on printmode
@@ -154,7 +159,15 @@ func (p *PrintJob) CalculatePrintCosts() (float64, error) {
if p.IsColored() {
partCost = 0.0478
}
printingCosts := float64(actualPageCount) * p.PaperType.Price
printingCosts := float64(actualPageCount-1) * p.PaperType.Price
if p.CoverPaperType != nil {
printingCosts += p.CoverPaperType.Price
} else {
printingCosts += p.PaperType.Price
}
printingCosts += float64(actualPageCount/2) * PPC
printingCosts += partCost * float64(actualPageCount)