This commit is contained in:
43
backend/modules/invoicing/admin.py
Normal file
43
backend/modules/invoicing/admin.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# backend/modules/invoicing/admin.py
|
||||
|
||||
from django.contrib import admin
|
||||
from .models import InvoiceTransaction
|
||||
|
||||
@admin.register(InvoiceTransaction)
|
||||
class InvoiceTransactionEntryAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Konfiguracija prikaza financijskih zapisa u Admin panelu.
|
||||
"""
|
||||
# Prikaz stupaca u listi
|
||||
list_display = ('invoice_number', 'work_order_ref', 'amount', 'created_at', 'is_active')
|
||||
|
||||
# Omogućuje brzo filtriranje
|
||||
list_filter = ('created_at', 'is_active', 'work_order')
|
||||
list_select_related = ('work_order__vehicle',)
|
||||
|
||||
# Omogućuje pretragu
|
||||
search_fields = ('invoice_number', 'work_order__id', 'work_order__vehicle__registration_number')
|
||||
|
||||
# Polja koja se ne smiju mijenjati u adminu
|
||||
readonly_fields = ('id', 'created_at', 'updated_at')
|
||||
|
||||
# Grupiranje polja za lakši pregled
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'fields': ('invoice_number', 'work_order', 'amount', 'payment_date', 'is_active')
|
||||
}),
|
||||
('Sustavni podaci', {
|
||||
'fields': ('id', 'created_at', 'updated_at'),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
)
|
||||
|
||||
@admin.display(description="Povezani putni nalog")
|
||||
def work_order_ref(self, obj):
|
||||
if not obj.work_order_id:
|
||||
return "—"
|
||||
short_id = str(obj.work_order_id).split('-')[0].upper()
|
||||
registration = getattr(obj.work_order.vehicle, 'registration_number', '')
|
||||
if registration:
|
||||
return f"WO-{short_id} ({registration})"
|
||||
return f"WO-{short_id}"
|
||||
Reference in New Issue
Block a user