Automatic Price Calculation #33

Merged
kalipso merged 17 commits from priceCalculation into master 2025-07-02 11:26:53 +02:00
Showing only changes of commit 6c0440f06d - Show all commits

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)