diff options
-rw-r--r-- | LedgerSMB/DBObject.pm | 14 | ||||
-rw-r--r-- | UI/payments/payments_filter.html | 5 | ||||
-rw-r--r-- | sql/modules/Payment.sql | 10 | ||||
-rw-r--r-- | sql/modules/Roles.sql | 2 | ||||
-rw-r--r-- | sql/modules/chart.sql | 22 |
5 files changed, 44 insertions, 9 deletions
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index be6ea7ef..145210eb 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -242,7 +242,7 @@ sub _parse_array { my @return_array; while ($value ne '{}') { - my $next = ""; + my $next; my $separator = ""; if ($value =~ /^\{"/){ while ($next eq "" or ($next =~ /\\".$/)){ @@ -250,17 +250,19 @@ sub _parse_array { $next .= $1; $next =~ /(.)$/; $separator = $1; + $next .= "quoted"; } $next =~ s/"(.*)"$separator$/$1/; - } elsif ($value =~ /^{({+})/){ + } elsif ($value =~ /^{({+)/){ my $open_braces = $1; my $close_braces = $open_braces; $close_braces =~ s/{/}/g; - $value =~ /^{($open_braces.*$close_braces)/; - $next = $1; - $value =~ s/^{$next/{/; - $next = $self->parse_array($next); + $value =~ /^{($open_braces[^}]*$close_braces)/; + my $parse_next = $1; + $value =~ s/^{$parse_next/{/; + $value =~ s/^{,/{/; + @$next = $self->_parse_array($parse_next); } else { $value =~ s/^\{([^,]*)(,|\})/\{/; diff --git a/UI/payments/payments_filter.html b/UI/payments/payments_filter.html index e1e095d5..e8cbd6b0 100644 --- a/UI/payments/payments_filter.html +++ b/UI/payments/payments_filter.html @@ -24,6 +24,11 @@ type = "hidden" name = "account_class" } ?> +<?lsmb INCLUDE input element_data={ + value = batch_id + type = "hidden" + name = "batch_id" +} ?> <div id = "payments-filter-categories" class="inputgroup"> <?lsmb IF projects ?> <div id = "payments-filter-projects" class="input"> diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql index c39e6945..d19a821b 100644 --- a/sql/modules/Payment.sql +++ b/sql/modules/Payment.sql @@ -130,7 +130,7 @@ BEGIN sum(a.amount - a.paid) AS total_due, compound_array(ARRAY[[ a.id::text, a.invnumber, a.transdate::text, - a.amount::text, + a.amount::text, a.paid::text, (CASE WHEN c.discount_terms > extract('days' FROM age(a.transdate)) THEN 0 @@ -148,12 +148,15 @@ BEGIN FROM entity e JOIN entity_credit_account c ON (e.id = c.entity_id) JOIN (SELECT id, invnumber, transdate, amount, entity_id, - paid, curr, 1 as invoice_class + paid, curr, 1 as invoice_class, + entity_credit_account FROM ap UNION SELECT id, invnumber, transdate, amount, entity_id, - paid, curr, 2 as invoice_class + paid, curr, 2 as invoice_class, + entity_credit_account FROM ar + ORDER BY transdate ) a USING (entity_id) JOIN transactions t ON (a.id = t.id) WHERE a.invoice_class = in_account_class @@ -163,6 +166,7 @@ BEGIN WHERE batch_id = in_batch_id)) AND c.entity_class = in_account_class AND a.curr = in_currency + AND a.entity_credit_account = c.id AND a.amount - a.paid <> 0 AND t.locked_by NOT IN (select "session_id" FROM "session" diff --git a/sql/modules/Roles.sql b/sql/modules/Roles.sql index 8ae539e9..3ed98d73 100644 --- a/sql/modules/Roles.sql +++ b/sql/modules/Roles.sql @@ -1385,4 +1385,6 @@ GRANT select on chart, gifi, country to public; GRANT SELECT ON parts, partsgroup TO public; GRANT SELECT ON language, project TO public; GRANT SELECT ON business, exchangerate, department, shipto, tax TO public; +GRANT ALL ON recurring, recurringemail, recurringprint TO public; +--TODO, lock recurring down more diff --git a/sql/modules/chart.sql b/sql/modules/chart.sql index 11e2e38b..4575bc69 100644 --- a/sql/modules/chart.sql +++ b/sql/modules/chart.sql @@ -21,3 +21,25 @@ END; $$ language plpgsql; COMMENT ON FUNCTION chart_list_cash(in_account_class int) IS $$ This function returns the cash account acording with in_account_class which must be 1 or 2 $$; + +CREATE OR REPLACE FUNCTION chart_get_ar_ap(in_account_class int) +RETURNS SETOF chart AS +$$ +DECLARE out_row chart%ROWTYPE; +BEGIN + IF in_account_class NOT IN (1, 2) THEN + RAISE EXCEPTION 'Bad Account Type'; + END IF; + FOR out_row IN + SELECT * FROM chart + WHERE link = CASE WHEN in_account_class = 1 THEN 'AP' + WHEN in_account_class = 2 THEN 'AR' + END + LOOP + RETURN NEXT out_row; + END LOOP; +END; +$$ LANGUAGE PLPGSQL; +COMMENT ON FUNCTION chart_get_ar_ap(in_account_class int) IS +$$ This function returns the cash account acording with in_account_class which must be 1 or 2 $$; + |