Skip to content

Commit

Permalink
version 0.5.9 add gl_transaction_id to incoming_invoices table
Browse files Browse the repository at this point in the history
  • Loading branch information
benreu committed Jan 21, 2019
1 parent 0dd90d9 commit c55a54f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/db/update_db_minor.sql
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,9 @@ CREATE TABLE IF NOT EXISTS incoming_invoices_gl_entry_expenses_ids (id bigserial
--version 0.5.8
ALTER TABLE public.purchase_order_line_items DROP CONSTRAINT IF EXISTS purchase_order_line_items_expense_account_fkey;
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;
--version 0.5.9
ALTER TABLE incoming_invoices ADD COLUMN IF NOT EXISTS gl_transaction_id bigint REFERENCES gl_transactions ON DELETE RESTRICT;
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;
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 ;


22 changes: 13 additions & 9 deletions src/incoming_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,25 +336,29 @@ def print_check_clicked (self, button):
self.window.destroy()

def save_incoming_invoice (self):
c = self.db.cursor()
contact_id = self.builder.get_object('combobox1').get_active_id()
description = self.builder.get_object('entry1').get_text()
total = Decimal(self.builder.get_object('spinbutton1').get_text())
self.invoice = transactor.ServiceProviderPayment (self.db,
self.date,
total)
self.cursor.execute("INSERT INTO incoming_invoices "
"(contact_id, date_created, amount, description) "
"VALUES (%s, %s, %s, %s) RETURNING id",
(contact_id, self.date, total, description))
invoice_id = self.cursor.fetchone()[0]
if self.file_data != None:
self.cursor.execute("UPDATE incoming_invoices "
"SET attached_pdf = %s "
"WHERE id = %s", (self.file_data, invoice_id))
c.execute( "INSERT INTO incoming_invoices "
"(contact_id, "
"date_created, "
"amount, "
"description, "
"gl_transaction_id, "
"attached_pdf) "
"VALUES (%s, %s, %s, %s, %s, %s) RETURNING id",
(contact_id, self.date, total, description,
self.invoice.transaction_id, self.file_data))
invoice_id = c.fetchone()[0]
for row in self.expense_percentage_store:
amount = row[1]
expense_account = row[2]
self.invoice.expense(amount, expense_account, invoice_id)
c.close()
return invoice_id, total

def balance_this_row_activated (self, menuitem):
Expand Down
2 changes: 1 addition & 1 deletion src/pygtk_posting.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@
<property name="transient_for">main_window</property>
<property name="has_resize_grip">True</property>
<property name="program_name">PyGtk Posting</property>
<property name="version">0.5.8 (alpha)</property>
<property name="version">0.5.9 (alpha)</property>
<property name="copyright" translatable="yes">Copyleft Reuben Rissler 2015-2018</property>
<property name="comments" translatable="yes">Accounting and business management for Linux</property>
<property name="authors">Reuben Rissler &lt;pygtk.posting@gmail.com&gt;
Expand Down

0 comments on commit c55a54f

Please sign in to comment.