Пример #1
0
 def get_policy_list_html_tbl(self, *args, **kwargs):
     usernow = request.identity['user']
     dbase_query = self.get_active_policy_list(*args, **kwargs)
     outputlist = []
     td = TypeDict()
     for item in dbase_query:
         print('Placeholder: get person name here.')
         print('Placeholder: for fake data stuff removal.')
         member_holder = Member.by_id(item.policy_holder_id)
         policy_holder = 'Soap, Josephine'
         member_owner = Member.by_id(item.policy_owner_id)
         policy_owner = 'Sizpack, Frederick'
         #product = Product.by_id(item.product_id)
         #product_name = product.name
         product_name = 'ACME Product Name'
         #policy_state = td.get_pretty_name('policy_state_type', policy.policy_state_type_id)
         policy_state = td.get_pretty_name(
             'policy_state_type',
             td.get_id_of_name('policy_state_type', 'proposal'))
         outputlist.append({
             'policy_number':
             "<div class='edit entity_edit' policy_id='{1}'>{0}</div>".
             format(item.policy_number, item.id),
             'policy_holder':
             policy_holder,
             'policy_owner':
             policy_owner,
             'product':
             product_name,
             'state':
             policy_state,
         })
     theadlist = [
         'Policy Number', 'Policy Holder', 'Policy Owner', 'Product',
         'State'
     ]
     dbcolumnlist = [
         'policy_number',
         'policy_holder',
         'policy_owner',
         'product',
         'state',
     ]
     tdclasslist = [
         'action_link',
         'text-left',
         'text-left',
         'text-left',
         'text-left',
     ]
     return build_html_table(outputlist, dbcolumnlist, theadlist,
                             "policy_table", tdclasslist)
Пример #2
0
    def save_new_policy(self, *args, **kwargs):
        product_id = kwargs.get('product_id')

        td = TypeDict()
        individual = td.get_id_of_name('policy_type', 'individual')
        proposal_date = td.get_id_of_name('policy_date_type', 'proposal')
        proposal_state = td.get_id_of_name('policy_state_type', 'proposal')

        product = Product.by_id(product_id)
        policy_number = self.generate_new_policy_number(product_id)
        product_frequency_type_id = kwargs.get('product_frequency_type_id')
        #Save Policy
        policy_id = self.write_new_policy({
            'policy_number':
            policy_number,
            'policy_type_id':
            individual,
            'product_id':
            policy_id,
            'policy_owner_id':
            kwargs.get('member_id'),
            'policy_holder_id':
            kwargs.get('member_id'),
            'application_form_serial_no':
            kwargs.get('application_form_serial_no'),
            'intermediary_id':
            kwargs.get('intermediary_id'),
        })
        policy_state_id = self.write_new_policy_state(
            **{
                'policy_id': policy_id,
                'policy_state_type_id': proposal_state
            })
        self.write_new_policy_date({
            'policy_id': policy_id,
            'policy_date_type_id': proposal_date,
            'date': now.today(),
        })
        return str(policy_id)
Пример #3
0
    def get_new_policy_html(self, *args, **kwargs):
        product_id = kwargs.get('product_id', None)
        product = Product.by_id(product_id)
        td = TypeDict()
        print('Placehodler: Fake date hereunder for removal')
        if product:  # Initial protective code. Testing only.
            product_type_id = product.product_type_id
        else:
            product_type_id = td.get_id_of_name('product_type', 'voucher')

        if product_type_id == td.get_id_of_name('product_type', 'voucher'):
            #Then do Voucher stuff
            return self.get_new_voucher_policy_html(*args, **kwargs)
        if product_type_id == td.get_id_of_name('product_type', 'traditional'):
            #Then do Traditional stuff
            return self.get_new_traditional_policy_html(*args, **kwargs)
        if product_type_id == td.get_id_of_name('product_type', 'term_life'):
            #Then do Term Life stuff
            return self.get_new_term_life_policy_html(*args, **kwargs)
        if product_type_id == td.get_id_of_name('product_type', 'credit_life'):
            #Then do Credit Life stuff
            return self.get_new_credit_life_policy_html(*args, **kwargs)
        return ''
Пример #4
0
SEARCHKEY_ALLOCATION_GROUP = 'Allocation_Group_SearchKeyword'
SEARCHKEY_ALLOCATION_FROM = 'Allocation_FromDate_SearchKeyword'
SEARCHKEY_ALLOCATION_PRODUCT = 'Allocation_Product_SearchKeyword'
SEARCHKEY_ALLOCATION_PRODUCT_CLASS = 'Allocation_ProductClass_SearchKeyword'

SEARCHKEY_GLEXTRACT_TO = 'GLExtract_ToDate_SearchKeyword'
SEARCHKEY_GLEXTRACT_GROUP = 'GLExtract_Group_SearchKeyword'
SEARCHKEY_GLEXTRACT_FROM = 'GLExtract_FromDate_SearchKeyword'
SEARCHKEY_GLEXTRACT_PRODUCT_CLASS = 'GLExtract_ProductClass_SearchKeyword'
SEARCHKEY_GLEXTRACT_ALLOCATION_TYPE = 'GLExtract_Allocation_Type_SearchKeyword'
SEARCHKEY_GLEXTRACT_CLAIM_VOUCHER_TYPE = 'GLExtract_Claim_Policy_Type_SearchKeyword'

DEFAULT_TO_DATE = datetime.date(datetime.now() - timedelta(days=1))
DEFAULT_FROM_DATE = DEFAULT_TO_DATE - timedelta(days=30)

TYPEUTIL = TypeDictionary()


class ReportController(BaseController):
    def __init__(self, *args, **kwargs):
        pass

    @require(predicates.not_anonymous())
    @expose('rocket.templates.generic')
    def policy_sales(self, *args, **kwargs):
        html = self.get_active_policy_sales_html(*args, **kwargs)
        javascript = self.get_javascript_policy_sales_onload()
        title = _("Policy Sales")
        return dict(title=title, html=html, javascript=javascript)

    @expose()
Пример #5
0
    def save_new_policy_dates(self, *args, **kwargs):
        product_id = kwargs.get('product_id')
        td = TypeDict()
        print('Placeholder: for fake data removal.')
        #product_frequency_type_id = kwargs.get('product_frequency_type_id')
        product_frequency_type_id = td.get_id_of_name('product_frequency_type',
                                                      'monthly')

        #Save Policy Dates
        wait_period = 0
        wait_period_type_id = None
        cover_period = 0
        cover_period_type_id = None
        cover_from_date = date.today()
        cover_to_date = None

        outputlist = ProductPeriod.by_attr_all('product_id', product_id)
        for item in outputlist:
            #Period Effect
            if item.product_period_effect_type_id == td.get_id_of_name(
                    'product_period_effect_type', 'active'):
                #Cover period can get set here..
                cover_period = item.time_period
                cover_period_type_id = item.product_period_type_id

            elif item.product_period_effect_type_id == td.get_id_of_name(
                    'product_period_effect_type', 'waiting'):
                #Set Wait period here
                wait_period = item.time_period
                wait_period_type_id = item.product_period_type_id

        #Evaluate the periods
        cover_from_date = self.set_cover_from_date(cover_from_date,
                                                   wait_period,
                                                   wait_period_type_id)
        cover_to_date = self.set_cover_to_date(cover_from_date, cover_period)
        #Default vaules
        accepted_date = date.today()
        policy_date = date.today()
        valid_from_date = cover_from_date
        valid_to_date = cover_to_date
        maturatity_date = None
        member_age = kwargs.get("memberage", None)
        # Maturity
        if product.maturity_age and member_age:
            #Then we can set the maturity date by obtaining the difference between the mmebers current age and the maturity age
            maturatity_date = add_months_to_date(
                date.today(), ((product.maturity_age - member_age) + 1))

        #Save away the various dates as needed.
        if accepted_date:
            policy_date_id = self.write_new_policy_date({
                'policy_id':
                policy_id,
                'policy_date_type_id':
                td.get_id_of_name('policy_date_type', 'accepted'),
                'date':
                accepted_date,
            })

        if policy_date:
            policy_date_id = self.write_new_policy_date({
                'policy_id':
                policy_id,
                'policy_date_type_id':
                td.get_id_of_name('policy_date_type', 'policy'),
                'date':
                policy_date,
            })

        if valid_from_date:
            policy_date_id = self.write_new_policy_date({
                'policy_id':
                policy_id,
                'policy_date_type_id':
                td.get_id_of_name('policy_date_type', 'valid_from'),
                'date':
                valid_from_date,
            })

        if valid_to_date:
            policy_date_id = self.write_new_policy_date({
                'policy_id':
                policy_id,
                'policy_date_type_id':
                td.get_id_of_name('policy_date_type', 'valid_to'),
                'date':
                valid_to_date,
            })

        if maturatity_date:
            policy_date_id = self.write_new_policy_date({
                'policy_id':
                policy_id,
                'policy_date_type_id':
                td.get_id_of_name('policy_date_type', 'maturatity'),
                'date':
                maturatity_date,
            })
        return 'true'
Пример #6
0
    def get_policy_card_header_html(self, policy_id=None, *args, **kwargs):
        print('Placeholder: remove comment next line')
        #if not policy_id: return ''
        policy = Policy.by_id(policy_id)
        print('Placeholder: remove comment next line')
        #if not policy: return ''
        member = Member.by_id(policy.policy_owner_id) if policy else None
        print('Placeholder: remove comment next line')
        #if not member: return ''
        product = Product.by_id(policy.product_id) if policy else None
        print('Placeholder: remove comment next line')
        #if not product: return ''

        #Get the person from Vault
        print('Placeholder: for vault.')

        print('Placeholder: left typedict here for sequenc.')
        td = TypeDict()

        print('Placeholder: for fake data removal.')
        person = 'Placeholder for vault'
        identity_number = '1234567890123'
        name = 'Joe'
        surname = 'Soap'

        this_person = surname + ', ' + name + ' (' + identity_number + ')'
        print('Placeholder: for fake data removel.')
        if product:  # Initial protective code. Testing only.
            product_type_id = product.product_type_id
            product_code = product.code
            product_name = product.name
            product_owner_id = product.product_owner_id
            product_insurer_id = product.insurer_id
            product_life_assured_type_id = product.product_life_assured_type_id
            currency_id = product.currency_id
        else:
            product_type_id = td.get_id_of_name('product_type', 'voucher')
            product_code = 'TEST001'
            product_name = 'Test Product Number 001'
            product_owner_id = 1
            product_insurer_id = 2
            product_life_assured_type_id = td.get_id_of_name(
                'product_life_assured_type', 'member_and_family')
            product_currency_id = 1

        traditional = td.get_id_of_name('product_type', 'traditional')
        fixed_price = td.get_id_of_name('product_price_initial_setup_type',
                                        'fixed_price')
        product_type = td.get_pretty_name('product_type', product_type_id)
        life_assured_type = td.get_pretty_name('product_life_assured_type',
                                               product_life_assured_type_id)

        html = f"""
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <div class="row d-flex">
                            <div class="col-md-9">
                                <h4 class="card-title">Create new Policy for: </h4>
                                <h3 class="card-title">{this_person}</h3>
                            </div>
                            <div class="col-md-3 text-right">
                                <button id="return_to_policy_list" class="btn btn-primary ml-auto">Return to Policy List</button>
                            </div>
                        </div>
                        <hr>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-7">
                                    <div class="form-group row">
                                        <label class="col-md-3 col-form-label">{product_code} - </label>
                                        <label class="col-md-3 col-form-label">{product_name}</label>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-md-3 col-form-label">{_('Life(s) Assured: ')}</label>
                                        <label class="col-md-3 col-form-label">{life_assured_type}</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        """
        return html
Пример #7
0
    def get_new_voucher_policy_html(self, *args, **kwargs):
        policy_id = kwargs.get('policy_id', None)
        if not policy_id: return 'false'
        policy = Policy.by_id(policy_id)
        member = Member.by_id(policy.policy_holder_id) if policy else None
        product = Product.by_id(policy.product_id) if policy else None
        td = TypeDict()
        #product_type_id = product.product_type_id
        product_type_id = td.get_id_of_name('product_type', 'voucher')
        product_type = td.get_pretty_name('product_type', product_type_id)

        # HEADER
        card_header = self.get_policy_card_header_html(policy_id)
        # TAB 1
        card_premium_and_dates = self.get_show_policy_premium_dates_html(
            policy_id)
        # TAB 2
        card_beneficiary = self.get_show_policy_beneficiary_html(policy_id)
        # TAB 3
        card_loaders = self.get_show_policy_loaders_html(policy_id)
        # TAB 4
        card_policy_summary = self.get_show_policy_summary_html(policy_id)
        # TAB 5
        card_policy_accept = self.get_show_policy_accept_html(policy_id)

        form_show_tab1 = f"""
        <form id='form_edit_voucher_product'>
            {card_premium_and_dates}
        </form>
        """

        form_show_tab2 = f"""
        <form id='form_edit_voucher_product'>
            {card_beneficiary}
        </form>
        """

        form_show_tab3 = f"""
        <form id='form_edit_voucher_product'>
            {card_loaders}
        </form>
        """

        form_show_tab4 = f"""
        <form id='form_edit_voucher_product'>
            {card_policy_summary}
        </form>
        """

        form_show_tab5 = f"""
        <form id='form_edit_voucher_product'>
            {card_policy_accept}
        </form>
        """

        html = f"""
        {card_header}
        <div class="row">
            <div class="col-md-12 ml-auto mr-auto">
                <div class="col-md-12 ml-auto mr-auto">
                    <ul class="nav nav-pills nav-pills-primary justify-content-center" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" data-toggle="tab" href="#tab1" role="tablist">
                                Premium and Dates
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#tab2" role="tablist">
                                Beneficiaries
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#tab3" role="tablist">
                                Loaders
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#tab4" role="tablist">
                                Summary
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" data-toggle="tab" href="#tab5" role="tablist">
                                Acceptance
                            </a>
                        </li>
                    </ul>
                </div>

                <div class="tab-content tab-space tab-subcategories">
                    <div class="tab-pane active" id="tab1">
                        {form_show_tab1}
                    </div>
                    <div class="tab-pane" id="tab2">
                        {form_show_tab2}
                    </div>
                    <div class="tab-pane" id="tab3">
                        {form_show_tab3}
                    </div>
                    <div class="tab-pane" id="tab4">
                        {form_show_tab4}
                    </div>
                    <div class="tab-pane" id="tab5">
                        {form_show_tab5}
                    </div>
                </div>
            </div>
        </div>
        """
        return html