|
1
|
|
|
# Copyright 2017 Mathias WOLFF |
|
2
|
|
|
# This file is part of pyfreebilling. |
|
3
|
|
|
# |
|
4
|
|
|
# pyfreebilling is free software: you can redistribute it and/or modify |
|
5
|
|
|
# it under the terms of the GNU General Public License as published by |
|
6
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
7
|
|
|
# (at your option) any later version. |
|
8
|
|
|
# |
|
9
|
|
|
# pyfreebilling is distributed in the hope that it will be useful, |
|
10
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
# GNU General Public License for more details. |
|
13
|
|
|
# |
|
14
|
|
|
# You should have received a copy of the GNU General Public License |
|
15
|
|
|
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/> |
|
16
|
|
|
|
|
17
|
|
|
from django.db import models |
|
18
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
19
|
|
|
|
|
20
|
|
|
from pyfreebilling.customerdirectory.models import CustomerDirectory |
|
21
|
|
|
from pyfreebilling.pyfreebill.models import Company |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
class Fraud(models.Model): |
|
25
|
|
|
"""Fraud model.""" |
|
26
|
|
|
company = models.OneToOneField( |
|
27
|
|
|
Company, |
|
28
|
|
|
on_delete=models.CASCADE, |
|
29
|
|
|
limit_choices_to={'customer_enabled': True}, |
|
30
|
|
|
blank=True, |
|
31
|
|
|
null=True) |
|
32
|
|
|
customerdirectory = models.OneToOneField( |
|
33
|
|
|
CustomerDirectory, |
|
34
|
|
|
on_delete=models.CASCADE, |
|
35
|
|
|
blank=True, |
|
36
|
|
|
null=True) |
|
37
|
|
|
# Fraud based on amount |
|
38
|
|
|
amount_fraud = models.BooleanField( |
|
39
|
|
|
_(u"Activate amount fraud system"), |
|
40
|
|
|
default=False, |
|
41
|
|
|
help_text=_(u"If checked, this account will be protected by threshold fraud system by checking daily consumption.")) |
|
42
|
|
|
amount_limit_alert = models.DecimalField( |
|
43
|
|
|
_(u'Amount - alert'), |
|
44
|
|
|
max_digits=12, |
|
45
|
|
|
decimal_places=4, |
|
46
|
|
|
default=0, |
|
47
|
|
|
help_text=_(u"Daily consumption allowed before alerting.")) |
|
48
|
|
|
amount_block_alert = models.DecimalField( |
|
49
|
|
|
_(u'Amount - block'), |
|
50
|
|
|
max_digits=12, |
|
51
|
|
|
decimal_places=4, |
|
52
|
|
|
default=0, |
|
53
|
|
|
help_text=_(u"Daily consumption allowed before blocking.")) |
|
54
|
|
|
high_amount_alert_sent = models.BooleanField( |
|
55
|
|
|
_(u"Fraud alert ON (based on daily consumption)"), |
|
56
|
|
|
default=False) |
|
57
|
|
|
# Fraud based on minutes |
|
58
|
|
|
minutes_fraud = models.BooleanField( |
|
59
|
|
|
_(u"Activate minutes fraud system"), |
|
60
|
|
|
default=False, |
|
61
|
|
|
help_text=_(u"If checked, this account will be protected by threshold fraud system by checking daily minutes consumption.")) |
|
62
|
|
|
minutes_limit_alert = models.IntegerField( |
|
63
|
|
|
_(u'Nb minutes - alert'), |
|
64
|
|
|
default=0, |
|
65
|
|
|
help_text=_(u"Daily minutes consumption allowed before alerting.")) |
|
66
|
|
|
minutes_block_alert = models.IntegerField( |
|
67
|
|
|
_(u'Nb minutes - Block'), |
|
68
|
|
|
default=0, |
|
69
|
|
|
help_text=_(u"Daily minutes consumption allowed before blocking.")) |
|
70
|
|
|
high_minutes_alert_sent = models.BooleanField( |
|
71
|
|
|
_(u"Fraud alert ON (based on daily minutes consumption)"), |
|
72
|
|
|
default=False) |
|
73
|
|
|
# General settings |
|
74
|
|
|
account_blocked_alert_sent = models.BooleanField( |
|
75
|
|
|
_(u"Account blocked - Fraud alert ON"), |
|
76
|
|
|
default=False) |
|
77
|
|
|
date_added = models.DateTimeField(_('date added'), |
|
78
|
|
|
auto_now_add=True) |
|
79
|
|
|
date_modified = models.DateTimeField(_(u'date modified'), |
|
80
|
|
|
auto_now=True) |
|
81
|
|
|
|
|
82
|
|
|
class Meta: |
|
83
|
|
|
db_table = 'fraud_alert' |
|
84
|
|
|
app_label = 'antifraud' |
|
85
|
|
|
verbose_name = _(u'antifraud') |
|
86
|
|
|
verbose_name_plural = _(u'antifraud') |
|
87
|
|
|
|
|
88
|
|
|
def __unicode__(self): |
|
89
|
|
|
return self.id |
|
90
|
|
|
|