Example #1
0
def register_product(transaction_executor, product, person_id):
    ## check if the vaccine with GTIN already exist
    # scentity_id = get_scentityid_from_personid(transaction_executor,person_id)

    logger.info("Person_id: {}".format(person_id))
    actual_scentity_id = get_scentityid_from_personid(transaction_executor,
                                                      person_id)
    if actual_scentity_id:
        product.update({'ManufacturerId': actual_scentity_id})
        # logger.info("Matched for authorization!")
        if get_document_superadmin_approval_status(
                transaction_executor, Constants.SCENTITY_TABLE_NAME,
                actual_scentity_id):
            logger.info("Entity is Approved to register product!")
            ProductCode = product["ProductCode"]
            if product_exist(transaction_executor, ProductCode):
                raise Exception(" Product already exists.")
            else:
                if check_products_per_container_and_selling_amount(
                        transaction_executor, product):
                    result = insert_documents(transaction_executor,
                                              Constants.PRODUCT_TABLE_NAME,
                                              [product])
                    product_id = result[0]
                    product_request_id = create_mcg_request(
                        transaction_executor, product_id, person_id, 2)
                    # logger.info("Request was created for product Id : {} with product request id {}".format(product_id, product_request_id))
                    logger.info(
                        " ================================== P R O D U C T =========== R E G I S T R A T I O N ========== B E G A N====================="
                    )
                    return product_id, product_request_id
                else:
                    cases_per_container = Constants.PALLETS_PER_CONTAINER * Constants.CASES_PER_PALLETE
                    raise Exception(
                        "Invalid ProductsPerContainer! Make it multple of : {}"
                        .format(cases_per_container))
        else:
            raise Exception(
                "Entity not approved yet. Cannot register the product")
    else:
        raise Exception("You don't belong to any entity")
Example #2
0
def pick_up_order(transaction_executor,pick_up_request_id,truck_carrier_person_id, freight_carrier_id, export_location_id,import_location_id):
    if document_exist(transaction_executor,Constants.PICK_UP_REQUESTS_TABLE,pick_up_request_id):
        update_document(transaction_executor,Constants.PICK_UP_REQUESTS_TABLE,"isAccepted",pick_up_request_id,True)
        purchase_order_id = get_value_from_documentid(transaction_executor,Constants.PICK_UP_REQUESTS_TABLE, pick_up_request_id, "PurchaseOrderId")
        purchase_order_id = purchase_order_id[0]
        container_ids = get_value_from_documentid(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,purchase_order_id,"HighestPackagingLevelIds")
        carrier_company_id = get_value_from_documentid(transaction_executor,Constants.CONTAINER_TABLE_NAME,container_ids[0][0],"CarrierCompanyId")

        actual_sc_entity_id = get_scentityid_from_personid(transaction_executor,truck_carrier_person_id)

        if carrier_company_id[0]== actual_sc_entity_id:

            location_ids = [export_location_id,import_location_id]
            scentity_type_code = list(map(lambda x: get_value_from_documentid(transaction_executor,Constants.SCENTITY_TABLE_NAME,x,"ScEntityTypeCode"),location_ids))

            # print(scentity_type_code)
            if ["3"] not in scentity_type_code[0] and ["4"] not in scentity_type_code[0] and scentity_type_code[0][0] != scentity_type_code[1][0]:
                raise Exception("import and export locations  can only be airports or sea ports")
            else:
                # logger.info("Authorized!")

                if get_document_superadmin_approval_status(transaction_executor,Constants.SCENTITY_TABLE_NAME,freight_carrier_id):
                    product_id = get_value_from_documentid(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,purchase_order_id,"ProductId")
                    product_id = product_id[0]
                    manufacturer_id = get_value_from_documentid(transaction_executor,Constants.PRODUCT_TABLE_NAME,product_id,"ManufacturerId")
                    manufacturer_name = get_value_from_documentid(transaction_executor,Constants.SCENTITY_TABLE_NAME,manufacturer_id[0],"ScEntityName")
                    pick_up_location = get_scentity_contact(transaction_executor,manufacturer_id[0],"Address")
                    delivery_location = get_scentity_contact(transaction_executor,export_location_id,"Address")
                    # logger.info("Pickup location is : {}".format(pick_up_location))
                    airway_bill_ids = []
                    bill_of_lading_ids = []
                    lorry_reciept_ids = []
                    for container_id in container_ids[0]:
                        isPicked = get_value_from_documentid(transaction_executor,Constants.CONTAINER_TABLE_NAME,container_id,"isPicked")
                        if isPicked[0] == 0:
                            lorry_reciept_id = create_lorry_reciept(transaction_executor,actual_sc_entity_id,truck_carrier_person_id,pick_up_location[0],delivery_location[0],manufacturer_id[0],manufacturer_name[0],True)
                            lorry_reciept_ids.append(lorry_reciept_id[0])
                            update_document_in_container(transaction_executor,container_id,"LorryRecieptIds",lorry_reciept_id[0])
                            export_location_type = get_value_from_documentid(transaction_executor,Constants.SCENTITY_TABLE_NAME,export_location_id,"ScEntityTypeCode")##
                            if export_location_type == ['3']:
                                airway_bill_id = create_airway_bill(transaction_executor,manufacturer_id[0],actual_sc_entity_id, container_id, freight_carrier_id,export_location_id,import_location_id)
                                airway_bill_ids.append(airway_bill_id[0])
                                update_document_in_container(transaction_executor,container_id,"AirwayBillIds",airway_bill_id[0])
                            elif export_location_type == ['4']:
                                bill_of_lading_id = create_bill_of_lading(transaction_executor,manufacturer_id[0],actual_sc_entity_id, container_id,freight_carrier_id,export_location_id,import_location_id)
                                bill_of_lading_ids.append(bill_of_lading_id[0])
                                update_document_in_container(transaction_executor,container_id,"BillOfLadingIds",bill_of_lading_id[0])
                            
                            update_document(transaction_executor,Constants.CONTAINER_TABLE_NAME,"isPicked",container_id,True)
                            
                        else:
                            raise Exception("Order Already Picked!")

                    logger.info("=====================  O R D E R ====== P I C K E D ===================")
                    return lorry_reciept_ids, airway_bill_ids, bill_of_lading_ids
                    
                else:
                    raise Exception("Carrier Company is not approved.")
        else:
            raise Exception("Person not authorized for the pickup")
    else:
        raise Exception("Check Request Id")
Example #3
0
def initiate_distributor_shipment(transaction_executor, purchase_order_id, distributor_person_id,carrier_company_id,tranport_type):
    # check if po exist
    if document_exist(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,purchase_order_id):        
        # check if po is accepted
        if get_document_superadmin_approval_status(transaction_executor, Constants.SCENTITY_TABLE_NAME, carrier_company_id):
            if order_already_accepted(transaction_executor,purchase_order_id):
                
                #check for authorization
                required_scentity_id = get_sub_details(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,"Acceptor",purchase_order_id,"AcceptorScEntityId")
                actual_scentity_id = get_scentityid_from_personid(transaction_executor,distributor_person_id)
                if required_scentity_id[0] == actual_scentity_id:
                    # check if enough enventory for the order
                    inventory_table = inventory_table_already_exist(transaction_executor,actual_scentity_id)
                    product_id = get_value_from_documentid(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,purchase_order_id,"ProductId")
                    containers_ordered = get_value_from_documentid(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,purchase_order_id,"OrderQuantity")
                    containers_ordered = containers_ordered[0]
                    inventory_id =  next(get_document_ids(transaction_executor,inventory_table[0],"ProductId",product_id[0]))

                    available_unit_inventory = get_value_from_documentid(transaction_executor,inventory_table[0],inventory_id,"CurrentInventory")
                    available_unit_inventory = int(available_unit_inventory[0])
                    products_per_container = get_value_from_documentid(transaction_executor,Constants.PRODUCT_TABLE_NAME,product_id[0],"ProductsPerContainer")
                    product_units_ordered = int(containers_ordered) * int(products_per_container[0])
                    
                    if available_unit_inventory >= product_units_ordered:
                        print("=======================================")
                        containers_in_inventory = get_value_from_documentid(transaction_executor,inventory_table[0],inventory_id,"ContainerIds")
                        # containers_in_inventory = containers_in_inventory[0]
                        # lis = [containers_in_inventory,[1,2]]
                        containers_in_inventory = oneDArray(containers_in_inventory)
                        total_containers = len(containers_in_inventory)

                        print(containers_in_inventory)
                        
                        available_containers = int(available_unit_inventory/products_per_container[0])
                        starting_container = total_containers - (available_containers)
                        ending_container = starting_container + int(containers_ordered)
                        # for containers in range((1,containers_ordered+1)):
                        # assign the first containers to the new purchase order
                        assigned_container_ids = containers_in_inventory[starting_container:ending_container]

                        logger.info("Assigned ids are :{}".format(assigned_container_ids))
                        # add purchase order to the new container
                        for container_id in assigned_container_ids:
                            update_document(transaction_executor,Constants.CONTAINER_TABLE_NAME,"PurchaseOrderId",container_id, purchase_order_id)
                            update_document(transaction_executor,Constants.CONTAINER_TABLE_NAME,"CarrierId",container_id, carrier_company_id)
                            update_document(transaction_executor,Constants.CONTAINER_TABLE_NAME,"isDelivered",container_id, False)
                            update_document(transaction_executor,Constants.CONTAINER_TABLE_NAME,"TransportType",container_id, tranport_type)
                            update_document(transaction_executor,Constants.CONTAINER_TABLE_NAME,"isPicked",container_id,False)
                        
                        update_document(transaction_executor,Constants.PURCHASE_ORDER_TABLE_NAME,"HighestPackagingLevelIds",purchase_order_id,assigned_container_ids)
                        available_unit_inventory = available_unit_inventory - product_units_ordered
                        update_document(transaction_executor,inventory_table[0],"CurrentInventory",inventory_id,available_unit_inventory)

                        pick_up_request_id = create_pick_up_request(transaction_executor,actual_scentity_id,carrier_company_id, purchase_order_id, tranport_type)
                        logger.info("===================== S H I P M E N T ======= I N I T I A T E D =======================")
                        return pick_up_request_id[0]
                    
                    else:
                        raise Exception("Not enough dosage in inventory to initiate shipment.")
                else:
                    raise Exception("Person not Authorized!")
            else:
                raise Exception("Accept the Order First!")
        else:
            raise Exception(" Carrier Company is not Approved")
    else:
        raise Exception("Cannot Locate Purchase Order.")
def custom_approval(transaction_executor, container_id, approval_type,
                    customs_person_id):
    if document_exist(transaction_executor, Constants.CONTAINER_TABLE_NAME,
                      container_id):
        scentity_id = get_scentityid_from_personid(transaction_executor,
                                                   customs_person_id)
        ## we will just check if person is a custom agent. and then airway bill/bill of lading will be made from the point where custom agen works
        print(scentity_id)
        scentity_type_code = get_value_from_documentid(
            transaction_executor, Constants.SCENTITY_TABLE_NAME, scentity_id,
            "ScEntityTypeCode")
        if scentity_type_code[0] == '3':
            # logger.info("Customs Agent confirmed")
            airway_bills = get_value_from_documentid(
                transaction_executor, Constants.CONTAINER_TABLE_NAME,
                container_id, "AirwayBillIds")
            destination_id = get_value_from_documentid(
                transaction_executor, Constants.AIRWAY_BILL_TABLE_NAME,
                airway_bills[0][-1],
                "{}".format(approval_type[:6]) + "AirportId")

            if scentity_id == destination_id[0]:
                # logger.info("Custom Agent belongs to {} airport.".format(approval_type[:6]))

                if get_document_superadmin_approval_status(
                        transaction_executor, Constants.SCENTITY_TABLE_NAME,
                        scentity_id):
                    if isContainerSafe(transaction_executor, container_id):
                        ##check if container is safe:
                        certificateofOrigin = get_value_from_documentid(
                            transaction_executor,
                            Constants.CONTAINER_TABLE_NAME, container_id,
                            "CertificateOfOriginId")
                        packinglist = get_value_from_documentid(
                            transaction_executor,
                            Constants.CONTAINER_TABLE_NAME, container_id,
                            "PackingListId")
                        already_approved = (
                            document_already_approved_by_customs(
                                transaction_executor, approval_type,
                                Constants.CERTIFICATE_OF_ORIGIN_TABLE_NAME,
                                certificateofOrigin[0])
                            and document_already_approved_by_customs(
                                transaction_executor, approval_type,
                                Constants.PACKING_LIST_TABLE_NAME,
                                packinglist[0]))

                        if already_approved:
                            raise Exception("Documents were already approved!")
                        else:
                            if approval_type == "ExportApproval":
                                lorry_reciepts = get_value_from_documentid(
                                    transaction_executor,
                                    Constants.CONTAINER_TABLE_NAME,
                                    container_id, "LorryRecieptIds")
                                update_document(
                                    transaction_executor,
                                    Constants.LORRY_RECEIPT_TABLE_NAME,
                                    "isDeliveryDone", lorry_reciepts[0][-1],
                                    True)
                                update_document(
                                    transaction_executor,
                                    Constants.LORRY_RECEIPT_TABLE_NAME,
                                    "DeliveryTime", lorry_reciepts[0][-1],
                                    datetime.datetime.now().timestamp())

                            update_document(
                                transaction_executor,
                                Constants.CERTIFICATE_OF_ORIGIN_TABLE_NAME,
                                "{}.isApprovedByCustoms".format(approval_type),
                                certificateofOrigin[0], True)
                            update_document(
                                transaction_executor,
                                Constants.CERTIFICATE_OF_ORIGIN_TABLE_NAME,
                                "{}.ApproverId".format(approval_type),
                                certificateofOrigin[0], customs_person_id)
                            update_document(
                                transaction_executor,
                                Constants.PACKING_LIST_TABLE_NAME,
                                "{}.isApprovedByCustoms".format(approval_type),
                                packinglist[0], True)
                            update_document(
                                transaction_executor,
                                Constants.PACKING_LIST_TABLE_NAME,
                                "{}.ApproverId".format(approval_type),
                                packinglist[0], customs_person_id)
                            logger.info(
                                "===================== C O N T A I N E R =========== C U S T O M ===========A P P R O V E D ==========="
                            )
                    else:
                        raise Exception(
                            "====A L A R M ==== CANNOT APPROVE=== CONTAINER DANGEROUS===="
                        )
                else:
                    raise Exception("Airport not confirmed yet.")
            else:
                raise Exception("Custom Agent doesn't belong to this airport")

        elif scentity_type_code[0] == '4':
            logger.info("Customs Agent confirmed")
            bill_of_ladings = get_value_from_documentid(
                transaction_executor, Constants.CONTAINER_TABLE_NAME,
                container_id, "BillOfLadingIds")
            destination_id = get_value_from_documentid(
                transaction_executor, Constants.BILL_OF_LADING_TABLE_NAME,
                bill_of_ladings[0][-1],
                "{}".format(approval_type[:6]) + "portId")

            if scentity_id == destination_id[0]:
                logger.info("Custom Agent belongs to {} airport.".format(
                    approval_type[:6]))

                if get_document_superadmin_approval_status(
                        transaction_executor, Constants.SCENTITY_TABLE_NAME,
                        scentity_id):
                    if isContainerSafe(transaction_executor, container_id):
                        ##check if container is safe:

                        certificateofOrigin = get_value_from_documentid(
                            transaction_executor,
                            Constants.CONTAINER_TABLE_NAME, container_id,
                            "CertificateOfOriginId")
                        packinglist = get_value_from_documentid(
                            transaction_executor,
                            Constants.CONTAINER_TABLE_NAME, container_id,
                            "PackingListId")
                        already_approved = (
                            document_already_approved_by_customs(
                                transaction_executor, approval_type,
                                Constants.CERTIFICATE_OF_ORIGIN_TABLE_NAME,
                                certificateofOrigin[0])
                            and document_already_approved_by_customs(
                                transaction_executor, approval_type,
                                Constants.PACKING_LIST_TABLE_NAME,
                                packinglist[0]))

                        if already_approved:
                            logger.info("Documents were already approved!")
                        else:
                            logger.info("approving CoO and PL")
                            lorry_reciepts = get_value_from_documentid(
                                transaction_executor,
                                Constants.CONTAINER_TABLE_NAME, container_id,
                                "LorryRecieptIds")
                            update_document(transaction_executor,
                                            Constants.LORRY_RECEIPT_TABLE_NAME,
                                            "isDeliveryDone",
                                            lorry_reciepts[0][-1], True)
                            update_document(
                                transaction_executor,
                                Constants.CERTIFICATE_OF_ORIGIN_TABLE_NAME,
                                "{}.isApprovedByCustoms".format(approval_type),
                                certificateofOrigin[0], True)
                            update_document(
                                transaction_executor,
                                Constants.CERTIFICATE_OF_ORIGIN_TABLE_NAME,
                                "{}.ApproverId".format(approval_type),
                                certificateofOrigin[0], customs_person_id)

                            update_document(
                                transaction_executor,
                                Constants.PACKING_LIST_TABLE_NAME,
                                "{}.isApprovedByCustoms".format(approval_type),
                                packinglist[0], True)
                            update_document(
                                transaction_executor,
                                Constants.PACKING_LIST_TABLE_NAME,
                                "{}.ApproverId".format(approval_type),
                                packinglist[0], customs_person_id)
                            logger.info(
                                "===================== C O N T A I N E R =========== C U S T O M ===========A P P R O V E D ==========="
                            )
                    else:
                        raise Exception(
                            "====A L A R M ==== CANNOT APPROVE=== CONTAINER DANGEROUS===="
                        )
                else:
                    raise Exception("Airport not confirmed yet.")
            else:
                raise Exception("Agent not Authorized.")
        else:
            raise Exception("Person not Custom Agent")
    else:
        raise Exception("Container not found!")
def create_purchase_order_to_manufacturer(transaction_executor, person_id,
                                          purchase_order_details):

    product_id = purchase_order_details["ProductId"]
    #check if the product exist and approved
    if product_exists(transaction_executor, product_id):
        # logger.info("Product Found!")
        order_quantity = purchase_order_details["OrderQuantity"]
        ##check if the product is approved
        if get_document_superadmin_approval_status(
                transaction_executor, Constants.PRODUCT_TABLE_NAME,
                product_id):
            #check if the orderQuantity is less than greater than
            if (isinstance(order_quantity, int)
                ):  #<<--------------- have to convery orderquantity to float
                min_selling_amount_containers = get_value_from_documentid(
                    transaction_executor, Constants.PRODUCT_TABLE_NAME,
                    product_id, "MinimumSellingAmount")
                if order_quantity >= min_selling_amount_containers[0]:
                    scentity_id = get_scentityid_from_personid(
                        transaction_executor, person_id)
                    if scentity_id:
                        #check if the orderer company is approved
                        if get_document_superadmin_approval_status(
                                transaction_executor,
                                Constants.SCENTITY_TABLE_NAME, scentity_id):
                            purchase_order_number = get_index_number(
                                transaction_executor,
                                Constants.PURCHASE_ORDER_TABLE_NAME,
                                "PurchaseOrderNumber")
                            purchase_order_details.update(
                                {"PurchaseOrderNumber": purchase_order_number})
                            purchase_order_details.update(
                                {"OrderType": "1"}
                            )  ## order type 1 is by distributor to manufacturer
                            ## order type 2 is to distributor by downstream entities
                            purchase_order_details['Orderer'].update(
                                {'OrdererScEntityId': scentity_id})
                            purchase_order_details['Orderer'].update(
                                {'OrdererPersonId': person_id})
                            sc_entity_type_code = get_value_from_documentid(
                                transaction_executor,
                                Constants.SCENTITY_TABLE_NAME, scentity_id,
                                "ScEntityTypeCode")
                            if sc_entity_type_code[
                                    0] == "2":  ## normal company
                                highest_packaging_level = "Container"
                            # logger.info(purchase_order_details)

                            product_id = purchase_order_details["ProductId"]
                            manufacturer_id = get_value_from_documentid(
                                transaction_executor,
                                Constants.PRODUCT_TABLE_NAME, product_id,
                                "ManufacturerId")

                            ## highest packagin level Id in this case is container since that is the minimum amount that distributor has to order

                            purchase_order = {
                                **purchase_order_details, "Acceptor": {
                                    "isOrderAccepted": False,
                                    "AcceptorScEntityId": manufacturer_id[0],
                                    "ApprovingPersonId": ""
                                },
                                "InvoiceId":
                                "",
                                "HighestPackagingLevelIds": [],
                                "HighestPackagingLevelType":
                                highest_packaging_level
                            }
                            purchase_order_id = insert_documents(
                                transaction_executor,
                                Constants.PURCHASE_ORDER_TABLE_NAME,
                                convert_object_to_ion(purchase_order))

                            # logger.info("Order was placed sucessfully with id: {}".format(purchase_order_id))
                            logger.info(
                                " ================================== O R D E R =========== P L A C E D ==============================="
                            )
                            return purchase_order_id[0]
                        else:
                            raise Exception(
                                "OrdererComany is not approved by the Admin.")
                    else:
                        raise Exception(
                            "check if person id is associated with an entity.")
                else:
                    raise Exception(
                        "Order quantity cannot be less than minimum quantity.")
            else:
                raise Exception(
                    "Order Quantity can only be in the form of integers.")
        else:
            raise Exception(
                "Product is not approved yet. Wait for the product to get approved first."
            )
    else:
        raise Exception(" Product Id is wrong!")
Example #6
0
def initiate_shipment(transaction_executor, carrier_company_id, transport_type,
                      purchase_order_id, person_id):
    if document_exist(transaction_executor,
                      Constants.PURCHASE_ORDER_TABLE_NAME, purchase_order_id):
        # logger.info("Purchase Order Found!")
        if get_document_superadmin_approval_status(
                transaction_executor, Constants.SCENTITY_TABLE_NAME,
                carrier_company_id):
            product_id = get_value_from_documentid(
                transaction_executor, Constants.PURCHASE_ORDER_TABLE_NAME,
                purchase_order_id, "ProductId")
            product_id = product_id[0]
            required_scentity_id = get_sub_details(
                transaction_executor, Constants.PURCHASE_ORDER_TABLE_NAME,
                "Acceptor", purchase_order_id, "AcceptorScEntityId")
            actual_scentity_id = get_scentityid_from_personid(
                transaction_executor, person_id)
            if required_scentity_id[0] == actual_scentity_id:
                # logger.info("Authorized!")
                batch_table_id = batch_table_exist(transaction_executor,
                                                   product_id)
                if order_already_accepted(transaction_executor,
                                          purchase_order_id):
                    if shipment_already_started(transaction_executor,
                                                purchase_order_id):
                        raise Exception('Shipment already started.')
                    else:
                        if batch_table_id:
                            batch_table_name = get_tableName_from_tableId(
                                transaction_executor, batch_table_id)

                            products_per_container = get_value_from_documentid(
                                transaction_executor,
                                Constants.PRODUCT_TABLE_NAME, product_id,
                                "ProductsPerContainer")
                            # min_selling_amount = int(min_selling_amount_containers[0])*int(products_per_container[0])
                            products_per_case = round(
                                (products_per_container[0] /
                                 (Constants.CASES_PER_PALLETE *
                                  Constants.PALLETS_PER_CONTAINER)))
                            # logger.info("products_per_case is : {}".format(products_per_case))
                            product_units_ordered = enough_inventory_registered_for_order(
                                transaction_executor, products_per_case,
                                purchase_order_id, batch_table_name)
                            if product_units_ordered:
                                # logger.info("Units Ordered are: {}".format(product_units_ordered))
                                update_document(
                                    transaction_executor,
                                    Constants.PURCHASE_ORDER_TABLE_NAME,
                                    "isOrderShipped", purchase_order_id, True)
                                product_code = get_value_from_documentid(
                                    transaction_executor,
                                    Constants.PRODUCT_TABLE_NAME, product_id,
                                    "ProductCode")
                                case_ids = assign_products_into_case(
                                    transaction_executor, product_id,
                                    batch_table_name, product_units_ordered,
                                    products_per_case, purchase_order_id,
                                    product_code)
                                pallete_ids = assign_cases_into_pallete(
                                    transaction_executor, case_ids,
                                    product_code)
                                certificate_of_origin_id = create_certificate_of_origin(
                                    transaction_executor, product_id)
                                # product_quantity = get_value_from_documentid(transaction_executor,Constants.PRODUCT_TABLE_NAME,product_id,"MinimumSellingAmount")
                                container_ids = assign_palletes_into_container(
                                    transaction_executor, pallete_ids,
                                    product_code, purchase_order_id,
                                    carrier_company_id,
                                    certificate_of_origin_id[0],
                                    products_per_container, transport_type)
                                update_container_ids_in_purchase_order(
                                    transaction_executor, container_ids,
                                    purchase_order_id)

                                pick_up_request_id = create_pick_up_request(
                                    transaction_executor, actual_scentity_id,
                                    carrier_company_id, purchase_order_id,
                                    transport_type)

                                logger.info(
                                    "===================== S H I P M E N T ======= I N I T I A T E D ======================="
                                )
                                return pick_up_request_id[0], container_ids
                            else:
                                raise Exception(
                                    " First produce and register the vaccines into the sytem before shipping them"
                                )
                        else:
                            raise Exception(
                                'Register the Batch table first by inputting inventory!'
                            )
                else:
                    raise Exception("Accept the order first!")
            else:
                raise Exception("Not authorized!")
        else:
            raise Exception("Carrier company is not approved by MCG.")
    else:
        raise Exception("order doesn't exist")