forked from erp-dev/erp
feat: BalanceChangeRecord
This commit is contained in:
@@ -47,3 +47,30 @@ class PurchaseOrderItemAdmin(admin.ModelAdmin):
|
||||
@admin.display(description='总金额')
|
||||
def _total_amount(self, obj: models.PurchaseOrderItem):
|
||||
return obj.total_amount()
|
||||
|
||||
|
||||
@admin.register(models.CustomerBalance)
|
||||
class CustomerBalancemAdmin(admin.ModelAdmin):
|
||||
list_display = ('id', 'customer', 'balance', 'created_at')
|
||||
search_fields = ('customer_balance__id', 'product__name')
|
||||
ordering = ('-created_at',)
|
||||
|
||||
|
||||
@admin.register(models.BalanceChangeRecord)
|
||||
class BalanceChangeRecordAdmin(admin.ModelAdmin):
|
||||
list_display = ('id', 'merchant', 'target_type', 'source_type', 'source_id', 'delta', 'balance_before', 'balance_after', 'direction', 'created_at')
|
||||
search_fields = ('merchant__name', 'target_type', 'source_type', 'source_id')
|
||||
list_filter = ('merchant', 'target_type', 'source_type', 'direction', 'created_at')
|
||||
ordering = ('-created_at',)
|
||||
|
||||
@admin.display(description='商户')
|
||||
def merchant(self, obj: models.BalanceChangeRecord):
|
||||
return obj.merchant.name
|
||||
|
||||
@admin.display(description='目标类型')
|
||||
def target_type(self, obj: models.BalanceChangeRecord):
|
||||
return obj.target_type.label
|
||||
|
||||
@admin.display(description='来源类型')
|
||||
def source_type(self, obj: models.BalanceChangeRecord):
|
||||
return obj.source_type.label
|
||||
Reference in New Issue
Block a user