Esempio n. 1
0
            }
            if (count($ex_ids) > 0) {
                if ($invoice->addExpenses($ex_ids, SI_EXPENSE_AGGREGATION_DESC) === FALSE) {
                    $error_msg .= "Error adding expenses to invoice!\n";
                    debug_message($invoice->getLastError());
                }
            }
            // Add the company transaction
            if (empty($error_msg)) {
                $ct = new SI_CompanyTransaction();
                $ct->amount = $invoice->getTotal();
                $ct->company_id = $invoice->company_id;
                $ct->description = "Invoice #" . $invoice->id;
                $ct->timestamp = $invoice->timestamp;
                if ($ct->add() === FALSE) {
                    $error_msg .= "Error adding company transaction!\n";
                    debug_message($ct->getLastError());
                }
                $invoice->trans_id = $ct->id;
                if ($invoice->update() === FALSE) {
                    $error_msg .= "Error updating invoice with company transaction id!\n";
                    debug_message($invoice->getLastError());
                }
            }
        } else {
            $echo("Error adding Invoice!\n");
            debug_message($invoice->getLastError());
        }
    }
}
echo "\n\nEnd of AutoInvoice.\n";