Ejemplo n.º 1
0
 def test_grand_total(self):
     from seantisinvoice.models import Customer
     from seantisinvoice.models import CustomerContact
     from seantisinvoice.models import Invoice
     from seantisinvoice.models import InvoiceItem
     # Customer
     contact = CustomerContact()
     contact.customer = Customer()
     # Invoice
     invoice = Invoice()
     invoice.contact = contact
     self.assertEquals(0, invoice.grand_total())
     item = InvoiceItem()
     item.amount = 100.0
     invoice.items.append(item)
     self.assertEquals(Decimal('100.00'), invoice.grand_total())
     invoice.tax = 7.6
     self.assertEquals(Decimal('107.60'), invoice.grand_total())
     item = InvoiceItem()
     item.amount = 60.0
     invoice.items.append(item)
     # Value is rounded
     self.assertEquals(Decimal('172.15'), invoice.grand_total())
     invoice.tax = None
     self.assertEquals(Decimal('160.00'), invoice.grand_total())
Ejemplo n.º 2
0
    def test_total(self):
        from seantisinvoice.models import Company
        from seantisinvoice.models import Customer
        from seantisinvoice.models import CustomerContact
        from seantisinvoice.models import Invoice
        from seantisinvoice.models import InvoiceItem

        company = Company()
        # Customer
        customer = Customer()
        contact = CustomerContact()
        contact.customer = customer
        # Invoice
        invoice = Invoice()
        invoice.company = company
        invoice.contact = contact

        item = InvoiceItem()
        item.invoice = invoice
        item.amount = 3000.0
        self.assertEquals(3000.0, item.total())
        # Hourly rate is defined on the company
        company.hourly_rate = 120.0
        item = InvoiceItem()
        item.invoice = invoice
        item.hours = 13
        self.assertEquals(1560.0, item.total())
        # Daily rate is also defined on the company
        company.daily_rate = 1300.0
        item = InvoiceItem()
        item.invoice = invoice
        item.days = 2.5
        self.assertEquals(3250.0, item.total())
        # Special daily rate on customer
        customer.special_daily_rate = 1100.0
        item = InvoiceItem()
        item.invoice = invoice
        item.days = 4.5
        self.assertEquals(4950.0, item.total())
        # Special hourly rate on customer
        customer.special_hourly_rate = 100.0
        item = InvoiceItem()
        item.invoice = invoice
        item.hours = 10
        self.assertEquals(1000.0, item.total())
Ejemplo n.º 3
0
 def test_sub_total(self):
     from seantisinvoice.models import Customer
     from seantisinvoice.models import CustomerContact
     from seantisinvoice.models import Invoice
     from seantisinvoice.models import InvoiceItem
     # Customer
     contact = CustomerContact()
     contact.customer = Customer()
     # Invoice
     invoice = Invoice()
     invoice.contact = contact
     item = InvoiceItem()
     item.amount = 1250.50
     invoice.items.append(item)
     self.assertEquals(1250.5, invoice.sub_total())
     item = InvoiceItem()
     item.amount = 120.0
     invoice.items.append(item)
     self.assertEquals(1370.5, invoice.sub_total())
Ejemplo n.º 4
0
    def test_tax_amount(self):
        from seantisinvoice.models import Customer
        from seantisinvoice.models import CustomerContact
        from seantisinvoice.models import Invoice
        from seantisinvoice.models import InvoiceItem
        # Customer
        contact = CustomerContact()
        contact.customer = Customer()
        # Invoice
        invoice = Invoice()
        invoice.contact = contact

        self.assertEquals(0, invoice.tax_amount())
        invoice.tax = 7.6
        self.assertEquals(0, invoice.tax_amount())
        item = InvoiceItem()
        item.amount = 100.0
        invoice.items.append(item)
        self.assertEquals(7.6, invoice.tax_amount())
Ejemplo n.º 5
0
 def _add_customer(self):
     from seantisinvoice.models import Customer
     from seantisinvoice.models import CustomerContact
     from seantisinvoice.models import DBSession
     session = DBSession()
     customer = Customer()
     customer.name = u'Customers Inc.'
     customer.address1 = u'Street'
     customer.postal_code = u'12234'
     customer.city = u'Dublin'
     session.add(customer)
     # Each customer needs at least one contact
     contact = CustomerContact()
     contact.first_name = u'Buck'
     contact.last_name = u'Mulligan'
     contact.title = u'Mr.'
     contact.customer = customer
     session.add(contact)
     session.flush()
     return customer