fix final invoice and certificatre
This commit is contained in:
		
							parent
							
								
									0cfa86bde3
								
							
						
					
					
						commit
						dd37ac3720
					
				
					 11 changed files with 120 additions and 66 deletions
				
			
		| 
						 | 
				
			
			@ -44,11 +44,11 @@ class PaymentInline(admin.TabularInline):
 | 
			
		|||
 | 
			
		||||
@admin.register(Invoice)
 | 
			
		||||
class InvoiceAdmin(SimpleHistoryAdmin):
 | 
			
		||||
    list_display = ['name', 'process_instance', 'customer', 'status_display', 'final_amount', 'paid_amount', 'remaining_amount', 'due_date']
 | 
			
		||||
    list_display = ['name', 'process_instance', 'customer', 'status_display', 'final_amount', 'paid_amount_display', 'remaining_amount_display', 'due_date']
 | 
			
		||||
    list_filter = ['status', 'created', 'due_date', 'process_instance__process']
 | 
			
		||||
    search_fields = ['name', 'customer__username', 'customer__first_name', 'customer__last_name', 'notes']
 | 
			
		||||
    prepopulated_fields = {'slug': ('name',)}
 | 
			
		||||
    readonly_fields = ['deleted_at', 'created', 'updated', 'total_amount', 'discount_amount', 'final_amount', 'paid_amount', 'remaining_amount']
 | 
			
		||||
    readonly_fields = ['deleted_at', 'created', 'updated', 'total_amount', 'discount_amount', 'final_amount', 'paid_amount_display', 'remaining_amount_display']
 | 
			
		||||
    inlines = [InvoiceItemInline, PaymentInline]
 | 
			
		||||
    ordering = ['-created']
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -56,6 +56,16 @@ class InvoiceAdmin(SimpleHistoryAdmin):
 | 
			
		|||
        return mark_safe(obj.get_status_display_with_color())
 | 
			
		||||
    status_display.short_description = "وضعیت"
 | 
			
		||||
 | 
			
		||||
    def paid_amount_display(self, obj):
 | 
			
		||||
        return f"{obj.get_paid_amount():,.0f} تومان"
 | 
			
		||||
    paid_amount_display.short_description = "مبلغ پرداخت شده"
 | 
			
		||||
 | 
			
		||||
    def remaining_amount_display(self, obj):
 | 
			
		||||
        amount = obj.get_remaining_amount()
 | 
			
		||||
        color = "green" if amount <= 0 else "red"
 | 
			
		||||
        return format_html('<span style="color: {};">{:,.0f} تومان</span>', color, amount)
 | 
			
		||||
    remaining_amount_display.short_description = "مبلغ باقیمانده"
 | 
			
		||||
 | 
			
		||||
@admin.register(Payment)
 | 
			
		||||
class PaymentAdmin(SimpleHistoryAdmin):
 | 
			
		||||
    list_display = ['invoice', 'amount', 'payment_method', 'payment_date', 'created_by']
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue