#69 feat(ReconciliationJar): accept post creation.
This commit is contained in:
parent
bea08da17d
commit
f0201a86b2
@ -112,6 +112,22 @@ class TestJarReconcliation(TestCase):
|
|||||||
reconciliation.clean()
|
reconciliation.clean()
|
||||||
reconciliation.save()
|
reconciliation.save()
|
||||||
|
|
||||||
|
def test_create_reconciliation_with_purchases(self):
|
||||||
|
url = '/don_confiao/reconciliation_jar/create'
|
||||||
|
data = {
|
||||||
|
'date_time': '2024-12-02T21:07',
|
||||||
|
'cashman': 'carlos',
|
||||||
|
'total_cash_purchases': 45000,
|
||||||
|
'cash_taken': 44000,
|
||||||
|
'cash_discrepancy': 1000,
|
||||||
|
}
|
||||||
|
response = self.client.post(url, data, format='json')
|
||||||
|
rawContent = response.content.decode('utf-8')
|
||||||
|
content = json.loads(rawContent)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertIn('id', content)
|
||||||
|
|
||||||
def _create_simple_reconciliation(self):
|
def _create_simple_reconciliation(self):
|
||||||
reconciliation = ReconciliationJar()
|
reconciliation = ReconciliationJar()
|
||||||
reconciliation.date_time = "2024-07-30"
|
reconciliation.date_time = "2024-07-30"
|
||||||
|
@ -23,10 +23,10 @@ urlpatterns = [
|
|||||||
path("exportar_ventas_para_tryton",
|
path("exportar_ventas_para_tryton",
|
||||||
views.exportar_ventas_para_tryton,
|
views.exportar_ventas_para_tryton,
|
||||||
name="exportar_ventas_para_tryton"),
|
name="exportar_ventas_para_tryton"),
|
||||||
path("cuadrar_tarro", views.reconciliate_jar, name="reconciliate_jar"),
|
|
||||||
path("resumen_compra/<int:id>", views.purchase_summary, name="purchase_summary"),
|
path("resumen_compra/<int:id>", views.purchase_summary, name="purchase_summary"),
|
||||||
path("resumen_compra_json/<int:id>", views.purchase_json_summary, name="purchase_json_summary"),
|
path("resumen_compra_json/<int:id>", views.purchase_json_summary, name="purchase_json_summary"),
|
||||||
path("payment_methods/all/select_format", views.payment_methods_to_select, name="payment_methods_to_select"),
|
path("payment_methods/all/select_format", views.payment_methods_to_select, name="payment_methods_to_select"),
|
||||||
path('purchases/for_reconciliation', views.sales_for_reconciliation, name='sales_for_reconciliation'),
|
path('purchases/for_reconciliation', views.sales_for_reconciliation, name='sales_for_reconciliation'),
|
||||||
|
path('reconciliation_jar/create', views.reconciliate_jar, name='reconciliate_jar'),
|
||||||
path('api/', include(router.urls)),
|
path('api/', include(router.urls)),
|
||||||
]
|
]
|
||||||
|
@ -4,7 +4,7 @@ from django.views.generic import ListView
|
|||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
Sale, SaleLine, Product, Customer, ProductCategory, Payment, PaymentMethods)
|
Sale, SaleLine, Product, Customer, ProductCategory, Payment, PaymentMethods, ReconciliationJar)
|
||||||
from .forms import (
|
from .forms import (
|
||||||
ImportProductsForm,
|
ImportProductsForm,
|
||||||
ImportCustomersForm,
|
ImportCustomersForm,
|
||||||
@ -16,6 +16,7 @@ import csv
|
|||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class DecimalEncoder(json.JSONEncoder):
|
class DecimalEncoder(json.JSONEncoder):
|
||||||
@ -109,7 +110,21 @@ def import_customers(request):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def reconciliate_jar(request):
|
def reconciliate_jar(request):
|
||||||
pass
|
date_format = '%Y-%m-%dT%H:%M'
|
||||||
|
if request.method == 'POST':
|
||||||
|
content = request.POST.dict()
|
||||||
|
reconciliation = ReconciliationJar()
|
||||||
|
reconciliation.date_time = content.get('date_time')
|
||||||
|
reconciliation.cashman = content.get('cashman')
|
||||||
|
reconciliation.total_cash_purchases = float(content.get('total_cash_purchases'))
|
||||||
|
reconciliation.cash_taken = float(content.get('cash_taken'))
|
||||||
|
reconciliation.cash_discrepancy = float(content.get('cash_discrepancy'))
|
||||||
|
reconciliation.clean()
|
||||||
|
reconciliation.save()
|
||||||
|
return JsonResponse(
|
||||||
|
{'id': reconciliation.id},
|
||||||
|
safe=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def reconciliations(request):
|
def reconciliations(request):
|
||||||
|
Loading…
Reference in New Issue
Block a user