Fakultas Ilmu Komputer UI

Commit aab3c788 authored by rayhan muzakki's avatar rayhan muzakki
Browse files

fix batch bug

parent 6c008477
{
"python.pythonPath": "/usr/bin/python"
"python.pythonPath": "C:\\Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
}
\ No newline at end of file
......@@ -72,10 +72,12 @@ def fill_dependent_transaction_item_fields(sender, instance, **_kwargs):
instance.product_name = None
instance.product_price = None
instance.product_pre_order = None
else:
instance.product_name = instance.product.name
instance.product_price = instance.product.price
instance.product_pre_order = instance.product.pre_order
@dispatch.receiver(signals.pre_save, sender=models.ProgramDonation)
......@@ -114,4 +116,7 @@ def fill_dependent_program_donation_fields(sender, instance, **_kwargs):
instance.transfer_destination_bank_account_number = (
instance.bank_account_transfer_destination.bank_account_number
)
\ No newline at end of file
......@@ -1199,6 +1199,7 @@ class ProductTest(rest_framework_test.APITestCase):
))
data = {
'name': 'Dummy',
'price':'4000'
}
response = request(
'PATCH',
......
......@@ -183,6 +183,12 @@ class CartCheckout(rest_framework_views.APIView):
payment_method=serializer.validated_data['payment_method'],
donation=serializer.validated_data['donation'],
transaction_status=transaction_status,
batch = (
None if serializer.validated_data['payment_method'] == 'TRF'
else models.Batch.objects.filter(
start_date__lte=timezone.now().date(),
end_date__gte=timezone.now().date()).first()
)
)
is_success = True
......@@ -631,10 +637,10 @@ class ProductList(generics.ListCreateAPIView):
price=serializer.validated_data['price'],
stock=serializer.validated_data['stock'],
modal=serializer.validated_data['modal'],
subcategory= models.Subcategory.objects.get(name=serializer.validated_data['subcategory']),
subcategory=models.Subcategory.objects.get(name=serializer.validated_data['subcategory']),
total_profit=0
)
product.profit= (product.price- product.modal)
product.profit= (product.price - product.modal)
product.save()
return response.Response(
{'id': product.id},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment