Пример #1
0
 public function testSaveAndMark_deleted()
 {
     error_reporting(E_ERROR | E_PARSE);
     $aosInvoices = new AOS_Invoices();
     $aosInvoices->name = 'test';
     $aosInvoices->save();
     //test for record ID to verify that record is saved
     $this->assertTrue(isset($aosInvoices->id));
     $this->assertEquals(36, strlen($aosInvoices->id));
     $this->assertGreaterThan(0, $aosInvoices->number);
     //mark the record as deleted and verify that this record cannot be retrieved anymore.
     $aosInvoices->mark_deleted($aosInvoices->id);
     $result = $aosInvoices->retrieve($aosInvoices->id);
     $this->assertEquals(null, $result);
 }
$dt = explode(' ', $rawRow['date_entered']);
$rawRow['quote_date'] = $dt[0];
$rawRow['invoice_date'] = date('Y-m-d');
$rawRow['total_amt'] = format_number($rawRow['total_amt']);
$rawRow['discount_amount'] = format_number($rawRow['discount_amount']);
$rawRow['subtotal_amount'] = format_number($rawRow['subtotal_amount']);
$rawRow['tax_amount'] = format_number($rawRow['tax_amount']);
$rawRow['date_entered'] = '';
$rawRow['date_modified'] = '';
if ($rawRow['shipping_amount'] != null) {
    $rawRow['shipping_amount'] = format_number($rawRow['shipping_amount']);
}
$rawRow['total_amount'] = format_number($rawRow['total_amount']);
$invoice->populateFromRow($rawRow);
$invoice->process_save_dates = false;
$invoice->save();
//Setting invoice quote relationship
require_once 'modules/Relationships/Relationship.php';
$key = Relationship::retrieve_by_modules('AOS_Quotes', 'AOS_Invoices', $GLOBALS['db']);
if (!empty($key)) {
    $quote->load_relationship($key);
    $quote->{$key}->add($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';
    if ($row['product_cost_price'] != null) {