Ejemplo n.º 1
0
	def product_combo_changed(self, combo):
		product_id = combo.get_active_id()
		if product_id != None:
			c = DB.cursor()
			self.product_id = product_id
			c = DB.cursor()
			c.execute("SELECT id::text, version_name "
						"FROM product_assembly_versions "
						"WHERE product_id = %s AND active = True",
						(self.product_id,))
			for row in c.fetchall():
				self.version_store.append(row)
			c.close()
Ejemplo n.º 2
0
 def db_query(self, db_queue, model_queue):
     c = DB.cursor()
     while True:
         list_ = db_queue.get()
         if list_ == 'End':
             break
         parent, entry_id, tx_id, progress = list_
         c.execute(
             "SELECT ge.id, "
             "COALESCE(ge.check_number::text, ''), "
             "ge.date_inserted::text, "
             "format_date(ge.date_inserted), "
             "ga.name, "
             "reconciled, "
             "ge.date_reconciled::text, "
             "format_date(ge.date_reconciled), "
             "CASE WHEN ge.credit_account IS NOT NULL "
             "THEN ge.amount::text ELSE '' END, "
             "CASE WHEN ge.credit_account IS NOT NULL "
             "THEN ge.amount ELSE 0.00 END, "
             "CASE WHEN ge.debit_account IS NOT NULL "
             "THEN ge.amount::text ELSE '' END, "
             "CASE WHEN ge.debit_account IS NOT NULL "
             "THEN ge.amount ELSE 0.00 END, "
             "ge.gl_transaction_id "
             "FROM gl_entries AS ge "
             "JOIN gl_accounts AS ga "
             "ON ga.number = ge.credit_account "
             "OR ga.number = ge.debit_account "
             "WHERE ge.id != %s AND ge.gl_transaction_id = %s "
             "UNION "
             # handle POs with special treatment
             "SELECT 0, "
             "'', "
             "'', "
             "'', "
             "ga.name, "
             "False, "
             "'', "
             "'', "
             "'', "
             "0.00, "
             "SUM(ge.amount)::text, "
             "SUM(ge.amount), "
             "0 "
             "FROM purchase_orders AS po "
             "JOIN purchase_order_items AS poli "
             "ON poli.purchase_order_id = po.id "
             "JOIN gl_entries AS ge "
             "ON ge.id = poli.gl_entries_id "
             "JOIN gl_accounts AS ga "
             "ON ga.number = ge.debit_account "
             "WHERE po.gl_transaction_payment_id = %s "
             "GROUP BY ga.name "
             "ORDER BY date_inserted",
             (entry_id, tx_id, tx_id))
         for row in c.fetchall():
             model_queue.put((parent, progress, row))
     model_queue.put('End')
     c.close()
Ejemplo n.º 3
0
	def __init__(self):

		self.search_iter = 0
		
		Gtk.Builder.__init__(self)
		self.add_from_file(UI_FILE)
		self.connect_signals(self)
		self.cursor = DB.cursor()

		contact_completion = self.get_object('contact_completion')
		contact_completion.set_match_func(self.contact_match_func)

		self.invoice_history = None

		self.contact_store = self.get_object('contact_store')
		self.cursor.execute("SELECT "
								"id::text, "
								"name, "
								"ext_name "
							"FROM contacts "
							"WHERE deleted = False "
							"ORDER BY name")
		for row in self.cursor.fetchall():
			self.contact_store.append(row)
		self.window = self.get_object('window1')
		self.window.show_all()
Ejemplo n.º 4
0
    def __init__(self):

        Gtk.Builder.__init__(self)
        self.add_from_file(UI_FILE)
        self.connect_signals(self)
        self.cursor = DB.cursor()

        self.loan_payment_store = self.get_object('loan_payments_store')
        self.loan_store = self.get_object('loan_store')
        self.populate_loans()

        column = self.get_object('treeviewcolumn2')
        renderer = self.get_object('cellrenderertext2')
        column.set_cell_data_func(renderer, self.cell_func, 2)

        column = self.get_object('treeviewcolumn3')
        renderer = self.get_object('cellrenderertext3')
        column.set_cell_data_func(renderer, self.cell_func, 3)

        column = self.get_object('treeviewcolumn4')
        renderer = self.get_object('cellrenderertext4')
        column.set_cell_data_func(renderer, self.cell_func, 4)

        self.window = self.get_object('window1')
        self.window.show_all()
Ejemplo n.º 5
0
	def __init__(self):

		self.builder = Gtk.Builder()
		self.builder.add_from_file(UI_FILE)
		self.builder.connect_signals(self)
		self.cursor = DB.cursor()
		self.datetime = datetime.today()
		date_text = datetime_to_text(self.datetime)
		self.builder.get_object('entry8').set_text(date_text)
		morrow = self.datetime + timedelta(days = 1)
		morrow_string = str(morrow)[0:10]
		struct_time = time.strptime(morrow_string,"%Y-%m-%d")
		self.stop_time = time.mktime(struct_time)
		calendar = self.builder.get_object('calendar1')
		self.popover = Gtk.Popover()
		self.popover.add(calendar)

		self.employee_store = self.builder.get_object('employee_store')
		self.employee_payment_store = self.builder.get_object('employee_payment_store')
		self.employee_id = 0

		self.adjusted_seconds = 0
		
		self.window = self.builder.get_object('window1')
		self.window.show_all()

		self.populate_employees ()
Ejemplo n.º 6
0
 def populate_credit_memo(self):
     c = DB.cursor()
     self.credit_items_store.clear()
     c.execute(
         "SELECT "
         "cmi.id, "
         "cmi.qty::text, "
         "p.id, "
         "p.name, "
         "p.ext_name, "
         "cmi.price::text, "
         "cmi.ext_price::text, "
         "cmi.tax::text, "
         "cmi.invoice_item_id, "
         "ili.invoice_id, "
         "date_returned::text, "
         "format_date(date_returned) "
         "FROM credit_memo_items AS cmi "
         "JOIN invoice_items AS ili ON ili.id = cmi.invoice_item_id "
         "JOIN products AS p ON p.id = ili.product_id "
         "WHERE (credit_memo_id, cmi.deleted) = (%s, False) "
         "ORDER BY cmi.id", (self.credit_memo_id, ))
     for row in c.fetchall():
         self.credit_items_store.append(row)
     c.close()
Ejemplo n.º 7
0
 def populate_treeview(self):
     c = DB.cursor()
     self.bank_transaction_store.clear()
     c.execute(
         "SELECT ge.id, "
         "COALESCE(ge.check_number::text, ''), "
         "ge.date_inserted::text, "
         "format_date(ge.date_inserted), "
         "CASE WHEN contacts.name IS NOT NULL "
         "THEN contacts.name "
         "ELSE transaction_description END, "
         "reconciled, "
         "CASE WHEN ge.credit THEN ge.amount::text ELSE '' END, "
         "CASE WHEN ge.debit THEN ge.amount::text ELSE '' END "
         "FROM bank_statement_view AS ge "
         "LEFT JOIN payments_incoming AS pi "
         "ON ge.id = pi.gl_entries_id "
         "LEFT JOIN contacts ON contacts.id = "
         "pi.customer_id "
         "WHERE date_reconciled IS NULL "
         "ORDER BY date_inserted;",
         (self.account_number, self.account_number))
     for row in c.fetchall():
         self.bank_transaction_store.append(row)
     c.close()
     DB.rollback()
Ejemplo n.º 8
0
 def select_employee(self):
     self.populating = True
     DB.commit()  # save and unlock the active employee
     cursor = DB.cursor()
     try:
         cursor.execute(
             "SELECT "
             "born, "
             "social_security, "
             "social_security_exempt, "
             "on_payroll_since, "
             "wage, "
             "payments_per_year, "
             "married, "
             "format_date(last_updated), "
             "state_withholding_exempt, "
             "state_credits, "
             "state_extra_withholding, "
             "fed_withholding_exempt, "
             "fed_credits, "
             "fed_extra_withholding "
             "FROM payroll.employee_info "
             "WHERE employee_id = %s "
             "ORDER BY active DESC, id DESC "
             "LIMIT 1 FOR UPDATE NOWAIT", (self.employee_id, ))
     except psycopg2.OperationalError as e:
         DB.rollback()
         cursor.close()
         self.get_object('box1').set_sensitive(False)
         error = str(
             e) + "Hint: somebody else is editing this employee info"
         self.show_message(error)
         self.populating = False
         return False
     for row in cursor.fetchall():
         self.born_calendar.set_date(row[0])
         self.get_object('entry2').set_text(row[1])
         self.get_object('checkbutton3').set_active(row[2])
         self.on_payroll_since_calendar.set_date(row[3])
         self.get_object('spinbutton6').set_value(row[4])
         self.get_object('spinbutton5').set_value(row[5])
         self.get_object('checkbutton4').set_active(row[6])
         self.get_object('label6').set_text(row[7])
         self.get_object('checkbutton2').set_active(row[8])
         self.get_object('spinbutton3').set_value(row[9])
         self.get_object('spinbutton2').set_value(row[10])
         self.get_object('checkbutton1').set_active(row[11])
         self.get_object('spinbutton4').set_value(row[12])
         self.get_object('spinbutton1').set_value(row[13])
         break
     else:
         cursor.execute(
             "INSERT INTO payroll.employee_info (employee_id) "
             "VALUES (%s)", (self.employee_id, ))
         DB.commit()
         GLib.timeout_add(50, self.select_employee)
     self.populating = False
     self.populate_exemption_forms()
     cursor.close()
     self.get_object('box1').set_sensitive(True)
Ejemplo n.º 9
0
 def append_product(self):
     c = DB.cursor()
     c.execute(
         "SELECT 	p.id, "
         "p.name, "
         "p.ext_name, "
         "p.description, "
         "p.barcode, "
         "u.name, "
         "p.weight::text, "
         "p.tare::text, "
         "p.manufacturer_sku, "
         "COALESCE ((SELECT name FROM gl_accounts "
         "WHERE number = default_expense_account), ''), "
         "COALESCE ((SELECT name FROM gl_accounts "
         "WHERE number = p.inventory_account), ''), "
         "COALESCE ((SELECT name FROM gl_accounts "
         "WHERE number = p.revenue_account), ''), "
         "p.sellable, "
         "p.purchasable, "
         "p.manufactured, "
         "p.job, "
         "p.stock "
         "FROM products AS p "
         "JOIN units AS u ON u.id = p.unit "
         "WHERE p.id = %s ", (self.product_id, ))
     for row in c.fetchall():
         self.product_store.append(row)
     c.close()
Ejemplo n.º 10
0
	def post_credit_entry (self, revenue_account, amount):
		c = DB.cursor()
		c.execute("INSERT INTO gl_entries "
				"(date_inserted, gl_transaction_id, credit_account, amount) "
				"VALUES (%s, %s, %s, %s)", 
				(self.date, self.trans_id, revenue_account, amount))
		c.close()
Ejemplo n.º 11
0
	def __init__ (self, date):
		self.date = date
		c = DB.cursor()
		c.execute("INSERT INTO gl_transactions "
					"(date_inserted) VALUES (now()) RETURNING id")
		self.trans_id = c.fetchone()[0]
		c.close()
Ejemplo n.º 12
0
def post_purchase_order_accounts (po_id, date):
	cursor = DB.cursor()
	cursor.execute ("SELECT gl_transactions.id FROM gl_transactions "
					"JOIN gl_entries "
						"ON gl_entries.gl_transaction_id = gl_transactions.id "
					"JOIN purchase_orders "
						"ON purchase_orders.gl_entries_id = gl_entries.id "
					"WHERE purchase_orders.id = %s", (po_id,))
	gl_transaction_id = cursor.fetchone()[0]
	cursor.execute("SELECT id, ext_price, expense_account "
							"FROM purchase_order_items "
							"WHERE purchase_order_id = %s ", (po_id,))
	for row in cursor.fetchall():
		row_id = row[0]
		amount = row[1]
		expense_account_number = row[2]
		cursor.execute("WITH new_row AS (INSERT INTO gl_entries "
						"(amount, debit_account, gl_transaction_id, "
						"date_inserted) VALUES "
						"(%s, %s, %s, %s) RETURNING id) "
						"UPDATE purchase_order_items SET gl_entries_id = "
							"((SELECT id FROM new_row)) WHERE id = %s",
						(amount, expense_account_number, 
						gl_transaction_id, date, row_id))
	cursor.close()
Ejemplo n.º 13
0
def cancel_invoice (datetime, invoice_id):
	c = DB.cursor()
	c.execute("SELECT gt.id FROM gl_transactions AS gt "
				"JOIN gl_entries AS ge ON ge.gl_transaction_id = gt.id "
				"JOIN invoices ON invoices.gl_entries_id = ge.id "
				"WHERE invoices.id = %s", (invoice_id,))
	t_id = c.fetchone()[0]
	c.execute("WITH credits AS "
				"(SELECT amount, credit_account, gl_transaction_id FROM gl_entries "
				"WHERE gl_transaction_id = %s AND credit_account IS NOT NULL"
					"), "
				"debits AS "
				"(SELECT amount, debit_account, gl_transaction_id FROM gl_entries "
				"WHERE gl_transaction_id = %s AND debit_account IS NOT NULL"
					"),"
				"insert_debits AS "
				"(INSERT INTO gl_entries "
					"(amount, debit_account, gl_transaction_id) "
					"SELECT * FROM credits"
				") "
				"INSERT INTO gl_entries "
					"(amount, credit_account, gl_transaction_id) "
					"SELECT * FROM debits"
				, (t_id, t_id))
	c.close()
Ejemplo n.º 14
0
	def cash (self, cash_deposit, cash_account):
		c = DB.cursor()
		c.execute("INSERT INTO gl_entries "
					"(credit_account, amount, gl_transaction_id) "
					"VALUES (%s, %s, %s)", 
					(cash_account, cash_deposit, self.transaction_id))
		c.close()
Ejemplo n.º 15
0
	def populate_purchase_order_items_store (self):
		self.purchase_order_items_store.clear()
		c = DB.cursor()
		c.execute("SELECT "
						"poli.id, "
						"qty, "
						"p.id, "
						"p.name, "
						"remark, "
						"price, "
						"ext_price, "
						"a.expense_account, "
						"a.name, "
						"CASE WHEN expense = TRUE THEN 0.00 ELSE price END, "
						"expense, "
						"order_number "
					"FROM purchase_order_items AS poli "
					"JOIN products AS p ON p.id = poli.product_id "
					"LEFT JOIN gl_accounts AS a "
					"ON a.number = poli.expense_account "
					"WHERE purchase_order_id = (%s) "
					"ORDER BY poli.sort, poli.id", 
					(self.purchase_order_id, ))
		for row in c.fetchall() :
			self.purchase_order_items_store.append(row)
		self.calculate_totals ()
		c.close()
		DB.rollback()
Ejemplo n.º 16
0
 def populate_contact_individuals(self):
     store = self.get_object('contact_individuals_store')
     store.clear()
     button = self.get_object('contact_individuals_button')
     c = DB.cursor()
     c.execute(
         "SELECT id, "
         "name, "
         "ext_name, "
         "address, "
         "city, "
         "state, "
         "zip, "
         "phone, "
         "fax, "
         "email "
         "FROM contact_individuals WHERE contact_id = %s "
         "ORDER BY name, ext_name", (self.contact_id, ))
     tupl = c.fetchall()
     if tupl == []:  # only show the individuals button when individuals exist
         button.hide()
     else:
         button.show()
     for row in tupl:
         store.append(row)
     c.close()
     DB.rollback()
Ejemplo n.º 17
0
 def populate_tag_flowbox(self):
     self.remove_tags()
     flowbox = self.builder.get_object('tag_flowbox')
     c = DB.cursor()
     c.execute(
         "SELECT "
         "tag, "
         "red, "
         "green, "
         "blue, "
         "alpha "
         "FROM resource_ids_tag_ids AS riti "
         "JOIN resource_tags AS rt ON rt.id = riti.resource_tag_id "
         "WHERE riti.resource_id = %s", (self.row_id, ))
     for row in c.fetchall():
         tag_name = row[0]
         red = int(row[1] * 255)
         green = int(row[2] * 255)
         blue = int(row[3] * 255)
         alpha = int(row[4] * 255)
         hex_color = '#%02x%02x%02x%02x' % (red, green, blue, alpha)
         string = "<span foreground='%s'>%s</span>\n" % (hex_color,
                                                         tag_name)
         label = Gtk.Label()
         label.set_markup(string)
         label.show()
         flowbox.add(label)
Ejemplo n.º 18
0
    def __init__(self, product_id=None):

        Gtk.Builder.__init__(self)
        self.add_from_file(UI_FILE)
        self.connect_signals(self)
        self.cursor = DB.cursor()
        if product_id != None:
            self.product_id = product_id
        self.exists = True
        self.treeview = self.get_object('treeview2')
        self.product_store = self.get_object('product_store')
        self.product_name_store = Gtk.ListStore(str)  # for product suggestions
        self.populate_product_names()
        self.filtered_product_store = self.get_object('filtered_product_store')
        self.filtered_product_store.set_visible_func(self.filter_func)
        dnd = Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags(1), 129)
        mask = Gdk.ModifierType.BUTTON1_MASK
        self.treeview.drag_source_set(mask, [dnd], Gdk.DragAction.COPY)
        self.treeview.connect('drag_data_get', self.on_drag_data_get)
        self.treeview.drag_source_set_target_list([dnd])
        self.populate_product_store()
        self.handler_ids = list()
        for connection in (("products_changed", self.show_refresh_button), ):
            handler = broadcaster.connect(connection[0], connection[1])
            self.handler_ids.append(handler)

        self.window = self.get_object('window')
        self.set_window_layout_from_settings()
        self.window.show_all()
        GLib.idle_add(self.window.set_position, Gtk.WindowPosition.NONE)
Ejemplo n.º 19
0
    def __init__(self):

        Gtk.Builder.__init__(self)
        self.add_from_file(UI_FILE)
        self.connect_signals(self)
        self.cursor = DB.cursor()

        self.employee_store = self.get_object('employee_store')
        self.s_s_medicare_store = self.get_object('s_s_medicare_store')
        self.federal_withholding_store = self.get_object(
            'federal_withholding_store')
        self.state_withholding_store = self.get_object(
            'state_withholding_store')

        self.populate_employee_store()
        self.born_calendar = DateTimeCalendar(override=True)
        self.on_payroll_since_calendar = DateTimeCalendar(override=True)
        self.born_calendar.connect("day-selected",
                                   self.born_calendar_date_selected)
        self.on_payroll_since_calendar.connect(
            "day-selected", self.on_payroll_since_calendar_date_selected)

        self.window = self.get_object('window1')
        self.window.show_all()
        broadcaster.connect("shutdown", self.main_shutdown)

        self.get_object("button5").set_label("No scanner selected")
        self.get_object("button5").set_sensitive(False)

        self.data_queue = Queue()
        self.scanner_store = self.get_object("scanner_store")
        thread = Process(target=self.get_scanners)
        thread.start()
        GLib.timeout_add(100, self.populate_scanners)
Ejemplo n.º 20
0
 def populate_contact_mailing_store(self):
     treeview = self.get_object('contact_mailing_treeview')
     store = treeview.get_model()
     treeview.set_model(None)
     store.clear()
     c = DB.cursor()
     c.execute(
         "SELECT mlr.id, "
         "c.id, "
         "c.name, "
         "ext_name, "
         "address, "
         "city, "
         "state, "
         "zip, "
         "phone, "
         "mlr.printed "
         "FROM contacts AS c "
         "JOIN mailing_list_register AS mlr "
         "ON mlr.contact_id = c.id "
         "JOIN mailing_lists AS ml ON ml.id = mlr.mailing_list_id "
         "WHERE (ml.id, mlr.active) = (%s, True) "
         "ORDER BY c.name, c.ext_name", (self.mailing_list_id, ))
     for row in c.fetchall():
         store.append(row)
     c.close()
     DB.rollback()
     treeview.set_model(store)
     self.get_object('contacts_amount_label').set_text(str(len(store)))
     self.count_addresses_to_print()
Ejemplo n.º 21
0
    def __init__(self):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(UI_FILE)
        self.builder.connect_signals(self)
        self.cursor = DB.cursor()

        self.customer_store = self.builder.get_object('customer_store')
        self.product_store = self.builder.get_object('credit_products_store')
        self.credit_items_store = self.builder.get_object('credit_items_store')
        self.handler_ids = list()
        for connection in (("contacts_changed",
                            self.populate_customer_store), ):
            handler = broadcaster.connect(connection[0], connection[1])
            self.handler_ids.append(handler)
        self.populate_customer_store()

        self.date_returned_calendar = DateTimeCalendar()
        self.date_returned_calendar.connect('day-selected',
                                            self.return_day_selected)
        date_column = self.builder.get_object('label3')
        self.date_returned_calendar.set_relative_to(date_column)

        self.date_calendar = DateTimeCalendar()
        self.date_calendar.connect('day-selected', self.day_selected)

        product_completion = self.builder.get_object('product_completion')
        product_completion.set_match_func(self.product_match_func)
        customer_completion = self.builder.get_object('customer_completion')
        customer_completion.set_match_func(self.customer_match_func)

        self.window = self.builder.get_object('window1')
        self.window.show_all()
Ejemplo n.º 22
0
 def post_project_clicked(self, button):
     selection = self.get_object('treeview-selection')
     model, path = selection.get_selected_rows()
     if path == []:
         return
     project_id = model[path][0]
     project_qty = model[path][3]
     serial_qty = model[path][5]
     cursor = DB.cursor()
     if serial_qty < project_qty:
         cursor.execute(
             "SELECT invoice_serial_numbers FROM products AS p "
             "JOIN manufacturing_projects AS mp "
             "ON mp.product_id = p.id "
             "WHERE mp.id = %s", (project_id, ))
         if cursor.fetchone()[0] == True:
             self.show_message("Missing serial numbers!")
             cursor.close()
             DB.rollback()
             return
     cursor.execute(
         "UPDATE time_clock_projects "
         "SET (active, stop_date) = "
         "(False, CURRENT_DATE) "
         "WHERE id = "
         "(SELECT time_clock_projects_id "
         "FROM manufacturing_projects WHERE id = %s);"
         "UPDATE manufacturing_projects "
         "SET active = False WHERE id = %s", (project_id, project_id))
     DB.commit()
     cursor.close()
     self.populate_projects()
Ejemplo n.º 23
0
 def new_item_clicked(self, button):
     c = DB.cursor()
     self.check_credit_memo_id()
     invoice_item_id = self.product_store[0][0]
     c.execute(
         "SELECT "
         "0, "
         "1.0::text, "
         "p.id, "
         "p.name, "
         "p.ext_name, "
         "price::text, "
         "price::text, "
         "ROUND(1.0 * price * tr.rate/100, 2)::text, "
         "ii.id, "
         "ii.invoice_id, "
         "CURRENT_DATE::text, "
         "format_date(CURRENT_DATE) "
         "FROM invoice_items AS ii "
         "JOIN products AS p ON p.id = ii.product_id "
         "JOIN tax_rates AS tr ON tr.id = ii.tax_rate_id "
         "WHERE ii.id = %s LIMIT 1", (invoice_item_id, ))
     for row in c.fetchall():
         iter_ = self.credit_items_store.append(row)
         treeview = self.builder.get_object('treeview1')
         column = treeview.get_column(0)
         path = self.credit_items_store.get_path(iter_)
         treeview.set_cursor(path, column, True)
Ejemplo n.º 24
0
	def save_incoming_invoice (self):
		c = DB.cursor()
		contact_id = self.get_object('combobox1').get_active_id()
		description = self.get_object('entry1').get_text()
		total = Decimal(self.get_object('spinbutton1').get_text())
		self.invoice = transactor.ServiceProviderPayment (
															self.date, 
															total)
		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))
		self.invoice_id = c.fetchone()[0] # self.invoice_id is a public variable
		self.invoice.incoming_invoice_id = self.invoice_id
		for row in self.expense_percentage_store:
			amount = row[1]
			account = row[2]
			remark = row[5]
			self.invoice.expense(amount, account, remark)
		c.close()
		return total
Ejemplo n.º 25
0
 def new_expense_product_clicked(self, button):
     c = DB.cursor()
     c.execute("INSERT INTO products "
               "(name, "
               "unit, "
               "cost, "
               "expense, "
               "tax_rate_id, "
               "revenue_account, "
               "default_expense_account) "
               "VALUES "
               "('New expense product', "
               "1, "
               "0.00, "
               "True, "
               "(SELECT id FROM tax_rates "
               "WHERE standard = True "
               "), "
               "(SELECT number FROM gl_accounts "
               "WHERE revenue_account = True LIMIT 1 "
               "), "
               "(SELECT number FROM gl_accounts "
               "WHERE expense_account = True LIMIT 1 "
               "))")
     DB.commit()
     c.close()
     self.emit('expense-products-changed')
Ejemplo n.º 26
0
	def load_project (self):
		cursor = DB.cursor()
		try:
			cursor.execute("SELECT product_id::text, "
							"qty, "
							"name, "
							"batch_notes, "
							"version_id::text "
							"FROM manufacturing_projects WHERE id = %s "
							"FOR UPDATE NOWAIT",
							(self.project_id, ))
		except psycopg2.OperationalError as e:
			DB.rollback()
			cursor.close()
			error = str(e) + "Hint: somebody else is editing this project"
			self.show_message (error)
			self.window.destroy()
			return False
		for row in cursor.fetchall():
			self.get_object('product_combo').set_active_id(row[0])
			self.get_object('units_spinbutton').set_value(row[1])
			self.get_object('description_entry').set_text(row[2])
			self.get_object('batch_notes_buffer').set_text(row[3])
			self.get_object('version_combo').set_active_id(row[4])
		self.get_object('product_combo').set_sensitive(False)
		cursor.close()
Ejemplo n.º 27
0
 def populate_loan_totals(self):
     c = DB.cursor()
     c.execute(
         "SELECT "
         "format_date(l.date_received), "
         "l.period_amount::text ||' '||l.period||'(s)', "
         "c.name, "
         "liability.name, "
         "l.finished, "
         "l.amount::money, "
         "COALESCE(SUM(principal.amount), 0.00)::money, "
         "COALESCE(l.amount - SUM(principal.amount), 0.00)::money, "
         "COALESCE(SUM(interest.amount), 0.00)::money "
         "FROM loans AS l "
         "LEFT JOIN loan_payments AS lp ON l.id = lp.loan_id "
         "LEFT JOIN gl_entries AS principal "
         "ON principal.id = lp.gl_entries_principal_id "
         "LEFT JOIN gl_entries AS interest "
         "ON interest.id = lp.gl_entries_interest_id "
         "JOIN gl_accounts AS liability "
         "ON liability.number = l.liability_account "
         "JOIN contacts AS c ON c.id = l.contact_id "
         "WHERE l.id = %s "
         "GROUP BY l.amount, l.date_received, l.period_amount, "
         "l.period, l.finished, liability.name, c.name", (self.loan_id, ))
     for row in c.fetchall():
         self.get_object('date_started_entry').set_text(row[0])
         self.get_object('payment_period_entry').set_text(row[1])
         self.get_object('contact_name_entry').set_text(row[2])
         self.get_object('liability_account_entry').set_text(row[3])
         self.get_object('finished_checkbutton').set_active(row[4])
         self.get_object('loan_total_entry').set_text(row[5])
         self.get_object('principal_paid_entry').set_text(row[6])
         self.get_object('principal_unpaid_entry').set_text(row[7])
         self.get_object('interest_paid_entry').set_text(row[8])
Ejemplo n.º 28
0
	def save_clicked (self, button):
		c = DB.cursor()
		product_id = self.get_object('product_combo').get_active_id()
		name = self.get_object('description_entry').get_text()
		qty = self.get_object('units_spinbutton').get_value()
		buf = self.get_object('batch_notes_buffer')
		start_iter = buf.get_start_iter()
		end_iter = buf.get_end_iter()
		notes = buf.get_text(start_iter, end_iter, True)
		if self.project_id == None:
			time_clock_id = self.get_time_clock_id (name)
			c.execute("INSERT INTO manufacturing_projects "
						"(product_id, name, qty, time_clock_projects_id, "
						"batch_notes, active, version_id) VALUES "
						"(%s, %s, %s, %s, %s, True, %s)", 
						(product_id, name, qty, time_clock_id, 
						notes, self.version_id))
		else:
			c.execute("UPDATE manufacturing_projects SET "
						"(name, qty, batch_notes, version_id) = "
						"(%s, %s, %s, %s) WHERE id = %s "
						"RETURNING time_clock_projects_id", 
						(name, qty, notes, self.version_id, self.project_id))
			active = self.get_object('time_clock_checkbutton').get_active()
			for row in c.fetchall():
				time_clock_projects_id = row[0]
				c.execute("UPDATE time_clock_projects "
							"SET (name, active, stop_date) = "
							"(%s, %s, CURRENT_DATE) "
							"WHERE id = %s",
							(name, active, time_clock_projects_id))
		DB.commit()
		c.close()
		self.window.destroy ()
		self.parent_class.populate_projects()
Ejemplo n.º 29
0
	def populate_contact_shipping (self):
		shipping_store = self.get_object('shipping_store')
		shipping_store.clear()
		count = 0
		c = DB.cursor()
		c.execute("SELECT "
						"si.id, "
						"si.tracking_number, "
						"si.reason, "
						"si.date_shipped::text, "
						"format_date(si.date_shipped), "
						"COALESCE(si.invoice_id::text, 'N/A'), "
						"COALESCE(ii.amount, 0.00), "
						"COALESCE(ii.amount::text, 'N/A') "
					"FROM shipping_info AS si "
					"LEFT JOIN incoming_invoices AS ii "
						"ON ii.id = si.incoming_invoice_id "
					"WHERE si.contact_id = %s"
					"ORDER BY date_shipped", 
					(self.contact_id,))
		for row in c.fetchall():
			count += 1
			shipping_store.append(row)
		if count == 0:
			self.get_object('label11').set_label('Shipping')
		else:
			label = "<span weight='bold'>Shipping (%s)</span>" % count
			self.get_object('label11').set_markup(label)
		c.close()
Ejemplo n.º 30
0
 def bank_account_combo_changed(self, combobox):
     account_number = combobox.get_active_id()
     if account_number == None:
         return
     c = DB.cursor()
     c.execute(
         "CREATE OR REPLACE TEMP VIEW "
         "bank_statement_report_view AS "
         "WITH account_numbers AS "
         "(SELECT number FROM gl_accounts "
         "WHERE number = %s OR parent_number = %s"
         ") "
         "SELECT id, amount, debit_account, "
         "credit_account, check_number, date_inserted, "
         "reconciled, transaction_description, "
         "date_reconciled, TRUE AS debit, FALSE AS credit, "
         "gl_transaction_id "
         "FROM gl_entries WHERE debit_account "
         "IN (SELECT * FROM account_numbers) "
         "UNION "
         "SELECT id, amount, debit_account, "
         "credit_account, check_number, date_inserted, "
         "reconciled, transaction_description, "
         "date_reconciled, FALSE AS debit, TRUE AS credit, "
         "gl_transaction_id "
         "FROM gl_entries WHERE credit_account "
         "IN (SELECT * FROM account_numbers)",
         (account_number, account_number))
     c.close()
     DB.commit()
     self.account_number = account_number
     self.populate_bank_statement_store()