~bernie/vatstuff/main

« back to all changes in this revision

Viewing changes to vatstuff_packages/vs_database/save_supplierinvoice.py

  • Committer: bernie
  • Date: 2010-09-28 16:48:32 UTC
  • Revision ID: bernie@packardbell-20100928164832-78lh6f61pp7ilnm1
Done transactions for closing and cancelling an order, and for
receiving a supplier invoice

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from vatstuff_packages.vs_database.transactions import *
36
36
 
37
37
 
38
 
def save(invoice, transaction_date, transaction_text, transaction_list):
 
38
def save(invoice, transaction_form):
39
39
    "Saves a SupplierInvoice as defined by SupplierInvoiceForm object invoice"
40
40
 
41
 
    if invoice == None: return False
 
41
    assert invoice
 
42
    assert transaction_form.system == 9
42
43
 
43
44
    # Get the purchaseorder
44
45
    purchaseorder = invoice.purchaseorder
45
 
    if not purchaseorder.is_open:
46
 
        return False
 
46
    assert purchaseorder.is_open
47
47
 
48
48
    # Get the running totals of invoice cost and vat from the purchaseorder
49
49
    total_invoices_cost = purchaseorder.invoice_cost
76
76
        conn, c = vs_connect()
77
77
 
78
78
        # Do the transaction
79
 
 
80
 
        # Note - this is a transaction system type 9 - Supplier invoice received transaction
81
 
 
82
 
        transaction_id = implement(c, transaction_date, transaction_text, transaction_list, 9)
 
79
        transaction_id = implement(c, transaction_form)
83
80
 
84
81
        new_supplierinvoice.append(transaction_id)
85
82
 
86
 
 
87
83
        c.execute("""INSERT INTO SUPPLIERINVOICES
88
84
                          (SUPPLIERINVOICE_ID,
89
85
                           SUPPLIER_ID,
114
110
            conn.close()
115
111
 
116
112
    info_log("Supplier invoice saved number: %s : id: %s" % (invoice.number, supplierinvoice_id))
117
 
    return True
118
 
 
119
 
 
120
 
################################################################################################
121
 
 
122
 
 
 
113
    return SupplierInvoice(supplierinvoice_id)
123
114
 
124
115