This commit is contained in:
@@ -21,6 +21,9 @@ type ConfigController interface {
|
||||
PaperHandler(*gin.Context)
|
||||
AddPaperHandler(*gin.Context)
|
||||
|
||||
InvoiceView(*gin.Context)
|
||||
InvoiceHandler(*gin.Context)
|
||||
|
||||
CreateTag(*gin.Context)
|
||||
GetAllTags(*gin.Context)
|
||||
TagView(*gin.Context)
|
||||
@@ -208,6 +211,35 @@ func (rc *configController) GetAllPaper(c *gin.Context) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
func (rc *configController) InvoiceView(c *gin.Context) {
|
||||
invoices, err := repositories.Invoices.GetAll()
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "invoiceview.html", gin.H{"data": gin.H{"error": err}})
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"invoices": invoices,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "invoiceview.html", data)
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "invoiceview.html", data)
|
||||
}
|
||||
|
||||
func (rc *configController) InvoiceHandler(ctx *gin.Context) {
|
||||
action := ctx.PostForm("action")
|
||||
if action == "delete" {
|
||||
repositories.Invoices.DeleteById(ctx.Param("id"))
|
||||
}
|
||||
|
||||
rc.InvoiceView(ctx)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
func (rc *configController) TagHandler(ctx *gin.Context) {
|
||||
name := ctx.PostForm("name")
|
||||
color := ctx.PostForm("color")
|
||||
|
||||
@@ -113,6 +113,7 @@ func (rc *printController) PrintHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
var printJobs []models.PrintJob
|
||||
priceTotal := 0.0
|
||||
for idx := range variantIds {
|
||||
variant, err := repositories.ShopItems.GetVariantById(variantIds[idx])
|
||||
|
||||
@@ -160,13 +161,7 @@ func (rc *printController) PrintHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
printJob.CalculatePrintCosts()
|
||||
printJob, err = repositories.PrintJobs.Create(printJob)
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
priceTotal += printJob.PriceTotal
|
||||
printJobs = append(printJobs, printJob)
|
||||
}
|
||||
|
||||
@@ -174,6 +169,7 @@ func (rc *printController) PrintHandler(c *gin.Context) {
|
||||
PrintJobs: printJobs,
|
||||
PricePerClick: 0.002604,
|
||||
PartCosts: 0.0067,
|
||||
PriceTotal: priceTotal,
|
||||
}
|
||||
invoice, err := repositories.Invoices.Create(invoice)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user