Exemplo n.º 1
0
def parse_uedate(string, uetitle, blamei):
    # 'Fr, 16. Okt 2018 [13:30]-Fr, 16. Okt 2018 [13:30]' -> (day, start_hm, end_hm)
    start,  end    = string.split("-")
    s_wday, e_wday = start[:2],    end[:2]
    s_day,  e_day  = start[4:-8],  end[4:-8]
    s_hm,   e_hm   = start[-6:-1], end[-6:-1]
    if s_wday != e_wday: print("\r(warn: inequal start/end weekday for '{}' cause {} - {}"
      .format(blamei, start, end))
    return "\t".join([utils.sanitize_date(s_day), s_hm, e_hm, uetitle, utils.sanitize_date(e_day)])
Exemplo n.º 2
0
 def get_time(day, start, end, room):
     return "\t".join([
         utils.sanitize_date(day.get_text(strip=True)[4:]),
         start.get_text(strip=True),
         end.get_text(strip=True),
         room.get_text(strip=True)
     ])
    def test__sanitize_data(self):
        date = '22/07/2019 14:05:01'

        date = sanitize_date(date)

        self.assertEquals(date, '2019-07-22 14:05:01')
Exemplo n.º 4
0
def canvi_titus(O, new_owners, create_case=False):

    for new_client in new_owners:
        try:
            cups = new_client.get('CUPS', '').strip().upper()

            msg = "Creating new profile of {}, dni: {}"
            step(
                msg.format(new_client['Nom nou titu'],
                           new_client['DNI'].strip().upper()))

            msg = "Getting address information of cups {}"
            step(msg.format(cups))

            cups_address = get_cups_address(O, cups)
            contract_info = get_contract_info(O,
                                              new_client.get('Contracte', ''))
            old_owner_vat = O.ResPartner.read(contract_info.titular[0],
                                              ['vat'])['vat']

            with transaction(O) as t:
                profile_data = create_fitxa_client(
                    t,
                    full_name=new_client['Nom nou titu'].strip(),
                    vat='ES{}'.format(new_client['DNI'].strip().upper()),
                    lang=LANG_TABLE.get(new_client['Idioma'].strip().upper(),
                                        'es_ES'),
                    email=new_client['Mail'].strip(),
                    phone=new_client['Tlf'].strip(),
                    street=cups_address['street'],
                    postal_code=cups_address['dp'] or '',
                    city_id=cups_address['id_municipi'],
                    state_id=cups_address['id_state'],
                    country_id=cups_address['id_country'],
                    iban=sanitize_iban(new_client['IBAN']))
                member_id = get_memberid_by_partner(t, profile_data.client_id)
                if create_case:
                    msg = "Creating change owner M1(T) atr case {} -> {}"
                    step(
                        msg.format(old_owner_vat,
                                   new_client['DNI'].strip().upper()))

                    changeowner_res = create_m1_chageowner(
                        t,
                        contract_number=new_client['Contracte'],
                        cups=cups,
                        new_owner_vat='ES{}'.format(
                            new_client['DNI'].strip().upper()),
                        new_owner_id=profile_data.client_id,
                        old_owner_id=contract_info.titular,
                        member_id=profile_data.client_id
                        if member_id else False,
                        address_id=profile_data.address_id,
                        notification_address_id=profile_data.address_id,
                        bank_id=profile_data.bank_id,
                        signature_date=sanitize_date(new_client['Data']),
                        cnae_id=contract_info.cnae[0],
                        owner_change_type='T',
                        lang=LANG_TABLE.get(
                            new_client['Idioma'].strip().upper(), 'es_ES'),
                        other_payer=False)
                    t.GiscedataSwitching.write(changeowner_res[2],
                                               dict(state='draft'))

                msg = "Setting as not 'estimable' and updating observations "\
                      "to contract: {}"
                step(msg.format(new_client['Contracte']))
                update_old_contract_information(
                    t,
                    contract_number=new_client['Contracte'],
                    cups=cups,
                    new_owner_id=profile_data.client_id,
                    new_bank_id=profile_data.bank_id,
                    member_id=member_id,
                    request_date=new_client['Data'])
        except xmlrpclib.Fault as e:
            msg = "An error ocurred creating {}, dni: {}, contract: {}. Reason: {}"
            error(
                msg.format(new_client['Nom nou titu'], new_client['DNI'],
                           new_client['Contracte'],
                           e.faultString.split('\n')[-2]))
        except Exception as e:
            msg = "An error ocurred creating {}, dni: {}, contract: {}. Reason: {}"
            error(
                msg.format(new_client['Nom nou titu'], new_client['DNI'],
                           new_client['Contracte'], e.message.encode('utf8')))
        else:
            result = profile_data.deepcopy()
            if create_case:
                contract_id = get_last_contract_on_cups(O, cups)
                result['case_id'] = changeowner_res[2]
                result['new_contract_id'] = contract_id
                result['cups'] = cups

            msg = "M1 ATR case successful created with data:\n {}"
            success(msg.format(json.dumps(result, indent=4, sort_keys=True)))