def get_ups_rating_request(delivery_note, params): # prepate the ups rating request dn = delivery_note packing_slips = [row.packing_slip for row in dn.packing_slip_details] if not packing_slips: frappe.throw("Can not find the linked Packing Slip ...") ship_from_address_name = params.get("default_warehouse") shipper_number = params.get("shipper_number") package_type = ups_packages.get(params.get("package_type")) ship_to_params = { "customer":dn.customer, "contact_display":dn.contact_display, "contact_mobile":dn.contact_mobile } shipment = E.Shipment( Helper.get_shipper(params), Helper.get_ship_to_address(ship_to_params, dn.shipping_address_name,), Helper.get_ship_from_address(params, ship_from_address_name), RatingService.service_type(Code='03'), ) packages = Helper.get_packages(packing_slips, package_type) shipment.extend(packages) rating_request = RatingService.rating_request_type( shipment, ) return rating_request
def get_ups_shipment_confirm_request(delivery_note, params): dn = delivery_note packing_slips = [row.packing_slip for row in dn.packing_slip_details] if not packing_slips: frappe.throw("Can not find the linked Packing Slip ...") ship_from_address_name = params.get("default_warehouse") shipper_number = params.get("shipper_number") package_type = ups_packages.get(params.get("package_type")) rates = {} if dn.ups_rates: rates = json.loads(dn.ups_rates) service_code = rates.get("service_used") or "03" ship_to_params = { "customer": dn.customer, "contact_display": dn.contact_display, "contact_mobile": dn.contact_mobile } packages = Helper.get_packages(packing_slips, package_type) request = ShipmentConfirm.shipment_confirm_request_type( Helper.get_shipper(params), Helper.get_ship_to_address( ship_to_params, dn.shipping_address_name, ), Helper.get_ship_from_address(params, ship_from_address_name), Helper.get_payment_info(AccountNumber=shipper_number), ShipmentConfirm.service_type(Code=service_code), # Labal specification container LabelSpecification=E.LabelSpecification( E.LabelPrintMethod(E.Code("ZPL"), ), E.LabelStockSize( E.Height("4"), E.Width("6"), ), E.LabelImageFormat(E.Code("ZPL"), ), ), Description="Description") request.find("Shipment").extend(packages) return request
def get_ups_shipment_confirm_request(delivery_note, params): dn = delivery_note packing_slips = [row.packing_slip for row in dn.packing_slip_details] if not packing_slips: frappe.throw("Can not find the linked Packing Slip ...") ship_from_address_name = params.get("default_warehouse") shipper_number = params.get("shipper_number") package_type = ups_packages.get(params.get("package_type")) rates = {} if dn.ups_rates: rates = json.loads(dn.ups_rates) service_code = rates.get("service_used") or "03" ship_to_params = { "customer":dn.customer, "contact_display":dn.contact_display, "contact_mobile":dn.contact_mobile } packages = Helper.get_packages(packing_slips, package_type) request = ShipmentConfirm.shipment_confirm_request_type( Helper.get_shipper(params), Helper.get_ship_to_address(ship_to_params, dn.shipping_address_name,), Helper.get_ship_from_address(params, ship_from_address_name), Helper.get_payment_info(AccountNumber=shipper_number), ShipmentConfirm.service_type(Code=service_code), # Labal specification container LabelSpecification = E.LabelSpecification( E.LabelPrintMethod(E.Code("ZPL"),), E.LabelStockSize(E.Height("4"),E.Width("6"),), E.LabelImageFormat(E.Code("ZPL"),), ), Description="Description" ) request.find("Shipment").extend(packages) return request