Skip to content

Commit

Permalink
Improved journal trans: added currency support, tax and source docume…
Browse files Browse the repository at this point in the history
…nt date. Allowed multiply customer/supplier allocations to single journal transaction.
  • Loading branch information
itronics committed Mar 25, 2015
1 parent c33fed6 commit 3b431d9
Show file tree
Hide file tree
Showing 30 changed files with 1,268 additions and 465 deletions.
26 changes: 14 additions & 12 deletions admin/db/fiscalyears_db.inc
Expand Up @@ -128,6 +128,8 @@ function check_years_before($date, $closed=false)
//---------------------------------------------------------------------------------------------
function close_year($year)
{
global $Refs;

$co = get_company_prefs();
if (get_gl_account($co['retained_earnings_act']) == false || get_gl_account($co['profit_loss_year_act']) == false)
{
Expand Down Expand Up @@ -157,15 +159,15 @@ function close_year($year)

if ($balance != 0.0)
{
$trans_type = ST_JOURNAL;
$trans_id = get_next_trans_no($trans_type);

add_gl_trans($trans_type, $trans_id, $to, $co['retained_earnings_act'],
0, 0, _("Closing Year"), -$balance);
add_gl_trans($trans_type, $trans_id, $to, $co['profit_loss_year_act'],
0, 0, _("Closing Year"), $balance);

}
$cart = new items_cart(ST_JOURNAL);
$cart->reference = $Refs->get_next(ST_JOURNAL, null, $to);
$cart->tran_date = $cart->doc_date = $cart->event_date = $to;

$cart->add_gl_item($co['retained_earnings_act'], 0, 0, -$balance, _("Closing Year"), '', 0);
$cart->add_gl_item($co['profit_loss_year_act'], 0, 0, $balance, _("Closing Year"), '', 0);
$cart->memo_ = _("Closing Year");
write_journal_entries($cart);
}
close_transactions($to);

commit_transaction();
Expand Down Expand Up @@ -368,10 +370,10 @@ function delete_this_fiscalyear($selected_id)
{
global $Refs;
$trans_type = ST_JOURNAL;
$reference = $Refs->get_next($trans_type);
$Refs->save($trans_type, $trans_no, $reference);
$date_ = sql2date($to);

$reference = $Refs->get_next($trans_type, null, $date_);
add_journal($trans_type, $trans_no, $total, $date_, get_company_currency(), $reference);
$Refs->save($trans_type, $trans_no, $reference);
add_audit_trail($trans_type, $trans_no, $date_);
}
$sql = "SELECT bank_act, SUM(amount) AS amount FROM ".TB_PREF."bank_trans WHERE trans_date <= '$to' GROUP BY bank_act";
Expand Down
51 changes: 31 additions & 20 deletions gl/accruals.php
@@ -1,4 +1,14 @@
<?php
/**********************************************************************
Copyright (C) FrontAccounting, LLC.
Released under the terms of the GNU General Public License, GPL,
as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
/**********************************************
Author: Joe Hunt
Name: Revenue / Cost Accruals v2.2
Expand All @@ -8,7 +18,7 @@
$path_to_root="..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/gl/includes/db/gl_db_trans.inc");
include_once($path_to_root . "/includes/ui/items_cart.inc");

$js = get_js_open_window(800, 500);
if (user_use_date_picker())
Expand Down Expand Up @@ -61,11 +71,11 @@
$date_ = begin_month($date_); // avoid skip on shorter months
$date = end_month($date_); // avoid skip on shorter months
}
$lastdate = ($freq == 1 ? add_days($date_, 7*$per)
: ($freq == 2 ? add_days($date_, 14*$per)
: ($freq == 3 ? add_months($date_, $per)
: add_months($date_, 3*$per))));


$lastdate = ($freq == 1 ? add_days($date_, 7*$per) :
($freq == 2 ? add_days($date_, 14*$per) :
($freq == 3 ? end_month(add_months($date_, $per)) :
end_month(add_months($date_, 3*$per)))));
if (!is_date_in_fiscalyears($lastdate, false))
{
display_error(_("Some of the period dates are outside the fiscal year or are closed for further data entry. Create a new fiscal year first!"));
Expand Down Expand Up @@ -112,31 +122,33 @@
switch($freq)
{
case 1:
$date = add_days($date_, $i*7);
$date = $date_ = add_days($date_, 7);
break;
case 2:
$date = add_days($date_, $i*14);
$date = $date_ = add_days($date_, 14);
break;
case 3:
$date = add_months($date_, $i*1);
$date_ = add_months($date_, 1);
$date = end_month($date_);
break;
case 4:
$date = add_months($date_, $i*3);
$date_ = add_months($date_, 3);
$date = end_month($date_);
break;
}
$am0 = $am;
}
if (isset($_POST['go']))
{
$id = get_next_trans_no(ST_JOURNAL);
$ref = $Refs->get_next(ST_JOURNAL);
add_gl_trans(ST_JOURNAL, $id, $date, get_post('acc_act'), 0,
0, $ref, $am0 * -1);
add_gl_trans(ST_JOURNAL, $id, $date, get_post('res_act'), get_post('dimension_id'),
get_post('dimension2_id'), $ref, $am0);
add_audit_trail(ST_JOURNAL, $id, $date);
add_comments(ST_JOURNAL, $id, $date, $memo);
$Refs->save(ST_JOURNAL, $id, $ref);
$cart = new items_cart(ST_JOURNAL);
$cart->memo_ = $memo;
$cart->reference = $Refs->get_next(ST_JOURNAL, null, $date);
$cart->tran_date = $cart->doc_date = $cart->event_date = $date;
$cart->add_gl_item(get_post('acc_act'), 0, 0, -$am0, $cart->reference);
$cart->add_gl_item(get_post('res_act'), get_post('dimension_id'),
get_post('dimension2_id'), $am0, $cart->reference);
write_journal_entries($cart);
$cart->clear_items();
}
else
{
Expand Down Expand Up @@ -224,4 +236,3 @@ function frequency_list_row($label, $name, $selected=null)
end_form();

end_page();

0 comments on commit 3b431d9

Please sign in to comment.