def setUp(self): super().setUp() self.receipt = fixtures.ReceiptFactory( document_type__code=80, point_of_sales=models.PointOfSales.objects.first(), ) fixtures.VatFactory(vat_type__code=5, receipt=self.receipt) fixtures.TaxFactory(tax_type__code=3, receipt=self.receipt)
def _bad_receipt(self): receipt = fixtures.ReceiptFactory( point_of_sales=models.PointOfSales.objects.first(), document_type__code=80, ) fixtures.VatFactory(vat_type__code=5, receipt=receipt) fixtures.TaxFactory(tax_type__code=3, receipt=receipt) return receipt
def test_validation_good_without_vat(self): """Test validating valid receipts.""" receipt = fixtures.ReceiptFactory( point_of_sales=models.PointOfSales.objects.first(), receipt_type__code=11, total_amount=109, ) fixtures.TaxFactory(tax_type__code=3, receipt=receipt) errs = models.Receipt.objects.all().validate() self.assertEqual(len(errs), 0) self.assertEqual( receipt.validation.result, models.ReceiptValidation.RESULT_APPROVED, ) self.assertEqual(models.ReceiptValidation.objects.count(), 1)
def test_validation_with_observations(self): receipt = fixtures.ReceiptFactory( document_number=20291144404, document_type__code=80, point_of_sales=models.PointOfSales.objects.first(), receipt_type__code=1, ) fixtures.VatFactory(vat_type__code=5, receipt=receipt) fixtures.TaxFactory(tax_type__code=3, receipt=receipt) errs = models.Receipt.objects.all().validate() self.assertEqual(len(errs), 0) self.assertEqual( receipt.validation.result, models.ReceiptValidation.RESULT_APPROVED, ) self.assertEqual(models.ReceiptValidation.objects.count(), 1) self.assertEqual(models.Observation.objects.count(), 1) self.assertEqual(receipt.validation.observations.count(), 1)
def test_proper_filtering(self): receipt = fixtures.ReceiptFactory() fixtures.TaxFactory(receipt=receipt) fixtures.TaxFactory() self.assertEqual(receipt.total_tax, 9)
def test_multiple_taxes(self): receipt = fixtures.ReceiptFactory() fixtures.TaxFactory(receipt=receipt) fixtures.TaxFactory(receipt=receipt) self.assertEqual(receipt.total_tax, 18)