Topic: REP_ID 107 Void Invoice Still Exist In Drop-down

My company setting is $SysPrefs->print_invoice_no() is FALSE

HOW TO PRODUCE THIS ERROR
I tried voiding invoice and then created invoice with same reference number which I voided earlier. When I try to print invoice it is displaying two invoice with same reference in drop-down

SOLUTIONS
in reporting/includes/reports_classes.inc I made these changes to prevent voided invoice displaying in print invoice section

                case 'INVOICE':
                    $IV = $type_shortcuts[ST_SALESINVOICE];
                    $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                    $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                concat('$IV ', debtor_trans.$ref,' ', debtor.name) as IName
                        FROM ".TB_PREF."debtors_master debtor,"
                            .TB_PREF."debtor_trans debtor_trans
                        WHERE type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no AND version = 0
                        ORDER BY debtor_trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));

In where clause I just added  AND version = 0

Mohsin Mujawar
Impulse Solutions

Re: REP_ID 107 Void Invoice Still Exist In Drop-down

A good issue, @joe looks like we have to add voided table in it.

it sholud be like this for sales invoice

case 'INVOICE':
                    $IV = $type_shortcuts[ST_SALESINVOICE];
                    $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                    $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                concat('$IV ', debtor_trans.$ref,' ', debtor.name) as IName
                        FROM ".TB_PREF."debtors_master debtor,"
                            .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
                        WHERE debtor_trans.type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                        ORDER BY debtor_trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
Subscription service based on FA
HRM CRM POS batch Themes

Re: REP_ID 107 Void Invoice Still Exist In Drop-down

for other types.

case 'INVOICE':
                    $IV = $type_shortcuts[ST_SALESINVOICE];
                    $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                    $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                concat('$IV ', debtor_trans.$ref,' ', debtor.name) as IName
                        FROM ".TB_PREF."debtors_master debtor,"
                            .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
                        WHERE debtor_trans.type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                        ORDER BY debtor_trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));

                case 'CREDIT':
                    $CN = $type_shortcuts[ST_CUSTCREDIT];
                    $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                    $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                concat('$CN ', debtor_trans.$ref,' ', debtor.name) as IName
                        FROM ".TB_PREF."debtors_master debtor,"
                            .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
                        WHERE debtor_trans.type=".ST_CUSTCREDIT." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                        ORDER BY debtor_trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));

                case 'DELIVERY':
                    $DN = $type_shortcuts[ST_CUSTDELIVERY];
                    $sql = "SELECT    concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
                                concat(debtor_trans.trans_no, ' $DN ', debtor.name) as IName
                        FROM ".TB_PREF."debtors_master debtor,"
                            .TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
                        WHERE debtor_trans.type=".ST_CUSTDELIVERY." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
                        ORDER BY debtor_trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));


                case 'REMITTANCE':
                    $BP = $type_shortcuts[ST_BANKPAYMENT];
                    $SP = $type_shortcuts[ST_SUPPAYMENT];
                    $CN = $type_shortcuts[ST_SUPPCREDIT];
                    $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                    $sql = "SELECT concat(trans.trans_no, '-',trans.type) AS TNO,
                                concat(trans.$ref, IF(type=".ST_BANKPAYMENT.", ' $BP ', IF(type=".ST_SUPPAYMENT.", ' $SP ', ' $CN ')), supplier.supp_name) as IName
                            FROM ".TB_PREF."suppliers supplier, "
                                .TB_PREF."supp_trans trans  LEFT JOIN ".TB_PREF."voided AS vd ON trans.type=vd.type AND trans.trans_no=vd.id
                            WHERE trans.type IN(".ST_BANKPAYMENT.",".ST_SUPPAYMENT.",".ST_SUPPCREDIT.")    AND supplier.supplier_id=trans.supplier_id AND ISNULL(vd.id)
                            ORDER BY trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));

                case 'RECEIPT':
                    $BD = $type_shortcuts[ST_BANKDEPOSIT];
                    $CP = $type_shortcuts[ST_CUSTPAYMENT];
                    $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
                    $sql = "SELECT concat(trans.trans_no, '-', trans.type) AS TNO,
                                concat(trans.$ref, IF(trans.type=".ST_BANKDEPOSIT.", ' $BD ', ' $CP '), debtor.name) as IName
                        FROM ".TB_PREF."debtors_master debtor,"
                            .TB_PREF."debtor_trans trans LEFT JOIN ".TB_PREF."voided AS vd ON trans.type=vd.type AND trans.trans_no=vd.id
                        WHERE trans.type IN(".ST_BANKDEPOSIT.",".ST_CUSTPAYMENT.",".ST_CUSTCREDIT.") AND debtor.debtor_no=trans.debtor_no AND ISNULL(vd.id)
                        ORDER BY trans.trans_no DESC";
                    return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
Subscription service based on FA
HRM CRM POS batch Themes

Re: REP_ID 107 Void Invoice Still Exist In Drop-down

Thanks @kvvaradha and @dearmosin

Will fix this later this evening

Joe

Re: REP_ID 107 Void Invoice Still Exist In Drop-down

Committed and sent to 2.4.7 repo.

/Joe