-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add status to transaction so to differenciate between transactions in…
… draft state, where order scope is the workbasket, and "finalised" transactions where the scope is global. On setting the Workbasket to approved, finalise the transactions.
- Loading branch information
Showing
6 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 3.1.12 on 2021-07-29 22:23 | ||
|
||
import django_fsm | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("common", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="transaction", | ||
name="status", | ||
field=django_fsm.FSMField( | ||
choices=[(1, "Draft"), (2, "Finalised")], | ||
db_index=True, | ||
default=1, | ||
max_length=50, | ||
protected=True, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 3.2.4 on 2021-07-14 01:41 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def set_initial_transaction_status(apps, schemaeditor): | ||
# Transactions that are part of approved Workbaskets | ||
# will have their status set to FINALISED. | ||
from common.validators import TransactionStatus | ||
from workbaskets.validators import WorkflowStatus | ||
|
||
Transaction = apps.get_model("common", "Transaction") | ||
|
||
transactions = Transaction.objects.exclude( | ||
status=TransactionStatus.FINALISED.value, | ||
).filter( | ||
workbasket__status__in=WorkflowStatus.approved_statuses(), | ||
) | ||
transactions.update(status=TransactionStatus.FINALISED.value) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("common", "0002_transaction_status"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_initial_transaction_status, lambda apps, schema: None), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters