#90 feat(api): add payment method to sales.
This commit is contained in:
@@ -139,22 +139,7 @@ class TestJarReconcliation(TestCase):
|
||||
self.assertIn('total_cash_purchases', content['error'])
|
||||
|
||||
def test_create_reconciliation_with_purchases(self):
|
||||
url = '/don_confiao/reconciliate_jar'
|
||||
total_purchases = (11 * 72500) + (27 * 72500)
|
||||
data = {
|
||||
'date_time': '2024-12-02T21:07',
|
||||
'reconcilier': 'carlos',
|
||||
'total_cash_purchases': total_purchases,
|
||||
'cash_taken': total_purchases,
|
||||
'cash_discrepancy': 0,
|
||||
'cash_purchases': [
|
||||
self.purchase.id,
|
||||
self.purchase2.id,
|
||||
self.purchase.id,
|
||||
],
|
||||
}
|
||||
response = self.client.post(url, data=json.dumps(data).encode('utf-8'),
|
||||
content_type='application/json')
|
||||
response = self._create_reconciliation_with_purchase()
|
||||
|
||||
rawContent = response.content.decode('utf-8')
|
||||
content = json.loads(rawContent)
|
||||
@@ -226,6 +211,30 @@ class TestJarReconcliation(TestCase):
|
||||
self.assertEqual('2024-07-30T00:00:00Z',
|
||||
content['results'][0]['date_time'])
|
||||
|
||||
def test_get_single_reconciliation(self):
|
||||
createResponse = self._create_reconciliation_with_purchase()
|
||||
reconciliationId = json.loads(
|
||||
createResponse.content.decode('utf-8')
|
||||
)['id']
|
||||
self.assertGreater(reconciliationId, 0)
|
||||
|
||||
url = f'/don_confiao/api/reconciliate_jar/{reconciliationId}/'
|
||||
response = self.client.get(url, content_type='application/json')
|
||||
content = json.loads(
|
||||
response.content.decode('utf-8')
|
||||
)
|
||||
self.assertEqual(reconciliationId, content['id'])
|
||||
self.assertGreater(len(content['Sales']), 0)
|
||||
self.assertIn(
|
||||
self.purchase.id,
|
||||
[sale['id'] for sale in content['Sales']]
|
||||
)
|
||||
|
||||
self.assertIn(
|
||||
'CASH',
|
||||
[sale['payment_method'] for sale in content['Sales']]
|
||||
)
|
||||
|
||||
def _create_simple_reconciliation(self):
|
||||
reconciliation = ReconciliationJar()
|
||||
reconciliation.date_time = "2024-07-30"
|
||||
@@ -235,3 +244,21 @@ class TestJarReconcliation(TestCase):
|
||||
reconciliation.clean()
|
||||
reconciliation.save()
|
||||
return reconciliation
|
||||
|
||||
def _create_reconciliation_with_purchase(self):
|
||||
url = '/don_confiao/reconciliate_jar'
|
||||
total_purchases = (11 * 72500) + (27 * 72500)
|
||||
data = {
|
||||
'date_time': '2024-12-02T21:07',
|
||||
'reconcilier': 'carlos',
|
||||
'total_cash_purchases': total_purchases,
|
||||
'cash_taken': total_purchases,
|
||||
'cash_discrepancy': 0,
|
||||
'cash_purchases': [
|
||||
self.purchase.id,
|
||||
self.purchase2.id,
|
||||
self.purchase.id,
|
||||
],
|
||||
}
|
||||
return self.client.post(url, data=json.dumps(data).encode('utf-8'),
|
||||
content_type='application/json')
|
||||
|
||||
Reference in New Issue
Block a user