forked from erp-dev/erp
feat: statement for supplier and customer
This commit is contained in:
@@ -34,3 +34,29 @@ class CustomerBalanceView(StockChangeViewMixin, views.APIView):
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class SupplierBalanceView(StockChangeViewMixin, views.APIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request, supplier_id: int):
|
||||
if not self.check_employee_permission(request):
|
||||
return self.permission_error_response('无权限访问')
|
||||
|
||||
merchant = request.user.employee.merchant
|
||||
try:
|
||||
supplier = basic_models.Supplier.objects.get(id=supplier_id, merchant=merchant)
|
||||
except basic_models.Supplier.DoesNotExist:
|
||||
return self.not_found_response('供应商不存在')
|
||||
|
||||
balance: Decimal = business_services.BalanceService.get_supplier_balance(
|
||||
merchant=merchant,
|
||||
supplier=supplier,
|
||||
)
|
||||
return Response(
|
||||
{
|
||||
'supplier': supplier.id,
|
||||
'supplier_name': supplier.name,
|
||||
'balance': str(balance),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user