[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[5586] trunk/sql/modules/Payment.sql
- Subject: SF.net SVN: ledger-smb:[5586] trunk/sql/modules/Payment.sql
- From: ..hidden..
- Date: Wed, 16 Jan 2013 07:02:40 +0000
Revision: 5586
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5586&view=rev
Author: einhverfr
Date: 2013-01-16 07:02:37 +0000 (Wed, 16 Jan 2013)
Log Message:
-----------
Payment.sql load errors fixed
Modified Paths:
--------------
trunk/sql/modules/Payment.sql
Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql 2013-01-16 06:53:28 UTC (rev 5585)
+++ trunk/sql/modules/Payment.sql 2013-01-16 07:02:37 UTC (rev 5586)
@@ -182,8 +182,7 @@
in_datefrom date,
in_dateto date,
in_amountfrom numeric,
- in_amountto numeric,
- in_department_id int)
+ in_amountto numeric)
RETURNS SETOF payment_invoice AS
$$
DECLARE payment_inv payment_invoice;
@@ -240,13 +239,13 @@
--FROM (SELECT id, invnumber, transdate, amount, entity_id,
FROM (SELECT id, invnumber, invoice, transdate, amount,
1 as invoice_class, curr,
- entity_credit_account, department_id, approved
+ entity_credit_account, approved
FROM ap
UNION
--SELECT id, invnumber, transdate, amount, entity_id,
SELECT id, invnumber, invoice, transdate, amount,
2 AS invoice_class, curr,
- entity_credit_account, department_id, approved
+ entity_credit_account, approved
FROM ar
) a
JOIN (SELECT trans_id, chart_id, sum(CASE WHEN in_account_class = 1 THEN amount
@@ -274,8 +273,6 @@
OR in_amountfrom IS NULL)
AND (a.amount <= in_amountto
OR in_amountto IS NULL)
- AND (a.department_id = in_department_id
- OR in_department_id IS NULL)
AND due <> 0
AND a.approved = true
GROUP BY a.invnumber, a.transdate, a.amount, amount_fx, discount, discount_fx, ac.due, a.id, c.discount_terms, ex.buy, ex.sell, a.curr, a.invoice
@@ -285,7 +282,7 @@
END;
$$ LANGUAGE PLPGSQL;
-COMMENT ON FUNCTION payment_get_open_invoices(int, int, char(3), date, date, numeric, numeric, int) IS
+COMMENT ON FUNCTION payment_get_open_invoices(int, int, char(3), date, date, numeric, numeric) IS
$$ This function is the base for get_open_invoice and returns all open invoices for the entity_credit_id
it has a lot of options to enable filtering and use the same logic for entity_class_id and currency. $$;
@@ -297,7 +294,6 @@
in_dateto date,
in_amountfrom numeric,
in_amountto numeric,
- in_department_id int,
in_invnumber text)
RETURNS SETOF payment_invoice AS
$$
@@ -305,7 +301,7 @@
BEGIN
FOR payment_inv IN
SELECT * from payment_get_open_invoices(in_account_class, in_entity_credit_id, in_curr, in_datefrom, in_dateto, in_amountfrom,
- in_amountto, in_department_id)
+ in_amountto)
WHERE (invnumber like in_invnumber OR in_invnumber IS NULL)
LOOP
RETURN NEXT payment_inv;
@@ -314,7 +310,7 @@
$$ LANGUAGE PLPGSQL;
-COMMENT ON FUNCTION payment_get_open_invoice(int, int, char(3), date, date, numeric, numeric, int, text) IS
+COMMENT ON FUNCTION payment_get_open_invoice(int, int, char(3), date, date, numeric, numeric, text) IS
$$
This function is based on payment_get_open_invoices and returns only one invoice if the in_invnumber is set.
if no in_invnumber is passed this function behaves the same as payment_get_open_invoices
@@ -680,7 +676,6 @@
in_entity_credit_id int,
in_curr char(3),
in_notes text,
- in_department_id int,
in_gl_description text,
in_cash_account_id int[],
in_amount numeric[],
@@ -727,14 +722,14 @@
-- THE ID IS GENERATED BY payment_id_seq
--
INSERT INTO payment (reference, payment_class, payment_date,
- employee_id, currency, notes, department_id, entity_credit_id)
+ employee_id, currency, notes, entity_credit_id)
VALUES ((CASE WHEN in_account_class = 1 THEN
setting_increment('rcptnumber') -- I FOUND THIS ON sql/modules/Settings.sql
ELSE -- and it is very usefull
setting_increment('paynumber')
END),
in_account_class, in_datepaid, var_employee,
- in_curr, in_notes, in_department_id, in_entity_credit_id);
+ in_curr, in_notes, in_entity_credit_id);
SELECT currval('payment_id_seq') INTO var_payment_id; -- WE'LL NEED THIS VALUE TO USE payment_link table
-- WE'LL NEED THIS VALUE TO JOIN WITH PAYMENT
-- NOW COMES THE HEAVY PART, STORING ALL THE POSSIBLE TRANSACTIONS...
@@ -839,10 +834,10 @@
IF (array_upper(in_op_cash_account_id, 1) > 0) THEN
INSERT INTO gl (reference, description, transdate,
- person_id, notes, approved, department_id)
+ person_id, notes, approved)
VALUES (setting_increment('glnumber'),
in_gl_description, in_datepaid, var_employee,
- in_notes, in_approved, in_department_id);
+ in_notes, in_approved);
SELECT currval('id') INTO var_gl_id;
--
-- WE NEED TO SET THE GL_ID FIELD ON PAYMENT'S TABLE
@@ -896,7 +891,6 @@
in_entity_credit_id int,
in_curr char(3),
in_notes text,
- in_department_id int,
in_gl_description text,
in_cash_account_id int[],
in_amount numeric[],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.