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_tax(self): """Test validating valid receipts.""" receipt = fixtures.ReceiptFactory( point_of_sales=models.PointOfSales.objects.first(), total_amount=121, ) fixtures.VatFactory(vat_type__code=5, 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.VatFactory(receipt=receipt) fixtures.VatFactory() self.assertEqual(receipt.total_vat, 21)
def test_multiple_vats(self): receipt = fixtures.ReceiptFactory() fixtures.VatFactory(receipt=receipt) fixtures.VatFactory(receipt=receipt) self.assertEqual(receipt.total_vat, 42)