def save_legalentity_closure_data(db, user_id, password, legal_entity_id,
                                  remarks, action_mode):
    current_time_stamp = get_current_date()
    data = db.call_proc("sp_legal_entity_name_by_id", (legal_entity_id, ))
    return_result = None
    if action_mode == "close":
        return_result = "Unable to Close the Legal Entity"
        result = db.call_update_proc(
            "sp_legalentity_closure_save",
            (user_id, legal_entity_id, 1, current_time_stamp, remarks))
        message_text = data[0]["legal_entity_name"] + ' has been closed'
    elif action_mode == "reactive":
        return_result = "Unable to Reactivate the Legal Entity"
        result = db.call_update_proc(
            "sp_legalentity_closure_save",
            (user_id, legal_entity_id, 0, current_time_stamp, remarks))
        message_text = data[0]["legal_entity_name"] + ' has been activated'

    if result:
        return_result = None
        db.save_activity(user_id, frmLegalEntityClosure, message_text)

    if (return_result is None):
        return result
    else:
        return return_result
Ejemplo n.º 2
0
    def reminder_to_assignee(self, client_info, compliance_info):
        current_date = get_current_date()
        print "Reminder to assignee ", self.legal_entity_id, " - ", current_date
        try :
            # print "begin process to remind inprogress compliance task %s " % (current_date)
            # client_info = get_client_settings(db)
            if client_info :
                # reminder_interval = int(client_info["assignee_reminder"])
                # logNotifyInfo("reminder_to_assignee", reminder_interval)
                count = 0
                for c in compliance_info:
                    if c["due_date"] is None :
                        continue

                    # if c["due_date"].date() < current_date.date() :
                    #     print "skipped due_date because due_date crossed", c["due_date"].date()
                    #     logNotifyInfo("skipped due_date", c["due_date"].date())
                    #     continue
                    days_left = abs((c["due_date"].date() - current_date.date()).days) + 1

                    if c["document_name"] not in (None, "None", "") :
                        compliance_name = c["document_name"] + " - " + c["compliance_task"]
                    else :
                        compliance_name = c["compliance_task"]
                    # date_diff = abs((current_date.date() - c["start_date"].date()).days)
                    # if date_diff == 0:
                    #     logNotifyInfo("skipped due_date reminder days is 0", current_date.date())
                    #     logNotifyInfo("skipped due_date", c["start_date"].date())
                    #     logNotifyInfo("skipped date_diff ", 0)
                    #     continue

                    # print date_diff
                    # print (date_diff % reminder_interval)

                    notification_text = "%s day(s) left to complete %s task" % (days_left, compliance_name)
                    extra_details = " %s - Reminder" % (c["compliance_history_id"])
                    # if (date_diff % reminder_interval) == 0 :
                    self.save_in_notification(
                        c["country_id"], c["domain_id"], c["business_group_id"], c["legal_entity_id"],
                        c["division_id"], c["unit_id"], c["compliance_id"], c["assignee"],
                        c["concurrence_person"], c["approval_person"],
                        notification_text, extra_details, notification_type_id=2, notify_to_all=False
                    )
                    a_name, assignee_email = self.get_email_id_for_users(c["assignee"])
                    email.notify_to_assignee(
                        a_name, days_left, compliance_name,
                        c["unit_name"], assignee_email
                    )
                    count += 1

                logNotifyInfo("reminder_to_assignee ", "%s compliances remind to assignee" % (count))
        except Exception, e:
            print e
            print(traceback.format_exc())
def process_get_assign_compliance_filters(db, session_user, session_category):
    le_info = get_user_based_legal_entity(db, session_user, session_category)
    div_info = get_user_based_division(db, session_user, session_category)
    cat_info = get_user_based_category(db, session_user, session_category)
    domains = get_domains_for_user(db, session_user, session_category)
    current_date = get_current_date()
    str_current_date = datetime_to_string(current_date)

    return clienttransactions.GetAssignCompliancesFormDataSuccess(
        le_info, div_info, cat_info, domains, str_current_date
    )
Ejemplo n.º 4
0
    def save_in_notification(self,
                             country_id,
                             domain_id,
                             business_group_id,
                             legal_entity_id,
                             division_id,
                             unit_id,
                             compliance_id,
                             assignee,
                             concurrence_person,
                             approval_person,
                             notification_text,
                             extra_details,
                             notification_type_id,
                             notify_to_all=True):
        def save_notification_users(notification_id, user_id):
            if user_id is not "NULL" and user_id is not None:
                q = "INSERT INTO tbl_notifications_user_log(notification_id, user_id) " + \
                    " VALUES (%s, %s) "
                v = (notification_id, user_id)
                self.execute(q, v)

        # notification_id = get_new_id(db, "tbl_notifications_log", "notification_id")
        created_on = get_current_date()
        column = [
            "country_id", "domain_id", "legal_entity_id", "unit_id",
            "compliance_id", "assignee", "approval_person",
            "notification_type_id", "notification_text", "extra_details",
            "created_on"
        ]
        values = [
            country_id, domain_id, legal_entity_id, unit_id, compliance_id,
            assignee, approval_person, notification_type_id, notification_text,
            extra_details, created_on
        ]
        if business_group_id is not None:
            column.append("business_group_id")
            values.append(business_group_id)
        if division_id is not None:
            column.append("division_id")
            values.append(division_id)
        if concurrence_person is not None:
            column.append("concurrence_person")
            values.append(concurrence_person)

        notification_id = self.insert("tbl_notifications_log", column, values)
        save_notification_users(notification_id, assignee)
        if notify_to_all:
            if approval_person is not None and assignee != approval_person:
                save_notification_users(notification_id, approval_person)
            if concurrence_person is not None or concurrence_person is not "NULL":
                save_notification_users(notification_id, concurrence_person)
Ejemplo n.º 5
0
def get_country_domain_timelines(db, country_ids, domain_ids, years):
    print years
    country_wise_timelines = []
    for country_id in country_ids:
        domain_wise_timeline = []
        for domain_id in domain_ids:
            columns = "month_from, month_to"
            condition = "country_id = %s and domain_id = %s "
            condition_val = [country_id, domain_id]
            rows = db.get_data(tblClientConfigurations, columns, condition,
                               condition_val)
            if len(rows) > 0:
                month_from = rows[0]["month_from"]
                month_to = rows[0]["month_to"]
                start_end_dates = []
                for year in years:
                    start_year = year
                    end_year = year + 1
                    start_date_string = None
                    end_date_string = None
                    start_date_string = "1-%s-%s" % (
                        db.string_months[month_from], start_year)
                    start_date = string_to_datetime(start_date_string)
                    if get_current_date() >= start_date.date():
                        # current year running
                        pass
                    else:
                        start_year = year - 1
                        end_year = year
                        start_date_string = "1-%s-%s" % (
                            db.string_months[month_from], start_year)
                        start_date = string_to_datetime(start_date_string)

                    end_date_string = "%s-%s-%s" % (
                        db.end_day_of_month[month_to],
                        db.string_months[month_to], end_year)
                    end_date = string_to_datetime(end_date_string)
                    r = relativedelta.relativedelta(
                        convert_datetime_to_date(end_date),
                        convert_datetime_to_date(start_date))
                    if r.years > 0:
                        end_date = (end_date -
                                    relativedelta.relativedelta(years=1))
                    start_end_dates.append({
                        "year": year,
                        "start_date": start_date,
                        "end_date": end_date
                    })
                domain_wise_timeline.append([domain_id, start_end_dates])
        country_wise_timelines.append([country_id, domain_wise_timeline])
        print country_wise_timelines
    return country_wise_timelines
def process_reassign_compliance_filters(db, request, session_user, session_category):
    domain_list = get_domains_for_user(db, session_user, session_category)
    unit_list = get_units_for_user(db, session_user)
    users_list = get_reassign_client_users(db)
    current_date = get_current_date()
    str_current_date = datetime_to_string(current_date)

    return clienttransactions.GetReassignComplianceFiltersSuccess(
        domains=domain_list,
        units=unit_list,
        legal_entity_users=users_list,
        current_date =str_current_date,
    )
Ejemplo n.º 7
0
    def save_in_group_db(self, export_obj, export_link):
        current_time_stamp = get_current_date()
        expiry_date = addHours(int(REGISTRATION_EXPIRY), current_time_stamp)

        _db = self._initiate_connection(self._group_info)
        try:
            _db.begin()
            export_obj.save_download_session(_db, expiry_date, export_link)
            _db.commit()

        except Exception, e:
            print e
            _db.rollback()
def resave_registration_token(db, client_id, email_id, save_mode, user_id):

    # def _del_olddata():
    #     condition = "client_id = %s and verification_type_id = %s"
    #     condition_val = [client_id, 1]
    #     db.delete(tblClientEmailVerification, condition, condition_val)
    #     return True

    short_name = get_short_name(db, client_id)
    current_time_stamp = get_current_date()
    registration_token = new_uuid()
    expiry_date = addHours(int(REGISTRATION_EXPIRY), current_time_stamp)

    link = "%suserregistration/%s/%s" % (CLIENT_URL, short_name,
                                         registration_token)
    print link

    notify_user_thread = threading.Thread(target=notify_user,
                                          args=[email_id, link])
    notify_user_thread.start()
    if short_name:
        SaveRegistrationData(db, registration_token, expiry_date, email_id,
                             client_id, current_time_stamp, user_id)
        if save_mode == "send":
            q = "insert into tbl_group_admin_email_notification(client_id, group_admin_email_id, " + \
                " registration_sent_by, registration_sent_on ) values(%s, %s, %s, %s)"
            db.execute(q, [client_id, email_id, user_id, current_time_stamp])
            message_text = 'Registartion Email has been sent successfully under the group - %s' % short_name
            db.save_activity(user_id, frmGroupAdminRegistraionEmail,
                             message_text)
            return True
        elif save_mode == "resend":
            q = "insert into tbl_group_admin_email_notification(client_id, group_admin_email_id, " + \
                " registration_resend_by, registration_resend_on ) values(%s, %s, %s, %s)"
            db.execute(q, [client_id, email_id, user_id, current_time_stamp])
            message_text = 'Registartion Email has been resend successfully under the group - %s' % short_name
            db.save_activity(user_id, frmGroupAdminRegistraionEmail,
                             message_text)
            return True
    else:
        return False
Ejemplo n.º 9
0
    def notify_escalation_to_all(self, client_info, compliance_info):
        current_date = get_current_date()
        print "Reminder escalation to all ", self.legal_entity_id, " - ", current_date
        logNotifyInfo("escalation_to_all", "begin process to notify escalations to all %s" % (current_date))
        # escalation_interval = int(client_info["escalation_reminder"])
        cnt = 0
        print compliance_info
        for c in compliance_info :
            if c["due_date"] is None :
                continue
            maps = json.loads(c["statutory_mapping"])[0]

            if c["document_name"] not in (None, "None", "") :
                compliance_name = c["document_name"] + " - " + c["compliance_task"]
            else :
                compliance_name = c["compliance_task"]

            compliance_name = '''"%s" under "%s"''' % (compliance_name, maps)
            uname = "%s & %s & %s" % (c["unit_code"], c["unit_name"], c["geography_name"])
            a_name, assignee_email = self.get_email_id_for_users(c["assignee"])

            over_due_days = abs((current_date.date() - c["due_date"].date()).days) + 1

            notification_text = "%s for %s is %s day(s) overdue by %s " % (compliance_name, uname, over_due_days, a_name)
            if c["frequency_id"] == 5 :
                notification_text = "On Occurrence Task - %s" % (notification_text)
            print notification_text
            extra_details = " %s - Escalation" % (c["compliance_history_id"])
            # if (over_due_days % escalation_interval) == 0 :
            self.save_in_notification(
                c["country_id"], c["domain_id"], c["business_group_id"],
                c["legal_entity_id"], c["division_id"], c["unit_id"], c["compliance_id"],
                c["assignee"], c["concurrence_person"], c["approval_person"], notification_text,
                extra_details, notification_type_id=3
            )

            cc_person = []
            concurrence_person = c["concurrence_person"]
            concur_msg = ''
            if concurrence_person == 0 :
                concurrence_person = None
            if concurrence_person is not None :
                c_name, concurrence_email = self.get_email_id_for_users(concurrence_person)
                cc_person.append(concurrence_email)
                concur_msg += '''"%s" for concurrence ''' % (c_name)
            ap_name, approval_email = self.get_email_id_for_users(c["approval_person"])
            cc_person.append(approval_email)

            concur_msg += '''and "%s" for approval''' % (ap_name)
            le_name = self.get_legal_entity_name(self.legal_entity_id)

            message = '''
                <p>Greetings from Compfie</p> \
                <p>We wish to notify that the "%s" assigned to %s with %s \
                for the "%s & %s" was expected to complete on or before %s. Now it
                has crossed due date and delayed for %s days. \
                This is a gentle reminder to rush up and comply  \
                the same in order to reduce the risk.</p> \
                <p>Always keep on track of reminders, messages, \
                escalations and statutory notifications and stay compliant.</p> \
                <p align="left">Thanks & regards,</p> \
                <p align="left">Compfie Administrator</p> \
            ''' % (compliance_name, concur_msg, le_name, uname, c["due_date"], over_due_days)

            email.notify_escalation(a_name, message, assignee_email, cc_person)
            cnt += 1
        logNotifyInfo("escalation count", cnt)
Ejemplo n.º 10
0
    def reminder_before_due_date(self, client_info, compliance_info):
        current_date = get_current_date()
        print "Reminder before due date ", self.legal_entity_id, " - ", current_date
        logNotifyInfo("before_due_date", "begin process to remind inprogress compliance task to all %s " % (current_date))

        # reminder_interval = int(client_info["escalation_reminder_in_advance"])
        cnt = 0
        for c in compliance_info:
            if c["due_date"] is None :
                continue

            if c["document_name"] not in (None, "None", "") :
                compliance_name = c["document_name"] + " - " + c["compliance_task"]
            else :
                compliance_name = c["compliance_task"]

            # if c["due_date"].date() < current_date.date() :
            #     logNotifyInfo("skipped due_date crossed current date", c["due_date"])
            #     continue

            days_left = abs((c["due_date"].date() - current_date.date()).days) + 1

            notification_text = "%s day(s) left to complete %s task" % (days_left, compliance_name)
            extra_details = " %s - Reminder" % (c["compliance_history_id"])
            # if days_left == reminder_interval:
            self.save_in_notification(
                c["country_id"], c["domain_id"], c["business_group_id"],
                c["legal_entity_id"], c["division_id"], c["unit_id"], c["compliance_id"],
                c["assignee"], c["concurrence_person"], c["approval_person"], notification_text,
                extra_details, notification_type_id=2
            )
            uname = "%s & %s & %s" % (c["unit_code"], c["unit_name"], c["geography_name"])
            compliance_name = '''"%s" under "%s"''' % (compliance_name, maps)
            a_name, assignee_email = self.get_email_id_for_users(c["assignee"])
            cc_person = []
            concurrence_person = c["concurrence_person"]
            if concurrence_person == 0 :
                concurrence_person = None
            if concurrence_person is not None :
                c_name, concurrence_email = self.get_email_id_for_users(concurrence_person)
                cc_person.append(concurrence_email)
                concur_msg += '''"%s" for concurrence''' % (c_name)
            ap_name, approval_email = self.get_email_id_for_users(c["approval_person"])
            cc_person.append(approval_email)

            concur_msg += '''and "%s" for approval''' % (ap_name)
            le_name = self.get_legal_entity_name(self.legal_entity_id)

            message = '''
                <p>Dear %s</p> \
                <p>Greetings from Compfie</p> \
                <p>We wish to notify that the "compliance_name" assigned to "%s" with %s \
                for the "%s & %s" falls due on %s. \
                This is a gentle reminder to rush up and comply  \
                the same in order to reduce the risk.</p> \
                <p>Always keep on track of reminders, messages, \
                escalations and statutory notifications and stay compliant.</p> \
                <p align="left">Thanks & regards,</p> \
                <p align="left">Compfie Administrator</p> \
            ''' % (a_name, compliance_name, concur_msg, le_name, uname, c["due_date"])

            email.notify_before_due_date(
                a_name, days_left, compliance_name,
                c["unit_name"],
                assignee_email, cc_person
            )
            cnt += 1
        logNotifyInfo("before_due_date", "%s compliance remind before due date" % cnt)