Re: [Ledger-smb-devel] Fwd: [PATCH] Save account headers to 'account_header' table (instead of 'account' table)

2011-05-30 Thread John Locke
Attaching patch for account_get stored function -- the commit in #3187
doesn't load into my version of postgres.

Cheers,
John

On 05/29/2011 09:53 AM, Erik Huelsmann wrote:
 Hi John,

 If you have a moment to check, I'm no longer able to reproduce your
 problems. Since Chris committed fixes in that area, one of them might
 have included the fix to your issue too.

 Could you validate that your problem has been resolved so I can close
 the tracker ticket?


 Thanks in advance!


 Bye,


 Erik.


 -- Forwarded message --
 From: Chris Travers chris.trav...@gmail.com
 Date: Sun, May 29, 2011 at 6:42 PM
 Subject: Re: [PATCH] Save account headers to 'account_header' table
 (instead of 'account' table)
 To: Erik Huelsmann ehu...@gmail.com
 Cc: Development discussion for LedgerSMB
 ledger-smb-devel@lists.sourceforge.net


 Committed

 --
 vRanger cuts backup time in half-while increasing security.
 With the market-leading solution for virtual backup and recovery, 
 you get blazing-fast, flexible, and affordable data protection.
 Download your free trial now. 
 http://p.sf.net/sfu/quest-d2dcopy1
 ___
 Ledger-smb-devel mailing list
 Ledger-smb-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

diff --git sql/modules/Account.sql sql/modules/Account.sql
index a233e3c..b4e0cad 100644
--- sql/modules/Account.sql
+++ sql/modules/Account.sql
@@ -19,7 +19,7 @@ $$ language sql;
 
 CREATE OR REPLACE FUNCTION account_get (in_id int) RETURNS setof chart AS
 $$
-SELECT * from chart where id = in_id and charttype = 'A';
+SELECT * from chart where id = $1 and charttype = 'A';
 $$ LANGUAGE sql;
 
 
--
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev___
Ledger-smb-devel mailing list
Ledger-smb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel


[Ledger-smb-devel] Issue 3309519: Email fields not populated when sending AR invoice

2011-05-30 Thread John Locke
Not sure I picked up all the changes that were required to make this
work, but the attached patch populates email/cc/bcc fields from the
customer's record when sending an AR invoice.

I think there was also a problem actually getting the invoice attached
with a relevant filename, which is also included in this patch. We've
been using this for months.

Cheers,
John Locke
http://freelock.com
diff --git UI/io-email.html UI/io-email.html
index decb298..3435891 100644
--- UI/io-email.html
+++ UI/io-email.html
@@ -21,12 +21,8 @@
 tr
   th align=right?lsmb text('Subject') ?/th
   td?lsmb PROCESS input element_data={name = 'subject', size = 30, value = form.subject} ?/td
-?lsmb IF user.role == 'admin' OR user.role == 'manager' ?
   th align=right?lsmb text('Bcc') ?/th
   td?lsmb PROCESS input element_data={name = 'bcc', size = 30, value = form.bcc} ?/td
-?lsmb ELSE ?
-  td colspan=2 /td
-?lsmb END ?
 /tr
   /table
 /td
diff --git bin/io.pl bin/io.pl
index 77d1698..3e35572 100644
--- bin/io.pl
+++ bin/io.pl
@@ -1181,7 +1181,7 @@ sub e_mail {
 
 my %hiddens;
 if ( $myconfig{role} !~ /(admin|manager)/ ) {
-$hiddens{bcc} = $form-{bcc};
+  #  $hiddens{bcc} = $form-{bcc};
 }
 
 if ( $form-{formname} =~ /(pick|packing|bin)_list/ ) {
@@ -1195,7 +1195,7 @@ sub e_mail {
 my $print_options = print_options(\%hiddens);
 
 for (
-qw(email cc bcc subject message sendmode format language_code action nextsub)
+qw(subject message sendmode format language_code action nextsub)
   )
 {
 delete $form-{$_};
@@ -1266,6 +1266,12 @@ sub print_options {
 };
 
 # SC: Option values extracted from other bin/ scripts
+if ($form-{type} eq 'invoice') {
+	push @{$options{formname}{options}}, {
+	text = $locale-text('Invoice'),
+	value = 'invoice',
+	};
+}
 if ($form-{type} eq 'sales_quotation') {
 push @{$options{formname}{options}}, {
 text = $locale-text('Quotation'),
@@ -1720,6 +1726,9 @@ sub print_form {
 	##SC: XXX the from address needs fixing
 $output_options{from} = $myconfig{email};
 $output_options{notify} = 1 if $form-{read_receipt};
+	$output_options{message} = $form-{message};
+	$output_options{filename} = $form-{formname} . '_'. $form-{${inv}number};
+	$output_options{filename} .= '.'. $form-{format}; # assuming pdf or html
 
 if ( %$old_form ) {
 $old_form-{intnotes} = qq|$old_form-{intnotes}\n\n|
@@ -1802,6 +1811,7 @@ sub print_form {
 user = \%myconfig, 
 template = $form-{'formname'},
 format = uc $form-{format},
+no_escape = true,
 method = $form-{media},
 output_options = \%output_options,
 );
--
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev___
Ledger-smb-devel mailing list
Ledger-smb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel


Re: [Ledger-smb-devel] State of Perl-based database setup utilities for LedgerSMB 1.3

2011-05-30 Thread Luke

On Sat, 28 May 2011, Erik Huelsmann wrote:


On Sat, May 28, 2011 at 7:07 PM, Chris Travers chris.trav...@gmail.com wrote:

On Sat, May 28, 2011 at 9:08 AM, Adam Thompson athom...@athompso.net wrote:

Where would the data be stored?  Do we require write permissions to
the ledgersmb directory?


Um, in the case I was describing, yes, I think so.  In the examples I've
seen, the administrator has the choice of either configuring their
webserver  system to allow the PHP script to write to the config file,
*or* updating the config file manually.  Which is what LSMB requires,
currently.


I think it's a lot safer not to trust the application with these
things.


Do I understand correctly, that the current design, requires CLI level 
activity, in order to create users, add companies, and populate company 
databases (COA, etc.)?

If not CLI, then some sort of PostGreSQL web frontend?

If that is so, is it also correct that no intent exists to integrate these 
operations into a web interface, such as 1.2's admin.pl, because doing so 
would require a PG admin user and admin database to exist, which we no 
longer want?


If so, the question has to be asked: what is the target audience for this 
application?


  There you have my complete support. I'm running the OTRS ticket

tracking tool and it wanted me to open up write access to parts of its
directory structure in /usr. I *hate* it when tools require that:
libraries and servers which need write access should do that in the
/var hierarchy.


but is that the fault of the mechanism, or of the application's notion of 
acceptable filesystem utilization?  Because it sounds like you are 
faulting the latter, but excluding the former as a result.


(By which I mean that you are agreeing with Chris that the application 
should not get write access to one of its own configuration files; and 
then sighting as an example of why that's bad, an application that wants 
write access under /usr, instead of /var [where it should potentially have 
it].)


  OTRS is a great example of a tool that comes with a great 

installation
script in Debian: you run the command 'apt-get install otrs2' and the
database, cron jobs and webserver all are configured when it
succesfully completes. That's what I envision for lsmb too, for its


Do you only get one single issue queue [or analogous concept] from that 
action, or can you create more without running the package manager again? 
If you can, how is it done?


  first company database - created by packagers for specific

distributions.


Is the COA part of that first database, and do we still lock users into a 
COA template at company creation time?



The other scenario would be to run LSMB with access to a user which
has enough permissions to do that when LSMB decides it's required to
do so. I'm not trusting LSMB enough to depend on that - after all, if
there turns out to be a security leak, anybody can start to create or
drop tables from my accounting system.


Anyone who could crack you at that level, could presumably crack any other 
PGSQL user as well, and do the same kind of damage on a company by company 
basis.


I am not up on PGSQL permission granularity, but does the user which 
creates a user or database, necessarily have to retain the ability to 
delete it?


I am suggesting that you could handicap your admin user (we could provide 
a script for this), so that creations can be done by web interface using 
that admin user, but deletions would have to be done manually.


Luke--
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev___
Ledger-smb-devel mailing list
Ledger-smb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel


[Ledger-smb-devel] Issue 3309520: Email AR Aging statement patch

2011-05-30 Thread John Locke
This one I just fixed today -- we've got a lot of accounts aging, and
I'm tired of having to look up email addresses ;-)

Note that AR - Aging calls LedgerSMB::RP-get_customer which looks for
the addresses in the customer view. This view did not even have an
email column and did not contain data for cc and bcc. I had to drop
the view because the number of columns was changing, then load the new
view with the appropriate joins to the eca_to_contact table. Also, in
the customer view, it needed to key off entity_id not id.

Regarding admin/manager access to the bcc field, Chris had indicated
several months ago when I spoke to him about this, that there wasn't an
equivalent in LSMB 1.3 to use, so for this and the previous patch, I
just stripped the check for this access from the template, so it always
shows bcc.

Cheers,
John Locke
http://freelock.com
diff --git LedgerSMB/RP.pm LedgerSMB/RP.pm
index c67b7dc..f1e5b1e 100644
--- LedgerSMB/RP.pm
+++ LedgerSMB/RP.pm
@@ -1872,7 +1872,7 @@ sub get_customer {
 
 my $query = qq|
 		SELECT name, email, cc, bcc FROM $form-{ct} ct
-		 WHERE ct.id = ?|;
+		 WHERE ct.entity_id = ?|;
 $sth = $dbh-prepare($query);
 $sth-execute( $form-{$form-{ct}_id} );
 ( $form-{ $form-{ct} }, $form-{email}, $form-{cc}, $form-{bcc} ) =
diff --git UI/rp-email.html UI/rp-email.html
index 731b388..d990dbf 100644
--- UI/rp-email.html
+++ UI/rp-email.html
@@ -20,11 +20,8 @@
 	tr
 	  th align=right nowrap=nowrap?lsmb text('Subject') ?/th
 	  td?lsmb PROCESS input element_data={name = 'subject', size= '30', value = form.subject} ?/td
-?lsmb IF user.role == 'admin' OR user.role == 'manager' ?
 	  th align=right nowrap=nowrap?lsmb text('Bcc') ?/th
-	  td?lsmb PROCESS input element_data={name = 'bcc', size= '30', value = form.bcc} ?/td?lsmb
-ELSE ?th /thtd /td?lsmb
-END ?
+	  td?lsmb PROCESS input element_data={name = 'bcc', size= '30', value = form.bcc} ?/td
 	/tr
   /table
 /td
diff --git bin/rp.pl bin/rp.pl
index af1f43f..326e7a3 100644
--- bin/rp.pl
+++ bin/rp.pl
@@ -1413,7 +1413,7 @@ sub e_mail {
 
 print_options;
 
-for (qw(email cc bcc subject message type sendmode format action nextsub)) {
+for (qw(subject message type sendmode format action nextsub)) {
 delete $form-{$_};
 }
 
diff --git sql/Pg-database.sql sql/Pg-database.sql
index 06cfd28..cd75561 100644
--- sql/Pg-database.sql
+++ sql/Pg-database.sql
@@ -940,8 +940,9 @@ CREATE VIEW customer AS
 emd.creditlimit,
 emd.terms,
 emd.meta_number as customernumber,
-emd.cc,
-emd.bcc,
+ece.contact as email,
+ecc.contact as cc,
+ecb.contact as bcc,
 emd.business_id,
 emd.language_code,
 emd.pricegroup_id,
@@ -954,6 +955,9 @@ CREATE VIEW customer AS
 FROM entity_credit_account emd 
 LEFT JOIN entity_bank_account eba on emd.entity_id = eba.entity_id
 Left join entity_note ein on ein.ref_key = emd.entity_id
+LEFT JOIN eca_to_contact ece ON emd.id = ece.credit_id AND ece.contact_class_id = 12
+LEFT JOIN eca_to_contact ecc ON emd.id = ecc.credit_id AND ecc.contact_class_id = 13
+LEFT JOIN eca_to_contact ecb ON emd.id = ecb.credit_id AND ecb.contact_class_id = 14
 join company c on c.entity_id = emd.entity_id
 join entity e on c.entity_id = e.id
 where emd.entity_class = 2;
--
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev___
Ledger-smb-devel mailing list
Ledger-smb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel