mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-05 03:12:34 -06:00
редактирование и удаление сопоставлений
список накладных с позициями
This commit is contained in:
@@ -160,10 +160,11 @@ func (h *DraftsHandler) UpdateItem(c *gin.Context) {
|
||||
}
|
||||
|
||||
type CommitRequestDTO struct {
|
||||
DateIncoming string `json:"date_incoming"` // YYYY-MM-DD
|
||||
StoreID string `json:"store_id"`
|
||||
SupplierID string `json:"supplier_id"`
|
||||
Comment string `json:"comment"`
|
||||
DateIncoming string `json:"date_incoming"` // YYYY-MM-DD
|
||||
StoreID string `json:"store_id"`
|
||||
SupplierID string `json:"supplier_id"`
|
||||
Comment string `json:"comment"`
|
||||
IncomingDocNum string `json:"incoming_doc_num"`
|
||||
}
|
||||
|
||||
func (h *DraftsHandler) CommitDraft(c *gin.Context) {
|
||||
@@ -196,7 +197,7 @@ func (h *DraftsHandler) CommitDraft(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.service.UpdateDraftHeader(draftID, &storeID, &supplierID, date, req.Comment); err != nil {
|
||||
if err := h.service.UpdateDraftHeader(draftID, &storeID, &supplierID, date, req.Comment, req.IncomingDocNum); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to update header: " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,14 +4,17 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"rmser/internal/services/drafts"
|
||||
invService "rmser/internal/services/invoices"
|
||||
"rmser/pkg/logger"
|
||||
)
|
||||
|
||||
type InvoiceHandler struct {
|
||||
service *invService.Service
|
||||
service *invService.Service
|
||||
draftsService *drafts.Service
|
||||
}
|
||||
|
||||
func NewInvoiceHandler(service *invService.Service) *InvoiceHandler {
|
||||
@@ -35,7 +38,8 @@ func (h *InvoiceHandler) SendInvoice(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
docNum, err := h.service.SendInvoiceToRMS(req)
|
||||
userID := c.MustGet("userID").(uuid.UUID)
|
||||
docNum, err := h.service.SendInvoiceToRMS(req, userID)
|
||||
if err != nil {
|
||||
logger.Log.Error("Ошибка отправки накладной", zap.Error(err))
|
||||
// Возвращаем 502 Bad Gateway, т.к. ошибка скорее всего на стороне RMS
|
||||
@@ -48,3 +52,36 @@ func (h *InvoiceHandler) SendInvoice(c *gin.Context) {
|
||||
"created_number": docNum,
|
||||
})
|
||||
}
|
||||
|
||||
// GetInvoice godoc
|
||||
// @Summary Получить детали накладной
|
||||
// @Description Возвращает детали синхронизированной накладной по ID
|
||||
// @Tags invoices
|
||||
// @Produce json
|
||||
// @Param id path string true "Invoice ID"
|
||||
// @Success 200 {object} invService.InvoiceDetailsDTO
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
func (h *InvoiceHandler) GetInvoice(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "ID накладной обязателен"})
|
||||
return
|
||||
}
|
||||
|
||||
uuidID, err := uuid.Parse(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Неверный формат ID"})
|
||||
return
|
||||
}
|
||||
|
||||
dto, err := h.service.GetInvoice(uuidID)
|
||||
if err != nil {
|
||||
logger.Log.Error("Ошибка получения накладной", zap.Error(err), zap.String("id", id))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Ошибка получения накладной"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, dto)
|
||||
}
|
||||
|
||||
@@ -132,3 +132,20 @@ func (h *OCRHandler) GetUnmatched(c *gin.Context) {
|
||||
}
|
||||
c.JSON(http.StatusOK, items)
|
||||
}
|
||||
|
||||
func (h *OCRHandler) DiscardUnmatched(c *gin.Context) {
|
||||
userID := c.MustGet("userID").(uuid.UUID)
|
||||
rawName := c.Query("raw_name")
|
||||
|
||||
if rawName == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "raw_name is required"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.service.DiscardUnmatched(userID, rawName); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"status": "discarded"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user