! -> Note
$ -> Affected files
+03-Feb-2009 Janusz Dobrowolski
+! Merging bugfixes since 2.0.6 from main trunk (see below)
+$ /config.php
+ /gl/includes/db/gl_db_banking.inc
+ /gl/manage/gl_account_classes.php
+ /includes/ui/items_cart.inc
+ /includes/ui/ui_view.inc
+ /purchasing/includes/db/invoice_db.inc
+ /reporting/rep101.php
+ /reporting/rep201.php
+ /reporting/includes/class.pdf.inc
+ /sales/credit_note_entry.php
+ /sales/customer_credit_invoice.php
+ /sales/customer_delivery.php
+ /sales/customer_invoice.php
+ /sales/includes/db/payment_db.inc
+ /sales/includes/db/sales_credit_db.inc
+ /sales/includes/db/sales_delivery_db.inc
+ /sales/includes/db/sales_invoice_db.inc
+ /sales/includes/ui/sales_order_ui.inc
+ /sales/view/view_credit.php
+
+------------------------------- Release 2.0.7 --------------------------------------------
+03-Feb-2009 Joe Hunt
+! New release 2.0.7
+$ config.php
+
+22-Jan-2009 Joe Hunt
+# Bug [0000112] It shows invoices as overdue still (in red), even though its been payed and allocated.
+$ /sales/inquiry/customer_inquiry.php
+
+13-Jan-2009 Joe Hunt
+# Bug [0000111] Accounts on Credit Hold can still process delivery notes on sales order and invoicing.
+$ /sales/customer_delivery.php
+ /sales/customer_invoice.php
+ /sales/includes/ui/sales_order_ui.inc
+
+08-Jan-2009 Janusz Dobrowolski
+# Numeric check on class id added.
+$ /gl/manage/gl_account_classes.php
+
+02-Jan-2009 Joe Hunt
+# [0000104] minor language updates in a few sales files
+$ /sales/customer_invoice.php
+
+23-Dec-2008 Joe Hunt
+# Fixed an accounting sync in GL when adding bank account transactions (no customer/supplier trans)
+$ /gl/includes/db/gl_db_banking.inc
+
+22-Dec-2008 Janusz Dobrowolski
+# [0000102] Credit note was stored without entered shippment cost and comment.
+$ /sales/credit_note_entry.php
+# [0000103] Error during save of modified freehand credit note.
+$ /sales/includes/db/cust_trans_db.inc
+
+18-Dec-2008 Joe Hunt
+# [0000101] Roll back of yeasterday issues
+$ /purchasing/includes/db/invoice_db.inc
+ /purchasing/includes/db/supp_payment_db.inc
+ /sales/includes/db/payment_db.inc
+ /sales/includes/db/sales_credit_db.inc
+ /sales/includes/db/sales_invoice_db.inc
+
+17-Dec-2008 Joe Hunt
+# [0000101] More wonderful rounding issues
+$ /includes/ui/ui_view.inc
+ /purchasing/includes/db/invoice_db.inc
+ /purchasing/includes/db/supp_payment_db.inc
+ /sales/includes/db/payment_db.inc
+ /sales/includes/db/sales_credit_db.inc
+ /sales/includes/db/sales_delivery_db.inc
+ /sales/includes/db/sales_invoice_db.inc
+
+16-Dec-2008 Joe Hunt
+# [0000100] Keep getting left allocated weird results (rounding problems).
+$ /includes/ui/ui_view.inc
+ /purchasing/inquiry/supplier_allocation_inquiry.php
+ /reporting/rep101.php
+ /reporting/rep201.php
+ /sales/inquiry/customer_allocation_inquiry.php
+
+10-Dec-2008 Janusz Dobrowolski
+# [0000099] New line added to inventory transfer/adjustment sometimes overwrites old one.
+$ /includes/ui/items_cart.inc
+
+09-Dec-2008 Janusz Dobrowolski
+# [0000098] Unable issue of credit note for invoice with removed item lines.
+$ /sales/customer_credit_invoice.php
+# [0000097] Can't void freehand customer credit note.
+$ /sales/includes/db/sales_invoice_db.inc
+# Fixed to hide empty credit note lines.
+$ /sales/view/view_credit.php
+-------------------------------------------------------------------------------
+
03-Feb-2009 Janusz Dobrowolski
# sql2date around row[date] in due date.
$ /purchasing/inquiry/supplier_inquiry.php
$debug = 1;
$show_sql = 0;
- $go_debug = 1;
+ $go_debug = 0;
$pdf_debug = 0;
// set $sql_trail to 1 only if you want to perform bugtracking sql trail
// Warning: this produces huge amount of data in sql_trail table.
// Main Title
$app_title = "FrontAccounting";
// application version
- $version = "2.1.0 CVS";
+ $version = "2.1.0 beta";
// Build for development purposes
$build_version = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt"));
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
***********************************************************************/
+function add_exchange_variation($trans_type, $trans_no, $date_, $account,
+ $currency, $person_type_id=null, $person_id = "")
+{
+ if (is_company_currency($currency))
+ return;
+ if ($date_ == null)
+ $date_ = Today();
+ $rate = get_exchange_rate_from_home_currency($currency, $date_);
+ $result = db_query("SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE
+ bank_act='$account' AND trans_date<='".date2sql($date_)."'",
+ "Transactions for account $account could not be calculated");
+ $row = db_fetch_row($result);
+ $foreign_amount = $row[0];
+ $amount = get_gl_trans_from_to("", $date_, $account);
+ $diff = $amount - (round2($foreign_amount * $rate, user_price_dec()));
+ if ($diff != 0)
+ {
+ if ($trans_type == null)
+ $trans_type = systypes::journal_entry();
+ if ($trans_no == null)
+ $trans_no = get_next_trans_no($trans_type);
+ if ($person_type_id == null)
+ $person_type_id = payment_person_types::misc();
+ add_gl_trans($trans_type, $trans_no, $date_, $account, 0, 0, _("Exchange Variance"),
+ -$diff, null, $person_type_id, $person_id);
+ add_gl_trans($trans_type, $trans_no, $date_, get_company_pref('exchange_diff_act'), 0, 0,
+ _("Exchange Variance"), $diff, null, $person_type_id, $person_id);
+ }
+}
+
+function add_exchange_variation_all()
+{
+ $trans_no = get_next_trans_no(0);
+ $sql = "SELECT * FROM ".TB_PREF."bank_accounts";
+ $result = db_query($sql, "could not retreive bank accounts");
+ while ($myrow = db_fetch($result))
+ add_exchange_variation(0, $trans_no, null, $myrow['account_code'],
+ $myrow['currency_code']);
+}
//----------------------------------------------------------------------------------
// Add bank tranfer to database.
//
// $from_account - source bank account id
// $to_account - target bank account id
//
+
function add_bank_transfer($from_account, $to_account, $date_,
$amount, $ref, $memo_)
{
payment_person_types::misc(), "", $currency,
"Cannot insert a source bank transaction");
+ add_exchange_variation($trans_type, $trans_no, $date_, $from_account,
+ $currency, payment_person_types::misc(), "");
+
// do the destination account postings
$total += add_gl_trans($trans_type, $trans_no, $date_, $to_gl_account, 0, 0, "",
$amount, $currency);
+
/*Post a balance post if $total != 0 */
add_gl_balance($trans_type, $trans_no, $date_, -$total);
$date_, $amount, payment_person_types::misc(), "",
$currency, "Cannot insert a destination bank transaction");
+ add_exchange_variation($trans_type, $trans_no, $date_, $from_account,
+ $currency, payment_person_types::misc(), "");
+
add_comments($trans_type, $trans_no, $date_, $memo_);
references::save_last($ref, $trans_type);
if ($trans_type != systypes::bank_payment() && $trans_type != systypes::bank_deposit())
display_db_error("Invalid type ($trans_type) sent to add_bank_transaction");
+ $do_exchange_variance = false;
+
begin_transaction();
$currency = get_bank_account_currency($from_account);
else
{
$trans_no = get_next_trans_no($trans_type);
+ $do_exchange_variance = true;
}
// do the source account postings
if ($is_bank_to)
{
add_bank_trans($trans_type, $trans_no, $gl_item->code_id, $ref,
- $date_, $gl_item->amount, $person_type_id, $person_id,
- $currency, "Cannot insert a destination bank transaction");
+ $date_, $gl_item->amount,
+ $person_type_id, $person_id, $currency,
+ "Cannot insert a destination bank transaction");
+ if ($do_exchange_variance)
+ add_exchange_variation($trans_type, $trans_no, $date_, $gl_item->code_id,
+ $currency, $person_type_id, $person_id);
}
// store tax details if the gl account is a tax account
add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, $memo_,
-$total, null, $person_type_id, $person_id);
+ if ($do_exchange_variance)
+ add_exchange_variation($trans_type, $trans_no, $date_, $from_account,
+ $currency, $person_type_id, $person_id);
+
add_comments($trans_type, $trans_no, $date_, $memo_);
references::save_last($ref, $trans_type);
function can_process()
{
-
+ if (!is_numeric($_POST['id']))
+ {
+ display_error( _("The account class ID must be numeric."));
+ set_focus('id');
+ return false;
+ }
if (strlen($_POST['name']) == 0)
{
display_error( _("The account class name cannot be empty."));
function remove_from_cart($line_no)
{
- unset($this->line_items[$line_no]);
+ array_splice($this->line_items, $line_no, 1);
}
function count_items()
{
if (isset($index))
{
- unset($this->gl_items[$index]);
+ array_splice($this->gl_items, $line_no, 1);
}
}
{
label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)",
number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right",$leftspan);
- $total += $taxitem['Value'];
+ $total += round2($taxitem['Value'], user_price_dec());
}
}
label_cell(systypes::name($alloc_row['type']));
label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no']));
label_cell(sql2date($alloc_row['tran_date']));
+ $alloc_row['Total'] = round2($alloc_row['Total'], user_price_dec());
+ $alloc_row['amt'] = round2($alloc_row['amt'], user_price_dec());
amount_cell($alloc_row['Total']);
//amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']);
amount_cell($alloc_row['Total'] - $alloc_row['amt']);
end_row();
start_row();
label_cell(_("Left to Allocate:"), "align=right colspan=5");
+ $total = round2($total, user_price_dec());
amount_cell($total - $total_allocated);
end_row();
foreach ($taxes as $taxitem)
{
+ $taxitem['Value'] = round2($taxitem['Value'], user_price_dec());
$tax_total += $taxitem['Value'];
}
{
case "ar_EG" : $fontname = "ae_tholoth"; break;
case "zh_CN" : $fontname = "gbsn00lp"; break;
+ case "zh_TW" : $fontname = "chinese_traditional_cid0"; break;
default : $fontname = "dejavu"; break;
}
}
$trans['TotalAmount'] *= -1;
if ($trans['TotalAmount'] > 0.0)
{
- $item[0] = abs($trans['TotalAmount']) * $rate;
+ $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec);
$rep->TextCol(4, 5, number_format2($item[0], $dec));
}
else
{
- $item[1] = Abs($trans['TotalAmount']) * $rate;
+ $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec);
$rep->TextCol(5, 6, number_format2($item[1], $dec));
}
- $item[2] = $trans['Allocated'] * $rate;
+ $item[2] = round2($trans['Allocated'] * $rate, $dec);
$rep->TextCol(6, 7, number_format2($item[2], $dec));
+ /*
if ($trans['type'] == 10)
$item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate;
else
$item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
+ */
+ if ($trans['type'] == 10)
+ $item[3] = $item[0] + $item[1] - $item[2];
+ else
+ $item[3] = $item[0] - $item[1] + $item[2];
$rep->TextCol(7, 8, number_format2($item[3], $dec));
for ($i = 0; $i < 4; $i++)
{
$rate = 1.0;
if ($trans['TotalAmount'] > 0.0)
{
- $item[0] = Abs($trans['TotalAmount']) * $rate;
+ $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec);
$rep->TextCol(4, 5, number_format2($item[0], $dec));
}
else
{
- $item[1] = Abs($trans['TotalAmount']) * $rate;
+ $item[1] = round2(abs($trans['TotalAmount']) * $rate, $dec);
$rep->TextCol(5, 6, number_format2($item[1], $dec));
}
- $item[2] = $trans['Allocated'] * $rate;
+ $item[2] = round2($trans['Allocated'] * $rate, $dec);
$rep->TextCol(6, 7, number_format2($item[2], $dec));
+ /*
if ($trans['type'] == 20)
$item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate;
else
$item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
+ */
+ if ($trans['type'] == 20)
+ $item[3] = $item[0] + $item[1] - $item[2];
+ else
+ $item[3] = $item[0] - $item[1] + $item[2];
$rep->TextCol(7, 8, number_format2($item[3], $dec));
for ($i = 0; $i < 4; $i++)
{
if (!isset($_POST['WriteOffGLCode'])) {
$_POST['WriteOffGLCode'] = 0;
}
+ copy_to_cn();
$credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']);
processing_end();
meta_forward($_SERVER['PHP_SELF'], "AddedID=$credit_no");
{
$ok =1;
foreach ($_SESSION['Items']->line_items as $line_no=>$itm) {
+ if ($itm->quantity == $itm->qty_done) {
+ continue; // this line was fully credited/removed
+ }
if (isset($_POST['Line'.$line_no])) {
if (check_num('Line'.$line_no, 0, $itm->quantity)) {
$_SESSION['Items']->line_items[$line_no]->qty_dispatched =
$k = 0; //row colour counter
foreach ($_SESSION['Items']->line_items as $line_no=>$ln_itm) {
- if ($ln_itm->quantity==$ln_itm->qty_done) {
- continue; // this line was fully credited
+ if ($ln_itm->quantity == $ln_itm->qty_done) {
+ continue; // this line was fully credited/removed
}
alt_table_row_color($k);
echo "</td></tr>";
end_table(1); // outer table
+$row = get_customer_to_order($_SESSION['Items']->customer_id);
+if ($row['dissallow_invoices'] == 1)
+{
+ display_error(_("The selected customer account is currently on hold. Please contact the credit control personnel to discuss."));
+ end_form();
+ end_page();
+ exit();
+}
display_heading(_("Delivery Items"));
div_start('Items');
start_table("$table_style width=80%");
} elseif (isset($_GET['ModifyInvoice']) && $_GET['ModifyInvoice'] > 0) {
if ( get_parent_trans(10, $_GET['ModifyInvoice']) == 0) { // 1.xx compatibility hack
- echo"<center><br><b>" . _("There in no delivery notes for this invoice.<br>
+ echo"<center><br><b>" . _("There are no delivery notes for this invoice.<br>
Most likely this invoice was created in Front Accounting version prior to 2.0
and therefore can not be modified.") . "</b></center>";
display_footer_exit();
end_row();
end_table();
+$row = get_customer_to_order($_SESSION['Items']->customer_id);
+if ($row['dissallow_invoices'] == 1)
+{
+ display_error(_("The selected customer account is currently on hold. Please contact the credit control personnel to discuss."));
+ end_form();
+ end_page();
+ exit();
+}
+
display_heading(_("Invoice Items"));
div_start('Items');
}
if (($discount + $amount) != 0) {
- /* Now Credit Debtors account with receipts + discounts */
- $total += add_gl_trans_customer(12, $payment_no, $date_,
- $debtors_account, 0, 0, -($discount + $amount), $customer_id,
- "Cannot insert a GL transaction for the debtors account credit", $rate);
+ /* Now Credit Debtors account with receipts + discounts */
+ $total += add_gl_trans_customer(12, $payment_no, $date_,
+ $debtors_account, 0, 0, -($discount + $amount), $customer_id,
+ "Cannot insert a GL transaction for the debtors account credit", $rate);
}
if ($discount != 0) {
/* Now Debit discount account with discounts allowed*/
$tax_total = 0;
foreach ($taxes as $taxitem) {
- $tax_total += $taxitem['Value'];
+ $taxitem['Value'] = round2($taxitem['Value'], user_price_dec());
+ $tax_total += $taxitem['Value'];
}
if ($credit_note->tax_included == 0) {
$taxes = $delivery->get_taxes(); // all taxes with freight_tax
foreach ($taxes as $taxitem) {
+ $taxitem['Value'] = round2($taxitem['Value'], user_price_dec());
$tax_total += $taxitem['Value'];
}
/* Insert/update the debtor_trans */
$taxes = $invoice->get_taxes(); // all taxes with freight_tax
foreach ($taxes as $taxitem) {
+ $taxitem['Value'] = round2($taxitem['Value'], user_price_dec());
$ov_gst += $taxitem['Value'];
}
$deliveries = get_parent_trans($type, $type_no);
- if (count($deliveries)) {
+ if ($deliveries !== 0) {
$srcdetails = get_customer_trans_details(get_parent_type($type), $deliveries);
while ($row = db_fetch($items_result)) {
$src_line = db_fetch($srcdetails);
- update_parent_line(10, $src_line['id'], -$row['quantity']);
+ update_parent_line($type, $src_line['id'], -$row['quantity']);
}
}
// clear details after they've been reversed in the sales order
customer_branches_list_row(_("Branch:"),
$_POST['customer_id'], 'branch_id', null, false, true, true);
- if( ($order->customer_id != get_post('customer_id', -1)) ||
+ if( ($order->customer_id != get_post('customer_id', -1)) ||
($order->Branch != get_post('branch_id', -1)) ||
- list_updated('customer_id')) {
-
- if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
+ list_updated('customer_id'))
{
- // ignore errors on customer search box call
- if ($_POST['customer_id'] == '')
- $customer_error = _("No customer found for entered text.");
+
+ if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "")
+ {
+ // ignore errors on customer search box call
+ if ($_POST['customer_id'] == '')
+ $customer_error = _("No customer found for entered text.");
+ else
+ $customer_error = _("The selected customer does not have any branches. Please create at least one branch.");
+ unset($_POST['branch_id']);
+ $order->Branch = 0;
+ }
else
- $customer_error = _("The selected customer does not have any branches. Please create at least one branch.");
- unset($_POST['branch_id']);
- $order->Branch = 0;
- } else
- {
+ {
$old_order = (PHP_VERSION<5) ? $order : clone( $order );
- $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
+ $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
$_POST['Location'] = $order->Location;
$_POST['deliver_to'] = $order->deliver_to;
$_POST['delivery_address'] = $order->delivery_address;
// change prices if necessary
// what about discount in template case?
if ($old_order->customer_currency != $order->customer_currency) {
- $change_prices = 1;
+ $change_prices = 1;
}
if ($old_order->sales_type != $order->sales_type) {
// || $old_order->default_discount!=$order->default_discount
$_POST['sales_type'] = $order->sales_type;
- $Ajax->activate('sales_type');
- $change_prices = 1;
+ $Ajax->activate('sales_type');
+ $change_prices = 1;
}
if ($old_order->dimension_id != $order->dimension_id) {
$_POST['dimension_id'] = $order->dimension_id;
}
unset($old_order);
}
- set_global_customer($_POST['customer_id']);
+ set_global_customer($_POST['customer_id']);
} // changed branch
+ else
+ {
+ $row = get_customer_to_order($_POST['customer_id']);
+ if ($row['dissallow_invoices'] == 1)
+ $customer_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss.");
+
+ }
}
if ($order->trans_type != 30) {
while ($myrow2 = db_fetch($result))
{
-
+ if ($myrow2["quantity"] == 0) continue;
alt_table_row_color($k);
$value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),