import - BankAccountDeviceLink for set device to a bank_account/changes in stakeholders & pos

This commit is contained in:
2025-12-30 16:57:15 +03:30
parent 9a02ad4622
commit e3318b7e1e
8 changed files with 104 additions and 11 deletions

View File

@@ -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__'