Dear Joe,
please note that there is a typo error in rep113.php file, causing report 113 to print all credit notes in the system, disregarding user selection.

in line 52-53 of rep113.php, replace $fto to $tno as below.


instead of
$from = min($fno[0], $fto[0]);
$to = max($fno[0], $fto[0]);
replace

$from = min($fno[0], $tno[0]);
$to = max($fno[0], $tno[0]);


Regards,
S

found it.

in case someone really needs it.

in /sales/includes/cart_class.inc at line 208
replace
$this->reference = $Refs->get_next($this->trans_type);
with
if ($this->trans_type == ST_CUSTCREDIT) {
    $this->reference = $Refs->get_next(ST_SALESINVOICE);
} else {
    $this->reference = $Refs->get_next($this->trans_type);
}

hello.

please a hint!

where should I look in order to change credit notes to use same numbering as sales invoices ?

Regards,
S

- in /modules/cronjobs add:
rec_price.php
<?php

$page_security = 'SA_SALESPRICE';
$path_to_root = "../..";


define("_CJ", 1); // needed in hooks.inc in order to skip authentication
define("_CJ_USER", "cron");
define("_CJ_COY", '1');


$_POST["company_login_name"] = _CJ_COY;

include_once($path_to_root . "/includes/session.inc");






include_once($path_to_root . "/sales/includes/sales_db.inc");
include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
include_once($path_to_root . "/inventory/includes/inventory_db.inc");

//required for working w/ currencies
include_once($path_to_root . "/gl/includes/db/gl_db_currencies.inc");
include_once($path_to_root . "/gl/includes/db/gl_db_rates.inc");


function get_last_exchange_rate($curr_abrev) {
    $sql = "SELECT rate_buy FROM "
        .TB_PREF."exchange_rates "
        ."WHERE curr_code=".db_escape($curr_abrev)." ORDER BY date_ DESC limit 1";

    $result = db_query($sql, "could not get last exchange rate for $curr_abrev ");

    if(db_num_rows($result) == 0)
    return 0;

    $row = db_fetch($result);
    return $row[0];
}

// get a list of all currencies and their latest exchange rates
$curr_from = array();
$curr_base = '';

$cs = get_currencies();
while($c = db_fetch($cs)) {
   if (is_company_currency($c['curr_abrev'])) {
    //is base currency
    $curr_base = $c['curr_abrev'];
//    echo "base = $curr_base\n";
   } else {
    // get the latest exchange rate for this currency
    $r = get_last_exchange_rate($c['curr_abrev']);
    if ($r == 0) {
        echo 'There is no exchange rate for currency: ' . $c['curr_abrev'];
        exit();
    } else {
        $curr_from[$c['curr_abrev']] = $r;
        echo "added " . $c['curr_abrev'] . "\n";
    }
   }
}



// get all the items
$items = get_items();

while ($item = db_fetch($items)) {
    echo "------------------------------------------------------------------------------------\n";
    echo "processing art code=" . $item['stock_id'] . " name=" . $item['description'] . "\n";
   
    // get prices for channels
    $prices = array();
    $prices_list = get_prices($item['stock_id']);
    while ($myrow = db_fetch($prices_list)) {
    echo "adding price for channel id=" . $myrow['sales_type_id'] . " currency=" . $myrow['curr_abrev'] . "\n";
    $prices[$myrow['sales_type_id']][$myrow['curr_abrev']] = array('price_id'=>$myrow['id'], 'price'=>$myrow['price']);
    }

    //foreach sales type (aka channel) perform price count check
    foreach($prices as $sales_type_id=>$price_per_sale_type) {
        echo "checking pricing for channel id=$sales_type_id\n";
    //check currency prices usage (count)
    $count = 0;
    foreach($curr_from as $c=>$r) {
        if (isset($price_per_sale_type[$c]))
            $count++;
    }
    echo "currency usage count =$count\n";

    if ($count == 0) {
            echo "this article has no defined price for any of the foreign currencies in this channel. no processing\n";
            continue;
    }
    if ($count > 1) {
            echo "this article has prices defined for more than one foreign currency in this channel. no processing\n";
            continue;
    }
       
        echo "creating or updating price for base currency $curr_base\n";
    //determine currency for this price
    $price_c = '';
    foreach($curr_from as $c=>$r) {
            if (isset($price_per_sale_type[$c]))
            $price_c = $c;
    }
    echo "price is expressed in $price_c\n";
        $price_in_base_curr = $price_per_sale_type[$price_c]['price'] * $curr_from[$price_c];
       
       

//    print_r($price_per_sale_type);
   
        if (isset($price_per_sale_type[$curr_base])) {
            echo "price id is" . $price_per_sale_type[$curr_base]['price_id'] . "\n";
        echo "This article has a price in $curr_base. update it. price=$price_in_base_curr\n";
        update_item_price($price_per_sale_type[$curr_base]['price_id'], $sales_type_id, $curr_base, $price_in_base_curr);
        } else {
            echo "This article does not have a price in $curr_base. create it. price=$price_in_base_curr\n";
        add_item_price($item['stock_id'], $sales_type_id, $curr_base, $price_in_base_curr);
        }
    }
    echo "------------------------------------------------------------------------------------\n";

}
?>

setup
- create a user (eg cron) and assign the proper rights for operation
- change the user in define('_CJ_USER',.......
- run the script via php-cli (php rec_price.php)

Notes
- this is very very alpha code - use it with care
- most probably you do need such price updates, so use these files as skeletons for developing your own command line scripts smile

Since I need to keep prices in EUR/USD and to make invoices in other currency, I created a php script (that can be added to a crontab) that calculates the prices in base currency, based on the prices in other currencies.

how to install (by hand)
- create a folder in /modules/cronjobs
- in /installed_extensions.php add:
XX => array(
  'name' => 'Cronjobs',
  'active' => true,
  'package' => 'cronjobs',
  'type' => 'extension',
  'version' => '0.1',
  'path' => 'modules/cronjobs',
),

where XX is the next extension id - do not forget to increment $next_extension_id

- in /modules/cronjobs add:
hooks.php
<?php
class hooks_cronjobs extends hooks {
    var $module_name = 'cronjobs';
    public function __construct() {
        global $_SESSION;
        // if _CJ is defined, login user non interactively
        if (_CJ==1) {
            $_SESSION['wa_current_user']->username = _CJ_USER;
            $_SESSION['wa_current_user']->loginname = _CJ_USER;
            $_SESSION['wa_current_user']->name = _CJ_USER;
            $_SESSION['wa_current_user']->set_company(_CJ_COY);
            $_SESSION['wa_current_user']->logged = true;
        }
    }
}
?>
--- continued on next post

31

(7 replies, posted in Modules Add-on's)

Hello all.

I am also implementing FA in my company and I am searching for such an automation.
Or develop it if none exists.

I am thinking of using the MT940 files available in multicash-like programs.

I already customized an mt940 php parser.

The fields that can identify a transaction are the account numbers (IBAN).
However, I did not saw a IBAN field for customers.

Can this be added ?
Is there a reason for this info not being added to customers ?

Regards,
S

32

(1 replies, posted in Reporting)

Dear all,

I need to modify the invoice format - in order to make it compliant with romanian law.

I managed to modify some of the fields and their location, but now I am having a question: whether it is possible to have different columns (in terms of names and their number) just in invoice, not in other reports.

Thanks!
Serban