def _build_description(self, action, data, template, conf): _params: ParamsObject = ParamsObject() if action == "UPDATE": _verification_get_params: ParamsObject = ParamsObject() _verification_get_params.set_params_list([data.verification_id]) verification = self.get_direct("sVerificationGet", _verification_get_params, False) verification = verification[0] _params.set_params_list([ verification["Transaction_ID"], verification["Transaction_Type"] ]) else: _params.set_params_list( [data.transaction_id, data.transaction_type]) """ Get Verification Object """ verification_detail = self.get_direct( "sNotificationVerificationObjectGet", _params, False) verification_detail = verification_detail[0] self.ext_params["current_assignee"] = verification_detail[ "Current_Assignee"] template = template.replace( "<INV_NUM>", str(verification_detail["Inv_Number"]) + "(" + str(verification_detail["Entity_Name"]) + ")") template = template.replace("<STATUS>", str(verification_detail["Status"])) return template
def _build_description(self, action, data, template, conf): invoice_repo: InvoiceHeaderRepo = InvoiceHeaderRepo() _params: ParamsObject = ParamsObject() _params.set_params_list([data.invoice_id]) invoice_object: InvoiceHeaderModel = invoice_repo.get_data(_params) recycler_params: ParamsObject = ParamsObject() recycler_params.set_params_list([invoice_object.recycler_id]) recycler_name_list = UserService().get_entity_name(recycler_params) recycler_name = recycler_name_list[0]["Entity_Name"] total: float = 0 for detail in invoice_object.invoice_detail: total += detail.quantity invoice_amount: float = invoice_object.invoice_total_amount invoice_amount = round(invoice_amount, 2) total = round(total, 2) template = template.replace("<INV_NUM>", invoice_object.updated_invoice_number + os.linesep) template = template.replace("<RECYCLER>", recycler_name + os.linesep) template = template.replace("<TOTALAMOUNT>", str(invoice_amount) + os.linesep) template = template.replace("<QUANTITY>", str(total)) return template
def _build_description(self, action, data, template, conf): document_type = '' transaction_id = None for i in data["file_detail"]: transaction_id = i["transaction_id"] for j in i["files"]: type = j["document_type"] document_type = document_type + type + "," # transaction_id = data["transaction_id"] params_object: ParamsObject = ParamsObject() params_object.set_params_list([transaction_id]) get_document_name = FileHelper().get_document_list_by_type( document_type) document_name = get_document_name["response_object"] display_name = "" cnt = 0 for i in document_name: if cnt == 0: display_name = display_name + i["display_name"] cnt = cnt + 1 else: display_name = display_name + "," + i["display_name"] invoice_params: ParamsObject = ParamsObject() invoice_params.set_params_list([transaction_id]) invoice_id = self.get_direct("sInvoiceHeaderGet", invoice_params, False) template = template.replace("<DOC_TYPE>", display_name) template = template.replace( "<INV_NUM>", str(invoice_id[0]["Updated_Invoice_Number"])) return template
def _get_recipients(self, data: InwardDraftModel, conf): user_device_list = [] params: ParamsObject = ParamsObject() params_list = [] for each_rec in conf: notification_default_recipients: NotificationDefaultRecipientsModel = each_rec if notification_default_recipients.procedure_config == None or notification_default_recipients.procedure_config == "": pass else: procedure_config_str = notification_default_recipients.procedure_config procedure_config_lst = [] if procedure_config_str != "" and procedure_config_str is not None: procedure_config_lst = json.loads(procedure_config_str) for each_config in procedure_config_lst: _property = each_config["property"] _from = each_config["from"] if _from == "session": params_list.append(self.ext_params.get(_property)) else: params_list.append(data.__getattribute__(_property)) params1: ParamsObject = ParamsObject() params1.set_params_list([data.state_id]) zone = self.get_direct("sGetZoneByStateID", params1, False) zone = zone[0] zone_id = zone["Zone_ID"] params_manager_id = ParamsObject() params_manager_id.set_params_list([zone_id]) zone_manager = self.get_direct("sGetZoneManagerByID", params_manager_id, False) manager_id = zone_manager[0]["Manager_ID"] params_list.append(manager_id) params.set_params_list(params_list) recipient_list = params.get_params_list() for id in recipient_list: params_obj = ParamsObject() params_obj.set_params_list([id]) device_list = self.get_direct("sUserDeviceByIDGet", params_obj, False) if device_list != "" and device_list is not None: if isinstance(device_list, list): if len(device_list) > 0: user_device_list.append(device_list) return user_device_list
def _get_recipients(self, data: InvoiceHeaderModel, conf): user_device_list = [] for each_rec in conf: notification_default_recipients: NotificationDefaultRecipientsModel = each_rec params: ParamsObject = ParamsObject() params_list = [] if notification_default_recipients.procedure_config == None or notification_default_recipients.procedure_config == "": pass else: procedure_config_str = notification_default_recipients.procedure_config procedure_config_lst = [] if procedure_config_str != "" and procedure_config_str is not None: procedure_config_lst = json.loads(procedure_config_str) for each_config in procedure_config_lst: _property = each_config["property"] _from = each_config["from"] if _from == "session": params_list.append(self.ext_params.get(_property)) else: params_list.append(data.__getattribute__(_property)) params.set_params_list(params_list) device_list = self.get_direct(notification_default_recipients.procedure_name, params, False) if device_list != "" and device_list is not None: if len(device_list) != 0: user_device_list.append(device_list) return user_device_list
def __get_data_direct(self, sp_name, params: ParamsObject, is_cacheable=True, cache_key_prefix="", is_multiple_rs=False): data = None if params is None: params = [] if is_multiple_rs: data = self.normal_repo.get_direct_multiple( sp_name, params.get_params_list()) else: data = self.normal_repo.get_direct(sp_name, params.get_params_list()) return data
def __add_update_delete_direct(self, sp_name, params: ParamsObject, flag="ADD"): data = None if flag == "ADD": data = self.normal_repo.add_direct(sp_name, params.get_params_list()) elif flag == "UPDATE": data = self.normal_repo.update_direct(sp_name, params.get_params_list()) elif flag == "DELETE": data = self.normal_repo.delete_direct(sp_name, params.get_params_list()) else: pass return data
def _build_description(self, action, data, template, conf): """ Get City Name """ city_id_params: ParamsObject = ParamsObject() city_id_params.set_params_list([data.collection_centre_id]) city_name = self.get_direct("sNotificationCCCityGet", city_id_params, False) city_name = city_name[0]["City_Name"] """ Get Created By User Name """ _params: ParamsObject = ParamsObject() lst = [] lst.append(self.ext_params.get("user_id")) _params.set_params_list(lst) user_list = self.get_direct("sNotificationUserNameGet", _params, False) user_name = user_list[0]["User_Name"] template = template.replace("<CITY>", str(city_name)) template = template.replace("<CREATED_BY>", str(user_name)) return template
def __add_update_delete_direct_transactional(self, sp_name, params: ParamsObject, flag="ADD"): data = None self.begin_transaction() if flag == "ADD": data = self.transaction_repo.add_direct(sp_name, params.get_params_list()) elif flag == "UPDATE": data = self.transaction_repo.update_direct( sp_name, params.get_params_list()) elif flag == "DELETE": data = self.transaction_repo.delete_direct( sp_name, params.get_params_list()) else: pass self.commit() return data
def get_cache_key(self, object, params: ParamsObject): try: params_list = params.get_params_list() prefix = "" if object != "" and object is not None: prefix = object key = ''.join(str(e) if e is not None else "" for e in params_list) return prefix + ':' + key except Exception as ex: pass
def _build_description(self, action, data, template, conf): total_quantity = 0 total_price = 0 seller_inv = data.seller_invoice_number data_dict = data.__dict__ cart_item = data_dict["cart_item"] params_object: ParamsObject = ParamsObject() params_object.set_params_list([data.entity_id]) get_entity_name = UserService().get_entity_name(params_object) user_name_params: ParamsObject = ParamsObject() user_name_params.set_params_list([self.ext_params["user_id"]]) user_name = self.get_direct("sNotificationUserNameGet", user_name_params, False) user_name = user_name[0]["User_Name"] entity_name = get_entity_name[0]["Entity_Name"] for i in range(len(cart_item)): detail_cart_item = cart_item[i] cart_quantity = detail_cart_item.quantity cart_price = detail_cart_item.price total_quantity += cart_quantity total_price += (cart_price * cart_quantity) karo_inv = data.karo_invoice_number if data.is_draft == 0: template = template.replace("<VENDOR_NAME>", str(entity_name)) template = template.replace("<TOTAL_QTY>", str(total_quantity)) template = template.replace("<TOTAL_PRICE>", str(total_price)) template = template.replace("<INV_NUM>", str(seller_inv)) template = template.replace("<CREATED_BY>", user_name) template = template.replace("draft", "") else: template = template.replace("Purchase draft", "Purchase") template = template.replace("<VENDOR_NAME>", str(entity_name)) template = template.replace("<TOTAL_QTY>", str(total_quantity)) template = template.replace("<TOTAL_PRICE>", str(total_price)) template = template.replace("<INV_NUM>", str(seller_inv) + os.linesep) template = template.replace("<CREATED_BY>", user_name + ". Please check and commit") return template
def _get_recipients(self, data: VerificationModel, conf): user_device_list = [] params: ParamsObject = ParamsObject() params_list = [] params_list.append(self.ext_params.get("current_assignee")) params.set_params_list(params_list) device_list = self.get_direct("sUserDeviceByIDGet", params, False) if device_list != "" and device_list is not None: if len(device_list) != 0: user_device_list.append(device_list) return user_device_list
def _build_description(self, action, data, template, conf): """ Get Workshop Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.workshop_id]) workshop = self.get_direct("sNotificationWorkshopGet", _params, False) workshop = workshop[0] template = template.replace("<TYPE>", str(workshop["Type"])) template = template.replace("<PLACE>", str(workshop["City_Name"])) template = template.replace("<CREATED_BY>", str(workshop["User_Name"])) return template
def _build_description(self, action, data, template, conf): """ Get Event Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.event_id]) event = self.get_direct("sNotificationCalendarGet", _params, False) event = event[0] template = template.replace("<TITLE>", str(event["Title"])) template = template.replace("<DESCRIPTION>", str(event["Description"])) template = template.replace("<CREATED_BY>", str(event["User_Name"])) return template
def _build_description(self, action, data, template, conf): """ Get Exercise Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.school_excercise_id]) exc = self.get_direct("sNotificationExerciseGet", _params, False) exc = exc[0] template = template.replace("<EXERCISE>", str(exc["Exercise"])) template = template.replace("<SCHOOL_NAME>", str(exc["Entity_Name"])) template = template.replace("<CREATED_BY>", str(exc["User_Name"])) return template
def _build_description(self, action, data, template, conf): """ Get Exercise Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.media_publication_id]) media = self.get_direct("sNotificationMediaGet", _params, False) media = media[0] template = template.replace("<TYPE>", str(media["Type_Name"])) template = template.replace("<DESCRIPTION>", str(media["Description"])) template = template.replace("<CREATED_BY>", str(media["User_Name"])) return template
def _build_description(self, action, data, template, conf): """ Get Payment Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.payment_id]) payment = self.get_direct("sNotificationPaymentGet", _params, False) payment = payment[0] self.ext_params["send_to"] = payment["Advised_By"] template = template.replace("<PAYMENT>", str(payment["Payments"])) return template
def _build_description(self, action, data, template, conf): visit_id = data.visit_id _params: ParamsObject = ParamsObject() _params.set_params_list([visit_id]) _visit_detail = self.get_direct("sNotificationVisitGet", _params, False) template = template.replace("<CREATED_BY>", str(_visit_detail[0]["User_Name"])) template = template.replace("<PLACE>", str(_visit_detail[0]["City_Name"])) template = template.replace("<REASON>", str(_visit_detail[0]["Purpose"])) return template
def __get_conf(self, action): """ This method is used to get the notification configuration Object type can be read from object_type method which overridden in the child class :param action: The action on the Object like ADD, UPDATE, DELETE etc. :return: NotificationConfiguration Object """ params: ParamsObject = ParamsObject() params.set_params_list([self._object_type(), action]) self.config = NotificationConfigRepo( self.ext_params).get_data_list_object(params) return self.config
def _build_description(self, action, data, template, conf): """ Get Payment Request Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.request_id]) payment = self.get_direct("sNotificationPaymentRequestGet", _params, False) payment = payment[0] template = template.replace("<CREATED_BY>", str(payment["User_Name"]) + os.linesep) template = template.replace("<INV_NUM>", str(payment["Bills"]) + os.linesep) template = template.replace("<VENDORS>", str(payment["Vendors"]) + os.linesep) template = template.replace("<AMOUNT>", str(payment["Total"])) return template
def _build_description(self, action, data, template, conf): invoce_number = data.invoice_id quantity = data.quantity # ext_params = self.get_entity_user_ext_params() # entity_id = self.ext_params['entity_id'] params_object:ParamsObject = ParamsObject() params_object.set_params_list([self.ext_params.get('entity_id')]) entity_service: EntityService = EntityService() get_producer_name = entity_service.get_data(params_object) producer_name = get_producer_name.entity_name category_params:ParamsObject = ParamsObject() category_params.set_params_list([data.category_id]) category_name = self.get_direct("_sGetCategory",category_params,False) template = template.replace("<item>", category_name[0]["Option_Text"]) template = template.replace("<target>",producer_name) template = template.replace("<allocated>",str(quantity)) # template = "<html><b>" + template + "<b></html>" #Total allocation for producer <item>-<target>-<allocated> return template
def _get_recipients(self, data: PaymentHeaderModel, conf): user_device_list = [] params: ParamsObject = ParamsObject() params_list = [] params_list.append(self.ext_params.get("send_to")) params.set_params_list(params_list) device_list = self.get_direct("sUserDeviceByIDGet", params, False) if device_list != "" and device_list is not None: if len(device_list) != 0: user_device_list.append(device_list) return user_device_list
def _build_description(self, action, data, template, conf): """ Get Awareness Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.awarness_id]) awareness = self.get_direct("sNotificationAwarenessGet", _params, False) awareness = awareness[0] template = template.replace("<TITLE>", str(awareness["Title"])) template = template.replace("<DESCRIPTION>", str(awareness["Description"])) template = template.replace("<CREATED_BY>", str(awareness["User_Name"])) return template
def _build_description(self, action, data, template, conf): """ Get Event Detail """ _params: ParamsObject = ParamsObject() _params.set_params_list([data.ticket_id]) ticket = self.get_direct("sNotificationTicketGet", _params, False) ticket = ticket[0] template = template.replace("<CREATED_BY>", str(ticket["User_Name"]) + os.linesep) template = template.replace("<TITLE>", str(ticket["Title"]) + os.linesep) template = template.replace("<DESCRIPTION>", str(ticket["Description"]) + os.linesep) template = template.replace("<SEVERITY>", str(ticket["Severity_Desc"])) return template
def post_get(self, cursor_object): if len(cursor_object.get_data()) > 0: cart_model: CartModel = CartModel() for each_tuple in cursor_object.get_data(): cart_model.cartid = each_tuple[0] cart_model.sessionid = each_tuple[1] cart_model.customerid = each_tuple[2] """ Get the Cart Items for this cart """ params: ParamsObject = ParamsObject() params.set_params_list([cart_model.cartid]) cart_model.items = CartItemRepo().get_data_list(params) return cart_model else: return None
def __get_group_users(self, notification_recipient_group_list): """ This method is used to get the users for the group if defined any :param notification_id: :return: List of User Device object """ user_device_list = [] if notification_recipient_group_list != "" and notification_recipient_group_list is not None: for each_group in notification_recipient_group_list: notification_recipient_group: NotificationRecipientGroupModel = each_group params: ParamsObject = ParamsObject() params.set_params_list([ notification_recipient_group.recipient_id, notification_recipient_group.type ]) device_list = self.get_direct( "sUserDeviceGetByNotificationGroup", params, False) if device_list != "" and device_list is not None: user_device_list.append(device_list) return user_device_list else: return user_device_list
def post_get_list(self, cursor_object): list_data = [] if len(cursor_object.get_data()) > 0: for each_tuple in cursor_object.get_data(): order_model: OrderModel = OrderModel() order_model.orderid = each_tuple[0] order_model.customerid = each_tuple[1] order_model.orderdate = str(each_tuple[2]) order_model.status = each_tuple[3] order_model.addressid = each_tuple[4] order_model.paymenttype = each_tuple[5] order_model.paymentstatus = each_tuple[6] order_model.totalprice = each_tuple[7] params: ParamsObject = ParamsObject() params.set_params_list([order_model.orderid]) order_model.items = OrderItemRepo().get_data_list(params) list_data.append(order_model) return list_data else: return None
def get_data_list_object_any_paginated(self, sp_name, params: ParamsObject): """ :description: This method allows user to get the data list object for any procedure which always returns the model object with pagination :param sp_name: Procedure name to call :param params: list of parameters :return: List of model object """ if base.DEBUG_ENABLED: LoggingHelper().log_debug(self.__class__, "", params) try: self.get_cursor(db_type="R").callproc(sp_name, params.get_params_list()) list_cursor_object = self.data_as_cursor_list_multiple_rs() return self.post_get_data_list_object_paginated(list_cursor_object) except Exception as ex: if base.DEBUG_ENABLED: LoggingHelper().log_error(self.__class__, "", str(ex)) if isinstance(ex, DatabaseException) or isinstance(ex, KaroException): raise DatabaseException(self.db_error_code, ex.error_message, self.data) else: raise DatabaseException(self.db_error_code, str(ex), self.data) finally: self.close_cursor() if base.DEBUG_ENABLED: LoggingHelper().log_debug(self.__class__, "", self.data)
def pre_get_list_object(self, params: ParamsObject): self.sp_name = "sBSSubjectDtlObjectGetList" self.params_list = params.get_params_list()
def get_products_by_search(self, params: ParamsObject): return self.get_direct_multiple("sGetProductBySearch", params.get_params_list())