2701-есть адекватный порядок для строк черновика и фикс пустого поиска

This commit is contained in:
2026-01-27 08:51:59 +03:00
parent 38a5143902
commit de4bd9c8d7
8 changed files with 148 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ func (r *pgRepository) GetByID(id uuid.UUID) (*drafts.DraftInvoice, error) {
var draft drafts.DraftInvoice
err := r.db.
Preload("Items", func(db *gorm.DB) *gorm.DB {
return db.Order("draft_invoice_items.raw_name ASC")
return db.Order("draft_invoice_items.order ASC")
}).
Preload("Items.Product").
Preload("Items.Product.MainUnit").
@@ -98,6 +98,13 @@ func (r *pgRepository) UpdateItem(itemID uuid.UUID, updates map[string]interface
Updates(updates).Error
}
// UpdateItemOrder обновляет порядок позиции
func (r *pgRepository) UpdateItemOrder(itemID uuid.UUID, newOrder int) error {
return r.db.Model(&drafts.DraftInvoiceItem{}).
Where("id = ?", itemID).
Update("order", newOrder).Error
}
func (r *pgRepository) Delete(id uuid.UUID) error {
return r.db.Delete(&drafts.DraftInvoice{}, id).Error
}