diff --git a/poms/transactions/handlers.py b/poms/transactions/handlers.py index 1c0bf5ede..dc1820cd9 100644 --- a/poms/transactions/handlers.py +++ b/poms/transactions/handlers.py @@ -140,7 +140,7 @@ def __init__( # noqa: PLR0913, PLR0915 self.complex_transaction_status = complex_transaction_status self.transactions_errors = transactions_errors or [] self.recalculate_inputs = recalculate_inputs or [] - self.source = source # JSON object that contains source dictionary from broker + self.source_data_dict = source # JSON object that contains source dictionary from broker self.uniqueness_reaction = uniqueness_reaction or (self.transaction_type.transaction_unique_code_options) self._now = now or date_now() self.next_transaction_order = transaction_order_gen or self._next_transaction_order_default @@ -2926,8 +2926,8 @@ def process(self): # noqa: PLR0915 if self.complex_transaction_status is not None: self.complex_transaction.status_id = self.complex_transaction_status - if self.source: - self.complex_transaction.source = self.source + if self.source_data_dict: + self.complex_transaction.source_data_dict = self.source_data_dict if self.complex_transaction.transaction_unique_code: count = ( diff --git a/poms/transactions/migrations/0043_remove_complextransaction_source_data_and_more.py b/poms/transactions/migrations/0043_remove_complextransaction_source_data_and_more.py new file mode 100644 index 000000000..f073ed4b8 --- /dev/null +++ b/poms/transactions/migrations/0043_remove_complextransaction_source_data_and_more.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.22 on 2026-01-20 19:37 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('provenance', '0003_platformversion_created_at_and_more'), + ('transactions', '0042_complextransaction_actual_at_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='complextransaction', + name='source', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='provenance.source', verbose_name='source'), + ), + ] diff --git a/poms/transactions/migrations/0044_alter_complextransaction_source_data.py b/poms/transactions/migrations/0044_alter_complextransaction_source_data.py new file mode 100644 index 000000000..76588cab3 --- /dev/null +++ b/poms/transactions/migrations/0044_alter_complextransaction_source_data.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.22 on 2026-01-20 19:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('transactions', '0043_remove_complextransaction_source_data_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='complextransaction', + name='source_data', + field=models.JSONField(blank=True, null=True, verbose_name='source data'), + ), + ] diff --git a/poms/transactions/models.py b/poms/transactions/models.py index 7feadabf5..d7bcde3ff 100644 --- a/poms/transactions/models.py +++ b/poms/transactions/models.py @@ -2798,18 +2798,18 @@ class ComplexTransaction(TimeStampedModel, ObjectStateModel, ProvenanceModel): blank=True, verbose_name=gettext_lazy("execution log"), ) - source_data = models.TextField( + source_data = models.JSONField( null=True, blank=True, verbose_name=gettext_lazy("source data"), ) @property - def source(self): + def source_data_dict(self): return None if self.source_data is None else json.loads(self.source_data) - @source.setter - def source(self, value): + @source_data_dict.setter + def source_data_dict(self, value): if value is None: self.source_data = None else: diff --git a/poms/transactions/serializers.py b/poms/transactions/serializers.py index 78cfaded2..025ce4a00 100644 --- a/poms/transactions/serializers.py +++ b/poms/transactions/serializers.py @@ -3868,7 +3868,7 @@ class ComplexTransactionSerializer( transaction_type = serializers.PrimaryKeyRelatedField(read_only=True) transactions = serializers.PrimaryKeyRelatedField(read_only=True, many=True) recon_fields = ReconciliationComplexTransactionFieldSerializer(required=False, many=True) - source = serializers.JSONField(read_only=True, allow_null=True) + # source = serializers.JSONField(read_only=True, allow_null=True) inputs = ComplexTransactionInputSerializer(many=True) def __init__(self, *args, **kwargs): @@ -3952,7 +3952,7 @@ class Meta: "user_date_5", "recon_fields", "execution_log", - "source", + "source_data", "inputs", ]