#69 feat(ReconciliationJar): send reconciliation jar from frontend

This commit is contained in:
2024-12-14 19:42:59 -05:00
parent f6620db6e2
commit 1b425542b3
6 changed files with 109 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.views.generic import ListView
from django.db import transaction
from django.middleware.csrf import get_token
from .models import (
Sale, SaleLine, Product, Customer, ProductCategory, Payment, PaymentMethods, ReconciliationJar)
@@ -204,7 +205,12 @@ def sales_for_reconciliation(request):
},
'total': sale.get_total(),
})
return JsonResponse(grouped_sales, safe=False)
response = JsonResponse(grouped_sales, safe=False)
csrf_token = get_token(request)
response['X-CSRFToken'] = csrf_token
response['Access-Control-Allow-Headers'] = 'X-CSRFToken'
response.set_cookie('csrftoken', csrf_token)
return response
def _mask_phone(phone):
digits = str(phone)[-3:] if phone else " " * 3