def crawler(coName, driver): """returns a dictionary with company link and similarity score""" google_exclude = get_config()['Google_exclude'] url = 'https://www.google.co.in/search?q=' + coName driver.get(url) soup = BeautifulSoup(driver.page_source, 'html.parser') results = soup.find_all('div', {'class': 'g'}, limit=3) linkScores = {} for result in results: try: title = result.find('h3', {'class': 'r'}).find('a').text score = round(similar(title, coName), 2) domain = result.find('cite').text.split('//')[-1].split('/' )[0] except AttributeError: continue # Filtering out results from News if ' ' in domain or '.' not in domain: continue # extracts domain from a sitename. ex: bbc from forums.bbc.co.uk mainDomain = tldextract.extract(domain).domain # Filtering out Fb, linkedin, wikipedia, glassdoor, google if mainDomain not in coName and mainDomain in google_exclude: continue if mainDomain in coName or coName.replace(' ', '').lower() \ in mainDomain or similar(mainDomain, coName) > 0.5: score = 1 linkScores[domain] = score return linkScores
def fakeNewsDetector(parent, tweets): parentFlag = checkNegative(parent) for tweet in tweets: similarityValue = similar(tweet, parent) if similarityValue >= similarityDegreeValue: if (checkNegative(tweet) ^ checkNegative(parent)): print(" ===> " + tweet)
def crawler(coName, driver): """returns a dictionary with company link and similarity score""" url = 'https://www.google.co.in/search?q=' + coName \ + '+site:https://www.bloomberg.com/research/stocks/private/snapshot.asp' driver.get(url) driver.save_screenshot('bloom1.png') soup = BeautifulSoup(driver.page_source, 'html.parser') results = soup.find_all('div', {'class': 'g'}, limit=2) linkScores = {} for result in results: try: resultUrl = result.find('h3', {'class': 'r'}).find('a')['href'] # print resultUrl driver.get(str(resultUrl)) # print driver.current_url blSoup = BeautifulSoup(driver.page_source, 'html.parser') title = blSoup.find('div', { 'id': 'columnLeft' }).find('h1').find('span').text domain = blSoup.find('div', { 'class': 'detailsDataContainerRt' }).find('a', { 'class': 'link_sb' }).text score = round(similar(title, coName), 2) linkScores[domain] = score except AttributeError: pass return linkScores
def search_item(self,supplier): if self.item_code: if supplier in Api.item_code_translation: trans_table_supplier = Api.item_code_translation[supplier] if self.item_code in trans_table_supplier: e_item_code = trans_table_supplier[self.item_code] e_item = Api.items_by_code[e_item_code] return e_item # look for most similar e_items sim_items = [] for e_code, e_item in Api.items_by_code.items(): sim_items.append((utils.similar(e_item['item_name'], self.description), e_item)) top_items = sorted(sim_items,reverse=True,key=lambda x:x[0])[0:20] #print(top_items) texts = ['Neuen Artikel anlegen'] texts += [i[1]['item_code']+' '+i[1]['item_name'] for i in top_items] title = "Artikel wählen" msg = "Artikel in Rechnung:\n{0}\n\n".format(self.long_description) msg += "Bitte passenden Artikel in ERPNext auswählen:" choice = easygui.choicebox(msg, title, texts) if choice: choice = texts.index(choice) if choice: e_item = top_items[choice-1][1] if self.item_code: doc = gui_api_wrapper(Api.api.get_doc,'Item', e_item['item_code']) doc['supplier_items'].append(\ { 'supplier': supplier, 'supplier_part_no' : self.item_code}) #print(doc['supplier_items']) gui_api_wrapper(Api.api.update,doc) return e_item else: title = "Neuen Artikel in ERPNext eintragen" msg = self.long_description+"\n" if self.item_code: msg += "Code Lieferant: "+self.item_code+"\n" msg += "Einzelpreis: {0:.2f}€".format(self.rate) msg += "\n\nDiesen Artikel eintragen?" if easygui.ccbox(msg, title): item_code = "new"+''.join(random.choices(\ string.ascii_uppercase + string.digits, k=8)) company_name = self.purchase_invoice.company_name e_item = {'doctype' : 'Item', 'item_code' : item_code, 'item_name' : self.description, 'description' : self.long_description, 'item_group' : STANDARD_ITEM_GROUP, 'item_defaults': [{'company': company_name, 'default_warehouse': WAREHOUSE}], 'stock_uom' : self.qty_unit} e_item = gui_api_wrapper(Api.api.insert,e_item) return e_item return None
def get_fetched_data_cell_lines_mapping(fetched_cell_lines, input_cell_lines): mapping = dict() max_similarity = 0 for input_cell_line in input_cell_lines: cleaned_input_cell_line = clean_up(input_cell_line) for fetched_cell_line in fetched_cell_lines: current_similarity = similar(clean_up(fetched_cell_line), cleaned_input_cell_line) if current_similarity > max_similarity: mapping[input_cell_line] = fetched_cell_line max_similarity = current_similarity max_similarity = 0 return mapping
def click_on_best_result(self, cell_line): self.click_on_cell_line_tab() table_result_xpath = ".//table[@class='tableOnSearchPage']" if self.wait_for(table_result_xpath): table = self.session.find_elements_by_xpath(table_result_xpath)[-1] results = table.find_elements_by_xpath( ".//tr[@class='tableOnSearchPage']") options = list() for result in results: relevant_cell = result.find_element_by_xpath( ".//td[@class='tableOnSearchPageLeft']") link = relevant_cell.find_element_by_xpath(".//a") options.append( (link, similar(link.text.lower(), cell_line.lower()))) max(options, key=lambda x: x[1])[0].click()
def Repetidos(Lista, Influ): co = 0 IndRep = list() for m in range(1, len(Lista)): for n in range(0, m): if m not in IndRep: if similar(Lista[m][2], Lista[n][2]) > 0.72: try: if Lista[m][1] == Lista[n][1] and Influ[Lista[m] [1]][3] >= 0: IndRep.append(m) except: pass Lista = [r for q, r in enumerate(Lista) if q not in IndRep] #elimina los indices de IndRep return Lista
def crawler(coName, driver): """returns a dictionary with company link and similarity score""" linkScores = {} try: url = 'https://angel.co/search?page=1&q=' + coName \ + '&type=companies' driver.get(url) soup = BeautifulSoup(driver.page_source, 'html.parser') result = soup.find_all('div', {'class': 'result'}, limit=1) # driver.save_screenshot('angel0.png') resultUrl = result[0].find('a')['href'] title = result[0].find('div', {'class': 'title'}).find('a').text # print resultUrl driver.get(resultUrl) # print driver.current_url # driver.save_screenshot('angel.png') agSoup = BeautifulSoup(driver.page_source, 'html.parser') domain = agSoup.find('a', {'class': 'company_url'}).text score = round(similar(title, coName), 2) linkScores[domain] = score except (IndexError, AttributeError), e: pass
def find_bank_transaction(cls, comp_name, total, text=""): key = 'deposit' if total < 0: key = 'withdrawal' total = -total bts = gui_api_wrapper(Api.api.get_list, 'Bank Transaction', filters={ 'company': comp_name, key: total, 'status': 'Pending' }) bts = [BankTransaction(bt) for bt in bts] l = len(bts) if l == 0: return None if l > 1 and text: bts1 = [(bt,utils.similar(bt.description,text)) \ for bt in bts] bts1.sort(key=lambda x: x[1], reverse=True) bt = bts1[0][0] else: bt = bts[0] return bt
def transfer(self, sinvs, pinvs): if self.deposit: accounts = self.company.leaf_accounts_for_debit invs = sinvs side = "withdrawal" else: accounts = self.company.leaf_accounts_for_credit invs = pinvs side = "deposit" # find accounts that could match, using previous journal entries account_names = list(map(lambda acc: acc['name'], accounts)) jaccs = [(je['account'], utils.similar(self.description,je['user_remark'])) \ for je in self.company.journal if 'user_remark' in je and je['user_remark']] jaccs.sort(key=lambda x: x[1], reverse=True) jaccs = list(set([j for (j, desc) in jaccs[0:5]])) for j in jaccs: try: account_names.remove(j) except Exception: pass account_names = jaccs + account_names # find invoices that could match invs.sort(key=lambda inv: abs(inv.outstanding - abs(self.amount))) inv_texts = list( map( lambda inv: utils.showlist( [inv.name, inv.party, inv.reference, inv.outstanding]), invs)) # find bank transactions in other bank accounts that could match filters = { 'company': self.company.name, 'status': 'Pending', 'bank_account': ['!=', self.bank_account], side: ['>', 0], 'unallocated_amount': abs(self.amount) } bts = gui_api_wrapper(Api.api.get_list, 'Bank Transaction', filters=filters, limit_page_length=LIMIT) bt_texts = list( map( lambda bt: utils.showlist([ bt['name'], bt['deposit'] if bt['deposit'] else -bt['withdrawal'], bt['description'], bt['unallocated_amount'] ]), bts)) # let the user choose between all these title = "Rechnung, Banktransaktion oder Buchungskonto wählen" msg = "Bankbuchung:\n" + self.show() + "\n\n" + title + "\n" options = ["Anzahlung"] + bt_texts + inv_texts + account_names choice = easygui.choicebox(msg, title, options) # and process the choice if choice == "Anzahlung": if self.deposit: party_type = 'Customer' party_descr = 'Kunden' is_recv = True else: party_type = 'Supplier' party_descr = 'Lieferanten' is_recv = False parties = gui_api_wrapper(Api.api.get_list, party_type) party_names = list(map(lambda p: p['name'], parties)) party_names.sort(key=str.casefold) title = party_descr + " wählen" msg = title choice = easygui.choicebox(msg, title, party_names) if choice: self.payment( { 'party_type': party_type, 'party': choice, 'is_recv': is_recv }, True) elif choice in inv_texts: inv = invs[inv_texts.index(choice)] self.payment(inv) elif choice: is_bt = choice in bt_texts if is_bt: choice = bts[bt_texts.index(choice)] self.journal_entry(choice, is_bt)
# starts ds recognizer fin = wave.open("DS/out.wav", 'rb') fs_orig = fin.getframerate() if fs_orig != ds.sampleRate(): print( "Your audio has not been correctly recorded. Please try to fix it and try again! (must be in 16000khz)" ) exit(1) audio = np.frombuffer(fin.readframes(fin.getnframes()), np.int16) stt_text = ds.stt(audio).lower().replace(" ", "") # check the output if float( utils.similar( stt_text, random_questions[progressed]["answer"].lower())) >= 0.5: progressed += 1 window['progbar'].update(progressed) window['lbl_result'].update("Esatto!", background_color="green") else: lives -= 1 progressed = 0 window['progbar'].update(progressed) window['lbl_result'].update("SBAGLIATO! Hai detto: " + stt_text, background_color="red") if progressed == limit: s = "COMPLIMENTI! Hai vinto!" if lives == 0:
sub_idx = find_pos(phrase_sen, sub) else: sub_idx = find_pos_wn(node_list, sub, "OBJ") if not isinstance(sub_idx, int): print "error subjs= word: ", sub print sub print obj_set print phrase_sen print phrasee print node_list[1].prop print node_list[0].prop print attributes print objects print relations print ut.similar(node_list[2].synsets, ut.word_to_wn(sub)) exit() if (find(phrase_sen.split(), obj) + 1): obj_idx = find_pos(phrase_sen, obj) else: obj_idx = find_pos_wn(node_list, obj, "OBJ") if not isinstance(obj_idx, int): print "error objs= word: ", obj print obj print obj_set print phrase_sen print phrasee print node_list[1].prop print relations print objects print ut.similar(node_list[1].synsets, ut.word_to_wn(sub))
def event_handler(event, window): settings = sg.UserSettings() show_company_data = False if event in (sg.WIN_CLOSED, 'Exit'): return "exit" if event in company.Company.all(): settings['-company-'] = event company.Company.current_load_data() return "outer" #print(event, values) elif event == 'Über': print() print('ERPNext Client für Solidarische Ökonomie Bremen', 'Version ' + VERSION) elif event == 'Hilfe Server': print() print('Anleitung für Einstellungen ERPNext-Server:') print( '- Adresse des ERPNext-Servers: z.B. https://erpnext.cafesunshine.de' ) print( '- API-Schlüssel und -Geheimnis bekommt man im ERPNext-Webclient') print('- (d.h. im Browser unter eben jener Adresse)') print(' - unter Einstellungen - My Settings') print(' - API-Zugriff (ganz unten auf der Seite)') print(' - dann "Schlüssel generieren" anklicken') print(' - das API-Geheimnis wird nur einmal angezeigt!') print(' - der API-Schlüssel wird stets angezeigt') print('- Diese Daten hier unter "Einstellungen" eingeben.') elif event == 'Hilfe Banktransaktionen': print() print('Das Datum des letzten Kontoauszugs wird angezeigt') print( 'Im Homebanking die Banktransaktionen seit diesem Datum herunterladen und als csv-Datein speichern' ) print( '- Doppelungen werden erkannt, also lieber einen zu großen statt zu kleinen Zeitraum wählen' ) print('Dann hier unter Einlesen - Kontoauszug die csv-Datei hochladen') print( 'Danach unter Bearbeiten - Banktransaktionen die Banktransaktionen zuordnen' ) print( 'Jeder Banktransaktion muss ein ERPNext-Buchungskonto oder eine offene Rechnung zugeordnet werden' ) print( '- Dadurch entsteht ein ERPNext-Buchungssatz oder eine ERPNext-Zahlung' ) print( '- Man kann die Bearbeitung einer Banktransaktion auch abbrechen und mit der nächsten weitermachen' ) print( ' - Die Banktransaktion bleibt dann offen und kann später bearbeitet werden' ) print( 'Schließlich müssen die ERPNext-Buchungssätze und ERPNext-Zahlungen noch gebucht werden' ) print( '-> Das geht unter Anzeigen - Buchungssätze bzw. Anzeigen - Zahlungen, oder auf der ERPNext-Seite' ) elif event == 'Hilfe Rechnungen': print() print('Einlesen von Einkaufsrechnungen:') suppliers = ", ".join( purchase_invoice.PurchaseInvoice.suppliers.keys()) print( 'Derzeit können Rechnungen von folgenden Lieferanten eingelesen werden: ' + suppliers) print( '(Für andere Lieferanten bitte im ERPNext-Webclient manuell eine Rechnung anlegen. Die Liste der hier möglichen Lieferanten kann ggf. erweitert werden.)' ) print('Das Einlesen einer Rechnung geht hier wie folgt:') print( '- Unter Einlesen - Einkaufsrechnung das PDF hochladen (bitte keinen Scan einer Rechnung und keine Auftragsbestätigung!)' ) print('- oder unter Einlesen - Einkaufsrechnung Balkonmodule') print('Bei Balkonmodul-Rechnungen wird das Lager aktualisiert, d.h.:') print( '- Für jeden Rechnungenartikel muss ein ERPNext-Artikel gefunden werden' ) print( '- Es kann auch ein neuer ERPNext-Artikel angelegt werden, mit den Daten aus der Rechnung' ) print('- Ggf. muss der Preis angepasst werden') print( 'Für alle Rechnungen (ob Balkonmodul oder nicht) wird schließlich die Einkaufsrechnungen in ERPNext hochgeladen.' ) print('Dort muss sie noch geprüft und gebucht werden') elif event == 'Hilfe Buchen': print() print( 'In ERPNext werden Dokumente wie Rechnungen, Buchungssätze und Zahlungen zunächst als Entwurf gespeichert.' ) print( 'Im Entwurfsstadium kann ein Dokument noch bearbeitet oder auch gelöscht werden.' ) print( 'Schließlich muss das Dokument gebucht werden. Nur dann wird es für die Abrechnung wirksam.' ) print( 'Ein einmal gebuchtes Dokument bleibt für immer im System. Es kann nicht mehr bearbeitet werden. Das ist gesetzlich so vorgeschrieben.' ) print( 'Es kann allerdings abgebrochen und abgeändert werden. Dadurch entsteht ein neues Dokument (eine Kopie).' ) print( 'Das alte Dokument bleibt aber als abgebrochenes Dokument im System.' ) elif event == 'ERPNext-Server': layout = [[sg.Text('Adresse des ERPNext-Servers')], [sg.Input(default_text=settings['-server-'])], [sg.Text('API-Schlüssel für Server-API')], [sg.Input(default_text=settings['-key-'])], [sg.Text('API-Geheimnis für Server-API')], [sg.Input(default_text=settings['-secret-'])], [sg.Button('Testen')]] window1 = sg.Window("ERPNext-Server-Einstellungen", layout, finalize=True) window1.bring_to_front() event, values = window1.read() if values: if len(values) > 0 and values[0]: settings['-server-'] = values[0] if len(values) > 1 and values[1]: settings['-key-'] = values[1] if len(values) > 2 and values[2]: settings['-secret-'] = values[2] window1.close() if "http:" in settings['-server-']: settings['-server-'] = settings['-server-'].replace( 'http', 'https') print() print("Teste API ...") result = api_wrapper(Api.initialize) if result['err_msg'] or result['exception']: if result['err_msg']: print(result['err_msg']) elif result['exception']: print(result['exception']) print("API-Test fehlgeschlagen!") settings['-setup-'] = True else: print("API-Test erfolgreich!") settings['-setup-'] = False initial_loads() window.close() return "outer" elif event == 'Update': print() print("Aktualisiere dieses Programm...") tmp = tempfile.mktemp() os.system("cd {}; git pull --rebase > {} 2>&1".format( settings['-folder-'], tmp)) f = open(tmp, 'r') print(f.read()) f.close() print("Bitte Programm neu starten.") elif event == 'Sofort buchen': c = checkbox_input( 'Buchungseinstellungen', 'Ein Dokument muss gebucht werden, um für die Abrechnung wirksam zu werden.\nEin einmal gebuchtes Dokument bleibt für immer im System. Es kann nicht mehr bearbeitet werden. Das ist gesetzlich so vorgeschrieben.\nBei einer Einkaufsrechnung wird in jedem Fall gefragt, ob diese gebucht werden soll.', 'Alle Dokumente immer gleich einbuchen', default=settings['-buchen-']) if c is not None: settings['-buchen-'] = c elif settings['-setup-']: print() print("Bitte erst ERPNext-Server einstellen (unter Einstellungen)") return "inner" elif event == 'Daten neu laden': company.Company.clear_companies() bank.BankAccount.clear_baccounts() initial_loads() show_company_data = True elif event == 'Kontoauszug': filename = utils.get_file('Kontoauszug als csv') if filename: print() print("Lese {} ein ...".format(filename)) b = bank.BankStatement.process_file(filename) if b: comp = b.baccount.company.name if settings['-company-'] != comp: print("Kontoauszug ist für " + comp) settings['-company-'] = comp show_company_data = True print("{} Banktransaktionen eingelesen, davon {} neu".\ format(len(b.entries),len(b.transactions))) else: print("Konnte keinen Kontoauszug einlesen") elif event == 'Einkaufsrechnung': if purchase_inv(False): show_company_data = True elif event == 'Einkaufsrechnung Balkonmodule': if purchase_inv(True): show_company_data = True elif event == 'Banktransaktionen bearbeiten': comp = company.Company.get_company(settings['-company-']) if comp: comp.reconciliate_all() show_company_data = True elif event == 'Buchungssätze': keys = [ 'posting_date', 'account', 'caccount', 'total_debit', 'user_remark' ] headings = [ 'Datum', 'Buchungskonto', 'Gegenkonto', 'Betrag', 'Bemerkung' ] while True: comp = company.Company.get_company(settings['-company-']) jes = comp.open_journal_entries() jes1 = [] for j in jes: j1 = gui_api_wrapper(Api.api.get_doc, 'Journal Entry', j['name']) j1['account'] = j1['accounts'][0]['account'] j1['caccount'] = j1['accounts'][1]['account'] jes1.append(j1) title = "Buchungssätze" tbl = table.Table(jes1, keys, headings, title, enable_events=True, display_row_numbers=True) ix = tbl.display() if ix is False: break je = jes[ix] details = utils.format_entry(jes1[ix], keys, headings) choice = easygui.buttonbox("Buchungssatz {}\n{} ".\ format(je['name'],details), "Buchungssatz", ["Buchen","Löschen","Nichts tun"]) if choice == "Buchen": bank.BankTransaction.submit_entry(je['name']) show_company_data = True elif choice == "Löschen": bank.BankTransaction.delete_entry(je['name']) show_company_data = True elif event == 'Zahlungen': while True: keys = ['posting_date', 'paid_amount', 'party', 'reference_no'] headings = ['Datum', 'Betrag', 'Gezahlt an', 'Referenz.'] comp = company.Company.get_company(settings['-company-']) pes = comp.open_payment_entries() title = "Zahlungen" tbl = table.Table(pes, keys, headings, title, enable_events=True, display_row_numbers=True) ix = tbl.display() if ix is False: break pe = pes[ix] details = utils.format_entry(pe, keys, headings) choice = easygui.buttonbox("Zahlung {}\n{} ".\ format(pe['name'],details), "Zahlung", ["Buchen","Löschen","Nichts tun"]) if choice == "Buchen": bank.BankTransaction.submit_entry(pe['name'], is_journal=False) show_company_data = True elif choice == "Löschen": bank.BankTransaction.delete_entry(pe['name'], is_journal=False) show_company_data = True elif event in ['Einkaufsrechnungen', 'Verkaufsrechnungen']: while True: keys = [ 'posting_date', 'outstanding_amount', 'bill_no', 'status', 'account', 'supplier', 'title' ] headings = [ 'Datum', 'Ausstehend', 'Rechungsnr.', 'Status', 'Buchungskonto', 'Lieferant', 'Titel' ] comp = company.Company.get_company(settings['-company-']) if event == 'Einkaufsrechnungen': inv_type = 'Purchase Invoice' else: inv_type = 'Sales Invoice' invs = comp.get_open_invoices_of_type(inv_type) inv_docs = [] bt_dict = defaultdict(list) for i in range(len(invs)): name = invs[i].name inv_doc = gui_api_wrapper(Api.api.get_doc, inv_type, name) if not 'bill_no' in inv_doc: inv_doc['bill_no'] = name accounts = list( set(map(lambda i: i['expense_account'], inv_doc['items']))) inv_doc['account'] = accounts[0] if len(accounts) > 1: inv_doc['account'] + " + weitere" total = inv_doc['grand_total'] if inv_type == 'Purchase Invoice': total = -total bt = bank.BankTransaction.find_bank_transaction(\ comp.name,total, inv_doc['bill_no'] if 'bill_no' in inv_doc else "") if bt: ref = None if 'customer' in inv_doc: ref = inv_doc['customer'] if 'supplier' in inv_doc: ref = inv_doc['supplier'] if ref: inv_doc['similarity'] = \ utils.similar(bt.description.lower(), ref.lower()) bt_dict[bt.name].append((i, inv_doc['similarity'])) inv_doc['bt'] = bt inv_doc['btname'] = bt.name inv_doc['disabled'] = not (bt or inv_doc['status'] == 'Draft') inv_docs.append(inv_doc) # handle duplicate bank transactions, use best matching invoice for bt, entries in bt_dict.items(): entries.sort(key=lambda e: e[1], reverse=True) for (i, s) in entries[1:]: del inv_docs[i]['bt'] del inv_docs[i]['btname'] tbl = table.Table(inv_docs, keys + ['btname'], headings + ['Bank'], event, enable_events=True, display_row_numbers=True) ix = tbl.display() if ix is False: break inv_doc = inv_docs[ix] details = utils.format_entry(inv_doc, keys, headings) msg = "{} {}\n{} ".\ format(event[:-2],inv_doc['name'],details) choices = [ "Buchen", "Löschen", "Buchungskonto bearbeiten", "Nichts tun" ] if 'bt' in inv_doc: bt = inv_doc['bt'] msg += "\n\nZugehörige Bank-Transaktion gefunden: {}\n".\ format(bt.description) choices[0] = "Sofort buchen und zahlen" if bt or inv_doc['status'] == 'Draft': choice = easygui.buttonbox(msg, event[:-2], choices) #print(choice) if choice == "Buchen" or choice == "Sofort buchen und zahlen": gui_api_wrapper(Api.submit_doc, inv_type, inv_doc['name']) show_company_data = True if choice == "Sofort buchen und zahlen": inv = Invoice(inv_doc, inv_type == 'Sales Invoice') inv.payment(bt) elif choice == "Löschen": gui_api_wrapper(Api.api.delete, inv_type, inv_doc['name']) show_company_data = True elif choice == "Buchungskonto bearbeiten": if inv_doc['account'][-10:] != ' + weitere': title = "Buchungskonto ändern" msg = "Bitte ein Buchungskonto auswählen" accounts = comp.leaf_accounts_for_credit account_names = [acc['name'] for acc in accounts] account_names.remove(inv_doc['account']) texts = [inv_doc['account']] + account_names account = easygui.choicebox(msg, title, texts) del inv_doc['account'] nitems = [] for item in inv_doc['items']: item['expense_account'] = account nitems.append(item) inv_doc['items'] = nitems gui_api_wrapper(Api.api.update, inv_doc) elif event == 'Banktransaktionen': keys = ['date', 'amount', 'description'] headings = ['Datum', 'Betrag', 'Bemerkung'] comp = company.Company.get_company(settings['-company-']) while True: bts = comp.open_bank_transactions() for bt in bts: bt['amount'] = bt['unallocated_amount'] * np.sign( bt['deposit'] - bt['withdrawal']) title = "Banktransaktionen" tbl = table.Table(bts, keys, headings, title, enable_events=True, max_col_width=120, display_row_numbers=True) ix = tbl.display() if ix is False: break comp.reconciliate(bts[ix]) show_company_data = True elif event in bank.BankAccount.get_baccount_names(): keys = ['date', 'open', 'amount', 'balance', 'description'] headings = ['Datum', 'Offen', 'Betrag', 'Stand', 'Bemerkung'] while True: bts = gui_api_wrapper(Api.api.get_list, 'Bank Transaction', filters={ 'bank_account': event, 'status': ['!=', 'Cancelled'] }, order_by='date asc', limit_page_length=LIMIT) balance = 0.0 for bt in bts: bt['amount'] = bt['deposit'] - bt['withdrawal'] balance += bt['amount'] bt['balance'] = balance bt['disabled'] = (bt['status'] == 'Reconciled') if bt['disabled']: bt['open'] = '' else: bt['open'] = '*' bts.reverse() title = "Banktransaktionen für " + event tbl = table.Table(bts, keys, headings, title, enable_events=True, max_col_width=120, display_row_numbers=True) ix = tbl.display() if ix is False: break comp = company.Company.get_company(settings['-company-']) comp.reconciliate(bts[ix]) show_company_data = True elif event in [ 'Abrechnung', 'Quartalsabrechnung', 'Monatsabrechnung', 'Bilanz' ]: comp = settings['-company-'] if event == 'Abrechnung': consolidated = True periodicity = 'Yearly' elif event == 'Quartalsabrechnung': consolidated = False periodicity = 'Quarterly' elif event == 'Monatsabrechnung': consolidated = False periodicity = 'Monthly' else: consolidated = False periodicity = None balance = event == 'Bilanz' tbl = report.build_report(comp, consolidated=consolidated, balance=balance, periodicity=periodicity) # in PDF, always also display balance if event != 'Bilanz': child = report.build_report(comp, consolidated=False, balance=True) tbl.child = child tbl.child_title = " mit Bilanz" while True: ix = tbl.display() if ix is False: break account = tbl.entries[ix]['account'] tbl1 = report.general_ledger(comp, account) if tbl1: tbl1.display() elif event in ['Chancen', 'Chancen Balkon']: tbl = report.opportunities(settings['-company-'], event == 'Chancen Balkon') tbl.display() if show_company_data: print() show_data() window.set_title(utils.title()) show_company_data = False return "inner"