コード例 #1
0
ファイル: services.py プロジェクト: adux/acrolama
def book_create_invoice(book):
    book = book_get(book)
    obj = Invoice()
    obj.balance = "CR"  # Credit
    obj.book = book
    obj.status = "PE"  # Pending
    obj.to_pay = int(book.price.price_chf)
    # Default 10 days to pay
    obj.pay_till = datetime.datetime.now().date() + datetime.timedelta(
        days=book.price.days_till_pay)
    obj.notes = "\n Automatic created Invoice"
    obj.save()
コード例 #2
0
 def test_missing_branch(self):
     """
     The branch was not provided
     """
     with self.assertRaises(IntegrityError) as context:
         invoice = Invoice(vendor=get_or_create_vendor(),
                           invoice_num='INV0001',
                           date="2020-06-15",
                           total_amount=100.0,
                           document=create_document())
         invoice.save()
         self.fail("'test_missing_branch' did not get the expected error")
     self.assertTrue(
         'null value in column "branch_id" violates not-null constraint' in
         str(context.exception))
コード例 #3
0
 def test_missing_date(self):
     """
     The date was not provided
     """
     branch = get_or_create_branch()
     with self.assertRaises(IntegrityError) as context:
         invoice = Invoice(branch=branch,
                           vendor=get_or_create_vendor(store=branch.store),
                           invoice_num='INV0001',
                           total_amount=100.0,
                           document=create_document())
         invoice.save()
         self.fail("'test_missing_date' did not get the expected error")
     self.assertTrue(
         'null value in column "date" violates not-null constraint' in str(
             context.exception))
コード例 #4
0
 def test_missing_invoice_num(self):
     """
     The invoice_num was not provided
     """
     branch = get_or_create_branch()
     with self.assertRaises(ValidationError) as context:
         invoice = Invoice(branch=branch,
                           vendor=get_or_create_vendor(store=branch.store),
                           date="2020-06-15",
                           total_amount=100.0,
                           document=create_document())
         invoice.full_clean()
         invoice.save()
         self.fail("'test_invoice_num' did not get the expected error")
     self.assertTrue("{'invoice_num': ['This field cannot be blank.']}" in
                     str(context.exception))