def main(company_name, format):
    """
    TODO: i should look into creating a pipeline to make it easier to read
    """
    company = Company(company_name)
    company_listings = company.get_all_listings()

    filtered = filter_jobs(company_listings, 'text')
    unnested = unnest_categories(filtered, 'categories')
    excluded = exclude_departments(unnested)
    if format == 'csv':
        excluded.to_csv(f'~/Desktop/{company_name}_jobs.csv', index=False)
    if format == 'pretty':
        # if im being lazy and just want to look at a pretty page instead
        open_urls(excluded, 'hostedUrl')
Exemple #2
0
    def retrieveCBidder(self):
        try:

            if not (self.cBidder == self.undefined):
                temp = Company.get(self.cBidder)
                if temp.readisValid():
                    return temp
                else:
                    return self.undefined
            else:
                return self.undefined
        except:
            return self._generalError
Exemple #3
0
    def connectAuthNet(self, company_id):
        payment_api_login = False
        payment_gateway_id = False
        comps = Company()
        companies = comps.where({'id': company_id})
        if companies:
            for company in companies:
                payment_api_login = str(company['payment_api_login'])
                payment_gateway_id = str(company['payment_gateway_id'])
        if payment_api_login and payment_gateway_id:
            authorize.Configuration.configure(
                authorize.Environment.PRODUCTION,
                payment_api_login,
                payment_gateway_id,
            )
            # authorize.Configuration.configure(
            #     authorize.Environment.PRODUCTION,
            #     'api_login_id',
            #     'api_transaction_key',
            # )

            return True
        else:
            return False
 def _format_company_data(self, data: Tuple, cnpj: str) -> Company:
     cnpj_only_digits = self._cnpj_only_digits(cnpj)
     cnpj_basico, cnpj_ordem, cnpj_dv = self._split_cnpj(cnpj)
     full_cnpj = self._format_full_cnpj(cnpj)
     formatted_data = [self._always_str_or_none(value) for value in data]
     return Company(
         cnpj_basico=cnpj_basico,
         cnpj_ordem=cnpj_ordem,
         cnpj_dv=cnpj_dv,
         cnpj_completo=full_cnpj,
         cnpj_completo_apenas_numeros=cnpj_only_digits,
         identificador_matriz_filial=formatted_data[4],
         nome_fantasia=formatted_data[5],
         situacao_cadastral=formatted_data[6],
         data_situacao_cadastral=formatted_data[7],
         motivo_situacao_cadastral=formatted_data[8],
         nome_cidade_exterior=formatted_data[9],
         data_inicio_atividade=formatted_data[10],
         cnae_fiscal_secundario=formatted_data[11],
         tipo_logradouro=formatted_data[12],
         logradouro=formatted_data[13],
         numero=formatted_data[14],
         complemento=formatted_data[15],
         bairro=formatted_data[16],
         cep=formatted_data[17],
         uf=formatted_data[18],
         ddd_telefone_1=formatted_data[19],
         ddd_telefone_2=formatted_data[20],
         ddd_telefone_fax=formatted_data[21],
         correio_eletronico=formatted_data[22],
         situacao_especial=formatted_data[23],
         data_situacao_especial=formatted_data[24],
         razao_social=formatted_data[25],
         natureza_juridica=formatted_data[26],
         qualificacao_do_responsavel=formatted_data[27],
         capital_social=formatted_data[28],
         porte=formatted_data[29],
         ente_federativo_responsavel=formatted_data[30],
         opcao_pelo_simples=formatted_data[31],
         data_opcao_pelo_simples=formatted_data[32],
         data_exclusao_pelo_simples=formatted_data[33],
         opcao_pelo_mei=formatted_data[34],
         data_opcao_pelo_mei=formatted_data[35],
         data_exclusao_pelo_mei=formatted_data[36],
         cnae=formatted_data[37],
         pais=formatted_data[38],
         municipio=formatted_data[39],
     )
Exemple #5
0
def update_database(data):
    print('updating db')
    # start upload text
    if int(data['rows_saved']) > 0:
        if 'saved' in data:
            saved = data['saved']
            if 'addresses' in saved:
                for addresses in saved['addresses']:
                    address = Address()
                    where = {'id': addresses['id']}
                    data = {'address_id': addresses['address_id']}
                    address.put(where=where, data=data)

            if 'colors' in saved:
                for colors in saved['colors']:
                    color = Colored()
                    where = {'id': colors['id']}
                    data = {'color_id': colors['color_id']}
                    color.put(where=where, data=data)
                    
            if 'cards' in saved:
                for cards in saved['cards']:
                    card = Card()
                    where = {'id': cards['id']}
                    data = {'card_id': cards['card_id']}
                    card.put(where=where, data=data)
            if 'credits' in saved:
                for credit in saved['credits']:
                    credits = Credit()
                    where = {'id': credit['id']}
                    data = {'credit_id': credit['credit_id']}
                    credits.put(where=where, data=data)
            if 'companies' in saved:
                for companies in saved['companies']:
                    company = Company()
                    where = {'id': companies['id']}
                    data = {'company_id': companies['company_id']}
                    company.put(where=where, data=data)

            if 'custids' in saved:
                for custids in saved['custids']:
                    custid = Custid()
                    where = {'id': custids['id']}
                    data = {'cust_id': custids['cust_id']}
                    custid.put(where=where, data=data)

            if 'deliveries' in saved:
                for deliveries in saved['deliveries']:
                    delivery = Delivery()
                    where = {'id': deliveries['id']}
                    data = {'delivery_id': deliveries['delivery_id']}
                    delivery.put(where=where, data=data)

            if 'discounts' in saved:
                for discounts in saved['discounts']:
                    discount = Discount()
                    where = {'id': discounts['id']}
                    data = {'discount_id': discounts['discount_id']}
                    discount.put(where=where, data=data)

            if 'inventories' in saved:
                for inventories in saved['inventories']:
                    inventory = Inventory()
                    where = {'id': inventories['id']}
                    data = {'inventory_id': inventories['inventory_id']}
                    inventory.put(where=where, data=data)

            if 'inventory_items' in saved:
                for inventory_items in saved['inventory_items']:
                    inventory_item = InventoryItem()
                    where = {'id': inventory_items['id']}
                    data = {'item_id': inventory_items['item_id']}
                    inventory_item.put(where=where, data=data)

            if 'invoices' in saved:
                for invoices in saved['invoices']:

                    invoice = Invoice()
                    where = {'id': invoices['id']}
                    data = {'invoice_id': invoices['invoice_id']}
                    invoice.put(where=where, data=data)

            if 'invoice_items' in saved:
                for invoice_items in saved['invoice_items']:

                    invoice_item = InvoiceItem()
                    where = {'id': invoice_items['id']}
                    data = {'invoice_items_id': invoice_items['invoice_items_id']}
                    invoice_item.put(where=where, data=data)

            if 'memos' in saved:
                for memos in saved['memos']:
                    memo = Memo()
                    where = {'id': memos['id']}
                    data = {'memo_id': memos['memo_id']}
                    memo.put(where=where, data=data)
            if 'printers' in saved:
                for printers in saved['printers']:
                    printer = Printer()
                    where = {'id': printers['id']}
                    data = {'printer_id': printers['printer_id']}
                    printer.put(where=where, data=data)
                    
            if 'profiles' in saved:
                for profiles in saved['profiles']:
                    profile = Profile()
                    where = {'id': profiles['id']}
                    data = {'p_id': profiles['p_id']}
                    profile.put(where=where, data=data)
                    
            if 'reward_transactions' in saved:
                for reward_transactions in saved['reward_transactions']:
                    reward_transaction = RewardTransaction()
                    where = {'id': reward_transactions['id']}
                    data = {'reward_id': reward_transactions['reward_id']}
                    reward_transaction.put(where=where, data=data)

            if 'rewards' in saved:
                for rewards in saved['rewards']:
                    reward = Reward()
                    where = {'id': rewards['id']}
                    data = {'reward_id': rewards['reward_id']}
                    reward.put(where=where, data=data)

            if 'schedules' in saved:
                for schedules in saved['schedules']:
                    schedule = Schedule()
                    where = {'id': schedules['id']}
                    data = {'schedule_id': schedules['schedule_id']}
                    schedule.put(where=where, data=data)

            if 'taxes' in saved:
                for taxes in saved['taxes']:
                    tax = Tax()
                    where = {'id': taxes['id']}
                    data = {'tax_id': taxes['tax_id']}
                    tax.put(where=where, data=data)

            if 'transactions' in saved:
                for transactions in saved['transactions']:
                    transaction = Transaction()
                    where = {'id': transactions['id']}
                    data = {'trans_id': transactions['trans_id']}
                    transaction.put(where=where, data=data)

            if 'users' in saved:
                for users in saved['users']:
                    user = User()
                    where = {'id': users['id']}
                    data = {'user_id': users['user_id']}
                    user.put(where=where, data=data)

            if 'zipcodes' in saved:
                for zipcodes in saved['zipcodes']:
                    zipcode = Zipcode()
                    where = {'id': zipcodes['id']}
                    data = {'zipcode_id': zipcodes['zipcode_id']}
                    zipcode.put(where=where, data=data)
Exemple #6
0
def sync_from_server(data):
    # print('sync from server')
    # start upload text
    # print(data)
    # print(data['rows_to_create'])
    if int(data['rows_to_create']) > 0:
        updates = data['updates']
        if 'addresses' in updates:
            for addresses in updates['addresses']:
                address = Address()
                address.address_id = addresses['id']
                address.user_id = addresses['user_id']
                address.name = addresses['name']
                address.street = addresses['street']
                address.suite = addresses['suite']
                address.city = addresses['city']
                address.state = addresses['state']
                address.zipcode = addresses['zipcode']
                address.primary_address = addresses['primary_address']
                address.concierge_name = addresses['concierge_name']
                address.concierge_number = addresses['concierge_number']
                address.status = addresses['status']
                address.deleted_at = addresses['deleted_at']
                address.created_at = addresses['created_at']
                address.updated_at = addresses['updated_at']
                # check to see if color_id already exists and update

                count_address = address.where({'address_id': address.address_id})
                if len(count_address) > 0 or address.deleted_at:
                    for data in count_address:
                        address.id = data['id']
                        if address.deleted_at:
                            address.delete()
                        else:
                            address.update_special()
                else:
                    address.add_special()
            address.close_connection()
 
        if 'cards' in updates:
            for cards in updates['cards']:
                card = Card()
                card.card_id = cards['id']
                card.company_id = cards['company_id']
                card.user_id = cards['user_id']
                card.profile_id = cards['profile_id']
                card.payment_id = cards['payment_id']
                card.root_payment_id = cards['root_payment_id']
                card.street = cards['street']
                card.suite = cards['suite']
                card.city = cards['city']
                card.state = cards['state']
                card.zipcode = cards['zipcode']
                card.exp_month = cards['exp_month']
                card.exp_year = cards['exp_year']
                card.status = cards['status']
                card.deleted_at = cards['deleted_at']
                card.created_at = cards['created_at']
                card.updated_at = cards['updated_at']
                # check to see if color_id already exists and update

                count_card = card.where({'card_id': card.card_id})
                if len(count_card) > 0 or card.deleted_at:
                    for data in count_card:
                        card.id = data['id']
                        if card.deleted_at:
                            card.delete()
                        else:
                            card.update_special()
                else:
                    card.add_special()
            card.close_connection()
        
        if 'colors' in updates:
            for colors in updates['colors']:
                color = Colored()
                color.color_id = colors['id']
                color.company_id = colors['company_id']
                color.color = colors['color']
                color.name = colors['name']
                color.ordered = colors['ordered']
                color.status = colors['status']
                color.deleted_at = colors['deleted_at']
                color.created_at = colors['created_at']
                color.updated_at = colors['updated_at']
                # check to see if color_id already exists and update

                count_color = color.where({'color_id': color.color_id})
                if len(count_color) > 0 or color.deleted_at:
                    for data in count_color:
                        color.id = data['id']
                        if color.deleted_at:
                            color.delete()
                        else:
                            color.update_special()
                else:
                    color.add_special()
            color.close_connection()

        if 'companies' in updates:
            for companies in updates['companies']:
                company = Company()
                company.company_id = companies['id']
                company.name = companies['name']
                company.street = companies['street']
                company.city = companies['city']
                company.state = companies['state']
                company.zip = companies['zip']
                company.email = companies['email']
                company.phone = companies['phone']
                company.store_hours = companies['store_hours']
                company.turn_around = companies['turn_around']
                company.api_token = companies['api_token']
                company.payment_gateway_id = companies['payment_gateway_id']
                company.payment_api_login = companies['payment_api_login']
                company.deleted_at = companies['deleted_at']
                company.created_at = companies['created_at']
                company.updated_at = companies['updated_at']
                company.server_at = now
                count_company = company.where({'company_id': company.company_id})
                if len(count_company) > 0 or company.deleted_at:
                    for data in count_company:
                        company.id = data['id']
                        if company.deleted_at:
                            company.delete()
                        else:
                            company.update_special()
                else:
                    company.add_special()
            company.close_connection()
            
        if 'credits' in updates:
            for credits in updates['credits']:
                credit = Credit()
                credit.credit_id = credits['id']
                credit.employee_id = credits['employee_id']
                credit.customer_id = credits['customer_id']
                credit.amount = credits['amount']
                credit.reason = credits['reason']
                credit.status = credits['status']
                credit.deleted_at = credits['deleted_at']
                credit.created_at = credits['created_at']
                credit.updated_at = credits['updated_at']
                # check to see already exists and update

                count_credit = credit.where({'credit_id': credit.credit_id})
                if len(count_credit) > 0 or credit.deleted_at:
                    for data in count_credit:
                        credit.id = data['id']
                        if credit.deleted_at:
                            credit.delete()
                        else:
                            credit.update_special()
                else:
                    credit.add_special()
            credit.close_connection()
        if 'custids' in updates:
            for custids in updates['custids']:
                custid = Custid()
                custid.cust_id = custids['id']
                custid.customer_id = custids['customer_id']
                custid.company_id = custids['company_id']
                custid.mark = custids['mark']
                custid.status = custids['status']
                custid.deleted_at = custids['deleted_at']
                custid.created_at = custids['created_at']
                custid.updated_at = custids['updated_at']
                count_custid = custid.where({'cust_id': custids['id']})
                if len(count_custid) > 0 or custid.deleted_at:
                    for data in count_custid:
                        custid.id = data['id']
                        if custid.deleted_at:
                            custid.delete()
                        else:
                            custid.update_special()
                else:
                    custid.add_special()
            custid.close_connection()

        if 'deliveries' in updates:
            for deliveries in updates['deliveries']:
                delivery = Delivery()
                delivery.delivery_id = deliveries['id']
                delivery.company_id = deliveries['company_id']
                delivery.route_name = deliveries['route_name']
                delivery.day = deliveries['day']
                delivery.delivery_limit = deliveries['limit']
                delivery.start_time = deliveries['start_time']
                delivery.end_time = deliveries['end_time']
                delivery.zipcode = deliveries['zipcode']
                delivery.blackout = deliveries['blackout']
                delivery.status = deliveries['status']
                delivery.deleted_at = deliveries['deleted_at']
                delivery.created_at = deliveries['created_at']
                delivery.updated_at = deliveries['updated_at']
                count_delivery = delivery.where({'delivery_id': delivery.delivery_id})
                if len(count_delivery) > 0 or delivery.deleted_at:
                    for data in count_delivery:
                        delivery.id = data['id']
                        if delivery.deleted_at:
                            delivery.delete()
                        else:
                            delivery.update_special()
                else:
                    delivery.add_special()
            delivery.close_connection()

        if 'discounts' in updates:
            for discounts in updates['discounts']:
                discount = Discount()
                discount.discount_id = discounts['id']
                discount.company_id = discounts['company_id']
                discount.inventory_id = discounts['inventory_id']
                discount.inventory_item_id = discounts['inventory_item_id']
                discount.name = discounts['name']
                discount.type = discounts['type']
                discount.discount = discounts['discount']
                discount.rate = discounts['rate']
                discount.end_time = discounts['end_time']
                discount.start_date = discounts['start_date']
                discount.end_date = discounts['end_date']
                discount.status = discounts['status']
                discount.deleted_at = discounts['deleted_at']
                discount.created_at = discounts['created_at']
                discount.updated_at = discounts['updated_at']
                count_discount = discount.where({'discount_id': discount.discount_id})
                if len(count_discount) > 0 or discount.deleted_at:
                    for data in count_discount:
                        discount.id = data['id']
                        if discount.deleted_at:
                            discount.delete()
                        else:
                            discount.update_special()
                else:
                    discount.add_special()
            discount.close_connection()

        if 'inventories' in updates:
            for inventories in updates['inventories']:
                inventory = Inventory()
                inventory.inventory_id = inventories['id']
                inventory.company_id = inventories['company_id']
                inventory.name = inventories['name']
                inventory.description = inventories['description']
                inventory.ordered = inventories['ordered']
                inventory.laundry = inventories['laundry']
                inventory.status = inventories['status']
                inventory.deleted_at = inventories['deleted_at']
                inventory.create_at = inventories['created_at']
                inventory.updated_at = inventories['updated_at']
                count_inventory = inventory.where({'inventory_id': inventory.inventory_id})
                if len(count_inventory) > 0 or inventory.deleted_at:
                    for data in count_inventory:
                        inventory.id = data['id']
                        if inventory.deleted_at:
                            inventory.delete()
                        else:
                            inventory.update_special()
                else:
                    inventory.add_special()
            inventory.close_connection()

        if 'inventory_items' in updates:
            for inventory_items in updates['inventory_items']:
                inventory_item = InventoryItem()
                inventory_item.item_id = inventory_items['id']
                inventory_item.inventory_id = inventory_items['inventory_id']
                inventory_item.company_id = inventory_items['company_id']
                inventory_item.name = inventory_items['name']
                inventory_item.description = inventory_items['description']
                inventory_item.tags = inventory_items['tags']
                inventory_item.quantity = inventory_items['quantity']
                inventory_item.ordered = inventory_items['ordered']
                inventory_item.price = inventory_items['price']
                inventory_item.image = inventory_items['image']
                inventory_item.status = inventory_items['status']
                inventory_item.deleted_at = inventory_items['deleted_at']
                inventory_item.created_at = inventory_items['created_at']
                inventory_item.updated_at = inventory_items['updated_at']
                count_inventory_item = inventory_item.where({'item_id': inventory_item.item_id})
                if len(count_inventory_item) > 0 or inventory_item.deleted_at:
                    for data in count_inventory_item:
                        inventory_item.id = data['id']
                        if inventory_item.deleted_at:
                            inventory_item.delete()
                        else:
                            inventory_item.update_special()
                else:
                    inventory_item.add_special()
            inventory_item.close_connection()

        # if 'invoice_items' in updates:
        #     for invoice_items in updates['invoice_items']:
        #         invoice_item = InvoiceItem()
        #         invoice_item.invoice_items_id = invoice_items['id']
        #         invoice_item.invoice_id = invoice_items['invoice_id']
        #         invoice_item.item_id = invoice_items['item_id']
        #         invoice_item.inventory_id = invoice_items['inventory_id']
        #         invoice_item.company_id = invoice_items['company_id']
        #         invoice_item.customer_id = invoice_items['customer_id']
        #         invoice_item.quantity = invoice_items['quantity']
        #         invoice_item.color = invoice_items['color']
        #         invoice_item.memo = invoice_items['memo']
        #         invoice_item.pretax = invoice_items['pretax']
        #         invoice_item.tax = invoice_items['tax']
        #         invoice_item.total = invoice_items['total']
        #         invoice_item.status = invoice_items['status']
        #         invoice_item.deleted_at = invoice_items['deleted_at']
        #         invoice_item.created_at = invoice_items['created_at']
        #         invoice_item.updated_at = invoice_items['updated_at']
        #         count_invoice_item = invoice_item.where({'invoice_items_id': invoice_item.invoice_items_id})
        #         if len(count_invoice_item) > 0 or invoice_item.deleted_at:
        #             for data in count_invoice_item:
        #                 invoice_item.id = data['id']
        #                 if invoice_item.deleted_at:
        #                     invoice_item.delete()
        #                 else:
        #                     invoice_item.update_special()
        #         else:
        #             invoice_item.add_special()
        #     invoice_item.close_connection()
        #
        # if 'invoices' in updates:
        #
        #     for invoices in updates['invoices']:
        #         invoice = Invoice()
        #         invoice.invoice_id = invoices['id']
        #         invoice.company_id = invoices['company_id']
        #         invoice.customer_id = invoices['customer_id']
        #         invoice.quantity = invoices['quantity']
        #         invoice.pretax = invoices['pretax']
        #         invoice.tax = invoices['tax']
        #         invoice.reward_id = invoices['reward_id']
        #         invoice.discount_id = invoices['discount_id']
        #         invoice.total = invoices['total']
        #         invoice.rack = invoices['rack']
        #         invoice.rack_date = invoices['rack_date']
        #         invoice.due_date = invoices['due_date']
        #         invoice.memo = invoices['memo']
        #         invoice.transaction_id = invoices['transaction_id']
        #         invoice.schedule_id = invoices['schedule_id']
        #         invoice.status = invoices['status']
        #         invoice.deleted_at = invoices['deleted_at']
        #         invoice.created_at = invoices['created_at']
        #         invoice.updated_at = invoices['updated_at']
        #
        #         # extra loop through invoice items to delete or check for data
        #         if 'invoice_items' in invoices:
        #
        #             iitems = invoices['invoice_items']
        #             if len(iitems) > 0:
        #                 for iitem in iitems:
        #                     invoice_item = InvoiceItem()
        #                     invoice_item.invoice_items_id = iitem['id']
        #                     invoice_item.invoice_id = iitem['invoice_id']
        #                     invoice_item.item_id = iitem['item_id']
        #                     invoice_item.inventory_id = iitem['inventory_id']
        #                     invoice_item.company_id = iitem['company_id']
        #                     invoice_item.customer_id = iitem['customer_id']
        #                     invoice_item.quantity = iitem['quantity']
        #                     invoice_item.color = iitem['color']
        #                     invoice_item.memo = iitem['memo']
        #                     invoice_item.pretax = iitem['pretax']
        #                     invoice_item.tax = iitem['tax']
        #                     invoice_item.total = iitem['total']
        #                     invoice_item.status = iitem['status']
        #                     invoice_item.deleted_at = iitem['deleted_at']
        #                     invoice_item.created_at = iitem['created_at']
        #                     invoice_item.updated_at = iitem['updated_at']
        #                     count_invoice_item = invoice_item.where({'invoice_items_id': invoice_item.invoice_items_id})
        #                     if len(count_invoice_item) > 0 or invoice_item.deleted_at:
        #                         for data in count_invoice_item:
        #                             invoice_item.id = data['id']
        #                             if invoice_item.deleted_at:
        #                                 invoice_item.delete()
        #                             else:
        #                                 invoice_item.update_special()
        #
        #         count_invoice = invoice.where({'invoice_id': invoice.invoice_id})
        #         if len(count_invoice) > 0 or invoice.deleted_at:
        #             for data in count_invoice:
        #                 invoice.id = data['id']
        #                 if invoice.deleted_at:
        #                     invoice.delete()
        #                 else:
        #                     invoice.update_special()
        #         else:
        #             invoice.add_special()
        #     invoice.close_connection()

        if 'memos' in updates:
            for memos in updates['memos']:
                memo = Memo()
                memo.memo_id = memos['id']
                memo.company_id = memos['company_id']
                memo.memo = memos['memo']
                memo.ordered = memos['ordered']
                memo.status = memos['status']
                memo.deleted_at = memos['deleted_at']
                memo.created_at = memos['created_at']
                memo.updated_at = memos['updated_at']
                count_memo = memo.where({'memo_id': memo.memo_id})
                if len(count_memo) > 0 or memo.deleted_at:
                    for data in count_memo:
                        memo.id = data['id']
                        if memo.deleted_at:
                            memo.delete()
                        else:
                            memo.update_special()
                else:
                    memo.add_special()
            memo.close_connection()

        # if 'printers' in updates:
        #     for printers in updates['printers']:
        #         printer = Printer()
        #         printer.printer_id = printers['id']
        #         printer.company_id = printers['company_id']
        #         printer.name = printers['name']
        #         printer.model = printers['model']
        #         printer.nick_name = printers['nick_name']
        #         printer.type = printers['type']
        #         printer.vendor_id = printers['vendor_id']
        #         printer.product_id = printers['product_id']
        #         printer.status = printers['status']
        #         printer.deleted_at = printers['deleted_at']
        #         printer.created_at = printers['created_at']
        #         printer.updated_at = printers['updated_at']
        #         count_printer = printer.where({'printer_id': printer.printer_id})
        #         if len(count_printer) > 0 or printer.deleted_at:
        #             for data in count_printer:
        #                 printer.id = data['id']
        #                 if printer.deleted_at:
        #                     printer.delete()
        #                 else:
        #                     printer.update_special()
        #         else:
        #             printer.add_special()
        #     printer.close_connection()

        if 'profiles' in updates:
            for profiles in updates['profiles']:
                profile = Profile()
                profile.p_id = profiles['id']
                profile.company_id = profiles['company_id']
                profile.user_id = profiles['user_id']
                profile.profile_id = profiles['profile_id']
                profile.status = profiles['status']
                profile.deleted_at = profiles['deleted_at']
                profile.created_at = profiles['created_at']
                profile.updated_at = profiles['updated_at']
                count_profile = profile.where({'p_id': profile.p_id})
                if len(count_profile) > 0 or profile.deleted_at:
                    for data in count_profile:
                        profile.id = data['id']
                        if profile.deleted_at:
                            profile.delete()
                        else:
                            profile.update_special()
                else:
                    profile.add_special()
            profile.close_connection()


        if 'reward_transactions' in updates:
            for reward_transactions in updates['reward_transactions']:
                reward_transaction = RewardTransaction()
                reward_transaction.reward_id = reward_transactions['reward_id']
                reward_transaction.transaction_id = reward_transactions['transaction_id']
                reward_transaction.customer_id = reward_transactions['customer_id']
                reward_transaction.employee_id = reward_transactions['employee_id']
                reward_transaction.company_id = reward_transactions['company_id']
                reward_transaction.type = reward_transactions['type']
                reward_transaction.points = reward_transactions['points']
                reward_transaction.credited = reward_transactions['credited']
                reward_transaction.reduced = reward_transactions['reduced']
                reward_transaction.running_total = reward_transactions['running_total']
                reward_transaction.reason = reward_transactions['reason']
                reward_transaction.name = reward_transactions['name']
                reward_transaction.status = reward_transactions['status']
                reward_transaction.deleted_at = reward_transactions['deleted_at']
                reward_transaction.created_at = reward_transactions['created_at']
                reward_transaction.updated_at = reward_transactions['updated_at']
                count_reward_transaction = reward_transaction.where({'reward_id': reward_transaction.reward_id})
                if len(count_reward_transaction) > 0 or reward_transaction.deleted_at:
                    for data in count_reward_transaction:
                        reward_transaction.id = data['id']
                        if reward_transaction.deleted_at:
                            reward_transaction.delete()
                        else:
                            reward_transaction.update_special()
                else:
                    reward_transaction.add_special()
            reward_transaction.close_connection()

        if 'rewards' in updates:
            for rewards in updates['rewards']:
                reward = Reward()
                reward.reward_id = rewards['id']
                reward.company_id = rewards['company_id']
                reward.name = rewards['name']
                reward.points = rewards['points']
                reward.discount = rewards['discount']
                reward.status = rewards['status']
                reward.deleted_at = rewards['deleted_at']
                reward.created_at = rewards['created_at']
                reward.updated_at = rewards['updated_at']
                count_reward = reward.where({'reward_id': reward.reward_id})
                if len(count_reward) > 0 or reward.deleted_at:
                    for data in count_reward:
                        reward.id = data['id']
                        if reward.deleted_at:
                            reward.delete()
                        else:
                            reward.update_special()
                else:
                    reward.add_special()
            reward.close_connection()

        if 'schedules' in updates:
            for schedules in updates['schedules']:
                schedule = Schedule()
                schedule.schedule_id = schedules['id']
                schedule.company_id = schedules['company_id']
                schedule.customer_id = schedules['customer_id']
                schedule.card_id = schedules['card_id']
                schedule.pickup_delivery_id = schedules['pickup_delivery_id']
                schedule.pickup_address = schedules['pickup_address']
                schedule.pickup_date = schedules['pickup_date']
                schedule.dropoff_delivery_id = schedules['dropoff_delivery_id']
                schedule.dropoff_address = schedules['dropoff_address']
                schedule.dropoff_date = schedules['dropoff_date']
                schedule.special_instructions = schedules['special_instructions']
                schedule.type = schedules['type']
                schedule.token = schedules['token']
                schedule.status = schedules['status']
                schedule.deleted_at = schedules['deleted_at']
                schedule.created_at = schedules['created_at']
                schedule.updated_at = schedules['updated_at']
                count_schedule = schedule.where({'schedule_id': schedule.schedule_id})
                if len(count_schedule) > 0 or schedule.deleted_at:
                    for data in count_schedule:
                        schedule.id = data['id']
                        if schedule.deleted_at:
                            schedule.delete()
                        else:
                            schedule.update_special()
                else:
                    schedule.add_special()
            schedule.close_connection()

        if 'taxes' in updates:
            for taxes in updates['taxes']:
                tax = Tax()
                tax.tax_id = taxes['id']
                tax.company_id = taxes['company_id']
                tax.rate = taxes['rate']
                tax.status = taxes['status']
                tax.deleted_at = taxes['deleted_at']
                tax.created_at = taxes['created_at']
                tax.updated_at = taxes['updated_at']
                count_tax = tax.where({'tax_id': tax.tax_id})
                if len(count_tax) > 0 or tax.deleted_at:
                    for data in count_tax:
                        tax.id = data['id']
                        if tax.deleted_at:
                            tax.delete()
                        else:
                            tax.update_special()
                else:
                    tax.add_special()
            tax.close_connection()

        if 'transactions' in updates:
            for transactions in updates['transactions']:
                transaction = Transaction()
                transaction.trans_id = transactions['id']
                transaction.company_id = transactions['company_id']
                transaction.customer_id = transactions['customer_id']
                transaction.schedule_id = transactions['schedule_id']
                transaction.pretax = transactions['pretax']
                transaction.tax = transactions['tax']
                transaction.aftertax = transactions['aftertax']
                transaction.credit = transactions['credit']
                transaction.discount = transactions['discount']
                transaction.total = transactions['total']
                transaction.invoices = transactions['invoices'] if transactions['invoices'] else None
                transaction.account_paid = transactions['account_paid']
                transaction.account_paid_on = transactions['account_paid_on']
                transaction.type = transactions['type']
                transaction.last_four = transactions['last_four']
                transaction.tendered = transactions['tendered']
                transaction.transaction_id = transactions['transaction_id']
                transaction.status = transactions['status']
                transaction.deleted_at = transactions['deleted_at']
                transaction.created_at = transactions['created_at']
                transaction.updated_at = transactions['updated_at']
                count_transaction = transaction.where({'trans_id': transaction.trans_id})
                if len(count_transaction) > 0 or transaction.deleted_at:
                    for data in count_transaction:
                        transaction.id = data['id']
                        if transaction.deleted_at:
                            transaction.delete()
                        else:
                            transaction.update_special()
                else:
                    transaction.add_special()
            transaction.close_connection()

        if 'users' in updates:
            for users in updates['users']:
                user = User()
                user.user_id = users['id']
                user.company_id = users['company_id']
                user.username = users['username']
                user.first_name = users['first_name']
                user.last_name = users['last_name']
                user.street = users['street']
                user.suite = users['suite']
                user.city = users['city']
                user.state = users['state']
                user.zipcode = users['zipcode']
                user.email = users['email']
                user.phone = users['phone']
                user.intercom = users['intercom']
                user.concierge_name = users['concierge_name']
                user.concierge_number = users['concierge_number']
                user.special_instructions = users['special_instructions']
                user.shirt_old = users['shirt_old']
                user.shirt = users['shirt']
                user.delivery = users['delivery']
                user.profile_id = users['profile_id']
                user.payment_status = users['payment_status']
                user.payment_id = users['payment_id']
                user.token = users['token']
                user.api_token = users['api_token']
                user.reward_status = users['reward_status']
                user.reward_points = users['reward_points']
                user.account = users['account']
                user.account_total = users['account_total']
                user.credits = users['credits']
                user.starch = users['starch']
                user.important_memo = users['important_memo']
                user.invoice_memo = users['invoice_memo']
                user.role_id = users['role_id']
                user.deleted_at = users['deleted_at']
                user.created_at = users['created_at']
                user.updated_at = users['updated_at']
                count_user = user.where({'user_id': user.user_id})
                if len(count_user) > 0 or user.deleted_at:
                    for data in count_user:
                        user.id = data['id']
                        if user.deleted_at:
                            user.delete()
                        else:
                            user.update_special()
                else:
                    user.add_special()
            user.close_connection()

        if 'zipcodes' in updates:
            for zipcodes in updates['zipcodes']:
                zipcode = Zipcode()
                zipcode.zipcode_id = zipcodes['id']
                zipcode.company_id = zipcodes['company_id']
                zipcode.delivery_id = zipcodes['delivery_id']
                zipcode.zipcode = zipcodes['zipcode']
                zipcode.status = zipcodes['status']
                zipcode.deleted_at = zipcodes['deleted_at']
                zipcode.created_at = zipcodes['created_at']
                zipcode.updated_at = zipcodes['updated_at']
                # check to see if color_id already exists and update
        
                count_zipcode = zipcode.where({'zipcode_id': zipcode.zipcode_id})
                if len(count_zipcode) > 0 or zipcode.deleted_at:
                    for data in count_zipcode:
                        zipcode.id = data['id']
                        if zipcode.deleted_at:
                            zipcode.delete()
                        else:
                            zipcode.update_special()
                else:
                    zipcode.add_special()
            zipcode.close_connection()
Exemple #7
0
from companies import Company
from employees_departments import Employee

amazon = Company("Amazon", "123 Fake St.", "Global Domination")
walmart = Company("Wal-Mart", "456 Nota Real St.", "Global Domination")

mike = Employee("Mike")
michael = Employee("Michael")
bruce = Employee("Bruce")
billy = Employee("Billy")
bob = Employee("Bob")

amazon.hire(mike, "President")
walmart.hire(michael, "President")
walmart.hire(bruce, "Vice President")
amazon.hire(billy, "Vice President")
walmart.hire(bob, "Secretary")

companies = [amazon, walmart]

for company in companies:
    print(f'{company.business_name} is in the {company.industry_type} industry and has the following employees:')
    for employee in company.employees:
        print(f'* {employee.name}')
    print(f'')
Exemple #8
0
from employees import Employee
from companies import Company

John = Employee("John Long", "Front End Developer")
Bishop = Employee("Ryan Bishop", "Full Stack Developer")
Jeremiah = Employee("Jeremiah Bell", "Dilletante")
Trey = Employee("Trey Suiter", "Motivational Speaker")
Brenda = Employee("Brenda Long", "UI/UX specialist")

Eventbrite = Company("Eventbrite", "Tech")
NSS = Company("Nashville Software School", "Creating Developers")

NSS.add_employee(John)
NSS.add_employee(Trey)
Eventbrite.add_employee(Brenda)
Eventbrite.add_employee(Jeremiah)
Eventbrite.add_employee(Bishop)

NSS.about_company()
Eventbrite.about_company()



        
    
from companies import Company
from employees import Employee

erin = Employee("Erin Polley", "software developer", "April 27, 2020")
corri = Employee("Corri Golden", "front end engineer", "June 3, 2020")
chase = Employee("Chase Fite", "software engineer", "April 12, 2020")
matt = Employee("Matthew Blagg", "software developer", "May 7, 2020")
guy = Employee("Guy Cherkesky", "company mogul", "March 23, 2020")

eventbrite = Company("EventBrite", "Cummins Station", "Tech")
asurion = Company("Asurion", "Downtown", "Insurance")

asurion.add_people([chase, guy])
eventbrite.add_people([erin, matt, corri])


def print_stuff(business):
    print(
        f'{business.name} is in the {business.type} industry and has the following employees:'
    )
    for employee in business.employees:
        print(f'*{employee.name}')


print_stuff(asurion)
print_stuff(eventbrite)
Exemple #10
0
from employees import Employee
from companies import Company

kurt_krafft = Employee("Kürt Krafft", "UI/UX Engineer", "6/27/2020")
sofia_candiani = Employee("Sofia Candiani", "Software Developer", "6/27/2020")
cooper_nichols = Employee("Cooper Nichols", "Back-End Engineer", "6/27/2020")
matt_kroeger = Employee("Matthew Kroeger", "Front-End Developer", "6/27/2020")
mike_prince = Employee("Joseph Prince", "Software Engineer 1", "6/27/2020")

lyft = Company("Lyft", "401 Church St.", "Transportation")
tdot = Company("Tennessee Department Of Transportation", "505 Deaderick St.",
               "Government Administration")

lyft.hire(kurt_krafft)
tdot.hire(sofia_candiani)
lyft.hire(cooper_nichols)
tdot.hire(matt_kroeger)
lyft.hire(mike_prince)

lyft.generate_report()

tdot.generate_report()