KPO: knjiga o ostvarenom prometu — lista, ručni unos, backfill, auto-upis iz prodaje i servisa

This commit is contained in:
2026-06-30 21:13:16 +02:00
parent 3166a93e1d
commit 432a559902
13 changed files with 664 additions and 2 deletions
+18
View File
@@ -2134,6 +2134,24 @@ func (h *Handler) PromeniStatus(w http.ResponseWriter, r *http.Request) {
}
}
}
// auto-KPO za servisni nalog
if h.modulUkljucen(r.Context(), "kpo") && iznos > 0 {
nalogKpo, _ := h.ServisRepo.DohvatiID(r.Context(), id)
if nalogKpo != nil {
kpoZ := model.KpoZapis{
DatumPrometa: time.Now(),
BrojDokumenta: nalogKpo.BrojNaloga,
Opis: fmt.Sprintf("Servis %s", nalogKpo.BrojNaloga),
Prihod: iznos,
NacinPlacanja: nacin,
Izvor: "servis",
IzvorID: &id,
}
if _, e := h.KpoRepo.Kreiraj(r.Context(), &kpoZ); e != nil {
slog.Error("auto-upis u KPO za servis nije uspeo", "servis_id", id, "error", e)
}
}
}
}
http.Redirect(w, r, "/servis/"+strconv.FormatInt(id, 10)+"?sacuvano=1", http.StatusSeeOther)