Skip to content

Commit c55a54f

Browse files
committed
version 0.5.9 add gl_transaction_id to incoming_invoices table
1 parent 0dd90d9 commit c55a54f

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/db/update_db_minor.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,9 @@ CREATE TABLE IF NOT EXISTS incoming_invoices_gl_entry_expenses_ids (id bigserial
139139
--version 0.5.8
140140
ALTER TABLE public.purchase_order_line_items DROP CONSTRAINT IF EXISTS purchase_order_line_items_expense_account_fkey;
141141
ALTER TABLE public.purchase_order_line_items ADD CONSTRAINT purchase_order_line_items_expense_account_fkey FOREIGN KEY (expense_account) REFERENCES public.gl_accounts ("number") MATCH SIMPLE ON UPDATE CASCADE ON DELETE RESTRICT;
142+
--version 0.5.9
143+
ALTER TABLE incoming_invoices ADD COLUMN IF NOT EXISTS gl_transaction_id bigint REFERENCES gl_transactions ON DELETE RESTRICT;
144+
UPDATE incoming_invoices SET gl_transaction_id = ge.gl_transaction_id FROM (SELECT id, gl_transaction_id FROM gl_entries) AS ge WHERE incoming_invoices.gl_entry_id = ge.id AND incoming_invoices.gl_transaction_id IS NULL;
145+
UPDATE incoming_invoices SET gl_transaction_id = ge.gl_transaction_id FROM (SELECT date_inserted, amount, gl_transaction_id FROM gl_entries) AS ge WHERE incoming_invoices.amount = ge.amount AND incoming_invoices.gl_transaction_id IS NULL AND incoming_invoices.date_created = ge.date_inserted ;
142146

143147

src/incoming_invoice.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,25 +336,29 @@ def print_check_clicked (self, button):
336336
self.window.destroy()
337337

338338
def save_incoming_invoice (self):
339+
c = self.db.cursor()
339340
contact_id = self.builder.get_object('combobox1').get_active_id()
340341
description = self.builder.get_object('entry1').get_text()
341342
total = Decimal(self.builder.get_object('spinbutton1').get_text())
342343
self.invoice = transactor.ServiceProviderPayment (self.db,
343344
self.date,
344345
total)
345-
self.cursor.execute("INSERT INTO incoming_invoices "
346-
"(contact_id, date_created, amount, description) "
347-
"VALUES (%s, %s, %s, %s) RETURNING id",
348-
(contact_id, self.date, total, description))
349-
invoice_id = self.cursor.fetchone()[0]
350-
if self.file_data != None:
351-
self.cursor.execute("UPDATE incoming_invoices "
352-
"SET attached_pdf = %s "
353-
"WHERE id = %s", (self.file_data, invoice_id))
346+
c.execute( "INSERT INTO incoming_invoices "
347+
"(contact_id, "
348+
"date_created, "
349+
"amount, "
350+
"description, "
351+
"gl_transaction_id, "
352+
"attached_pdf) "
353+
"VALUES (%s, %s, %s, %s, %s, %s) RETURNING id",
354+
(contact_id, self.date, total, description,
355+
self.invoice.transaction_id, self.file_data))
356+
invoice_id = c.fetchone()[0]
354357
for row in self.expense_percentage_store:
355358
amount = row[1]
356359
expense_account = row[2]
357360
self.invoice.expense(amount, expense_account, invoice_id)
361+
c.close()
358362
return invoice_id, total
359363

360364
def balance_this_row_activated (self, menuitem):

src/pygtk_posting.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@
14211421
<property name="transient_for">main_window</property>
14221422
<property name="has_resize_grip">True</property>
14231423
<property name="program_name">PyGtk Posting</property>
1424-
<property name="version">0.5.8 (alpha)</property>
1424+
<property name="version">0.5.9 (alpha)</property>
14251425
<property name="copyright" translatable="yes">Copyleft Reuben Rissler 2015-2018</property>
14261426
<property name="comments" translatable="yes">Accounting and business management for Linux</property>
14271427
<property name="authors">Reuben Rissler &lt;pygtk.posting@gmail.com&gt;

0 commit comments

Comments
 (0)