3 Commits

Author SHA1 Message Date
16c68cd0f8 set WasPrinted after printjob execution
All checks were successful
Go / build (push) Successful in 12m19s
2025-07-02 00:33:11 +02:00
ad5573ee2c add CoverPage hint to <select> 2025-07-02 00:28:27 +02:00
6c0440f06d add coverpage to price calculation 2025-07-02 00:28:13 +02:00
3 changed files with 21 additions and 8 deletions

View File

@@ -180,6 +180,12 @@ func (rc *printController) PrintHandler(c *gin.Context) {
executeJobs := func() {
for _, printJob := range printJobs {
err := printJob.Execute()
if err == nil {
return
}
printJob.ShopItem.WasPrinted = true
_, err = repositories.ShopItems.Update(printJob.ShopItem)
@@ -187,12 +193,6 @@ func (rc *printController) PrintHandler(c *gin.Context) {
fmt.Printf("Error: %s\n", err)
}
err := printJob.Execute()
if err == nil {
return
}
}
}

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)

View File

@@ -53,7 +53,7 @@
<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">
<option selected value="0">None</option>
<option selected value="0">CoverPage: None</option>
{{ range $.data.paper }}
<option value="{{ .ID }}">{{ .Brand }} - {{ .Name }}: {{ .Size }} {{ .Weight }}g/m2</option>
{{ end}}