Try to create a quote with 2 groups, A and B
Convert into invoice
at this point, there is 4 group in database, A,B for the quote et A,B for the invoice
in QUOTE, rename groupe AA and BB
magic! group name changed in invoice too
the 2 invoice groups are created in database when converting quote into invoice but actually never used, invoice takes quote group instead of its own copy of groups
3 questions :
1/ can you reproduce this bug?
2/ what file do I have to fix for prevent that?
3/ if question 1 answer is Yes, is this normal for and advanced CRM to still have this kind of TERRIBLE bugs? I’m starting to lose my trust into SuiteCRM
Hi EXA
you can try and reproduce it yourself in one of the online demos:
demo.suiteondemand.com (user will password will)
https://www.softaculous.com/demos/SuiteCRM
I don’t know how to fix it, but it can be investigated once the bug is confirmed and reported…
SuiteCRM is not a full-blown ERP, so the invoicing is only used by some people, and then only in simple scenarios. You’re talking about a very specific situation, maybe it was never fixed because the developers don’t even know the bug exists.
No point in “losing trust”. You can of course, move to another software if you find another one that is better or cheaper (but since SuiteCRM is free…).
This is community software. Your report will help make the software better, that’s all. It’s not perfect; it keeps getting better with the help of people like you and me.
1 Like
Actually I found a lot of bugs due to localization and local formats, but not big deal.
This one is the first which are a design flaw and can lead to corrupt sensible data about a compagny incomes, that’s why I was a bit afraid
I let you know here when I’ll find the solution
1 Like
Take a look at this pull request which addresses this issue: https://github.com/salesagility/SuiteCRM/pull/2017/files
1 Like
Still creates ghost records in db but at least it works, thank you Simeon
What exactly is that about creating ghost records? Let’s get this 100% fixed… 
I’ve spotted the issue. Think this would fix it(but I haven’t tested it fully yet will try and make some time to later).
//Setting Group Line Items
$sql = "SELECT * FROM aos_line_item_groups WHERE parent_type = 'AOS_Quotes' AND parent_id = '".$quote->id."' AND deleted = 0";
$result = $this->bean->db->query($sql);
$quoteToInvoiceGroupIds = array();
while ($row = $this->bean->db->fetchByAssoc($result)) {
$quoteGroupId = $row['id'];
$row['id'] = '';
$row['parent_id'] = $invoice->id;
$row['parent_type'] = 'AOS_Invoices';
if($row['total_amt'] != null) $row['total_amt'] = format_number($row['total_amt']);
if($row['discount_amount'] != null) $row['discount_amount'] = format_number($row['discount_amount']);
if($row['subtotal_amount'] != null) $row['subtotal_amount'] = format_number($row['subtotal_amount']);
if($row['tax_amount'] != null) $row['tax_amount'] = format_number($row['tax_amount']);
if($row['subtotal_tax_amount'] != null) $row['subtotal_tax_amount'] = format_number($row['subtotal_tax_amount']);
if($row['total_amount'] != null) $row['total_amount'] = format_number($row['total_amount']);
$group_invoice = new AOS_Line_Item_Groups();
$group_invoice->populateFromRow($row);
$group_invoice->save();
$quoteToInvoiceGroupIds[$quoteGroupId] = $group_invoice->id;
}
//Setting Line Items
$sql = "SELECT * FROM aos_products_quotes WHERE parent_type = 'AOS_Quotes' AND parent_id = '".$quote->id."' AND deleted = 0";
$result = $this->bean->db->query($sql);
while ($row = $this->bean->db->fetchByAssoc($result)) {
$row['id'] = '';
$row['parent_id'] = $invoice->id;
$row['parent_type'] = 'AOS_Invoices';
$row['group_id'] = $quoteToInvoiceGroupIds[$row['group_id']];
if($row['product_cost_price'] != null)
{
$row['product_cost_price'] = format_number($row['product_cost_price']);
}
$row['product_list_price'] = format_number($row['product_list_price']);
if($row['product_discount'] != null)
{
$row['product_discount'] = format_number($row['product_discount']);
$row['product_discount_amount'] = format_number($row['product_discount_amount']);
}
$row['product_unit_price'] = format_number($row['product_unit_price']);
$row['vat_amt'] = format_number($row['vat_amt']);
$row['product_total_price'] = format_number($row['product_total_price']);
$row['product_qty'] = format_number($row['product_qty']);
$prod_invoice = new AOS_Products_Quotes();
$prod_invoice->populateFromRow($row);
$prod_invoice->save();
}
1 Like
[EDIT] I posted this before the last Simeon answer, I try your solution right now.
Ok, let’s say I am on a perfectly brand new db with my SuiteCRM
1/ I create a test quote with 2 group “1” and “2” with dummy products in it
I hit “save”, I have this in table aos_line_item_groups:

2/ then I hit “convert to invoice” and just stop here, I have this :

3/ then I save my generated invoice, I have this (check parent_type) :

4/ then I rename quote groups with “111” and “222” and invoice groups with “11” and “22”, everything work as intended but I have this

As you can see, I have 2 ghost records since step 2/ and according to step 4/ they are actually useless
Did I miss something?
Simeon your last solution fix the groups problem but double all product_line_items into the generated invoice, I am looking for a correction to this
[EDIT] No everything works like a charm, I just double pasted your code snippet, too much coffee…, Thank you!
Nice one. I’ve created a new pull request for the fix: https://github.com/salesagility/SuiteCRM/pull/3907/files
2 Likes