public static function createProductTemplateByName($name) { $currencies = Currency::getAll(); $currencyValue = new CurrencyValue(); $currencyValue->value = 500.54; $currencyValue->currency = $currencies[0]; $productTemplate = new ProductTemplate(); $productTemplate->name = $name; $productTemplate->description = 'Description'; $productTemplate->priceFrequency = 2; $productTemplate->cost = $currencyValue; $currencyValueListPrice = new CurrencyValue(); $currencyValueListPrice->value = 600.54; $currencyValueListPrice->currency = $currencies[0]; $productTemplate->listPrice = $currencyValueListPrice; $currencyValueSellPrice = new CurrencyValue(); $currencyValueSellPrice->value = 500.54; $currencyValueSellPrice->currency = $currencies[0]; $productTemplate->sellPrice = $currencyValueSellPrice; $productTemplate->type = ProductTemplate::TYPE_PRODUCT; $productTemplate->status = ProductTemplate::STATUS_ACTIVE; $sellPriceFormula = new SellPriceFormula(); $sellPriceFormula->type = SellPriceFormula::TYPE_EDITABLE; $productTemplate->sellPriceFormula = $sellPriceFormula; $saved = $productTemplate->save(); assert('$saved'); return $productTemplate; }
public function testFormatResults() { $tempPT = new ProductTemplate(); $tempPT->name = 'MasonUnitTest'; $tempPT->description = "Unit'test"; $tempPT->cost_price = 1000; $tempPT->discount_price = 800; $tempPT->list_price = 1100; $tempPT->save(); $_REQUEST['data'] = '{"conditions":[{"end":"%","name":"name","op":"like_custom","value":""}],"field_list":["name","id","type_id","mft_part_num","cost_price","list_price","discount_price","pricing_factor","description","cost_usdollar","list_usdollar","discount_usdollar","tax_class_name"],"form":"EditView","group":"or","id":"EditView_product_name[1]","limit":"30","method":"query","modules":["ProductTemplates"],"no_match_text":"No Match","order":"name","populate_list":["name_1","product_template_id_1"],"post_onblur_function":"set_after_sqs"}'; $_REQUEST['query'] = 'MasonUnitTest'; require_once 'modules/home/quicksearchQuery.php'; $json = getJSONobj(); $data = $json->decode(html_entity_decode($_REQUEST['data'])); if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) { foreach ($data['conditions'] as $k => $v) { if (empty($data['conditions'][$k]['value'])) { $data['conditions'][$k]['value'] = $_REQUEST['query']; } } } $this->quickSearch = new quicksearchQuery(); $result = $this->quickSearch->query($data); $resultBean = $json->decodeReal($result); $this->assertEquals($resultBean['fields'][0]['description'], $tempPT->description); }
public function testDemoDataMaker() { $productTemplate = new ProductTemplate(); $productTemplate->name = 'Amazing Kid'; $productTemplate->priceFrequency = ProductTemplate::PRICE_FREQUENCY_ONE_TIME; $productTemplate->cost->value = 200; $productTemplate->listPrice->value = 200; $productTemplate->sellPrice->value = 200; $productTemplate->type = ProductTemplate::TYPE_PRODUCT; $productTemplate->status = ProductTemplate::STATUS_ACTIVE; $sellPriceFormula = new SellPriceFormula(); $sellPriceFormula->type = SellPriceFormula::TYPE_EDITABLE; $productTemplate->sellPriceFormula = $sellPriceFormula; $this->assertTrue($productTemplate->save()); $productTemplates[] = $productTemplate->id; }
$template->name = $v['name']; $template->tax_class = $v['tax_class']; $template->cost_price = $v['cost_price']; $template->cost_usdollar = $v['cost_usdollar']; $template->list_price = $v['list_price']; $template->list_usdollar = $v['list_usdollar']; $template->discount_price = $v['discount_price']; $template->discount_usdollar = $v['discount_usdollar']; $template->pricing_formula = $v['pricing_formula']; $template->mft_part_num = $v['mft_part_num']; $template->pricing_factor = $v['pricing_factor']; $template->status = $v['status']; $template->weight = $v['weight']; $template->date_available = $v['date_available']; $template->qty_in_stock = $v['qty_in_stock']; $template->save(); } echo '.'; include_once 'modules/TeamNotices/DefaultNotices.php'; /// /// SEED DATA FOR CONTRACTS /// include_once 'modules/Contracts/Contract.php'; foreach ($sugar_demodata['contract_seed_data'] as $v) { $contract = new Contract(); $contract->currency_id = '-99'; $contract->name = $v['name']; $contract->reference_code = $v['reference_code']; $contract->status = 'signed'; $contract->account_id = $account->id; $contract->total_contract_value = $v['total_contract_value'];
function create_product($category_id) { global $sugar_demodata; $first_name_array = $sugar_demodata['first_name_array']; $first_name_count = count($sugar_demodata['first_name_array']); $company_name_array = $sugar_demodata['company_name_array']; $company_name_count = count($sugar_demodata['company_name_array']); global $dollar_id; if (empty($dollar_id)) { $dollar_id = '-99'; } global $manufacturer_id_arr; $first_name_max = $first_name_count - 1; $cost = rand(300, 600); $list = rand(700, 1000); $discount = rand($list - 200, $list - 50); $template = new ProductTemplate(); $template->name = $first_name_array[mt_rand(0, $first_name_max)] . $sugar_demodata['product_ext_name']; $template->tax_class = "Taxable"; $template->manufacturer_id = $manufacturer_id_arr[0]; $template->currency_id = $dollar_id; $template->cost_price = $cost; $template->cost_usdollar = $cost; $template->list_price = $list; $template->list_usdollar = $list; $template->discount_price = $discount; $template->discount_usdollar = $discount; $template->pricing_formula = "IsList"; $template->mft_part_num = $company_name_array[mt_rand(0, $company_name_count - 1)] . ' ' . mt_rand(1, 1000000) . "XYZ987"; $template->pricing_factor = "1"; $template->status = "Available"; $template->weight = rand(10, 40); $template->date_available = "2004-10-15"; $template->qty_in_stock = rand(0, 150); $template->category_id = $category_id; $template->save(); unset($template); //end function create_product }