예제 #1
0
파일: owner.py 프로젝트: manibhushan05/tms
    def retrieve(self, request, pk=None):
        vehicle = get_or_none(Vehicle, id=pk)
        if not isinstance(vehicle, Vehicle):
            return Response({"error": "Vehicle does not exist"}, status=status.HTTP_404_NOT_FOUND)

        vehicle_serializers = VehicleSerializer(vehicle)
        if is_fms_user(request.user):
            vehicle_serializers = FMSVehicleSerializer(vehicle)
        return Response(template_name='team/registrations/update-vehicle.html', data=vehicle_serializers.data,
                        status=status.HTTP_200_OK)
예제 #2
0
파일: utils.py 프로젝트: manibhushan05/tms
 def retrieve(self, request, pk=None):
     bank = get_or_none(Bank, id=pk)
     if isinstance(bank, Bank):
         bank_serializer = BankSerializer(bank)
         return Response(
             template_name='team/registrations/update-bank-account.html',
             data=bank_serializer.data,
             status=status.HTTP_200_OK)
     return Response({"error": "Bank does not exist"},
                     status=status.HTTP_404_NOT_FOUND)
예제 #3
0
def detailed_full_booking_page_data(data):
    from_city = get_or_none(City, id=data.get('from_city', None))
    to_city = get_or_none(City, id=data.get('to_city', None))
    customer_placed_order = get_or_none(Sme, id=data.get('customer_placed_order', None))
    customer_billed = get_or_none(Sme, id=data.get('customer_to_be_billed', None))
    vehicle_category = get_or_none(VehicleCategory, id=data.get('vehicle_category_id', None))
    truck_driver = get_or_none(Driver, id=data.get('truck_driver_id', None))
    # broker = get_or_none(Broker, id=data.get('supplier_id', None))
    # owner = get_or_none(Owner, id=data.get('truck_owner_id', None))
    source_office_obj = get_or_none(AahoOffice, id=data.get('source_office', None))
    destination_office_obj = get_or_none(AahoOffice, id=data.get('destination_office', None))
    if isinstance(customer_placed_order, Sme):
        consignor = customer_placed_order.consignorconsignee_set.filter(type='consignor').last()
        consignee = customer_placed_order.consignorconsignee_set.filter(type='consignee').last()
        if isinstance(consignor, ConsignorConsignee):
            data['consignor'] = ConsignorConsigneeSerializer(consignor).data
        if isinstance(consignee, ConsignorConsignee):
            data['consignee'] = ConsignorConsigneeSerializer(consignee).data

    data['from_city'] = {'id': from_city.id, 'name': from_city.name, 'state': from_city.state} if isinstance(from_city,
                                                                                                             City) else {}
    data['to_city'] = {'id': to_city.id, 'name': to_city.name, 'state': to_city.state} if isinstance(to_city,
                                                                                                     City) else {}
    data['customer_placed_order'] = {'id': customer_placed_order.id,
                                     'name': customer_placed_order.get_name()} if isinstance(customer_placed_order,
                                                                                             Sme) else {}
    data['customer_billed'] = {'id': customer_billed.id,
                               'name': customer_billed.get_name()} if isinstance(customer_billed,
                                                                                 Sme) else {}
    data['vehicle_category'] = {'id': vehicle_category.id, 'type': vehicle_category.vehicle_type} \
        if isinstance(vehicle_category, VehicleCategory) else {}
    data['truck_driver'] = {'id': truck_driver.id, 'name': truck_driver.name} \
        if isinstance(truck_driver, Driver) else {}
    # data['supplier'] = {'id': broker.id, 'name': broker.get_name()} \
    #     if isinstance(broker, Broker) else {}
    # data['owner'] = {'id': owner.id, 'name': owner.get_name()} \
    #     if isinstance(owner, Owner) else {}
    data['source_office_obj'] = {'id': source_office_obj.id, 'name': source_office_obj.branch_name} \
        if isinstance(source_office_obj, AahoOffice) else {}
    data['destination_office_obj'] = {'id': destination_office_obj.id, 'name': destination_office_obj.branch_name} \
        if isinstance(destination_office_obj, AahoOffice) else {}

    data['supplier_deductions'] = supplier_deductions(
        source_office=data.get('source_office', None),
        destination_office=data.get('destination_office', None),
        supplier_charged_weight=data.get('supplier_charged_weight', None),
        supplier_rate=data.get('supplier_rate', None),
        company=data.get('customer_placed_order', None),
        gst_liability=data.get('gst_liability', None),
        supplier=data.get('supplier_id', None),
    )
    return data
예제 #4
0
 def retrieve(self, request, pk=None):
     user = get_or_none(User, id=pk)
     if not isinstance(user, User):
         return Response({"error": "User does not exist"},
                         status=status.HTTP_404_NOT_FOUND)
     user_serializers = UserSerializer(user).data
     if Profile.objects.filter(user=user).exists():
         profile_serializer = ProfileSerializer(user.profile).data
     else:
         profile_serializer = {}
     user_serializers["profile"] = profile_serializer
     return Response(user_serializers, status=status.HTTP_200_OK)
예제 #5
0
def detailed_commission_booking_page_data(data):
    from_city = get_or_none(City, id=data.get('from_city', None))
    to_city = get_or_none(City, id=data.get('to_city', None))
    customer_placed_order = get_or_none(Sme, id=data.get('customer_placed_order', None))
    data['from_city'] = {
        'id': from_city.id, 'name': from_city.name, 'state': from_city.state} if isinstance(from_city, City) else {}
    data['to_city'] = {
        'id': to_city.id, 'name': to_city.name, 'state': to_city.state} if isinstance(to_city, City) else {}
    data['customer_placed_order'] = {
        'id': customer_placed_order.id, 'name': customer_placed_order.get_name()} if isinstance(customer_placed_order,
                                                                                                Sme) else {}
    data['supplier_deductions'] = supplier_deductions(
        source_office=data.get('source_office', None),
        destination_office=data.get('destination_office', None),
        supplier_charged_weight=data.get('supplier_charged_weight', None),
        supplier_rate=data.get('supplier_rate', None),
        company=data.get('customer_placed_order', None),
        gst_liability=data.get('gst_liability', None),
        supplier=data.get('supplier_id', None),
    )
    return data
예제 #6
0
def parse_pending_inward_adjustment_data(data):
    credit_note_number = ', '.join(
        CreditNoteCustomer.objects.filter(
            id__in=[row.get('id') for row in data.get('cnc', [])]).values_list(
                'credit_note_number', flat=True))
    debit_note_number = ', '.join(
        DebitNoteCustomer.objects.filter(
            id__in=[row.get('id') for row in data.get('dnc', [])]).values_list(
                'debit_note_number', flat=True))
    pending_inward = get_or_none(PendingInwardPaymentEntry,
                                 id=data.get('payment_id', None))
    bookings_id = []
    inward_payments_data = []
    if isinstance(pending_inward, PendingInwardPaymentEntry):
        for booking in data.get('bookings', []):
            if to_int(booking.get('amount', None)) != 0:
                remarks_data = []
                remarks = booking.get('remarks') if booking.get(
                    'remarks', None) else data.get(
                        'common_inward_payment_remarks', None)
                if remarks:
                    remarks_data.append(remarks)
                if credit_note_number:
                    remarks_data.append(credit_note_number)
                if debit_note_number:
                    remarks_data.append(debit_note_number)
                bookings_id.append(booking.get('booking_id', None))
                inward_payments_data.append({
                    'booking_id': [booking.get('booking_id', None)],
                    'received_from':
                    pending_inward.customer.get_name() if
                    pending_inward.customer else pending_inward.customer_name,
                    'actual_amount':
                    to_int(booking.get('amount', 0)),
                    'tds':
                    to_int(booking.get('tds', 0)),
                    'payment_mode':
                    pending_inward.payment_mode,
                    'payment_date':
                    pending_inward.payment_date,
                    'invoice_number':
                    booking.get('invoice_number', None),
                    'trn':
                    pending_inward.trn,
                    'remarks':
                    ', '.join(remarks_data),
                    'created_by':
                    data.get('username', None),
                    'changed_by':
                    data.get('username', None),
                })
    return inward_payments_data, bookings_id
예제 #7
0
    def retrieve(self, request, pk=None):
        cheque_file = get_or_none(ChequeFile, id=pk)

        if isinstance(cheque_file, ChequeFile):
            cheque_file_serializer = ChequeFileSerializer(cheque_file)
            # if request.META["CONTENT_TYPE"] == "application/json":
            return Response(cheque_file_serializer.data,
                            status=status.HTTP_200_OK)
            # else:
            #     return HttpResponseRedirect(redirect_to='/page/uncredited-cheques/')

        return Response({"error": "ChequeFile does not exist"},
                        status=status.HTTP_404_NOT_FOUND)
예제 #8
0
 def commission_booking_invoice(self, request):
     customer = get_or_none(Sme, id=request.GET.get('customer_to_be_billed'))
     bookings = ManualBooking.objects.filter(id__in=request.GET.getlist('booking_id[]'))
     if not bookings.exists() or not isinstance(customer, Sme):
         return HttpResponseRedirect('/team/commission-invoice-data-page/')
     invoice_data = get_invoice_data(bookings, 'commission')
     comment_list = get_comment_list(bookings, invoice_data)
     return Response(template_name='team/invoices/commission_booking_invoice.html', status=status.HTTP_200_OK,
                     data={'booking_data': invoice_data, 'customer': customer,
                           'gst_liability': bookings.last().gst_liability,
                           'booking_ids': ','.join(map(str, bookings.values_list('id', flat=True))),
                           'comment_list': comment_list,
                           'invoice_amount_data': get_amount_data(bookings=bookings, booking_type='full'),
                           })
예제 #9
0
파일: owner.py 프로젝트: manibhushan05/tms
 def get_queryset(self):
     if is_fms_user(user=self.request.user):
         broker = Broker.objects.get(name=self.request.user)
         bv_id = broker.broker_vehicle.exclude(deleted=True).values_list('vehicle_id', flat=True)
         return Vehicle.objects.filter(id__in=bv_id).exclude(deleted=True)
     elif is_sme_user(user=self.request.user):
         from team.models import ManualBooking
         sme = get_or_none(Sme, name=self.request.user)
         if isinstance(sme, Sme):
             vehicles_id = ManualBooking.objects.filter(company=sme).exclude(booking_status='cancelled').values_list(
                 'vehicle_id', flat=True)
             return Vehicle.objects.filter(id__in=list(set(list(vehicles_id))))
         return Vehicle.objects.none()
     return Vehicle.objects.exclude(deleted=True)
예제 #10
0
 def retrieve(self, request, pk):
     user = get_or_none(User, id=pk)
     if not isinstance(user, User):
         return Response({"error": "User does not exist"},
                         status=status.HTTP_404_NOT_FOUND)
     if Profile.objects.filter(user=user).exists():
         profile_serializer = ProfileSerializer(user.profile).data
         return Response(profile_serializer,
                         status=status.HTTP_202_ACCEPTED)
     else:
         return Response(
             {
                 "error":
                 "User's Profile does not exist. Please create it first"
             },
             status=status.HTTP_400_BAD_REQUEST)
예제 #11
0
 def post(self, request):
     token = request.data.get('token')
     token_obj = get_or_none(Token, key=token)
     if isinstance(token_obj, Token) and isinstance(token_obj.user, User):
         user_serializer = UserSerializer(token_obj.user)
         return Response(
             {
                 'status': 'success',
                 'msg': 'Login Successful',
                 'token': token_obj.key,
                 'data': user_serializer.data,
                 'status_code': status.HTTP_200_OK
             },
             status=status.HTTP_200_OK)
     return error_response(status=status.HTTP_400_BAD_REQUEST,
                           msg='User doesnot exits',
                           data={})
예제 #12
0
 def resubmit(self, request):
     resubmission_remark = request.data.get('resubmission_remark')
     booking_id = request.data.get('booking_id')
     resubmitted_pod = request.data.get('resubmitted_pod')
     if not resubmission_remark:
         return error_response(msg="Remarks is mandatory",
                               status=status.HTTP_400_BAD_REQUEST,
                               data={})
     if not booking_id:
         return error_response(msg="Booking id is required",
                               status=status.HTTP_400_BAD_REQUEST,
                               data={})
     booking = get_or_none(ManualBooking, booking_id=booking_id)
     if not isinstance(booking, ManualBooking):
         return error_response(msg="BAD request",
                               status=status.HTTP_400_BAD_REQUEST,
                               data={})
     if not PODFile.objects.filter(booking=booking).exists():
         return error_response(msg="BAD Request",
                               status=status.HTTP_400_BAD_REQUEST,
                               data={})
     PODFile.objects.filter(id__in=resubmitted_pod).update(verified=False,
                                                           is_valid=False)
     PODFile.objects.filter(booking=booking).exclude(
         id__in=resubmitted_pod).update(verified=True, is_valid=False)
     booking.pod_status = 'unverified'
     booking.save()
     booking_unloaded = check_booking_status(booking, 'unloaded')
     if booking_unloaded:
         unloaded_obj = get_booking_status_mapping_object(
             booking, 'unloaded')
         if unloaded_obj.created_by == User.objects.get(username='******') and \
                 unloaded_obj.changed_by == User.objects.get(username='******'):
             update_booking_status(booking, 'unloaded', 'in_progress',
                                   User.objects.get(username='******'))
     booking_pod_uploaded = check_booking_status(booking, 'pod_uploaded')
     if not booking_pod_uploaded:
         create_new_booking_status(booking, 'pod_uploaded', request.user)
     else:
         update_booking_status(booking, 'pod_uploaded', 'in_progress',
                               request.user)
     return success_response(msg="success",
                             status=status.HTTP_200_OK,
                             data={})
예제 #13
0
def parse_driver_registration_data(data):
    if 'driver_phone' in data and data.get('driver_phone'):
        phone = data.get('driver_phone')[0].get('phone', None)
    else:
        phone = None
    if 'dl_city' in data:
        city = get_or_none(City, id=data.get('dl_city'))
        if isinstance(city, City):
            driving_licence_location = city.name
        else:
            driving_licence_location = None
    else:
        driving_licence_location = None

    parsed_data = {
        "user": {
            "username": generate_username(),
            "password": '******'
        },
        'profile': {
            'name': data.get('driver_name', None),
            'phone': phone
        },
        'driver': {
            'driving_licence_number': data.get('dl_number', None),
            'driving_licence_validity': data.get('dl_validity', None),
            'route': data.get('driver_route', None),
            'created_by': data.get('created_by', None),
            'changed_by': data.get('changed_by', None),
            'driving_licence_location': driving_licence_location,
        },
        'driver_phone': [{
            'phone': row.get('phone', None),
            'created_by': data.get('created_by', None),
            'changed_by': data.get('changed_by', None)
        } for row in data.get('driver_phone', [])]
    }
    return parsed_data
예제 #14
0
파일: owner.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username

        fuel_card = get_or_none(FuelCard, id=pk)
        if not isinstance(fuel_card, FuelCard):
            return Response({"error": "Fuel Card does not exist"}, status=status.HTTP_404_NOT_FOUND)
        fuel_card_serializers = FuelCardSerializer(instance=fuel_card, data=request.data)
        if fuel_card_serializers.is_valid():
            fuel_card_serializers.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "Fuel Card Updated",
                "data": fuel_card_serializers.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "Fuel Card not Updated",
            "data": fuel_card_serializers.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #15
0
파일: owner.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username

        vehicle = get_or_none(Vehicle, id=pk)
        if not isinstance(vehicle, Vehicle):
            return Response({"error": "Vehicle does not exist"}, status=status.HTTP_404_NOT_FOUND)
        vehicle_serializers = VehicleSerializer(instance=vehicle, data=request.data)
        if vehicle_serializers.is_valid():
            vehicle_serializers.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "Vehicle Updated",
                "data": vehicle_serializers.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "Vehicle not Updated",
            "data": vehicle_serializers.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #16
0
파일: owner.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username

        route = get_or_none(Route, id=pk)
        if not isinstance(route, Route):
            return Response({"error": "Route does not exist"}, status=status.HTTP_404_NOT_FOUND)
        route_serializer = RouteSerializer(instance=route, data=request.data)
        if route_serializer.is_valid():
            route_serializer.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "Route Updated",
                "data": route_serializer.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "Route not Updated",
            "data": route_serializer.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #17
0
파일: utils.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username
        bank = get_or_none(Bank, id=pk)
        if not isinstance(bank, Bank):
            return Response({"error": "Bank does not exist"},
                            status=status.HTTP_404_NOT_FOUND)
        bank_serializer = BankSerializer(bank, data=request.data)

        if bank_serializer.is_valid():
            bank_serializer.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "Bank Updated",
                "data": bank_serializer.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "Bank not Updated",
            "data": bank_serializer.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #18
0
파일: utils.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username
        city = get_or_none(City, id=pk)
        if not isinstance(city, City):
            return Response({"error": "City does not exist"},
                            status=status.HTTP_404_NOT_FOUND)
        city_serializer = CitySerializer(city, data=request.data)

        if city_serializer.is_valid():
            city_serializer.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "City Updated",
                "data": city_serializer.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "City not Updated",
            "data": city_serializer.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #19
0
파일: utils.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username
        address = get_or_none(Address, id=pk)
        if not isinstance(address, Address):
            return Response({"error": "Address does not exist"},
                            status=status.HTTP_404_NOT_FOUND)
        address_serializer = AddressSerializer(address, data=request.data)

        if address_serializer.is_valid():
            address_serializer.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "Address Updated",
                "data": address_serializer.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "Address not Updated",
            "data": address_serializer.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #20
0
파일: owner.py 프로젝트: manibhushan05/tms
    def update(self, request, pk=None):
        request.data["changed_by"] = self.request.user.username

        owner = get_or_none(Owner, id=pk)
        if not isinstance(owner, Owner):
            return Response({"error": "Owner does not exist"}, status=status.HTTP_404_NOT_FOUND)

        owner_serializer = OwnerSerializer(instance=owner, data=request.data)
        if owner_serializer.is_valid():
            owner_serializer.save()
            response = {
                "status_code": status.HTTP_202_ACCEPTED,
                "status": "Success",
                "msg": "Owner Updated",
                "data": owner_serializer.data
            }
            return Response(data=response, status=status.HTTP_202_ACCEPTED)
        response = {
            "status_code": status.HTTP_400_BAD_REQUEST,
            "status": "Error",
            "msg": "Owner not Updated",
            "data": owner_serializer.errors
        }
        return Response(data=response, status=status.HTTP_400_BAD_REQUEST)
예제 #21
0
def adjust_pending_inward_payment_data():
    data = {
        'common_inward_payment_remarks':
        '1233',
        'payment_id':
        '112',
        'booking': [{
            'booking_id': '2326',
            'amount': '16000',
            'tds': '0',
            'balance': '0',
            'remarks': '23'
        }, {
            'booking_id': '2846',
            'amount': '2950',
            'tds': '0',
            'balance': '0',
            'remarks': '443'
        }, {
            'booking_id': '2878',
            'amount': '44100',
            'tds': '0',
            'balance': '0',
            'remarks': '222'
        }, {
            'booking_id': '2907',
            'amount': '44100',
            'tds': '0',
            'balance': '0',
            'remarks': '222'
        }, {
            'booking_id': '2905',
            'amount': '18850',
            'tds': '0',
            'balance': '33650',
            'remarks': '22122'
        }, {
            'booking_id': '2906',
            'amount': '0',
            'tds': '0',
            'balance': '0'
        }, {
            'booking_id': '2920',
            'amount': '0',
            'tds': '0',
            'balance': '0'
        }]
    }
    parsed_data = []
    pending_payment = get_or_none(PendingInwardPaymentEntry,
                                  id=data.get('payment_id'))
    if isinstance(pending_payment, PendingInwardPaymentEntry):
        received_from = pending_payment.customer.get_name() if isinstance(
            pending_payment.customer, Sme) else None,
        trn = pending_payment.trn
        payment_mode = pending_payment.payment_mode
        payment_date = pending_payment.payment_date
    else:
        received_from = None,
        trn = None
        payment_mode = None
        payment_date = None

    for row in data.get('booking', []):
        if to_int(row['amount']) > 0:
            parsed_data.append({
                'booking_id': [row.get('booking_id')],
                'received_from':
                received_from,
                'tds':
                to_float(row['tds']),
                'actual_amount':
                to_float(row['amount']),
                'expected_amount':
                to_float(row['amount']),
                'payment_mode':
                payment_mode,
                'trn':
                trn,
                'remarks':
                row.get('remarks') if row.get('remarks', None) else data.get(
                    'common_inward_payment_remarks', None),
                'payment_date':
                payment_date
            })
예제 #22
0
def booking_create_data(data):
    customer = get_or_none(Sme, id=data.get('customer_placed_order'))
    source_office = get_or_none(AahoOffice, id=data.get('source_office'))
    destination_office = get_or_none(AahoOffice, id=data.get('destination_office'))
    if (isinstance(source_office, AahoOffice) and isinstance(destination_office, AahoOffice)) and (
            source_office == '2' or source_office == '3' or destination_office == '2' or destination_office == '3'):
        is_advance = data.get('is_print_payment_mode_instruction')
    else:
        is_advance = None

    shipment_date = None if not data.get('shipment_datetime') or is_blank(
        data.get('shipment_datetime')) else datetime.strptime(
        data.get('shipment_datetime'), '%d-%b-%Y %I:%M %p')

    update_vehicles = update_vehicle(
        vehicle_number=data.get('vehicle_number', None),
        supplier_id=data.get('supplier_id', None),
        owner_id=data.get('truck_owner_id', None),
        driver_id=data.get('truck_driver_id', None),
        vehicle_category_id=data.get('vehicle_category_id', None),
        user=data.get('user', None)
    )
    supplier = get_or_none(Supplier, id=data.get('supplier_id', None))
    owner = get_or_none(Supplier, id=data.get('truck_owner_id', None))
    driver = get_or_none(Driver, id=data.get('truck_driver_id', None))
    vehicle = get_or_none(Vehicle, vehicle_number=compare_format(data.get('vehicle_number', None)))
    vehicle_type = get_or_none(VehicleCategory, id=data.get('vehicle_category_id', None))

    generate_booking_and_finish = data.get('generate-booking-and-finish')
    if generate_booking_and_finish == 'quick_full_booking':
        booking_id = full_booking_id()
        deductions = supplier_deductions(
            source_office=data.get('source_office', None),
            destination_office=data.get('destination_office', None),
            supplier_charged_weight=data.get('supplier_charged_weight', None),
            supplier_rate=data.get('supplier_rate', None),
            company=data.get('customer_placed_order', None),
            gst_liability=data.get('gst_liability', None),
            supplier=data.get('supplier_id', None),
        )
        commission = deductions['commission']['amount']
        lr_cost = deductions['lr_cost']['amount']
        deduction_for_advance = deductions['deduction_for_advance']['amount']
        deduction_for_balance = deductions['deduction_for_balance']['amount']
        amount_to_owner = to_int(data.get('total_amount_to_owner', 0)) - (
                commission + lr_cost + deduction_for_advance + deduction_for_balance)
    elif generate_booking_and_finish == 'quick_commission_booking':
        booking_id = commission_booking_id()
        commission = 0
        lr_cost = 0
        deduction_for_advance = 0
        deduction_for_balance = 0
        amount_to_owner = to_int(data.get('total_amount_to_owner', 0)) - (
                commission + lr_cost + deduction_for_advance + deduction_for_balance)

    elif generate_booking_and_finish == 'detailed_full_booking' or generate_booking_and_finish == 'detailed_commission_booking':
        if generate_booking_and_finish == 'detailed_commission_booking':
            booking_id = commission_booking_id()
        else:
            booking_id = full_booking_id()
        commission = data.get('commission')
        lr_cost = data.get('lr_cost')
        deduction_for_advance = data.get('deduction_for_advance')
        deduction_for_balance = data.get('deduction_for_balance')
        amount_to_owner = to_int(data.get('freight_owner', 0)) + (
                to_int(data.get('loading_charge', 0)) + to_int(data.get('unloading_charge', 0)) + to_int(
            data.get('detention_charge')) + to_int(
            data.get('additional_charges_for_owner', 0))) - (
                                  commission + lr_cost + deduction_for_advance + deduction_for_balance + to_int(
                              data.get('other_deduction', 0)))

    else:
        booking_id = full_booking_id()
        commission = data.get('commission', 0)
        lr_cost = data.get('lr_cost', 0)
        deduction_for_advance = data.get('deduction_for_advance', 0)
        deduction_for_balance = data.get('deduction_for_balance', 0)
        amount_to_owner = to_int(data.get('total_amount_to_owner', 0)) + (
                to_int(data.get('loading_charge')) + to_int(data.get('unloading_charge')) + to_int(
            data.get('detention_charge')) + to_int(data.get('additional_charges_for_owner'))) - (
                                  commission + lr_cost + deduction_for_advance + deduction_for_balance)

    from_city = get_or_none(City, id=data.get('from_city'))
    if isinstance(from_city, City):
        from_city_fk = from_city
        from_city = from_city.name

    else:
        from_city = None
        from_city_fk = None
    to_city = get_or_none(City, id=data.get('to_city'))
    if isinstance(to_city, City):
        to_city_fk = to_city
        to_city = to_city.name
    else:
        to_city = None
        to_city_fk = None
    consignor_city = get_or_none(City, id=data.get('consignor_city'))
    if isinstance(consignor_city, City):
        consignor_city_fk = consignor_city
        consignor_city = consignor_city.name
    else:
        consignor_city_fk = None
        consignor_city = None
    consignee_city = get_or_none(City, id=data.get('consignee_city'))
    if isinstance(consignee_city, City):
        consignee_city_fk = consignee_city
        consignee_city = consignee_city.name
    else:
        consignee_city_fk = None
        consignee_city = None

    if get_contract_party_rate(from_city=from_city_fk, to_city=to_city_fk,
                               customer=customer):
        party_rate = get_contract_party_rate(from_city=from_city_fk, to_city=to_city_fk, customer=customer)
        party_weight = to_float(data.get('charged_weight'))
        total_amount_to_party = party_rate * party_weight
    else:
        party_rate = data.get('party_rate')
        party_weight = to_float(data.get('charged_weight'))
        total_amount_to_party = data.get('total_amount_to_party', 0)
    data = {
        'booking_id': booking_id,
        'company': data.get('customer_placed_order', None),
        'company_code': customer.company_code if isinstance(customer, Sme) else None,
        'customer_to_be_billed_to': data.get('customer_to_be_billed', None),
        'to_be_billed_to': data.get('to_be_billed_to', None),
        'source_office': source_office.id if isinstance(source_office, AahoOffice) else None,
        'destination_office': destination_office.id if isinstance(destination_office, AahoOffice) else None,
        'supplier': data.get('supplier_id', None),
        'owner_supplier': data.get('truck_owner_id', None),
        'invoice_status': data.get('invoice_status', None),
        'truck_broker_owner_name': supplier.name if isinstance(supplier, Supplier) else None,
        'truck_broker_owner_phone': supplier.phone if isinstance(supplier, Supplier) else None,
        'truck_owner_name': owner.name if isinstance(owner, Supplier) else None,
        'truck_owner_phone': owner.phone if isinstance(owner, Supplier) else None,
        'driver_supplier': data.get('truck_driver_id', None),
        'driver_name': driver.name if isinstance(driver, Driver) else None,
        'driver_phone': driver.phone if isinstance(driver, Driver) else None,
        'driver_dl_number': driver.driving_licence_number if isinstance(driver,
                                                                        Driver) and driver.driving_licence_number else None,
        'driver_dl_validity': driver.driving_licence_validity if isinstance(driver, Driver) else None,
        'is_advance': data.get('is_print_payment_mode_instruction', None),
        'consignor_name': data.get('consignor_name', None),
        'consignor_address': data.get('consignor_address', None),
        'consignor_city': consignor_city,
        'consignor_city_fk': data.get('consignor_city', None),
        'consignor_pin': data.get('consignor_pin', None),
        'consignor_phone': data.get('consignor_phone', None),
        'consignor_gstin': data.get('consignor_gstin', None),
        'consignee_name': data.get('consignee_name', None),
        'consignee_address': data.get('consignee_address', None),
        'consignee_city': consignee_city,
        'consignee_city_fk': data.get('consignee_city', None),
        'consignee_pin': data.get('consignee_pin', None),
        'consignee_phone': data.get('consignee_phone', None),
        'consignee_gstin': data.get('consignee_gstin', None),
        'party_invoice_number': data.get('party_invoice_number', None),
        'party_invoice_date': data.get('party_invoice_date'),
        'party_invoice_amount': to_float(data.get('party_invoice_amount')),
        'road_permit_number': data.get('road_permit_number', None),
        'shipment_date': shipment_date.date() if isinstance(shipment_date, datetime) else None,
        'billing_type': data.get('billing_type', None),
        'number_of_package': data.get('number_of_package', None),
        'material': data.get('material', None),
        'from_city': from_city,
        'from_city_fk': data.get('from_city', None),
        'to_city': to_city,
        'to_city_fk': data.get('to_city', None),
        'liability_of_service_tax': data.get('liability_of_service_tax', None),
        'lorry_number': vehicle.vehicle_number if isinstance(vehicle, Vehicle) else None,
        'vehicle': vehicle.id if isinstance(vehicle, Vehicle) else None,
        'type_of_vehicle': vehicle_type.vehicle_category if vehicle_type else '',
        'vehicle_category': data.get('vehicle_category_id', None),
        'gst_liability': data.get('gst_liability', None),
        'comments': data.get('comments', None),
        'invoice_summary': data.get('invoice_summary', None),
        'loading_charge': data.get('loading_charge', 0),
        'unloading_charge': data.get('unloading_charge', 0),
        'detention_charge': data.get('detention_charge', 0),
        'additional_charges_for_owner': data.get('additional_charges_for_owner', 0),
        'note_for_additional_owner_charges': data.get('note_for_additional_owner_charges', None),
        'commission': commission,
        'lr_cost': lr_cost,
        'deduction_for_advance': deduction_for_advance,
        'deduction_for_balance': deduction_for_balance,
        'other_deduction': data.get('other_deduction', 0),
        'remarks_about_deduction': data.get('remarks_about_deduction'),
        'loaded_weight': to_float(data.get('loaded_weight')),
        'supplier_charged_weight': to_float(data.get('supplier_charged_weight')),
        'supplier_rate': data.get('supplier_rate'),
        'total_amount_to_owner': amount_to_owner,
        'charged_weight': to_float(data.get('charged_weight', 0)),
        'party_rate': party_rate,
        'total_amount_to_company': total_amount_to_party,
        'refund_amount': data.get('refundable_amount', 0),
        'additional_charges_for_company': data.get('additional_charges_for_company', 0),
        'deductions_for_company': data.get('deductions_for_company', 0),
        'invoice_remarks_for_deduction_discount': data.get('invoice_remarks_for_deduction_discount', None),
        'advance_amount_from_company': data.get('advance_from_company', 0),
        'invoice_remarks_for_additional_charges': data.get('invoice_remarks_for_additional_charges', None),
        'tds_deducted_amount': data.get('tds_deducted_amount', 0),
        'insurance_provider': data.get('insurance_provider', None),
        'insurance_policy_number': data.get('insurance_policy_number', None),
        'insured_amount': data.get('insurance_amount', 0),
        'insurance_date': data.get('insurance_date', None),
        'inward_payment_status': data.get('inward_payment_status', 'no_payment'),
        'pod_status': data.get('pod_status', 'pending'),
        'outward_payment_status': data.get('outward_payment_status', 'no_payment_made'),
        'pod_date': data.get('pod_date', None),
        'tds_certificate_status': data.get('tds_certificate_status', 'n'),
        'invoice_number': data.get('invoice_number', None),
        'insurance_risk': data.get('insurance_risk', None),
        'is_insured': data.get('insured', None) == 'insured',
        'consignee_cst_tin': data.get('consignee_cst_tin', None),
        'billing_invoice_date': data.get('billing_invoice_date', None),
        'created_by': data.get('user', None),
        'changed_by': data.get('user', None),
        'loading_points': data.get('loading_points', None),
        'unloading_points': data.get('unloading_points', None),
        'is_print_payment_mode_instruction': data.get('is_print_payment_mode_instruction', None) == 'yes'
    }
    return data
예제 #23
0
def supplier_deductions(gst_liability, supplier, source_office, destination_office, supplier_charged_weight,
                        supplier_rate, company):
    freight_to_owner = to_int(to_float(supplier_charged_weight) * to_float(supplier_rate))
    sme = get_or_none(Sme, id=company)
    company_code = sme.company_code if isinstance(sme, Sme) else None
    source_office_id = to_int(source_office)
    destination_office_id = to_int(destination_office)
    destination_office = get_or_none(AahoOffice, id=destination_office_id)
    if source_office_id == 2 and destination_office_id == 3:
        if gst_liability != 'exempted':
            try:
                booking = ManualBooking.objects.filter(
                    source_office_id=2, destination_office_id=3, supplier=supplier).exclude(
                    gst_liability='exempted').latest('created_on')
            except ManualBooking.DoesNotExist:
                booking = None

            data = {
                'commission': {
                    'amount': booking.commission if booking else 0,
                    'editable': True if booking else True
                },
                'lr_cost': {
                    'amount': 200,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 200,
                    'editable': True
                },
            }
        elif company_code in ['JSM', 'CNS']:
            try:
                booking = ManualBooking.objects.filter(
                    source_office_id=2, destination_office_id=3, supplier=supplier, company_code=company_code,
                    gst_liability='exempted').latest('created_on')
            except ManualBooking.DoesNotExist:
                booking = None

            data = {
                'commission': {
                    'amount': booking.commission if booking else 0,
                    'editable': True if booking else True
                },
                'lr_cost': {
                    'amount': 200,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 0,
                    'editable': True
                },
            }
        else:
            try:
                booking = ManualBooking.objects.filter(
                    source_office_id=2, destination_office_id=3, supplier=supplier, gst_liability='exempted').latest(
                    'created_on')

            except ManualBooking.DoesNotExist:
                booking = None

            data = {
                'commission': {
                    'amount': booking.commission if booking else 0,
                    'editable': True if booking else True
                },
                'lr_cost': {
                    'amount': 200,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 350,
                    'editable': True
                },
            }
    elif source_office_id == 2 and destination_office_id == 1:
        data = {
            'commission': {
                'amount': 1000,
                'editable': True
            },
            'lr_cost': {
                'amount': 200,
                'editable': True
            },
            'deduction_for_advance': {
                'amount': 0,
                'editable': True
            },
            'deduction_for_balance': {
                'amount': 0,
                'editable': True
            },
        }
    elif source_office_id == 2:
        try:
            booking = ManualBooking.objects.filter(
                source_office_id=2,
                destination_office_id=destination_office.id if isinstance(destination_office, AahoOffice) else 1,
                supplier=supplier
            ).exclude(destination_office_id__in=[1, 3]).latest('created_on')
        except ManualBooking.DoesNotExist:
            booking = None
        data = {
            'commission': {
                'amount': booking.commission if booking else 0,
                'editable': True if booking else True
            },
            'lr_cost': {
                'amount': 200,
                'editable': True
            },
            'deduction_for_advance': {
                'amount': 0,
                'editable': True
            },
            'deduction_for_balance': {
                'amount': 0,
                'editable': True
            },
        }
    elif source_office_id == 3:
        data = {
            'commission': {
                'amount': 0,
                'editable': True
            },
            'lr_cost': {
                'amount': 200,
                'editable': True
            },
            'deduction_for_advance': {
                'amount': 0,
                'editable': True
            },
            'deduction_for_balance': {
                'amount': 200,
                'editable': True
            },
        }
    elif source_office_id == 1:
        if freight_to_owner < 10000:
            data = {
                'commission': {
                    'amount': 0,
                    'editable': True
                },
                'lr_cost': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 100,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 0,
                    'editable': True
                },
            }
        elif 10000 <= freight_to_owner < 30000:
            data = {
                'commission': {
                    'amount': 0,
                    'editable': True
                },
                'lr_cost': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 200,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 0,
                    'editable': True
                },
            }
        elif 30000 <= freight_to_owner < 70000:
            data = {
                'commission': {
                    'amount': 0,
                    'editable': True
                },
                'lr_cost': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 300,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 0,
                    'editable': True
                },
            }
        else:
            data = {
                'commission': {
                    'amount': 0,
                    'editable': True
                },
                'lr_cost': {
                    'amount': 0,
                    'editable': True
                },
                'deduction_for_advance': {
                    'amount': 400,
                    'editable': True
                },
                'deduction_for_balance': {
                    'amount': 0,
                    'editable': True
                }
            }
    else:
        data = {
            'commission': {
                'amount': 0,
                'editable': True
            },
            'lr_cost': {
                'amount': 0,
                'editable': True
            },
            'deduction_for_advance': {
                'amount': 0,
                'editable': True
            },
            'deduction_for_balance': {
                'amount': 0,
                'editable': True
            }
        }
    return data
예제 #24
0
    def get_filtered_requirements(self, queryset, aaho_office_id,
                                  requirement_status):
        return_response = {
            "status": "failure",
            "queryset": {
                "msg": "No inquiry found"
            },
            "status_code": status.HTTP_400_BAD_REQUEST
        }
        q_objects = Q()
        unfiltered_queryset = queryset
        no_filter = False
        city_head_filter = False
        emp_roles_response = get_employee_roles(self.request.user)
        if emp_roles_response['status'] == 'success' and (
                'management' in emp_roles_response['roles']
                or 'tech' in emp_roles_response['roles']):
            no_filter = True
        elif emp_roles_response['status'] == 'success' and (
                'city_head' in emp_roles_response['roles']):
            city_head_filter = True

        if aaho_office_id and requirement_status:
            q_objects |= Q(**{
                'aaho_office': aaho_office_id,
                'req_status': requirement_status
            })
        elif requirement_status:
            q_objects |= Q(**{'req_status': requirement_status})
        else:
            q_objects |= Q(**{'aaho_office': aaho_office_id})

        if requirement_status and requirement_status not in [
                x[0] for x in REQ_STATUS
        ]:
            return_response['queryset']['msg'] = 'Inquiry status is wrong'
            return return_response

        queryset = queryset.filter(q_objects)
        present = datetime.datetime.now()
        if not no_filter:
            queryset = queryset.filter(
                Q(to_shipment_date__isnull=False,
                  from_shipment_date__lte=(present.date() + timedelta(days=3)),
                  to_shipment_date__gte=present.date())
                | Q(to_shipment_date__isnull=True,
                    from_shipment_date__range=(present.date(),
                                               (present.date() +
                                                timedelta(days=3)))))

        if requirement_status == 'unverified':
            emp_functions = EmployeeRolesFunctionalityMapping.objects.filter(
                employee_role__employee_role__employee__username=self.request.
                user,
                td_functionality__functionality='customer_inquiries')
            if emp_functions and emp_functions.count(
            ) == 1 and emp_functions[0].employee_role.role == 'sales':
                queryset = queryset.filter(
                    client__aaho_poc__username=self.request.user)

        if city_head_filter:
            employee = get_or_none(Employee, username=self.request.user)
            if requirement_status:
                queryset = unfiltered_queryset.filter(
                    aaho_office_id__in=employee.office_multiple.values_list(
                        'id'),
                    req_status=requirement_status)
            else:
                queryset = unfiltered_queryset.filter(
                    aaho_office_id__in=employee.office_multiple.values_list(
                        'id'))

        if not queryset:
            return return_response

        return_response['queryset'] = queryset
        return_response['status'] = 'success'
        return return_response
예제 #25
0
 def get(self, request):
     emp = get_or_none(Employee, username=User.objects.get(username=request.user.username))
     employee_serializer = EmployeeSerializer(instance=emp)
     return Response(template_name='team/employee/emp-profile.html', data=employee_serializer.data,
                     status=status.HTTP_200_OK)
예제 #26
0
파일: owner.py 프로젝트: manibhushan05/tms
 def retrieve(self, request, pk=None):
     fuel_card_transaction = get_or_none(FuelCardTransaction, id=pk)
     if not isinstance(fuel_card_transaction, FuelCardTransaction):
         return Response({"error": "Fuel Card Transaction does not exist"}, status=status.HTTP_404_NOT_FOUND)
     fuel_card_transaction_serializers = FuelCardTransactionSerializer(fuel_card_transaction)
     return Response(fuel_card_transaction_serializers.data, status=status.HTTP_200_OK)
예제 #27
0
def update_booking_field(data):
    booking = get_or_none(ManualBooking, id=data['booking_id'])
    booking.customer_to_be_billed_to = get_or_none(Sme, id=int_or_none(data['to_be_billed_to']))
    booking.save()
예제 #28
0
    def create(self, request):
        invoice = get_or_none(Invoice,
                              invoice_number=request.data.get(
                                  'invoice_number', -1))
        if not isinstance(invoice, Invoice):
            return error_response(msg="Bad request",
                                  status=status.HTTP_400_BAD_REQUEST,
                                  data={})
        request.data["created_by"] = self.request.user.username
        request.data["changed_by"] = self.request.user.username
        request.data["uploaded_by"] = self.request.user.username
        request.data["invoice_receipt"] = invoice.id
        request.data["serial"] = generate_random_string(N=20)

        invoice_receipt_file_serializer = InvoiceReceiptFileSerializer(
            data=request.data)
        if invoice_receipt_file_serializer.is_valid():
            invoice_receipt_file_serializer.save()
            invoice_sent_mode = request.data.get('invoice_sent_mode', None)
            invoice_confirm_mode = request.data.get('invoice_confirm_mode',
                                                    None)
            invoice_confirm_by_name = request.data.get(
                'invoice_confirm_by_name', None)
            invoice_confirm_by_phone = request.data.get(
                'invoice_confirm_by_phone', None)
            INVOICE_SENT_MODE_CHOICES = (('CR', 'Courier'), ('HD',
                                                             'Hand Delivered'),
                                         ('EM', 'Email Screenshot'))
            INVOICE_CONFIRM_MODE_CHOICES = (('PH', 'Phone'),
                                            ('WA', 'Written Acknowledgement'),
                                            ('EM', 'Email Screenshot'))
            if invoice_sent_mode:
                if invoice_sent_mode not in [
                        x[0] for x in INVOICE_SENT_MODE_CHOICES
                ]:
                    return error_response(msg='Invalid Invoice Sent Mode',
                                          status=400,
                                          data={})
            if invoice_confirm_mode:
                if invoice_confirm_mode not in [
                        x[0] for x in INVOICE_CONFIRM_MODE_CHOICES
                ]:
                    return error_response(msg='Invalid Invoice Confirm Mode',
                                          status=400,
                                          data={})
                if invoice_confirm_mode == 'PH' and not invoice_confirm_by_name and not invoice_confirm_by_phone:
                    return error_response(
                        msg='Invoice Confirm Name and Phone required',
                        status=400,
                        data={})
            if not invoice_sent_mode and not invoice_confirm_mode:
                return error_response(
                    msg='Invoice Sent or Confirm Mode Required',
                    status=status.HTTP_400_BAD_REQUEST,
                    data={})

            if invoice_sent_mode:
                update_invoice_booking_status(invoice.id, 'party_invoice_sent',
                                              request.user)
            if invoice_confirm_mode:
                update_invoice_booking_status(invoice.id, 'invoice_confirmed',
                                              request.user)
            return success_response(data=invoice_receipt_file_serializer.data,
                                    status=status.HTTP_201_CREATED,
                                    msg="InvoiceReceiptFile Created")
        return error_response(msg="InvoiceReceiptFile not Created",
                              data=invoice_receipt_file_serializer.errors,
                              status=status.HTTP_400_BAD_REQUEST)
예제 #29
0
def parse_create_confirmed_booking_lr_data(data, existing_booking=None):
    consignor_city = get_or_none(City, id=data.get('consignor_city', None))
    if isinstance(consignor_city, City):
        consignor_city_fk = consignor_city
        consignor_city = consignor_city.name
    else:
        consignor_city_fk = None
        consignor_city = None
    consignee_city = get_or_none(City, id=data.get('consignee_city', None))
    if isinstance(consignee_city, City):
        consignee_city_fk = consignee_city
        consignee_city = consignee_city.name
    else:
        consignee_city_fk = None
        consignee_city = None
    return_response = {
        'consignor_name': data.get('consignor_name', None),
        'consignor_address': data.get('consignor_address', None),
        'consignor_city': consignor_city,
        'consignor_city_fk': consignor_city_fk.id if isinstance(consignor_city_fk, City) else None,
        'consignor_pin': data.get('consignor_pin', None),
        'consignor_phone': data.get('consignor_phone', None),
        'consignor_gstin': data.get('consignor_gstin', None),
        'consignee_name': data.get('consignee_name', None),
        'consignee_address': data.get('consignee_address', None),
        'consignee_city': consignee_city,
        'consignee_city_fk': consignee_city_fk.id if isinstance(consignee_city_fk, City) else None,
        'consignee_pin': data.get('consignee_pin', None),
        'consignee_phone': data.get('consignee_phone', None),
        'consignee_gstin': data.get('consignee_gstin', None),
        'number_of_package': data.get('number_of_package', None),
        'material': data.get('material', None),
        'party_invoice_number': data.get('party_invoice_number', None),
        'party_invoice_date': django_date_format(data.get('party_invoice_date')).date() if data.get(
            'party_invoice_date', None) else None,
        'party_invoice_amount': data.get('party_invoice_amount', None),
        'road_permit_number': data.get('road_permit_number', None),
        'loading_charge': data.get('loading_charge', 0),
        'unloading_charge': data.get('unloading_charge', 0),
        'detention_charge': data.get('detention_charge', 0),
        'additional_charges_for_owner': data.get('additional_charges_for_owner', 0),
        'note_for_additional_owner_charges': data.get('note_for_additional_owner_charges', None),
        'commission': data.get('commission', 0),
        'lr_cost': data.get('lr_cost', 0),
        'deduction_for_advance': data.get('deduction_for_advance', 0),
        'deduction_for_balance': data.get('deduction_for_balance', 0),
        'other_deduction': data.get('other_deduction', 0),
        'remarks_about_deduction': data.get('remarks_about_deduction', None),
        'supplier_rate': data.get('supplier_rate', 0),
        'party_rate': data.get('party_rate', 0),
        'additional_charges_for_company': data.get('additional_charges_for_company', 0),
        'deductions_for_company': data.get('deductions_for_company', 0),
        'invoice_remarks_for_deduction_discount': data.get('invoice_remarks_for_deduction_discount', None),
        'advance_amount_from_company': data.get('advance_from_company', 0),
        'invoice_remarks_for_additional_charges': data.get('invoice_remarks_for_additional_charges', None),
        'tds_deducted_amount': data.get('tds_deducted_amount', 0),
        'insurance_provider': data.get('insurance_provider', None),
        'insurance_policy_number': data.get('insurance_policy_number', None),
        'insured_amount': to_float(data.get('insurance_amount', None)),
        'booking_status': data.get('booking_status', 'confirmed'),
        'insurance_date': django_date_format(data.get('insurance_date')).date() if data.get('insurance_date',
                                                                                            None) else None,
        'insurance_risk': None,
        'is_insured': data.get('insured', False),
        'supplier_charged_weight': data.get('supplier_charged_weight', 0),
        'loaded_weight': data.get('loaded_weight', 0),
        'charged_weight': data.get('charged_weight', 0),
        'refund_amount': data.get('refundable_amount', 0),
    }
    return_response = merge_existing_booking_data(return_response, existing_booking)
    return return_response
예제 #30
0
 def full_booking_invoice(self, request):
     customer = get_or_none(Sme, id=request.GET.get('customer_to_be_billed'))
     return Response(template_name='team/invoices/full_booking_invoices.html',
                     data=full_booking_invoice_data(customer=customer), status=status.HTTP_200_OK)