Compare commits
3 Commits
9e638dcfc2
...
16c68cd0f8
| Author | SHA1 | Date | |
|---|---|---|---|
|
16c68cd0f8
|
|||
|
ad5573ee2c
|
|||
|
6c0440f06d
|
@@ -180,6 +180,12 @@ func (rc *printController) PrintHandler(c *gin.Context) {
|
|||||||
|
|
||||||
executeJobs := func() {
|
executeJobs := func() {
|
||||||
for _, printJob := range printJobs {
|
for _, printJob := range printJobs {
|
||||||
|
err := printJob.Execute()
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
printJob.ShopItem.WasPrinted = true
|
printJob.ShopItem.WasPrinted = true
|
||||||
_, err = repositories.ShopItems.Update(printJob.ShopItem)
|
_, err = repositories.ShopItems.Update(printJob.ShopItem)
|
||||||
|
|
||||||
@@ -187,12 +193,6 @@ func (rc *printController) PrintHandler(c *gin.Context) {
|
|||||||
fmt.Printf("Error: %s\n", err)
|
fmt.Printf("Error: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := printJob.Execute()
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
<td class="whitespace-nowrap py-4">
|
<td class="whitespace-nowrap py-4">
|
||||||
<select name="variant-coverpage[]" required class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
<select name="variant-coverpage[]" required class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||||
<option selected value="0">None</option>
|
<option selected value="0">CoverPage: None</option>
|
||||||
{{ range $.data.paper }}
|
{{ range $.data.paper }}
|
||||||
<option value="{{ .ID }}">{{ .Brand }} - {{ .Name }}: {{ .Size }} {{ .Weight }}g/m2</option>
|
<option value="{{ .ID }}">{{ .Brand }} - {{ .Name }}: {{ .Size }} {{ .Weight }}g/m2</option>
|
||||||
{{ end}}
|
{{ end}}
|
||||||
|
|||||||
Reference in New Issue
Block a user