Skip to content

Commit 34da17d

Browse files
authored
Product Revenue: Do no allow negative revenue (#12160)
* Product Revenue: Do no allow negative revenue * Correcting warnings * Fixing ruff
1 parent 0e27c55 commit 34da17d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 5.1.7 on 2025-04-02 17:28
2+
3+
import django.core.validators
4+
from decimal import Decimal
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('dojo', '0224_alter_regulation_category'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='product',
17+
name='revenue',
18+
field=models.DecimalField(blank=True, decimal_places=2, help_text="Estimate the application's revenue.", max_digits=15, null=True, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))]),
19+
),
20+
]

dojo/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import warnings
77
from contextlib import suppress
88
from datetime import datetime
9+
from decimal import Decimal
910
from pathlib import Path
1011
from uuid import uuid4
1112

@@ -1159,7 +1160,7 @@ class Product(models.Model):
11591160
lifecycle = models.CharField(max_length=12, choices=LIFECYCLE_CHOICES, blank=True, null=True)
11601161
origin = models.CharField(max_length=19, choices=ORIGIN_CHOICES, blank=True, null=True)
11611162
user_records = models.PositiveIntegerField(blank=True, null=True, help_text=_("Estimate the number of user records within the application."))
1162-
revenue = models.DecimalField(max_digits=15, decimal_places=2, blank=True, null=True, help_text=_("Estimate the application's revenue."))
1163+
revenue = models.DecimalField(max_digits=15, decimal_places=2, blank=True, null=True, validators=[MinValueValidator(Decimal("0.00"))], help_text=_("Estimate the application's revenue."))
11631164
external_audience = models.BooleanField(default=False, help_text=_("Specify if the application is used by people outside the organization."))
11641165
internet_accessible = models.BooleanField(default=False, help_text=_("Specify if the application is accessible from the public internet."))
11651166
regulations = models.ManyToManyField(Regulation, blank=True)

0 commit comments

Comments
 (0)