Skip to content

Commit

Permalink
Merge 74f05e1 into 88a4a89
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuelsmann committed Jul 24, 2023
2 parents 88a4a89 + 74f05e1 commit b6a08b5
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 157 deletions.
257 changes: 113 additions & 144 deletions UI/accounts/yearend.html
Expand Up @@ -4,158 +4,127 @@
id="gl-yearend"
method="post"
action="[% request.script %]">
<div id="closing-tabs"
data-dojo-type="dijit/layout/TabContainer"
style="height: 100%" >
<div id="closing-year"
title="[% text('Close Year') %]"
data-dojo-type="dijit/layout/ContentPane" >
<table width="100%">
<tr><th class="listtop">[% text('Closing data') %]</th></tr>
<tr><td> </td></tr>
<tr>
<td>
<table width="100%">
<tr>
<th align="right"><label
for='end-date'>[% text('Yearend')
%]</label></th>
<td>[% PROCESS input element_data={
class = 'date',
name = 'end_date',
size = 11,
title = user.dateformat,
} -%]</td>
<table style="width:100%">
<thead>
<tr>
<th colspan="3" class="listtop">Period closing dates</th>
</tr>
<tr>
<th align="right"><label
for="reference">[% text('Reference')
%]</label></th>
<td>[% PROCESS input element_data={
name = 'reference',
size = 20,
value = text('Yearend'),
} -%]</td>
<th colspan="3">
Post year closing
</th>
</tr>
<tr>
<th align="right"><label for="description">[% text('Description') %]</label></th>
<td>[% PROCESS textarea element_data={
name = 'description',
rows = 3,
cols = 50,
} -%]</td>
<td colspan="3">
<table style="margin-top:2em;margin-bottom:2em">
<tr>
<td>
<label for='end-date'>[% text('Yearend') %]</label>
</td>
<td>[% PROCESS input element_data={
class = 'date',
name = 'end_date',
size = 11,
title = user.dateformat,
} -%]</td>
</tr>
<tr>
<td>
<label for="reference">[% text('Reference') %]</label>
</td>
<td>[% PROCESS input element_data={
name = 'reference',
size = 20,
value = text('Yearend'),
} -%]</td>
</tr>
<tr>
<td>
<label for="description">[% text('Description') %]</label>
</td>
<td>[% PROCESS textarea element_data={
name = 'description',
rows = 3,
cols = 50,
} -%]</td>
</tr>
<tr>
<td>
<label for="retention-acc-id">[% text('Retained Earnings') %]</label>
</td>
[% FOREACH opt = eoy.earnings_accounts;
opt.text = opt.accno _ '--' _ opt.description;
END -%]
<td>[% PROCESS select element_data={
name = "retention_acc_id"
options = eoy.earnings_accounts
value_attr = "id"
} -%]</td>
<td>
[% FOREACH hidden IN eoy.hiddens.keys;
PROCESS input element_data={
type = 'hidden',
name = hidden,
value = hiddens.item(hidden)
}; END %]
[% PROCESS button element_data = {
name = "__action"
type = "submit"
class = "submit"
value = "post_yearend"
text = text('Post Yearend') #'
} %]</td></tr>
</table>
</td>
</tr>
<tr>
<th align="right"><label for="retention-acc-id">[% text('Retained Earnings') %]</label></th>
[% FOREACH opt = eoy.earnings_accounts;
opt.text = opt.accno _ '--' _ opt.description;
END -%]
<td>[% PROCESS select element_data={
name = "retention_acc_id"
options = eoy.earnings_accounts
value_attr = "id"
} -%]</td>
</tr>
<tr><td colspan="2">
<hr size="3" noshade="noshade" />
[% FOREACH hidden IN eoy.hiddens.keys;
PROCESS input element_data={
type = 'hidden',
name = hidden,
value = hiddens.item(hidden)
}; END %]</td>
<th>Date</th>
<th>Is Year-end</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">
[% PROCESS button element_data = {
name = "__action"
type = "submit"
class = "submit"
value = "post_yearend"
text = text('Post Yearend') #'
} %]</td></tr>
</table>
</td>
</tr>
</table>

</div>

<div id="closing-period"
title="[% text('Close Period') %]"
data-dojo-type="dijit/layout/ContentPane" >
<table width="100%">
<tr><td>
<table width="100%">
<tr><th colspan="2"
class="listtop">[% text('Close books') %]</th></tr>
<tr><th align="right">[% text('Books closed up to') %]</th>
<td>[% eoy.closed_date %]</td>
<tr>
<th align="right">
<label for="period-close-date">[% text('Close As-Of')
%]</label></th>
<td>[% PROCESS input element_data={
class = 'date',
name = 'period_close_date',
size = 11,
title = user.dateformat,
} -%]</td></tr>
<tr><td colspan="2">
<hr size="3" noshade="noshade" /></td></tr>
<td align="left">
[% PROCESS button element_data = {
name = "__action"
type = "submit"
class = "submit"
value = "close_period"
text = text('Close Period') #'
} %]</td></tr>
</table>
</td>
</tr>
</table>
</div>


<div id="reopen"
title="[% text('Re-open Books') %]"
data-dojo-type="dijit/layout/ContentPane" >

<table width="100%">
<tr><td>
<table width="100%">
<tr><th colspan="2"
class="listtop">[% text('Re-open Books')
%]</th></tr>
<tr><th align="right">[% text('Books closed on') %]</th>
<td>[% eoy.closed_date %]</td></tr>
<tr>
<th align="right"><label
for="reopen-date">[% text('Re-Open As Of')
%]</label></th>
<td>[% 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="left">
[% PROCESS button element_data = {
name = "__action"
type = "submit"
class = "submit"
value = "reopen_books"
text = text('Re-open Period') #'
} %]</td></tr>
</table>
</td>
</tr>
</table>
</div>
</div>
class = 'date',
name = 'period_close_date',
size = 11,
title = 'Close As-Of'
} -%]</td>
<td>
no
</td>
<td>
[% PROCESS button element_data={
name = '__action'
value = 'close_period'
text = 'Close Period'
title = 'Close only, no year-end'
} %]
</td>
</tr>
[% FOREACH closing IN eoy.closing_dates -%]
<tr>
<td>[% closing.end_date %]</td>
<td>[% IF closing.is_yearend %]yes[% ELSE %]no[% END %]</td>
<td>[% IF loop.first;
PROCESS input element_data = {
name = 'reopen_date'
value = closing.end_date
type = 'hidden'
};
PROCESS button element_data = {
text = "Re-open Period"
value = 'reopen_books'
name = '__action'
id = '__action-' _ loop.count
};
END %]</td>
</tr>
[% END %]
</tbody>
<tfoot>
</tfoot>
</table>
</form>
</body>
6 changes: 3 additions & 3 deletions cpanfile
Expand Up @@ -185,7 +185,7 @@ on 'develop' => sub {
requires 'Perl::Critic';
requires 'Perl::Critic::Moose';
requires 'Perl::Critic::Policy::Modules::RequireExplicitInclusion';
requires 'Pherkin::Extension::Weasel', '0.15';
requires 'Pherkin::Extension::Weasel', '0.16';
requires 'Pod::ProjectDocs';
requires 'Selenium::Remote::Driver';
requires 'TAP::Parser::SourceHandler::pgTAP', '3.33';
Expand All @@ -205,9 +205,9 @@ on 'develop' => sub {
requires 'Test2::Plugin::Feature', '0.001112';
requires 'Test2::Plugin::pgTAP';
requires 'Text::Diff';
requires 'Weasel', '0.29';
requires 'Weasel', '0.31';
requires 'Weasel::Driver::Selenium2', '0.12';
requires 'Weasel::Session', '0.11';
requires 'Weasel::Session', '0.30';
requires 'Weasel::Widgets::Dojo', '0.07';

feature 'debug', 'Debug pane' =>
Expand Down
25 changes: 20 additions & 5 deletions lib/LedgerSMB/Scripts/account.pm
Expand Up @@ -279,16 +279,31 @@ Shows the yearend screen. No expected inputs.

sub yearend_info {
my ($request) = @_;
my ($closed_date) = map {
$_->{end_date}
} $request->call_procedure(funcname => 'eoy__latest_checkpoint');
my $template = $request->{_wire}->get('ui');
my $dbh = $request->{dbh};
my @closing_dates = $dbh->selectall_array(
q|select end_date,
exists (select *
from yearend y
where y.transdate = x.end_date
and not y.reversed) as is_yearend
from (
select distinct end_date
from account_checkpoint) x
order by end_date desc
limit 10|,
{ Slice => {} }
);
die $dbh->errstr if $dbh->err;

use Data::Dumper;
print STDERR Dumper \@closing_dates;
return $template->render(
$request, 'accounts/yearend',
{
request => $request,
eoy => {
closed_date => $closed_date,
closing_dates => \@closing_dates,
earnings_accounts => [
$request->call_procedure(
funcname => 'eoy_earnings_accounts')
Expand Down Expand Up @@ -352,7 +367,7 @@ This reopens books as of $request->{reopen_date}
sub reopen_books {
my ($request) = @_;
$request->call_procedure(
funcname => 'eoy__reopen_books_at',
funcname => 'eoy_reopen_books',
args => [ $request->{reopen_date} ]);
delete $request->{reopen_date};
return yearend_info($request);
Expand Down
6 changes: 5 additions & 1 deletion sql/modules/EndOfYear.sql
Expand Up @@ -182,11 +182,15 @@ RETURNS bool AS
$$
BEGIN
PERFORM count(*) FROM account_checkpoint WHERE end_date = in_end_date;

IF NOT FOUND THEN
RETURN FALSE;
END IF;

PERFORM * FROM account_checkpoint WHERE end_date > in_end_date;
IF FOUND THEN
RAISE EXCEPTION 'Only last closed period can be reopened';
END IF;

DELETE FROM account_checkpoint WHERE end_date = in_end_date;

PERFORM count(*) FROM yearend
Expand Down
6 changes: 2 additions & 4 deletions xt/66-cucumber/01-basic/closing.feature
Expand Up @@ -17,16 +17,15 @@ Scenario: Closed books disallow posting
| 1060 | 200.00 | |
| 2210 | | 200.00 |
When I navigate the menu and select the item at "General Journal > Year End"
And I select the "Close Period" tab
And I enter "2015-11-15" into "Close As-Of"
And I press "Close Period"
And I enter "2015-11-30" into "Close As-Of"
And I press "Close Period"
Then I can't post a transaction on 2015-11-16


Scenario: Reopen a closed period
When I navigate the menu and select the item at "General Journal > Year End"
And I select the "Re-open Books" tab
And I enter "2015-11-16" into "Re-Open As Of"
And I press "Re-open Period"
Then I can't post a transaction on 2015-11-15
When I post the following GL transaction on 2015-11-16:
Expand All @@ -42,7 +41,6 @@ Scenario: Reopen a closed period

Scenario: Post year-end
When I navigate the menu and select the item at "General Journal > Year End"
And I select the "Close Year" tab
And I enter these values:
| label | value |
| Yearend | 2015-12-31 |
Expand Down

0 comments on commit b6a08b5

Please sign in to comment.