コード例 #1
0
def get_legal_entity_info(db, entity_id):
    data = db.call_proc_with_multiresult_set(
        "sp_client_groups_legal_entity_info", (entity_id, ), 2)
    org_list = []
    result = None
    for d in data[1]:
        org_list.append(
            clientcoordinationmaster.LegalEntityOrganisation(
                d["legal_entity_id"], d["domain_id"], d["domain_name"],
                d["organisation_id"], d["organisation_name"], d["count"],
                d["o_count"]))
    for d1 in data[0]:
        old_file_space = None
        if (d1["o_file_space_limit"] is not None):
            old_file_space = int(d1["o_file_space_limit"])

        result = clientcoordinationmaster.GetLegalEntityInfoSuccess(
            d1["legal_entity_id"], d1["bg_name"],
            datetime_to_string(d1["contract_from"]),
            datetime_to_string(d1["contract_to"]), int(d1["file_space_limit"]),
            d1["total_licence"], d1["total_view_licence"], d1["remarks"],
            org_list, d1["o_legal_entity_name"], d1["o_business_group_name"],
            datetime_to_string(d1["o_contract_from"]),
            datetime_to_string(d1["o_contract_to"]), old_file_space,
            d1["o_total_licence"], d1["o_total_view_licence"],
            d1["o_group_admin_email_id"])

    return result
コード例 #2
0
def return_domainwise_agreement_report(domainwise_agreement_list):
    results = []
    for client_agreement in domainwise_agreement_list:
        le_admin_contactno = 'Not Available'
        if client_agreement["le_admin_contactno"] is not None:
            le_admin_contactno = client_agreement["le_admin_contactno"]

        le_admin_email = 'Not Available'
        if client_agreement["le_admin_email"] is not None:
            le_admin_email = client_agreement["le_admin_email"]
        results.append(
            technoreports.DomainwiseAgreementList(
                legal_entity_id = int(client_agreement["legal_entity_id"]),
                domain_id = int(client_agreement["domain_id"]),
                legal_entity_name = client_agreement["legal_entity_name"],
                contract_from = datetime_to_string(client_agreement["contract_from"]),
                contract_to = datetime_to_string(client_agreement["contract_to"]),
                group_name=client_agreement["group_name"],
                group_admin_email=client_agreement["groupadmin_email"],
                domain_total_unit=int(client_agreement["domain_total_unit"]),
                activation_date=datetime_to_string(client_agreement["activation_date"]),
                domain_used_unit=int(client_agreement["domain_used_unit"]),
                legal_entity_admin_contactno = le_admin_contactno,
                legal_entity_admin_email = le_admin_email,
                business_group_name=client_agreement["business_group_name"]
            )
        )
    return results
コード例 #3
0
def return_client_agreement_report(client_agreement_list):
    results = []
    for client_agreement in client_agreement_list:
        le_admin_contactno = 'Not Available'
        if client_agreement["le_admin_contactno"] is not None:
            le_admin_contactno = client_agreement["le_admin_contactno"]

        le_admin_email = 'Not Available'
        if client_agreement["le_admin_email"] is not None:
            le_admin_email = client_agreement["le_admin_email"]
        results.append(
            technoreports.ClientAgreementList(
                legal_entity_id = int(client_agreement["legal_entity_id"]),
                domain_id = int(client_agreement["domain_id"]),
                legal_entity_name = client_agreement["legal_entity_name"],
                total_licence = int(client_agreement["total_licence"]),
                used_licence = int(client_agreement["used_licence"]),
                file_space = int(client_agreement["file_space_limit"]),
                used_file_space = int(client_agreement["used_file_space"]),
                contract_from = datetime_to_string(client_agreement["contract_from"]),
                contract_to = datetime_to_string(client_agreement["contract_to"]),
                group_name=client_agreement["group_name"],
                group_admin_email=client_agreement["groupadmin_email"],
                is_closed=bool(client_agreement["is_closed"]),
                domain_count=int(client_agreement["domaincount"]),
                d_name=client_agreement["domain_name"],
                domain_total_unit=int(client_agreement["domain_total_unit"]),
                activation_date=datetime_to_string(client_agreement["activation_date"]),
                domain_used_unit=int(client_agreement["domain_used_unit"]),
                legal_entity_admin_contactno = le_admin_contactno,
                legal_entity_admin_email = le_admin_email,
                business_group_name=client_agreement["business_group_name"],
            )
        )
    return results
コード例 #4
0
def get_notifications(db, notification_type, session_user, client_id=None):
    user_type = None
    if session_user != 0:
        user_type = get_user_type(db, session_user)

    columns = "tn.notification_id, notification_text, link, " + \
        "created_on, read_status"
    join_type = "left join"
    tables = [tblNotifications, tblNotificationsStatus]
    aliases = ["tn", "tns"]
    join_conditions = ["tn.notification_id = tns.notification_id"]
    where_condition = " tns.user_id =%s "
    where_condition_val = [session_user]
    if user_type == "Techno":
        where_condition += " AND link not like %s "
        cond = "%sstatutory%s" % ("%", "%")
        where_condition_val.append(cond)
    elif user_type == "Knowledge":
        where_condition += " AND link not like %s "
        cond = "%client%s" % ("%", "%")
        where_condition_val.append(cond)
    where_condition += "order by created_on DESC limit 30"
    rows = db.get_data_from_multiple_tables(columns, tables, aliases,
                                            join_type, join_conditions,
                                            where_condition,
                                            where_condition_val)
    notifications = []
    for row in rows:
        notifications.append(
            generalprotocol.Notification(row["notification_id"],
                                         row["notification_text"], row["link"],
                                         bool(row["created_on"]),
                                         datetime_to_string(
                                             row["created_on"])))
    return notifications
コード例 #5
0
def process_onoccurrence_transaction_list(db, request, session_user):

    compliance_id = request.compliance_id
    unit_id = request.unit_id

    resultRows = getLastTransaction_Onoccurrence(db, compliance_id, unit_id)
    transactionList = []

    for row in resultRows:
        compliance_hisory_id = int(row["compliance_history_id"])
        compliance_id = int(row["compliance_id"])
        compliance_task = row["compliance_task"]
        on_statutory = row["statutory"]
        on_unit = row["unit"]
        compliance_description = row["compliance_description"]
        start_date = datetime_to_string(row["start_date"])
        assignee_name = row["assignee"]
        completion_date = datetime_to_string_time(row["completion_date"])
        concurrer_name = row["concurr"]
        concurred_on = datetime_to_string_time(row["concurred_on"])
        approver_name = row["approver"]
        approver_on = datetime_to_string_time(row["approved_on"])
        on_compliance_status = row["compliance_status"]

        transactionList.append(
            clientcore.GetOnoccurrencce_Last_Transaction(
                compliance_hisory_id, compliance_id, compliance_task,
                on_statutory, on_unit, compliance_description, start_date,
                assignee_name, completion_date, concurrer_name, concurred_on,
                approver_name, approver_on, on_compliance_status))

    return transactionList
コード例 #6
0
def get_profile(db, contract_from, contract_to, no_of_user_licence,
                total_disk_space, total_disk_space_used):
    contract_from = datetime_to_string(contract_from)
    contract_to = datetime_to_string(contract_to)

    licence_holder_rows = get_licence_holder_details(db)
    licence_holders = []
    for row in licence_holder_rows:
        employee_name = None
        unit_name = None
        if row["is_service_provider"] == 0:
            if (row["employee_code"] == "0"):
                employee_name = row["employee_name"]
            else:
                employee_name = "%s - %s" % (row["employee_code"],
                                             row["employee_name"])
        else:
            employee_name = "%s - %s" % (row["service_provider_name"],
                                         row["employee_name"])

        if row["unit_name"] == None:
            unit_name = " - "
        else:
            unit_name = "%s - %s" % (row["unit_code"], row["unit_name"])
        user_id = row["user_id"]
        email_id = row["email_id"]
        contact_no = row["contact_no"]
        address = row["address"]
        is_admin = False if (row["is_admin"] == 0) else True
        is_active = False if (row["is_active"] == 0) else True
        is_primary_admin = False if (row["is_primary_admin"] == 0) else True
        licence_holders.append(
            clientadminsettings.LICENCE_HOLDER(user_id, employee_name,
                                               email_id, contact_no, unit_name,
                                               address, is_admin, is_active,
                                               is_primary_admin))
    remaining_licence = (no_of_user_licence) - len(licence_holder_rows)

    used_space = round((total_disk_space_used / (1024 * 1024 * 1024)), 2)
    total_space = round(total_disk_space / (1024 * 1024 * 1024), 2)

    profile_detail = clientadminsettings.PROFILE_DETAIL(
        contract_from, contract_to, no_of_user_licence, remaining_licence,
        licence_holders, total_space, used_space)
    return profile_detail
コード例 #7
0
def process_UserManagement_list_LegalEntities(db, request, session_user):
    resultRows = userManagement_list_GetLegalEntities(db)
    leList = []
    for row in resultRows:
        country_name = row["country_name"]
        business_group_name = row["business_group_name"]
        legal_entity_id = row["legal_entity_id"]
        legal_entity_name = row["legal_entity_name"]
        contract_from = datetime_to_string(row["contract_from"])
        contract_to = datetime_to_string(row["contract_to"])
        total_licence = row["total_licence"]
        used_licence = row["used_licence"]
        leList.append(
            clientcore.ClientLegalEntities_UserManagementList(
                country_name, business_group_name, legal_entity_id,
                legal_entity_name, contract_from, contract_to, total_licence,
                used_licence))
    return leList
コード例 #8
0
def get_download_bulk_compliance_data(db, unit_id, domain_id,
                                      level_1_statutory_name, frequency_name,
                                      session_user, start_count, to_count):
    rows = return_past_due_dates(db, domain_id, unit_id,
                                 level_1_statutory_name)
    level_1_statutory_wise_compliances = {}
    total_count = 0
    compliance_count = 0
    for compliance in rows:
        s_maps = compliance["statutory_mapping"]
        statutories = s_maps
        level_1 = statutories
        if level_1 not in level_1_statutory_wise_compliances:
            level_1_statutory_wise_compliances[level_1] = []

        compliance_name = compliance["compliance_task"]
        if compliance["document_name"] not in (None, "None", ""):
            compliance_name = "%s - %s" % (compliance["document_name"],
                                           compliance_name)
        employee_code = compliance["employee_code"]
        if employee_code is None:
            employee_code = "Administrator"
        assingee_name = "%s - %s" % (employee_code,
                                     compliance["employee_name"])
        final_due_dates, summary = calculate_final_due_dates(
            db, (compliance, ), domain_id, unit_id)
        total_count += len(final_due_dates)

        for due_date in final_due_dates:
            due_date_parts = due_date.replace("'", "").split("-")
            year = due_date_parts[0]
            month = due_date_parts[1]
            day = due_date_parts[2]
            due_date = datetime.date(int(year), int(month), int(day))

            statutories_strip = statutories[0].strip()

            level_1_statutory_wise_compliances[level_1].append(
                UNIT_WISE_STATUTORIES_FOR_PAST_RECORDS(
                    compliance["compliance_id"], compliance_name,
                    compliance["compliance_description"],
                    clientcore.COMPLIANCE_FREQUENCY(compliance["frequency"]),
                    summary, datetime_to_string(due_date), assingee_name,
                    compliance["assignee"]))
    statutory_wise_compliances = []
    for (level_1_statutory_name,
         compliances) in level_1_statutory_wise_compliances.iteritems():
        print "len(compliances)-->", len(compliances)
        if len(compliances) > 0:
            statutory_wise_compliances.append(
                STATUTORY_WISE_COMPLIANCES(level_1_statutory_name,
                                           compliances))
    # print [STATUTORY_WISE_COMPLIANCES.level_1_statutory_name for STATUTORY_WISE_COMPLIANCES in statutory_wise_compliances]
    # print [STATUTORY_WISE_COMPLIANCES.compliances for STATUTORY_WISE_COMPLIANCES in statutory_wise_compliances]
    print statutory_wise_compliances
    print "Total-> ", total_count
    return statutory_wise_compliances, total_count
コード例 #9
0
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
    )
コード例 #10
0
def upload_completed_task_current_year_csv(db, request_frame, session_user):

    if request_frame.csv_size > 0:
        pass
    # save csv file
    csv_name = convert_base64_to_file(BULKUPLOAD_CSV_PATH,
                                      request_frame.csv_name,
                                      request_frame.csv_data)
    # read data from csv file
    header, completed_task_data = read_data_from_csv(csv_name)
    # csv data validation
    cObj = ValidateCompletedTaskCurrentYearCsvData(db, completed_task_data,
                                                   session_user,
                                                   request_frame.csv_name,
                                                   header)
    # print "request_frame.legal_entity_id>>", request_frame.legal_entity_id
    res_data = cObj.perform_validation(request_frame.legal_entity_id)

    if res_data is False:
        return bu_ct.InvalidCsvFile()
    elif res_data["return_status"] is True:
        current_date_time = get_date_time_in_date()
        str_current_date_time = datetime_to_string(current_date_time)
        unit_id = res_data["unit_id"]
        domain_id = res_data["domain_id"]
        client_id, client_group_name = get_client_id_by_le(
            db, request_frame.legal_entity_id)
        csv_args = [
            client_id, request_frame.legal_entity_id, domain_id, unit_id,
            client_group_name, csv_name, session_user, str_current_date_time,
            res_data["total"], res_data["doc_count"], "0", "0"
        ]

        new_csv_id = save_completed_task_current_year_csv(
            db, csv_args, session_user)
        if new_csv_id:
            if save_completed_task_data(db, new_csv_id, res_data["data"],
                                        client_id) is True:
                result = bu_ct.UploadCompletedTaskCurrentYearCSVSuccess(
                    res_data["total"], res_data["valid"], res_data["invalid"],
                    new_csv_id, csv_name, res_data["doc_count"],
                    res_data["doc_names"], unit_id, domain_id)
        # csv data save to temp db
    else:
        result = bu_ct.UploadCompletedTaskCurrentYearCSVFailed(
            res_data["invalid_file"], res_data["mandatory_error"],
            res_data["max_length_error"], res_data["duplicate_error"],
            res_data["invalid_char_error"], res_data["invalid_data_error"],
            res_data["inactive_error"], res_data["total"], res_data["invalid"],
            res_data["invalid_file_format"], res_data["invalid_date"])

    return result
コード例 #11
0
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,
    )
コード例 #12
0
def return_statutory_notifications(
    statutory_notifications
):
    notifications = []
    for notification in statutory_notifications:
        notifications.append(
            technoreports.StatutoryNotificationList(
                statutory_name=notification["statutory_name"],
                compliance_task=notification["compliance_task"],
                description=notification["description"],
                notification_text=notification["notification_text"],
                date=datetime_to_string(notification["created_on"])
            )
        )

    return notifications
コード例 #13
0
    def initiate_contract_request(self, row):
        _db_info = self.db_server_indo()
        _file_server_url = "http://%s:%s/api/formulatedownload" % (self.file_server_ip, self.file_server_port)
        _data = [
            "FormulateDownload",
            {
                "le_id": self.legal_entity_id,
                "formulate_info": str(_db_info),
                "extra_details": "",
                "unique_code": ""
            }
        ]
        req = {
            "session_token": "%s-session" % (str(self.client_id)),
            "request": _data
        }
        req = json.dumps(["%s" % (self.client_id), req])
        if self.file_server_request(_file_server_url, req) :
            if row :
                group_name, group_email = self.get_group_name()

                le_name = row.get("legal_entity_name")
                c_id = row.get("country_id")
                le_id = row.get("legal_entity_id")
                expire_date = datetime_to_string(row.get("contract_to"))

                n_text = ''' Your contract with Compfie for the legal entity %s of %s is about to expire on %s.
                        Kindly renew your contract to avail the services continuously.
                        Before contract expiration you can download documents ''' % (le_name, group_name, expire_date)

                extra_details = "download/%s-data.zip" % (le_name)

                column = ["notification_type_id", "notification_text", "created_on", "legal_entity_id", "country_id", "extra_details"]
                values = [2, n_text, self.current_date, le_id, c_id, extra_details]
                notify_id = self.insert("tbl_notifications_log", column, values)
                users = self.get_admins()
                q = "INSERT INTO tbl_notifications_user_log(notification_id, user_id) " + \
                    " VALUES (%s, %s) "
                for u in users :
                    self.execute(q, [notify_id, u["user_id"]])

                email.notify_contract_expiration(group_email, le_name, group_name, expire_date)