feat: create a correct reconciliation jar.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
|
||||
from django.template import loader
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from .models import Sale, Product, ProductCategory, Payment
|
||||
from .forms import ImportProductsForm, PurchaseForm, LineaFormSet, ReconciliationJarForm
|
||||
@@ -71,17 +72,31 @@ def import_products(request):
|
||||
|
||||
|
||||
def reconciliate_jar(request):
|
||||
if request.method == 'POST':
|
||||
return HttpResponseRedirect("cuadres")
|
||||
|
||||
form = ReconciliationJarForm()
|
||||
summary = Payment.get_reconciliation_jar_summary()
|
||||
if request.method == 'POST':
|
||||
form = ReconciliationJarForm(request.POST)
|
||||
reconciliation = form.save()
|
||||
try:
|
||||
if form.is_valid():
|
||||
reconciliation.payment_set.set(summary.payments)
|
||||
reconciliation.manual_clean()
|
||||
form.save()
|
||||
return HttpResponseRedirect('cuadres')
|
||||
except Exception as e:
|
||||
reconciliation.payment_set.set({})
|
||||
reconciliation.delete()
|
||||
raise e
|
||||
else:
|
||||
form = ReconciliationJarForm()
|
||||
return render(
|
||||
request,
|
||||
"don_confiao/reconciliate_jar.html",
|
||||
{'summary': summary, 'form': form}
|
||||
)
|
||||
|
||||
def reconciliations(request):
|
||||
return HttpResponse('<h1>Reconciliaciones</h1>')
|
||||
|
||||
|
||||
def _categories_from_csv_string(categories_string, separator="&"):
|
||||
categories = categories_string.split(separator)
|
||||
|
||||
Reference in New Issue
Block a user