1

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

would you please explain more.
I want to post json object like below to insert an invoice:
{
        "customer_id":2,
        "order_date":"06/27/2018",
        "ref":"001/2018",
        "trans_type":"ST_SALESINVOICE",
        "items":[
            {"stock_id":103, "qty":5, "price":5555, "discount":0,"description":"no desc"}
            ]
}
I want to know how _parse_next function handle the next reference if there is no record in journal table with trans_type=ST_SALESINVOICE
When I post this object dbquery in references.inc 170+ does not respond:
$sql = "SELECT MAX(CAST(SUBSTR($ref_fld, ".(strlen($prefix)+1).",LENGTH($ref_fld)-".(strlen($postfix)+strlen($prefix)).") AS UNSIGNED))"
                ." FROM `$trans_table` tbl
                    LEFT JOIN ".TB_PREF."voided v ON tbl.`$tno_fld`=v.id AND v.type=$type"
                ." WHERE ISNULL(v.id)"
                .($type_fld ? " AND tbl.`$type_fld`=$type" : '')
                ." AND `$ref_fld` REGEXP ".db_escape('^'.preg_quote($prefix).'[0-9]*'.preg_quote($postfix).'$');
        $result = db_query($sql, 'cannot retrieve last reference');

2

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

Because there is no record with required trans_type in journal table.

3

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

Thanks for your reply.
I use v2.4.
But in File: includes/references.inc 170+
the code line $result = db_query($sql, 'cannot retrieve last reference'); does not return any data or error and the subsequence codes are not executed.

4

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

hi
i think there is problem in ADD-Sales API when returning last ref-no in _parse_next method in references.inc.
It can not return the last reference. (I think there is a problem when joining journal and voided tables because it does not return any data row because the type field in journal table is always 0)

Can you please help me how to resolve the problem.

5

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

Hi,
In purchase API module, post API inserts cart with trans_type=sales_order and inserts into sales_order table.
I dont understand why it does not create cart with trans_type=purchase_order to insert into purch_orders table.
Is it a mistake?

Would u please help me.