Hi,
What I can propose you is to add a new invoice number format in HikaMarket.
In the HikaMarket order class, you can replace
$query = 'SELECT MAX(a.order_invoice_id)+1 FROM '.hikamarket::table('shop.order').' AS a WHERE a.order_type = '.$this->db->Quote('subsale').' AND a.order_vendor_id = '. (int)$vendor_id;
By
if($format == '{parent_code}') {
$order_parent_id = !empty($order->order_parent_id) ? $order->order_parent_id : $order->old->order_parent_id;
$query = 'SELECT o.order_invoice_id, o.order_invoice_number FROM '.hikamarket::table('shop.order').' AS o WHERE o.order_type = '.$this->db->Quote('sale').' AND o.order_id = '.(int)$order_parent_id;
$this->db->setQuery($query);
$order_number_data = $this->db->loadObject();
$order->order_invoice_id = (int)$order_number_data->order_invoice_id;
$order->order_invoice_number = $order_number_data->order_invoice_number;
} else {
$query = 'SELECT MAX(a.order_invoice_id)+1 FROM '.hikamarket::table('shop.order').' AS a WHERE a.order_type = '.$this->db->Quote('subsale').' AND a.order_vendor_id = '. (int)$vendor_id;
Then
$order->order_invoice_number = hikamarket::encodeNumber($order, 'invoice', $format);
$order->order_invoice_created = time();
By
$order->order_invoice_number = hikamarket::encodeNumber($order, 'invoice', $format);
}
$order->order_invoice_created = time();
And finally you will be able to set that new format in your HikaMarket configuration.
So instead of generating an invoice number for the subsales ; HikaMarket will extract the invoice number from the parent (main) order.
Let me know if you have feedback on it.
Regards,