Skip to content

Commit 4c344fa

Browse files
authored
Merge pull request #63 from openimis/feature/add-blank
Feature/add blank
2 parents af4920d + 8b6c396 commit 4c344fa

File tree

3 files changed

+57
-55
lines changed

3 files changed

+57
-55
lines changed

invoice/models.py

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,26 @@ class Status(models.IntegerChoices):
2727
RECONCILIATED = 7, _('reconciliated')
2828

2929
thirdparty_type = models.ForeignKey(ContentType, models.DO_NOTHING,
30-
db_column='ThirdpartyType', null=True, unique=False)
31-
thirdparty_id = models.CharField(db_column='ThirdpartyId', max_length=255, null=True) # object is referenced by uuid
30+
db_column='ThirdpartyType', blank=True, null=True, unique=False)
31+
thirdparty_id = models.CharField(db_column='ThirdpartyId', max_length=255, blank=True, null=True) # object is referenced by uuid
3232
thirdparty = GenericForeignKey('thirdparty_type', 'thirdparty_id')
3333

34-
code_tp = models.CharField(db_column='CodeTp', max_length=255, null=True)
34+
code_tp = models.CharField(db_column='CodeTp', max_length=255, blank=True, null=True)
3535
code = models.CharField(db_column='Code', max_length=255, null=False)
36-
code_ext = models.CharField(db_column='CodeExt', max_length=255, null=True)
36+
code_ext = models.CharField(db_column='CodeExt', max_length=255, blank=True, null=True)
3737

38-
date_due = DateField(db_column='DateDue', null=True)
38+
date_due = DateField(db_column='DateDue', blank=True, null=True)
3939

40-
date_payed = DateField(db_column='DatePayed', null=True)
40+
date_payed = DateField(db_column='DatePayed', blank=True, null=True)
4141

4242
amount_discount = models.DecimalField(
43-
db_column='AmountDiscount', max_digits=18, decimal_places=2, null=True, default=0.0)
43+
db_column='AmountDiscount', max_digits=18, decimal_places=2, null=True, default=0.0)
4444
amount_net = models.DecimalField(
4545
db_column='AmountNet', max_digits=18, decimal_places=2, default=0.0)
4646
amount_total = models.DecimalField(
4747
db_column='AmountTotal', max_digits=18, decimal_places=2, default=0.0)
4848

49-
tax_analysis = models.JSONField(db_column='TaxAnalysis', null=True)
49+
tax_analysis = models.JSONField(db_column='TaxAnalysis', blank=True, null=True)
5050

5151
status = models.SmallIntegerField(
5252
db_column='Status', null=False, choices=Status.choices, default=Status.DRAFT)
@@ -59,7 +59,7 @@ class Status(models.IntegerChoices):
5959
note = models.TextField(db_column='Note', blank=True, null=True)
6060
terms = models.TextField(db_column='Terms', blank=True, null=True)
6161

62-
payment_reference = models.CharField(db_column='PaymentReference', max_length=255, null=True)
62+
payment_reference = models.CharField(db_column='PaymentReference', max_length=255, blank=True, null=True)
6363

6464
objects = GenericInvoiceManager()
6565

@@ -71,9 +71,9 @@ class GenericInvoiceLineItem(GenericInvoiceQuerysetMixin, HistoryBusinessModel):
7171
code = models.CharField(db_column='Code', max_length=255, null=False)
7272

7373
description = models.TextField(db_column='Description', blank=True, null=True)
74-
details = models.JSONField(db_column='Details', null=True)
74+
details = models.JSONField(db_column='Details', blank=True, null=True)
7575

76-
ledger_account = models.CharField(db_column='LedgerAccount', max_length=255, null=True)
76+
ledger_account = models.CharField(db_column='LedgerAccount', max_length=255, blank=True, null=True)
7777

7878
quantity = models.IntegerField(db_column='Quantity', default=0.0)
7979
unit_price = models.DecimalField(db_column='UnitPrice', max_digits=18, decimal_places=2, default=0.0)
@@ -82,10 +82,10 @@ class GenericInvoiceLineItem(GenericInvoiceQuerysetMixin, HistoryBusinessModel):
8282

8383
deduction = models.DecimalField(db_column='Deduction', max_digits=18, decimal_places=2, default=0.0)
8484

85-
tax_rate = models.UUIDField(db_column="CalculationUUID", null=True)
86-
tax_analysis = models.JSONField(db_column='TaxAnalysis', null=True)
85+
tax_rate = models.UUIDField(db_column="CalculationUUID", blank=True, null=True)
86+
tax_analysis = models.JSONField(db_column='TaxAnalysis', blank=True, null=True)
8787

88-
amount_total = models.DecimalField(db_column='AmountTotal', max_digits=18, decimal_places=2, null=True)
88+
amount_total = models.DecimalField(db_column='AmountTotal', max_digits=18, decimal_places=2, default=0.0)
8989
amount_net = models.DecimalField(db_column='AmountNet', max_digits=18, decimal_places=2, default=0.0)
9090

9191
objects = GenericInvoiceManager()
@@ -101,21 +101,21 @@ class PaymentStatus(models.IntegerChoices):
101101
REFUNDED = 2, _('refunded')
102102
CANCELLED = 3, _('cancelled')
103103

104-
code_tp = models.CharField(db_column='CodeTp', max_length=255, null=True)
105-
code_ext = models.CharField(db_column='CodeExt', max_length=255, null=True)
106-
code_receipt = models.CharField(db_column='CodeReceipt', max_length=255, null=True)
104+
code_tp = models.CharField(db_column='CodeTp', max_length=255, blank=True, null=True)
105+
code_ext = models.CharField(db_column='CodeExt', max_length=255, blank=True, null=True)
106+
code_receipt = models.CharField(db_column='CodeReceipt', max_length=255, blank=True, null=True)
107107

108-
label = models.CharField(db_column='Label', max_length=255, null=True)
108+
label = models.CharField(db_column='Label', max_length=255, blank=True, null=True)
109109

110110
status = models.SmallIntegerField(db_column='Status', null=False, choices=PaymentStatus.choices)
111111

112-
amount_payed = models.DecimalField(db_column='AmountPayed', max_digits=18, decimal_places=2, null=True)
113-
fees = models.DecimalField(db_column='Fees', max_digits=18, decimal_places=2, null=True)
114-
amount_received = models.DecimalField(db_column='AmountReceived', max_digits=18, decimal_places=2, null=True)
112+
amount_payed = models.DecimalField(db_column='AmountPayed', max_digits=18, decimal_places=2, blank=True, null=True)
113+
fees = models.DecimalField(db_column='Fees', max_digits=18, decimal_places=2, blank=True, null=True)
114+
amount_received = models.DecimalField(db_column='AmountReceived', max_digits=18, decimal_places=2, blank=True, null=True)
115115

116-
date_payment = DateField(db_column='DatePayment', null=True)
116+
date_payment = DateField(db_column='DatePayment', blank=True, null=True)
117117

118-
payment_origin = models.CharField(db_column='PaymentOrigin', max_length=255, null=True)
118+
payment_origin = models.CharField(db_column='PaymentOrigin', max_length=255, blank=True, null=True)
119119

120120
objects = GenericInvoiceManager()
121121

@@ -131,7 +131,7 @@ class EventType(models.IntegerChoices):
131131
PAYMENT = 3, _('payment')
132132
PAYMENT_ERROR = 4, _('payment_error')
133133

134-
message = models.CharField(db_column='Message', max_length=500, null=True)
134+
message = models.CharField(db_column='Message', max_length=500, blank=True, null=True)
135135
event_type = models.SmallIntegerField(
136136
db_column='Status', null=False, choices=EventType.choices, default=EventType.MESSAGE)
137137

@@ -143,11 +143,11 @@ class Meta:
143143

144144
class Invoice(GenericInvoice):
145145
subject_type = models.ForeignKey(ContentType, models.DO_NOTHING,
146-
db_column='SubjectType', null=True, related_name='subject_type', unique=False)
147-
subject_id = models.CharField(db_column='SubjectId', max_length=255, null=True) # object is referenced by uuid
146+
db_column='SubjectType', blank=True, null=True, related_name='subject_type', unique=False)
147+
subject_id = models.CharField(db_column='SubjectId', max_length=255, blank=True, null=True) # object is referenced by uuid
148148
subject = GenericForeignKey('subject_type', 'subject_id')
149149

150-
date_invoice = DateField(db_column='DateInvoice', default=date.today, null=True)
150+
date_invoice = DateField(db_column='DateInvoice', default=date.today, blank=True, null=True)
151151

152152
class Meta:
153153
managed = True
@@ -156,8 +156,8 @@ class Meta:
156156

157157
class InvoiceLineItem(GenericInvoiceLineItem):
158158
line_type = models.ForeignKey(
159-
ContentType, models.DO_NOTHING, db_column='LineType', null=True, related_name='line_type', unique=False)
160-
line_id = models.CharField(db_column='LineId', max_length=255, null=True) # object is referenced by uuid
159+
ContentType, models.DO_NOTHING, db_column='LineType', blank=True, null=True, related_name='line_type', unique=False)
160+
line_id = models.CharField(db_column='LineId', max_length=255, blank=True, null=True) # object is referenced by uuid
161161
line = GenericForeignKey('line_type', 'line_id')
162162

163163
invoice = models.ForeignKey(Invoice, models.DO_NOTHING, db_column='InvoiceId', related_name="line_items")
@@ -185,12 +185,12 @@ class Meta:
185185

186186
class Bill(GenericInvoice):
187187
subject_type = models.ForeignKey(ContentType, models.DO_NOTHING,
188-
db_column='SubjectType', null=True, related_name='subject_type_bill',
188+
db_column='SubjectType', null=True,blank=True, related_name='subject_type_bill',
189189
unique=False)
190-
subject_id = models.CharField(db_column='SubjectId', max_length=255, null=True) # object is referenced by uuid
190+
subject_id = models.CharField(db_column='SubjectId', max_length=255, blank=True, null=True) # object is referenced by uuid
191191
subject = GenericForeignKey('subject_type', 'subject_id')
192192

193-
date_bill = DateField(db_column='DateBill', default=date.today, null=True)
193+
date_bill = DateField(db_column='DateBill', default=date.today,blank=True, null=True)
194194

195195
class Meta:
196196
managed = True
@@ -199,8 +199,8 @@ class Meta:
199199

200200
class BillItem(GenericInvoiceLineItem):
201201
line_type = models.ForeignKey(
202-
ContentType, models.DO_NOTHING, db_column='LineType', null=True, related_name='line_type_bill', unique=False)
203-
line_id = models.CharField(db_column='LineId', max_length=255, null=True) # object is referenced by uuid
202+
ContentType, models.DO_NOTHING, db_column='LineType', blank=True, null=True, related_name='line_type_bill', unique=False)
203+
line_id = models.CharField(db_column='LineId', max_length=255, blank=True, null=True) # object is referenced by uuid
204204
line = GenericForeignKey('line_type', 'line_id')
205205

206206
bill = models.ForeignKey(Bill, models.DO_NOTHING, db_column='BillId', related_name="line_items_bill")
@@ -306,24 +306,24 @@ class ReconciliationStatus(models.IntegerChoices):
306306
REFUNDED = 2, _('refunded')
307307
CANCELLED = 3, _('cancelled')
308308

309-
code_tp = models.CharField(db_column='CodeTp', max_length=255, null=True)
310-
code_ext = models.CharField(db_column='CodeExt', max_length=255, null=True)
311-
code_receipt = models.CharField(db_column='CodeReceipt', max_length=255, null=True)
309+
code_tp = models.CharField(db_column='CodeTp', max_length=255, blank=True, null=True)
310+
code_ext = models.CharField(db_column='CodeExt', max_length=255, blank=True, null=True)
311+
code_receipt = models.CharField(db_column='CodeReceipt', max_length=255, blank=True, null=True)
312312

313-
label = models.CharField(db_column='Label', max_length=255, null=True)
313+
label = models.CharField(db_column='Label', max_length=255, blank=True, null=True)
314314

315315
reconciliation_status = models.SmallIntegerField(db_column='ReconciliationStatus', null=False,
316316
choices=ReconciliationStatus.choices)
317317

318-
fees = models.DecimalField(db_column='Fees', max_digits=18, decimal_places=2, null=True)
319-
amount_received = models.DecimalField(db_column='AmountReceived', max_digits=18, decimal_places=2, null=True)
318+
fees = models.DecimalField(db_column='Fees', max_digits=18, decimal_places=2, blank=True, null=True)
319+
amount_received = models.DecimalField(db_column='AmountReceived', max_digits=18, decimal_places=2, blank=True, null=True)
320320

321-
date_payment = DateField(db_column='DatePayment', null=True)
321+
date_payment = DateField(db_column='DatePayment', blank=True, null=True)
322322

323-
payment_origin = models.CharField(db_column='PaymentOrigin', max_length=255, null=True)
323+
payment_origin = models.CharField(db_column='PaymentOrigin', max_length=255, blank=True, null=True)
324324

325325
payer_ref = models.CharField(db_column='PayerRef', max_length=255)
326-
payer_name = models.CharField(db_column='PayerName', max_length=255, null=True)
326+
payer_name = models.CharField(db_column='PayerName', max_length=255, blank=True, null=True)
327327

328328
objects = GenericInvoiceManager()
329329

@@ -343,16 +343,16 @@ class DetailPaymentStatus(models.IntegerChoices):
343343
db_column='PaymentUUID', related_name="invoice_payments")
344344

345345
subject_type = models.ForeignKey(ContentType, models.DO_NOTHING, db_column='SubjectType',
346-
related_name='subject_type_payment', null=True, unique=False)
347-
subject_id = models.CharField(db_column='SubjectId', max_length=255, null=True)
346+
related_name='subject_type_payment', blank=True, null=True, unique=False)
347+
subject_id = models.CharField(db_column='SubjectId', max_length=255, blank=True, null=True)
348348
subject = GenericForeignKey('subject_type', 'subject_id')
349349

350350
status = models.SmallIntegerField(db_column='Status', null=False, choices=DetailPaymentStatus.choices)
351-
fees = models.DecimalField(db_column='Fees', max_digits=18, decimal_places=2, null=True)
352-
amount = models.DecimalField(db_column='Amount', max_digits=18, decimal_places=2, null=True)
351+
fees = models.DecimalField(db_column='Fees', max_digits=18, decimal_places=2, blank=True, null=True)
352+
amount = models.DecimalField(db_column='Amount', max_digits=18, decimal_places=2, blank=True, null=True)
353353

354-
reconcilation_id = models.CharField(db_column='ReconcilationId', max_length=255, null=True)
355-
reconcilation_date = models.DateField(db_column='ReconcilationDate', null=True)
354+
reconcilation_id = models.CharField(db_column='ReconcilationId', max_length=255, blank=True, null=True)
355+
reconcilation_date = models.DateField(db_column='ReconcilationDate', blank=True, null=True)
356356

357357
objects = GenericInvoiceManager()
358358

invoice/tests/services/invoice.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from contract.tests.helpers import create_test_contract
88
from core.forms import User
9+
from core.test_helpers import compare_dicts
910
from insuree.test_helpers import create_test_insuree
1011
from invoice.models import Invoice, InvoiceLineItem, InvoicePayment
1112
from invoice.services import InvoiceService
@@ -153,7 +154,7 @@ def test_invoice_create(self):
153154
expected_response['data']['subject_type'] = invoice.subject_type.id
154155
expected_response['data']['thirdparty_type'] = invoice.thirdparty_type.id
155156

156-
self.assertDictEqual(expected_response, response)
157+
self.assertTrue(compare_dicts(expected_response, response))
157158
Invoice.objects.filter(code=payload['code']).delete()
158159

159160
def test_invoice_update(self):
@@ -175,7 +176,7 @@ def test_invoice_update(self):
175176
invoice = Invoice.objects.filter(code=update_payload['code']).first()
176177

177178
expected_response['data']['thirdparty_type'] = invoice.thirdparty_type.id
178-
self.assertDictEqual(expected_response, response)
179+
self.assertTrue(compare_dicts(expected_response, response))
179180

180181
Invoice.objects.filter(code=update_payload['code']).delete()
181182

invoice/tests/services/invoiceLineItem.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from product.test_helpers import create_test_product
44

55
from core.forms import User
6+
from core.test_helpers import compare_dicts
67
from django.test import TestCase
78

89
from invoice.models import InvoiceLineItem
@@ -76,8 +77,8 @@ class ServiceTestInvoiceLineItems(TestCase):
7677
'details': {"test_int": 1, "test_txt": "some_str"},
7778
'ledger_account': 'account2',
7879
'quantity': 12,
79-
'unit_price': 10,
80-
'discount': 20,
80+
'unit_price': 10.0,
81+
'discount': 20.0,
8182
'tax_analysis': {'lines': [{'code': 'c', 'label': 'l', 'base': '0.1', 'amount': '1.00'}], 'total': '1.0'},
8283
'line_id': None,
8384
'line_type': None
@@ -123,7 +124,7 @@ def test_line_items_create(self):
123124
expected_response['data']['line_type'] = line_item.line_type.id
124125
expected_response['data']['line_id'] = self.policy.pk
125126

126-
self.assertDictEqual(expected_response, response)
127+
self.assertTrue(compare_dicts(expected_response, response))
127128
InvoiceLineItem.objects.filter(code=payload['code']).delete()
128129

129130
def test_line_items_update(self):
@@ -150,7 +151,7 @@ def test_line_items_update(self):
150151
expected_response['data']['line_type'] = line_item.line_type.id
151152
expected_response['data']['line_id'] = str(self.policy.pk)
152153

153-
self.assertDictEqual(expected_response, response)
154+
self.assertTrue(compare_dicts(expected_response, response))
154155
InvoiceLineItem.objects.filter(code=update_payload['code']).delete()
155156

156157
def test_line_items_delete(self):

0 commit comments

Comments
 (0)