[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[5753] trunk
- Subject: SF.net SVN: ledger-smb:[5753] trunk
- From: ..hidden..
- Date: Fri, 10 May 2013 12:37:02 +0000
Revision: 5753
http://sourceforge.net/p/ledger-smb/code/5753
Author: einhverfr
Date: 2013-05-10 12:36:59 +0000 (Fri, 10 May 2013)
Log Message:
-----------
reopen books now works again, some logic needs to be redone for 1.3
Modified Paths:
--------------
trunk/Changelog
trunk/LedgerSMB/DBObject/EOY.pm
trunk/LedgerSMB/Scripts/account.pm
trunk/UI/accounts/yearend.html
trunk/sql/modules/EndOfYear.sql
Modified: trunk/Changelog
===================================================================
--- trunk/Changelog 2013-05-10 08:15:04 UTC (rev 5752)
+++ trunk/Changelog 2013-05-10 12:36:59 UTC (rev 5753)
@@ -90,6 +90,7 @@
* Fixed cash transfer enforces ticked 'FX' boxes (Nick P, 802)
* Fixed extra newline-related errors in tex template engine (Chris T)
* Added updated Hungarian charts of accounts (Pongracz Istvan, 813)
+* Reopen books now works again (Chris T, 792)
Nick P is Nick Prater
Modified: trunk/LedgerSMB/DBObject/EOY.pm
===================================================================
--- trunk/LedgerSMB/DBObject/EOY.pm 2013-05-10 08:15:04 UTC (rev 5752)
+++ trunk/LedgerSMB/DBObject/EOY.pm 2013-05-10 12:36:59 UTC (rev 5753)
@@ -50,17 +50,30 @@
=item $eoy->reopen_books()
-This reverses any end of year transaction on $eoy->{end_date}, and deletes
-checkpoints for that day.
+This reverses any end of year transaction on $eoy->{reopen_date}, and deletes
+checkpoints later than that and creates a checkpoint for the prior day.
=cut
sub reopen_books {
my ($self) = @_;
- $self->exec_method(funcname => 'eoy_reopen_books');
+ $self->exec_method(funcname => 'eoy__reopen_books_at');
$self->{dbh}->commit;
}
+=item $eoy->latest_closing()
+
+Needs no properties set (other than internal private ones). Retrieves the
+latest closing date and returns it.
+
+=cut
+
+sub latest_closing {
+ my ($self) = @_;
+ my ($ref) = $self->exec_method(funcname => 'eoy__latest_checkpoint');
+ return $ref->{end_date};
+}
+
=item $eoy->close_books()
Requires all properies in BASIC PROPERTIES to be set. This creates a gl
Modified: trunk/LedgerSMB/Scripts/account.pm
===================================================================
--- trunk/LedgerSMB/Scripts/account.pm 2013-05-10 08:15:04 UTC (rev 5752)
+++ trunk/LedgerSMB/Scripts/account.pm 2013-05-10 12:36:59 UTC (rev 5753)
@@ -1,5 +1,6 @@
use Template;
use LedgerSMB::DBObject::Account;
+use LedgerSMB::DBObject::EOY;
package LedgerSMB::Scripts::account;
use Log::Log4perl;
use Data::Dumper;
@@ -176,10 +177,10 @@
=cut
sub yearend_info {
- use LedgerSMB::DBObject::EOY;
my ($request) = @_;
my $eoy = LedgerSMB::DBObject::EOY->new(base => $request);
$eoy->list_earnings_accounts;
+ $eoy->{closed_date} = $eoy->latest_closing;
$eoy->{user} = $request->{_user};
my $template = LedgerSMB::Template->new_UI(
user => $request->{_user},
@@ -202,7 +203,6 @@
=cut
sub post_yearend {
- use LedgerSMB::DBObject::EOY;
my ($request) = @_;
my $eoy = LedgerSMB::DBObject::EOY->new(base => $request);
$eoy->close_books;
@@ -215,6 +215,20 @@
}
+=item reopen_books
+
+This reopens books as of $request->{reopen_date}
+
+=cut
+
+sub reopen_books {
+ my ($request) = @_;
+ my $eoy = LedgerSMB::DBObject::EOY->new(base => $request);
+ $eoy->reopen_books;
+ delete $request->{reopen_date};
+ yearend_info($request);
+}
+
=back
=head1 COPYRIGHT
Modified: trunk/UI/accounts/yearend.html
===================================================================
--- trunk/UI/accounts/yearend.html 2013-05-10 08:15:04 UTC (rev 5752)
+++ trunk/UI/accounts/yearend.html 2013-05-10 12:36:59 UTC (rev 5753)
@@ -3,11 +3,11 @@
<body>
<form method="post" action="<?lsmb script ?>">
<table width="100%">
- <tr><th class="listtop"><?lsmb title ?></th></tr>
+ <tr><th class="listtop"><?lsmb text('Post Yearend') ?></th></tr>
<tr><td> </td></tr>
<tr>
<td>
- <table>
+ <table width="100%">
<tr>
<th align="right"><?lsmb text('Yearend') ?></th>
<td><?lsmb PROCESS input element_data={
@@ -44,24 +44,50 @@
value_attr = "id"
} -?></td>
</tr>
- </table>
- </td>
- </tr>
-</table>
+<tr><td colspan="2">
<hr size="3" noshade="noshade" />
<?lsmb FOREACH hidden IN hiddens.keys;
PROCESS input element_data={
type = 'hidden',
name = hidden,
value = hiddens.item(hidden)
- }; END ?>
+ }; END ?></td>
+</tr>
+<tr>
+<td align="right">
<?lsmb PROCESS button element_data = {
name = "action"
type = "submit"
class = "submit"
value = "post_yearend"
text = text('Post Yearend') #'
-} ?>
+} ?></td></tr>
+<tr><th colspan="2" class="listtop"><?lsmb text('Re-open Books') ?></th></tr>
+<tr><th align="right"><?lsmb text('Books closed on') ?></th>
+ <td><?lsmb closed_date ?></td>
+<tr>
+ <th align="right"><?lsmb text('Re-Open As Of') ?></th>
+ <td><?lsmb PROCESS input element_data={
+ class = 'date',
+ name = 'reopen_date',
+ size = 11,
+ title = user.dateformat,
+ } -?></td></tr>
+<tr>
+<tr><td colspan="2">
+<hr size="3" noshade="noshade" /></td></tr>
+<td align="right">
+<?lsmb PROCESS button element_data = {
+ name = "action"
+ type = "submit"
+ class = "submit"
+ value = "reopen_books"
+ text = text('Reopen Books') #'
+} ?></td></tr>
+ </table>
+ </td>
+ </tr>
+</table>
</form>
</body>
</html>
Modified: trunk/sql/modules/EndOfYear.sql
===================================================================
--- trunk/sql/modules/EndOfYear.sql 2013-05-10 08:15:04 UTC (rev 5752)
+++ trunk/sql/modules/EndOfYear.sql 2013-05-10 12:36:59 UTC (rev 5753)
@@ -1,5 +1,32 @@
BEGIN;
+CREATE OR REPLACE FUNCTION eoy__latest_checkpoint() RETURNS account_checkpoint
+LANGUAGE SQL AS
+$$
+ SELECT * FROM account_checkpoint ORDER BY end_date DESC LIMIT 1;
+$$;
+
+COMMENT ON FUNCTION eoy__latest_checkpoint() IS $$
+This returns a single checkpoint from the latest set. Which account and info
+is returned is non-determinative and so only the end date shoudl be relied on.
+$$;
+
+CREATE OR REPLACE FUNCTION eoy__reopen_books_at(in_reopen_date date)
+RETURNS BOOL
+LANGUAGE SQL AS
+$$
+
+ SELECT eoy_reopen_books(end_date)
+ FROM (SELECT end_date
+ FROM account_checkpoint
+ WHERE end_date >= $1
+ GROUP BY end_date) eoy_dates
+ ORDER BY end_date;
+
+SELECT eoy_create_checkpoint($1 - 1) > 0;
+
+$$;
+
CREATE OR REPLACE FUNCTION eoy_create_checkpoint(in_end_date date)
RETURNS int AS
$$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.