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

SF.net SVN: ledger-smb:[4955] branches/1.3



Revision: 4955
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4955&view=rev
Author:   ehuelsmann
Date:     2012-07-01 09:57:02 +0000 (Sun, 01 Jul 2012)
Log Message:
-----------
Fix bug 3539177 (reported by Matthew Bourque) preventing discounts on
single payments to be calculated.

Modified Paths:
--------------
    branches/1.3/LedgerSMB/DBObject/Payment.pm
    branches/1.3/sql/modules/Payment.sql

Modified: branches/1.3/LedgerSMB/DBObject/Payment.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Payment.pm	2012-07-01 09:33:55 UTC (rev 4954)
+++ branches/1.3/LedgerSMB/DBObject/Payment.pm	2012-07-01 09:57:02 UTC (rev 4955)
@@ -198,7 +198,7 @@
 sub get_entity_credit_account{
   my ($self) = @_;
   @{$self->{entity_accounts}} =
-    $self->exec_method(funcname => 'payment_get_entity_accounts'); 
+    ($self->exec_method(funcname => 'payment_get_entity_account_payment_info'),);
    return  @{$self->{entity_accounts}};
 }
 

Modified: branches/1.3/sql/modules/Payment.sql
===================================================================
--- branches/1.3/sql/modules/Payment.sql	2012-07-01 09:33:55 UTC (rev 4954)
+++ branches/1.3/sql/modules/Payment.sql	2012-07-01 09:57:02 UTC (rev 4955)
@@ -34,7 +34,9 @@
 $$ Returns all information on a payment type by the id.  This should be renamed
 to account for its behavior in future versions.$$;
 
-
+-- ### To be dropped in 1.4: it's imprecise
+-- to return a set of entity accounts based on their names,
+-- if we're going to use them for discount calculations...
 CREATE OR REPLACE FUNCTION payment_get_entity_accounts
 (in_account_class int,
  in_vc_name text,
@@ -67,6 +69,25 @@
 $$ Returns a minimal set of information about customer or vendor accounts
 as needed for discount calculations and the like.$$;
 
+CREATE OR REPLACE FUNCTION payment_get_entity_account_payment_info
+(in_entity_credit_id int)
+RETURNS payment_vc_info
+AS $$
+ SELECT ec.id, cp.legal_name ||
+        coalesce(':' || ec.description,'') as name,
+        e.entity_class, ec.discount_account_id, ec.meta_number
+ FROM entity_credit_account ec
+ JOIN entity e ON (ec.entity_id = e.id)
+ JOIN company cp ON (cp.entity_id = e.id)
+ WHERE ec.id = $1;
+$$ LANGUAGE SQL;
+
+COMMENT ON FUNCTION payment_get_entity_account_payment_info
+(in_entity_credit_id int)
+IS $$ Returns payment information on the entity credit account as
+  required to for discount calculations and payment processing. $$;
+
+
 -- payment_get_open_accounts and the option to get all accounts need to be
 -- refactored and redesigned.  -- CT
 CREATE OR REPLACE FUNCTION payment_get_open_accounts(in_account_class int)

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