Reviewed-on: #28
This commit is contained in:
@@ -99,7 +99,8 @@ class ReconciliateJarView(APIView):
|
||||
|
||||
def _is_valid_total(self, purchases, total):
|
||||
calculated_total = sum(p.get_total() for p in purchases)
|
||||
return calculated_total == Decimal(total)
|
||||
return Decimal(calculated_total).quantize(Decimal('.0001')) == (
|
||||
Decimal(total).quantize(Decimal('.0001')))
|
||||
|
||||
def _get_other_purchases(self, other_totals):
|
||||
if not other_totals:
|
||||
|
||||
@@ -235,6 +235,47 @@ class TestJarReconcliation(TestCase):
|
||||
[sale['payment_method'] for sale in content['Sales']]
|
||||
)
|
||||
|
||||
def test_create_reconciliation_with_decimal_on_sale_lines(self):
|
||||
customer = Customer()
|
||||
customer.name = 'Consumidor final'
|
||||
customer.save()
|
||||
|
||||
product = Product()
|
||||
product.name = "Mantequilla natural gramos"
|
||||
product.price = "57.50"
|
||||
product.save()
|
||||
|
||||
purchase = Sale()
|
||||
purchase.customer = customer
|
||||
purchase.date = "2024-07-30"
|
||||
purchase.payment_method = 'CASH'
|
||||
purchase.clean()
|
||||
purchase.save()
|
||||
|
||||
line = SaleLine()
|
||||
line.sale = purchase
|
||||
line.product = product
|
||||
line.quantity = "0.24"
|
||||
line.unit_price = "57.50"
|
||||
line.save()
|
||||
|
||||
url = '/don_confiao/reconciliate_jar'
|
||||
total_purchases = 13.80
|
||||
data = {
|
||||
'date_time': '2024-12-02T21:07',
|
||||
'reconcilier': 'carlos',
|
||||
'total_cash_purchases': total_purchases,
|
||||
'cash_taken': total_purchases,
|
||||
'cash_discrepancy': 0,
|
||||
'cash_purchases': [purchase.id],
|
||||
}
|
||||
response = self.client.post(
|
||||
url, data=json.dumps(data).encode('utf-8'),
|
||||
content_type='application/json'
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
def _create_simple_reconciliation(self):
|
||||
reconciliation = ReconciliationJar()
|
||||
reconciliation.date_time = "2024-07-30"
|
||||
|
||||
Reference in New Issue
Block a user