1

(2 replies, posted in Fixed Assets)

Straight line basis is calculated by dividing the difference between an asset's cost and its expected salvage value by the number of years it is expected to be used.

To calculate straight line basis, take the purchase price of an asset and then subtract the salvage value, its estimated sell-on value when it is no longer expected to be needed. Then divide the resulting figure by the total number of years the asset is expected to be useful, referred to as the useful life in accounting jargon.

    Straight Line Basis = (Purchase Price of Asset - Salvage Value) / Estimated Useful Life of Asset

Example scenario below
Assume that Company A buys a piece of equipment for $10,500. The equipment has an expected life of 10 years and a salvage value of $500. To calculate straight line depreciation, the accountant divides the difference between the salvage value and the cost of the equipment—also referred to as the depreciable base or asset cost—by the expected life of the equipment.

The straight line depreciation for this piece of equipment is ($10,500 - $500) / 10 = $1,000. This means that instead of writing off the full cost of the equipment in the current period, the company only needs to expense $1,000. The company will continue to expense $1,000 to a contra account, referred to as accumulated depreciation, until $500 is left on the books as the value of the equipment.

Regards
@notrinos @joe @kvvaradha

kvvaradha wrote:
cedricktshiyoyo wrote:
joe wrote:

Thanks @kvvaradha, I will fix and commit.

Joe

Why are you guys not considering the issue with fixed asset depreciation problems? The value is not correct... Who can assist correct this error.
@ap.muthu . The depreciation value is not correct with the rate provided. whether straight line or declining method. the book value is incorrect,
it seems like the focus is more given into sales and purchases, what about the other modules ?

Probably we need more clear explanation to implement a change in code.  The straight line or decline method. Whatever it's. Explain the issue clearly with the calculation of sample.

If you are not interested to contribute the open source community,  hire a freelancer and do that for you.

Most of the shouting users are not helping the community to grow.

I am not part of the shouting community, review my activities, you will see that i have a contribute in many areas. I am just trying to point out a error i have noticed, isn't a company asset management of a great importance?
I am just asking one thing, where the maths is happening when it comes to asset depreciation... The book value after depreciation is not correct according to the percentage you entered.

joe wrote:

Thanks @kvvaradha, I will fix and commit.

Joe

Why are you guys not considering the issue with fixed asset depreciation problems? The value is not correct... Who can assist correct this error.
@ap.muthu . The depreciation value is not correct with the rate provided. whether straight line or declining method. the book value is incorrect,
it seems like the focus is more given into sales and purchases, what about the other modules ?

4

(8 replies, posted in Report Bugs here)

lugezz wrote:

I understand you have to download now the 2.4.9 version from SourceForge and install it again and it should work.

----------
install/isession.incDiffSwitch to side-by-side view
--- a/install/isession.inc
+++ b/install/isession.inc
@@ -31,7 +31,7 @@
//
function strip_quotes($data)
{
-    if(get_magic_quotes_gpc()) {
+    if(version_compare(phpversion(), '5.4', '<') && get_magic_quotes_gpc()) {
        if(is_array($data)) {
            foreach($data as $k => $v) {
                $data[$k] = strip_quotes($data[$k]);

thanks it worked fine

apmuthu wrote:

@itronics: I hope this has not affected the depreciation / fixed assets reports

the depreciation value is not correct based on the % rate.
for instance if you purchase and an asset with 30,000 $ with straight-line method of 5%, the book value will not be 5% of 30, 000, rather 2.4% why is that?

Anybody encountered the same problem?
@joe @itronics

On which section of the journal entry table do you want to add fields, and why do you need to add those fields for?

kvvaradha wrote:

For straight line method, you need to use the purchase cost. so the purchase cost may be 15000 USD, this is a chance.

and probably you need to trace it with calculation from the compute_gl_rows_for_depreciation with some display errors placed in between locations i cant understand full concept of straight line method here programmed. it looks they are getting remaining months and process with new one. so in the each line place some display errors to make it readable for you.

I am not very good at Ajax, how do I replace the calculation of % to get the exact percent value of and asset after depreciation.

e.g: if I purchased my asset with 5000 USD, with 5% depreciation rate, I am expecting to get 250 usd depreciation after 1 year. and my book value will be 4750 USD.

THanks

kvvaradha wrote:

Hello dude, May be it will be in the calculation issue, you need to describe, what comes and what you exactly need it with this code. describe that. We needs to understand it.

Hello, just forget about my code I was trying to use the fixed asset module, to register my assets, but when I process depreciation, the value is not correct according to the depreciation rate,

for example: when you register an asset with purchase value of 30,000 USD, with Straight Line depreciation rate of 5%. for the first year I am supposed to get 1500 USD and my book value should be 28,500 USD,
So instead i am getting depreciation value of 650 USD which is 2.2%,... WHERE DO YOU FIX THIS IN THE CODE for it to get the exact 5%

can somebody help, i am trying to depreciate asset with straight line, 5% rate
but when process depreciation, the amount is not correct. it's less than 5%
for example

i have an asset of 20,000 USD with 5% depreciation rate, when I process depreciation for the first year instead of 1000 i am getting something less than that.

function next_depreciation_date($depreciation_date) {

  $start = strtotime($depreciation_date);

  $y = date('Y', $start);
  $m = date('n', $start) + 1;

  if ($m > 12) {
    $m = 1;
    $y++;
  }

  return strtotime("$y-$m-1");
}

function depreciation_months($depreciation_start) {

  // assume that depreciation start is the same fiscal year
  //$start = strtotime($depreciation_start);
  //$end = strtotime($year['end']);

  $start = next_depreciation_date($depreciation_start);

  return 12 - date('n', $start) + 1;

  //$d1 = date('j', $start); // day of the month
  //$d2 = date('t', $start); // number of days in month

  //if ($d2 > $d1)
    //$months++;
}

function months_between_dates($start, $end) {
  $start = strtotime($start);
  $end = strtotime($end);

  $y1 = date('Y', $start);
  $m1 = date('n', $start);

  $y2 = date('Y', $end);
  $m2 = date('n', $end);

  return 12 * ($y2 - $y1) + $m2 - $m1;
}

function compute_gl_rows_for_depreciation($item, $no_months, $period) {
  $rows = array();

  $year = get_current_fiscalyear();
  $y = date('Y', strtotime($year['end']));

  switch ($item['depreciation_method']) {
    case 'D':
        $line_value = $item['purchase_cost']*$item['depreciation_rate']/100/12;
        $value = $item['material_cost'] * $item['depreciation_rate'] * $item['depreciation_factor']/100/12;
        if ($value < $line_value)
            $value = $line_value;
        break;

    case 'S':    // purchase_cost stores start cost of item
        $done_months = months_between_dates($item['depreciation_start'], $item['depreciation_date']);
        $remaining_months = 12.0 * 100.0/$item['depreciation_rate'] - $done_months;
        $value = $item['purchase_cost']*$item['depreciation_rate']/100/12;
        break;

    case 'N':
        $N = $item['depreciation_rate'];
        $done_years = months_between_dates($item['depreciation_start'], $item['depreciation_date'])/12;
        $value = $item['purchase_cost']* ($N-$done_years)/($N*($N+1)/2)/12;
        break;

    case 'O':
        $value = $item['material_cost'];
        break;
  }

  $next = next_depreciation_date($item['depreciation_date']);
  $m = date('n', $next);

  $total = 0;
  $cnt = 0;
  for ($i=$m; $i < $m + $no_months; $i++) {

    if ($item['depreciation_method'] == 'S') {
        if ($cnt >= $remaining_months)
            $value = 0;
    }

    $date = sql2date(date("$y-$i-t", strtotime("$y-$i-1")));

    $total += $value;

    if (FA_YEARLY == $period) {
      // yearly
      if ($i == $m + $no_months - 1)
        $rows[] = array('date' => $date, 'value' => $total);
      /*else
        $rows[] = array('date' => $date, 'value' => 0);
        */
    }
    else {
      // monthly
      $rows[] = array('date' => $date, 'value' => $value);
    }

    $cnt++;

    if ($item['depreciation_method'] == 'O') {
        // depreciate only in the first month
        $value = 0;
    }
}

  return $rows;
}

10

(2 replies, posted in Fixed Assets)

Dear all , i am trying to depreciate my fixed asset using straight line, but the depreciation value is not correct according to the method and percentage.

e.g i have and asset value of 20,000 with depreciation of 5% straight line, after depreciation the value must be 19,000 but instead it giving lesser value

anybody can help explain how depreciation works a bit more?
Does the tax affect the amount in the depreciation? @joe

thanks

well done @joe

Dear @joe I just installed new FA on Ubuntu 20.4 with PHP 7.43 MYSQL 8

After registering assets in the system, i am not able to find them again, to modify or delete them,
supposed to be under maintenance fixed Asset tab, but it only showing 2 tabs, general settings and transactions. there is no where to select existing assets to either modify the description, code or depreciation date.

thanks

@tom.horton been a while since we last communicated,

I had also stopped using FA for a while, been doing other things, Now, i wanna setup a new company using FA, i have already created assets classes, locations and categories, Also i have just created and one asset including depreciation date, but i can't find it in a list.

the drop down menu that display the assets to either modify or delete it is not showing

Any help on how to fix it

Thanks

14

(8 replies, posted in Report Bugs here)

Function get_magic_quotes_gpc() is deprecated in file: /var/www/html/finance/includes/session.inc at line 308
Trying to access array offset on value of type bool in file: /var/www/html/finance/gl/includes/db/gl_db_accounts.inc at line 220
implode(): Passing glue string after array is deprecated. Swap the parameters in file: /var/www/html/finance/includes/ui/ui_lists.inc at line 151

Hello guys, i am having the same message, I am using ubuntu 20.04 with php 7.4.3   mysql  Ver 8.0.23-0ubuntu0.20.04.1

Any idea?

DrCard wrote:

When making a Payment or a Deposit, The bank Amount is rounded to 2 Digits. Example:
A payment of 50.555 it is rounded to 50.560,  our currency is 3 digits.


The rounding error happens only for the the (Payment or a Deposit) only



https://ibb.co/L5yYp1S  Input Picture
https://ibb.co/4RRkJsJ  Output Picture


i have noticed the same thing too, although our currency does not use 3 digit decimal.

Yeah, i am getting this error from journal entry   

finance/gl/gl_journal.php?NewJournal=Yes

And of course the validation to not accept empty field in cheque no... that's all I did

if (strlen($_POST['check_no']) == 0 || $_POST['check_no'] == "") // new line validation added on sunday november 21 2020
    {
        display_error(_("The cheque no  reference field must be entered.")); // new line validation
         if (get_post('currency') != get_company_pref('curr_default'))
        set_focus('check_no'); if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 0.000001))
        return false; {
    }                  display_error(_("The exchange rate must be numeric and greater than zero."));
                set_focus('_ex_rate');
            $input_error = 1;
        }

5. in gl/includes/ui/gl_bank_ui.inc

text_row(_("Cheque No:"),  'check_no', $_POST['check_no'], 16, 40);

payment_person_types_list_row( $payment ? _("Pay To:"):_("From:"),
         'PayType', $_POST['PayType'], true);
    switch ($_POST['PayType'])
    {
        case PT_MISC :
            text_row_ex($payment ?_("To the Order of:"):_("Name:"),
                 'person_id', 20, 50);
            text_row(_("Voucher No:"), 'source_ref', null, 20, 50);    // Newly Added
            break;

4. gl/includes/db/gl_db_banking.inc

function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $date_,
    $person_type_id, $person_id, $person_detail_id,    $ref, $check_no, $source_ref ,$memo_, $use_transaction=true, $settled_amount=null)
{
    global $Refs, $SysPrefs;

    // we can only handle type 1 (payment)and type 2 (deposit)
    if ($trans_type != ST_BANKPAYMENT && $trans_type != ST_BANKDEPOSIT)
        display_db_error("Invalid type ($trans_type) sent to add_bank_transaction");

    $do_exchange_variance = false;
    $exchanged = false;
    if ($use_transaction)
        begin_transaction();

    $args = func_get_args(); if (count($args) < 11) $args[] = true;
    $args = (object)array_combine(array('trans_type', 'trans_no', 'from_account', 'items', 'date_',
        'person_type_id', 'person_id', 'person_detail_id', 'ref','check_no','source_ref', 'memo_', 'use_transaction', 'settled_amount'),
        $args);

yeah it may be confusing for sure.

I think you know what I was trying to do recently with bank payments.

1. I have altered bank_trans , added 2 extra fields, check_no & source_ref
2. I have made little changes in gl/gl_bank.php
3. gl/includes/db/gl_db_bank_trans.inc // New code

function add_bank_trans($type, $trans_no, $bank_act, $ref,$check_no, $source_ref, $date_,
    $amount, $person_type_id, $person_id, $currency="", $err_msg="", $rate=0)
{
    $sqlDate = date2sql($date_);

    // convert $amount to the bank's currency
    if ($currency != "")
    {
        $bank_account_currency = get_bank_account_currency($bank_act);
        if ($rate == 0)
            $to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_);
        else
            $to_bank_currency = 1 / $rate;
        $amount_bank = ($amount / $to_bank_currency);
    }
    else
        $amount_bank = $amount;
    $amount_bank = round2($amount_bank, user_price_dec());   

    $sql = "INSERT INTO ".TB_PREF."bank_trans (type, trans_no, bank_act, ref, check_no, source_ref,
        trans_date, amount, person_type_id, person_id) ";

    $sql .= "VALUES ($type, $trans_no, '$bank_act', ".db_escape($ref).", ".db_escape($check_no).",".db_escape($source_ref).",'$sqlDate',
        ".db_escape($amount_bank).", ".db_escape($person_type_id)
        .", ". db_escape($person_id).")";

    if ($err_msg == "")
        $err_msg = "The bank transaction could not be inserted";

    db_query($sql, $err_msg);
}

INSERT INTO bank_trans (type, trans_no, bank_act, ref, check_no, source_ref, trans_date, amount, person_type_id, person_id) VALUES (0, 1406, '5', '126/2021', <check_no>, <source_ref>, '01/28/2021','-45', '<person_type_id>', '<person_id>')

Here i am dealing with journal entry, not bank payment. The code above is correct when i process bank payment. but only when happens when i SWITCH TO journal entry.

Are you able to perfom journal entry which involves bank accounts?

tom.horton wrote:

It looks like your SQL is trying to insert "ETB" (string) into the "person_type_id" field (an integer). I think it just needs re-aligning again.

yeah, but i have not made changes for gl_journal.php
I think the code is supposed to ignore person_id when the entry type is ST_JOURNAL

I was able to solve one of the errors, now on journal entry, I am getting this error. when there is a bank account involved in the process.
Tell me are you able to process journal entries after ALTERING bank_trans table with CHEQUE_NO AND SOURCE_REF?

Undefined offset: 1 in file: /var/www/html/finance/includes/date_functions.inc at line 386Undefined offset: 2 in file: /var/www/html/finance/includes/date_functions.inc at line 386DATABASE ERROR : The bank transaction could not be inserted
error code : 1366
error message : Incorrect integer value: 'ETB' for column 'person_type_id' at row 1
sql that failed was : INSERT INTO bank_trans (type, trans_no, bank_act, ref, check_no, source_ref, trans_date, amount, person_type_id, person_id) VALUES (0, 1406, '5', '126/2021', '01/28/2021','-45','0000-00-00', '0', 'ETB', 'Cannot insert a destination bank transaction')

Sorry for this error i found the problem, I add forgotten to  check_no inside quotes like this

 text_row(_("Cheque no:"), 'check_no', null, 16,30);

Journal Entry   
Missing argument 5 for text_row(), called in /var/www/html/finance/gl/includes/ui/gl_journal_ui.inc on line 46 and defined in file: /var/www/html/finance/includes/ui/ui_input.inc at line 631Undefined variable: max in file: /var/www/html/finance/includes/ui/ui_input.inc at line 634

@tom.horton hope you are fine.

I was not able to process journal entries or Bank Transfer after modifying the code.
Are you able to process journal entries without any errors?

Journal Entry   
Missing argument 5 for text_row(), called in /var/www/html/finance/gl/includes/ui/gl_journal_ui.inc on line 46 and defined in file: /var/www/html/finance/includes/ui/ui_input.inc at line 631Undefined variable: max in file: /var/www/html/finance/includes/ui/ui_input.inc at line 634

You must enter at least one journal line.Undefined index: check_no in file: /var/www/html/finance/gl/gl_journal.php at line 243The source reference field must be entered.The exchange rate must be numeric and greater than zero.Missing argument 5 for text_row(), called in /var/www/html/finance/gl/includes/ui/gl_journal_ui.inc on line 46 and defined in file: /var/www/html/finance/includes/ui/ui_input.inc at line 631Undefined variable: max in file: /var/www/html/finance/includes/ui/ui_input.inc at line 634