Fakultas Ilmu Komputer UI

Commit b72011d9 authored by Rayhan Muzakki's avatar Rayhan Muzakki 💬
Browse files

Merge branch 'bugfixing' into 'staging'

Bugfixing

See merge request ppl-fasilkom-ui/itproject-2020/group-b/pilar-backend!96
parents a6f5a145 72180ce0
{
"python.pythonPath": "/usr/bin/python"
"python.pythonPath": "C:\\Users\\Rayhan Muzakki\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
}
\ No newline at end of file
......@@ -99,7 +99,7 @@ SHIPMENT_CONFIG_DATA = {
BATCH_DATA = {
'batch_name': 'Batch 1',
'start_date': '2020-10-08',
'end_date': '2020-10-15',
'start_date': '2020-12-12',
'end_date': '2020-12-18',
'shipping_cost': '60000',
}
......@@ -51,8 +51,8 @@ def fill_dependent_transaction_fields(sender, instance, **_kwargs):
instance.transfer_destination_bank_account_number = (
instance.bank_account_transfer_destination.bank_account_number
)
if (obj is not None) and (instance.transaction_status == '002'):
if (instance.transaction_status == '002'):
if instance.batch is None:
instance.batch = utils.get_batch_transaction(instance)
instance.batch_name = instance.batch.batch_name
......@@ -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
......@@ -292,6 +292,7 @@ class CartTest(rest_framework_test.APITestCase): # pylint: disable=too-many-inst
))
self.shopping_cart = models.ShoppingCart.objects.get(user=self.user)
self.proof_of_payment_file = create_tmp_image()
self.batch = models.Batch.objects.create(**seeds.BATCH_DATA)
def test_cart_checkout_success(self):
data = {
......@@ -1199,6 +1200,7 @@ class ProductTest(rest_framework_test.APITestCase):
))
data = {
'name': 'Dummy',
'price':'4000'
}
response = request(
'PATCH',
......
......@@ -178,11 +178,19 @@ class CartCheckout(rest_framework_views.APIView):
start_date__lte=timezone.now().date(),
end_date__gte=timezone.now().date()).first()
)
transaction = models.Transaction.objects.create(
user=user,
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 +639,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},
......@@ -650,6 +658,8 @@ class ProductDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = models.Product.objects.all()
serializer_class = api_serializers.ProductSerializer
class ProgramProgressList(generics.ListCreateAPIView):
permission_classes = [
api_permissions.IsAdminUserOrReadOnly,
......
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