Skip to content

Commit

Permalink
Display firstname for person customer on proposal and invoice. Closes f…
Browse files Browse the repository at this point in the history
  • Loading branch information
fgaudin committed Oct 12, 2011
1 parent 30a5180 commit 3f5573a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
46 changes: 45 additions & 1 deletion accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from accounts.models import INVOICE_STATE_EDITED, Invoice, InvoiceRow, \
INVOICE_STATE_SENT, InvoiceRowAmountError, PAYMENT_TYPE_CHECK, \
PAYMENT_TYPE_CASH, Expense, INVOICE_STATE_PAID
from contact.models import Country, Contact
from contact.models import Country, Contact, CONTACT_TYPE_PERSON
from autoentrepreneur.models import UserProfile
from django.contrib.webdesign import lorem_ipsum

Expand Down Expand Up @@ -956,6 +956,50 @@ def testBug240(self):
self.assertEquals(hashlib.md5("\n".join(invariant_content)).hexdigest(),
"0e993bfe0f5694eb08370106e59a360a")

def testBug245(self):
"""
Firstname was not displayed when customer is a person
"""
customer = self.proposal.project.customer
customer.name = 'Dupont'
customer.firstname = 'Pierre'
customer.type = CONTACT_TYPE_PERSON
customer.save()

i = Invoice.objects.create(customer_id=self.proposal.project.customer_id,
invoice_id=1,
state=INVOICE_STATE_EDITED,
amount='1000',
edition_date=datetime.date(2010, 8, 31),
payment_date=datetime.date(2010, 9, 30),
paid_date=None,
payment_type=PAYMENT_TYPE_CHECK,
execution_begin_date=datetime.date(2010, 8, 1),
execution_end_date=datetime.date(2010, 8, 7),
penalty_date=datetime.date(2010, 10, 8),
penalty_rate='1.5',
discount_conditions='Nothing',
owner_id=1)

i_row = InvoiceRow.objects.create(proposal_id=self.proposal.id,
invoice_id=i.id,
label='Day of work',
category=ROW_CATEGORY_SERVICE,
quantity=10,
unit_price='100',
balance_payments=False,
owner_id=1)

response = self.client.get(reverse('invoice_download', kwargs={'id': i.id}))
self.assertEqual(response.status_code, 200)
f = open('/tmp/invoice_bug245.pdf', 'w')
f.write(response.content)
f.close()
content = response.content.split("\n")
invariant_content = content[0:66] + content[67:110] + content[111:-1]
self.assertEquals(hashlib.md5("\n".join(invariant_content)).hexdigest(),
"3b9001285e1f36df25f4e6f3a005f058")

def testInvoiceBookDownloadPdf(self):
"""
Tests non-regression on pdf
Expand Down
40 changes: 39 additions & 1 deletion project/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PAYMENT_DELAY_TYPE_OTHER_END_OF_MONTH, VAT_RATES_19_6
from accounts.models import Invoice, InvoiceRow, INVOICE_STATE_EDITED, \
PAYMENT_TYPE_CHECK
from contact.models import Contact, Address, Country
from contact.models import Contact, Address, Country, CONTACT_TYPE_PERSON
import datetime
import hashlib
from django.contrib.auth.models import User
Expand Down Expand Up @@ -840,6 +840,44 @@ def testBug240(self):
self.assertEquals(hashlib.md5("\n".join(invariant_content)).hexdigest(),
"b0ba361910042d9fd727ad17eb80e94a")

def testBug245(self):
"""
Firstname was not displayed when customer is a person
"""
customer = Contact.objects.get(project=30)
customer.firstname = 'Pierre'
customer.name = 'Dupont'
customer.type = CONTACT_TYPE_PERSON
customer.save()

p = Proposal.objects.create(project_id=30,
update_date=datetime.date(2011, 2, 5),
state=PROPOSAL_STATE_DRAFT,
begin_date=datetime.date(2010, 8, 1),
end_date=datetime.date(2010, 8, 15),
contract_content='Content of contract',
amount=2005,
reference='XXX',
expiration_date=datetime.date(2010, 8, 2),
owner_id=1)

p_row = ProposalRow.objects.create(proposal_id=p.id,
label='Day of work',
category=ROW_CATEGORY_SERVICE,
quantity=20,
unit_price='200.5',
owner_id=1)

response = self.client.get(reverse('proposal_download', kwargs={'id': p.id}))
self.assertEqual(response.status_code, 200)
f = open('/tmp/proposal_bug245.pdf', 'w')
f.write(response.content)
f.close()
content = response.content.split("\n")
invariant_content = content[0:66] + content[67:110] + content[111:-1]
self.assertEquals(hashlib.md5("\n".join(invariant_content)).hexdigest(),
"72424ed26747855a7166a887b77eb75b")

def testContractDownloadPdf(self):
"""
Tests non-regression on pdf
Expand Down
2 changes: 1 addition & 1 deletion project/utils/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def add_headers(self, proposal, customer, document_date):

data.append([user_header,
'',
Paragraph(customer_header_content % (customer.name,
Paragraph(customer_header_content % (customer,
customer.address.street.replace("\n", "<br/>"),
customer.address.zipcode,
customer.address.city,
Expand Down

0 comments on commit 3f5573a

Please sign in to comment.