[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6268] addons/1.3/wxPOS/setup/invoices.sql



Revision: 6268
          http://sourceforge.net/p/ledger-smb/code/6268
Author:   einhverfr
Date:     2013-11-09 02:19:18 +0000 (Sat, 09 Nov 2013)
Log Message:
-----------
Invoices procedures now load

Modified Paths:
--------------
    addons/1.3/wxPOS/setup/invoices.sql

Modified: addons/1.3/wxPOS/setup/invoices.sql
===================================================================
--- addons/1.3/wxPOS/setup/invoices.sql	2013-11-08 15:40:36 UTC (rev 6267)
+++ addons/1.3/wxPOS/setup/invoices.sql	2013-11-09 02:19:18 UTC (rev 6268)
@@ -2,7 +2,7 @@
 
 CREATE OR REPLACE FUNCTION invoice__start_ar
 (in_invnumber text, in_transdate date, in_taxincluded bool, 
- in_amount numeric, in_netamount numeric, in_paid numeric, in_datepaid numeric,
+ in_amount numeric, in_netamount numeric, in_paid numeric, in_datepaid date,
  in_duedate date, in_invoice bool, in_curr char(3), person_id int,
  in_till varchar(20), in_department_id int, in_approved bool, 
  in_entity_credit_account int, in_ar_accno text)
@@ -10,7 +10,7 @@
 $$
  INSERT INTO ar 
         (invnumber, transdate, taxincluded,
-         amount, netamount, paid, datepaid
+         amount, netamount, paid, datepaid,
          duedate, invoice, curr, person_id,
          till, department_id, approved, entity_credit_account)
  VALUES ($1, $2, coalesce($3, 'f'),
@@ -22,14 +22,14 @@
  INSERT INTO acc_trans
         (trans_id, transdate, chart_id, amount, approved)
  SELECT currval('id')::int, $2, a.id, $4, true
-   FROM account WHERE accno = $16;
+   FROM account a WHERE accno = $16;
 
  SELECT currval('id')::int;
 $$;
 
-COMMENT ON invoice__start_ar
+COMMENT ON FUNCTION invoice__start_ar
 (in_invnumber text, in_transdate date, in_taxincluded bool, 
- in_amount numeric, in_netamount numeric, in_paid numeric, in_datepaid numeric,
+ in_amount numeric, in_netamount numeric, in_paid numeric, in_datepaid date,
  in_duedate date, in_invoice bool, in_curr char(3), person_id int,
  in_till varchar(20), in_department_id int, in_approved bool, 
  in_entity_credit_account int, in_ar_accno text) 
@@ -57,8 +57,8 @@
 RETURNS BOOL LANGUAGE SQL AS
 $$
 INSERT INTO invoice(trans_id, parts_id, qty, discount, unit, allocated)
-SELECT$1, p.id, $3, $4, calesce($5), 0
-  FROM parts WHERE id = $2;
+SELECT $1, p.id, $3, $4, coalesce($5), 0
+  FROM parts p WHERE id = $2;
 
 SELECT TRUE;
 $$;
@@ -68,7 +68,7 @@
  in_unit text)
 IS $$This adds an item to the invoice.  This is not safe to use alone.  If you 
 use it, you MUST also use invoice__finalize_ar.  In particular this function does
-not add income, inventory, or COGS calculations.
+not add income, inventory, or COGS calculations. $$;
 
 CREATE OR REPLACE FUNCTION invoice__add_payment_ar
 (in_id int, in_ar_accno text, in_cash_accno text, in_transdate date,
@@ -77,8 +77,12 @@
 $$
 INSERT INTO acc_trans (trans_id, chart_id, transdate, source, memo, amount,
                        approved)
-VALUES ($1, $2, coalesce($4, 'today'), $5, $6, $7, true),
-       ($1, $3, coalesce($4, 'today'), $5, $6, $7 * -1, true);
+VALUES ($1, (select id from account where accno = $2), coalesce($4, 'today'), $5, 
+        $6, $7, true),
+       ($1, (select id from account where accno = $3), coalesce($4, 'today'), $5, 
+        $6, $7 * -1, true);
+
+SELECT TRUE;
 $$;
 
 CREATE OR REPLACE FUNCTION invoice__finalize_ar(in_id int) 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits