import - BankAccountDeviceLink for set device to a bank_account/changes in stakeholders & pos
This commit is contained in:
@@ -81,8 +81,12 @@ class StakeHoldersSerializer(ModelSerializer):
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
|
||||
# get organization bank account that set to a device
|
||||
bank_account_device_links = instance.organization.bank_account_device_links.filter(device=instance.device)
|
||||
|
||||
representation['bank_account'] = BankAccountSerializer(
|
||||
instance.organization.bank_information.all().first()
|
||||
if not bank_account_device_links.exists() else bank_account_device_links.first().bank_account
|
||||
).data
|
||||
|
||||
representation['device'] = instance.device.device_identity
|
||||
@@ -127,3 +131,9 @@ class StakeHolderShareAmountSerializer(ModelSerializer):
|
||||
representation['stakeholders'] = StakeHoldersSerializer(instance.stakeholders).data
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
class BankAccountDeviceLinkSerializer(ModelSerializer):
|
||||
class Meta:
|
||||
model = pos_models.BankAccountDeviceLink
|
||||
fields = '__all__'
|
||||
|
||||
Reference in New Issue
Block a user