Hi Joe,
I have troubleshooting rep301.php
function get_domestic_price($myrow, $stock_id)
{
if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT)
{
#below using standard_cost, change price to standard_cost
$price = $myrow['price'];
#$price = $myrow['standard_cost'];
if ($myrow['person_id'] > 0)
{
// Do we have foreign currency?
$supp = get_supplier($myrow['person_id']);
$currency = $supp['curr_code'];
$ex_rate = get_exchange_rate_to_home_currency($currency, sql2date($myrow['tran_date']));
$price /= $ex_rate;
}
}
else
$price = $myrow['standard_cost']; // Item Adjustments just have the real cost
return $price;
}
sql query adding for currency type
SELECT move.*, move.type, debtor.curr_code, supplier.supplier_id, supplier.curr_code FROM 23_stock_moves move LEFT JOIN 23_supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type LEFT JOIN 23_grn_batch grn ON grn.id=move.trans_no AND 25=move.type LEFT JOIN 23_suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id LEFT JOIN 23_debtor_trans cust_trans ON cust_trans.trans_no=move.trans_no AND cust_trans.type=move.type LEFT JOIN 23_debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no WHERE stock_id=8996969010247;
+----------+----------+---------------+------+----------+------------+--------+-----------+-----+-----------------+------+-----------+-------------+-----------+
| trans_id | trans_no | stock_id | type | loc_code | tran_date | price | reference | qty | standard_cost | type | curr_code | supplier_id | curr_code |
+----------+----------+---------------+------+----------+------------+--------+-----------+-----+-----------------+------+-----------+-------------+-----------+
| 287 | 63 | 8996969010247 | 25 | SUB | 2016-10-11 | 260000 | | 10 | 260000 | 25 | NULL | 17 | IDR |
| 317 | 2 | 8996969010247 | 17 | SUB | 2016-10-10 | 0 | 2 | 5 | 380000 | 17 | NULL | NULL | NULL |
| 328 | 61 | 8996969010247 | 13 | SUB | 2016-10-18 | 315000 | auto | -10 | 300000 | 13 | IDR | NULL | NULL |
| 765 | 191 | 8996969010247 | 25 | SUB | 2017-01-23 | 210000 | | 10 | 240000 | 25 | NULL | 17 | IDR |
| 774 | 135 | 8996969010247 | 13 | SUB | 2017-01-31 | 215250 | auto | -10 | 240000 | 13 | IDR | NULL | NULL |
| 1317 | 384 | 8996969010247 | 25 | SUB | 2017-05-23 | 17 | | 1 | 225000 | 25 | NULL | 17 | IDR |
| 1334 | 245 | 8996969010247 | 13 | SUB | 2017-05-26 | 153750 | auto | -1 | 225000 | 13 | IDR | NULL | NULL |
| 1495 | 439 | 8996969010247 | 25 | SUB | 2017-07-11 | 17 | | 10 | 171666.66666667 | 25 | NULL | 17 | IDR |
| 1520 | 284 | 8996969010247 | 13 | SUB | 2017-07-20 | 148625 | auto | -10 | 171666.66666667 | 13 | IDR | NULL | NULL |
+----------+----------+---------------+------+----------+------------+--------+-----------+-----+-----------------+------+-----------+-------------+-----------+
9 rows in set, 219 warnings (0.01 sec)
as in the line 4th, the result for
$price = get_domestic_price($row, $stock_id);
return $price
it show 210000, as it is strange as the currency still in IDR, it should 240000, debugging it catch by
if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT)
but as this home currency, the price shown in line 36
$price = $myrow['price'];
questions why line 4 is calculate as different currency?