Exemplo n.º 1
0
 function save_groups($post_data, $parent, $key = '')
 {
     $groups = array();
     $group_count = count($post_data[$key . 'group_number']);
     $j = 0;
     for ($i = 0; $i < $group_count; ++$i) {
         if ($post_data[$key . 'deleted'][$i] == 1) {
             $this->mark_deleted($post_data[$key . 'id'][$i]);
         } else {
             $product_quote_group = new AOS_Line_Item_Groups();
             foreach ($this->field_defs as $field_def) {
                 if (isset($post_data[$key . $field_def['name']][$i])) {
                     $product_quote_group->{$field_def}['name'] = $post_data[$key . $field_def['name']][$i];
                 }
             }
             $product_quote_group->number = ++$j;
             $product_quote_group->assigned_user_id = $parent->assigned_user_id;
             $product_quote_group->currency_id = $parent->currency_id;
             $product_quote_group->parent_id = $parent->id;
             $product_quote_group->parent_type = $parent->object_name;
             $product_quote_group->save();
             if (isset($post_data[$key . 'group_number'][$i])) {
                 $groups[$post_data[$key . 'group_number'][$i]] = $product_quote_group->id;
             }
         }
     }
     require_once 'modules/AOS_Products_Quotes/AOS_Products_Quotes.php';
     $productQuote = new AOS_Products_Quotes();
     $productQuote->save_lines($post_data, $parent, $groups, 'product_');
     $productQuote->save_lines($post_data, $parent, $groups, 'service_');
 }
 public function testsave()
 {
     $aosLineItemGroup = new AOS_Line_Item_Groups();
     $aosLineItemGroup->name = 'test';
     $aosLineItemGroup->total_amount = 100;
     $aosLineItemGroup->total_amount_usdollar = 100;
     $aosLineItemGroup->save();
     //test for record ID to verify that record is saved
     $this->assertTrue(isset($aosLineItemGroup->id));
     $this->assertEquals(36, strlen($aosLineItemGroup->id));
     //mark the record as deleted and verify that this record cannot be retrieved anymore.
     $aosLineItemGroup->mark_deleted($aosLineItemGroup->id);
     $result = $aosLineItemGroup->retrieve($aosLineItemGroup->id);
     $this->assertEquals(null, $result);
 }
Exemplo n.º 3
0
    }
    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_contract = new AOS_Line_Item_Groups();
    $group_contract->populateFromRow($row);
    $group_contract->save();
    $group_id_map[$old_id] = $group_contract->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'] = $contract->id;
    $row['parent_type'] = 'AOS_Contracts';
    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']);
Exemplo n.º 4
0
    }
    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();
}
//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) {
        $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']);