add coverpage to price calculation
This commit is contained in:
@@ -133,6 +133,11 @@ func (p *PrintJob) Execute() error {
|
|||||||
|
|
||||||
func (p *PrintJob) CalculatePrintCosts() (float64, error) {
|
func (p *PrintJob) CalculatePrintCosts() (float64, error) {
|
||||||
pageCount := utils.CountPagesAtPath(p.ShopItem.Pdf)
|
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)
|
printMode := GetPrintMode(p.ShopItem.PrintMode)
|
||||||
|
|
||||||
//Get actual pagecount depending on printmode
|
//Get actual pagecount depending on printmode
|
||||||
@@ -154,7 +159,15 @@ func (p *PrintJob) CalculatePrintCosts() (float64, error) {
|
|||||||
if p.IsColored() {
|
if p.IsColored() {
|
||||||
partCost = 0.0478
|
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 += float64(actualPageCount/2) * PPC
|
||||||
printingCosts += partCost * float64(actualPageCount)
|
printingCosts += partCost * float64(actualPageCount)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user