/** * @param array|null $params * * @return InvoiceItem The resulting invoice item. */ public function addInvoiceItem($params = null) { if (!$params) { $params = array(); } $params['customer'] = $this->id; $ii = InvoiceItem::create($params, $this->_opts); return $ii; }
public function testItemsAccessWithParameter() { self::authorizeFromEnv(); $customer = self::createTestCustomer(); InvoiceItem::create(array('customer' => $customer->id, 'amount' => 100, 'currency' => 'usd')); $invoice = Invoice::upcoming(array('customer' => $customer->id)); $lines = $invoice->lines->all(array('limit' => 10)); $this->assertSame(count($lines->data), 1); $this->assertSame($lines->data[0]->amount, 100); }
public function run() { Eloquent::unguard(); DB::table('invoices')->truncate(); DB::table('invoice_items')->truncate(); $faker = Faker\Factory::create(); for ($i = 0; $i < 30; $i++) { $invoice = Invoice::create(array('user_id' => $faker->randomNumber(1, 20), 'due_date' => $faker->dateTimeThisYear, 'status' => $faker->randomElement(array('Draft', 'Unpaid', 'Paid')))); InvoiceItem::create(array('invoice_id' => $invoice->id, 'description' => $faker->sentence, 'unit_price' => $faker->randomNumber(1, 200), 'quantity' => $faker->randomNumber(1, 2))); } }
public function run() { DB::table('DEMO_Invoice_Item')->delete(); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 1)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 1)); InvoiceItem::create(array('description' => 'Chai', 'category' => 'Beverages', 'unitCost' => 13.0, 'quantity' => 1, 'total' => 13.0, 'invoice' => 1)); InvoiceItem::create(array('description' => 'Chang', 'category' => 'Beverages', 'unitCost' => 14.0, 'quantity' => 1, 'total' => 14.0, 'invoice' => 1)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 1)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 1)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 2)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 2)); InvoiceItem::create(array('description' => 'Boston Crab Meat', 'category' => 'Seafood', 'unitCost' => 25, 'quantity' => 1, 'total' => 25.0, 'invoice' => 2)); InvoiceItem::create(array('description' => 'Chai', 'category' => 'Beverages', 'unitCost' => 13.0, 'quantity' => 1, 'total' => 13.0, 'invoice' => 2)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 3)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 3)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 3)); InvoiceItem::create(array('description' => 'Ikura', 'category' => 'Seafood', 'unitCost' => 34, 'quantity' => 1, 'total' => 34.0, 'invoice' => 3)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 3)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 4)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 4)); InvoiceItem::create(array('description' => 'Boston Crab Meat', 'category' => 'Seafood', 'unitCost' => 25, 'quantity' => 1, 'total' => 25.0, 'invoice' => 4)); InvoiceItem::create(array('description' => 'Ikura', 'category' => 'Seafood', 'unitCost' => 34, 'quantity' => 1, 'total' => 34.0, 'invoice' => 4)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 4)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 5)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 5)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 6)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 6)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 6)); InvoiceItem::create(array('description' => 'Chai', 'category' => 'Beverages', 'unitCost' => 13.0, 'quantity' => 1, 'total' => 13.0, 'invoice' => 7)); InvoiceItem::create(array('description' => 'Boston Crab Meat', 'category' => 'Seafood', 'unitCost' => 25, 'quantity' => 1, 'total' => 25.0, 'invoice' => 7)); InvoiceItem::create(array('description' => 'Ikura', 'category' => 'Seafood', 'unitCost' => 34, 'quantity' => 1, 'total' => 34.0, 'invoice' => 7)); InvoiceItem::create(array('description' => 'Chang', 'category' => 'Beverages', 'unitCost' => 14.0, 'quantity' => 1, 'total' => 14.0, 'invoice' => 7)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 8)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 8)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 8)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 8)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 8)); InvoiceItem::create(array('description' => 'Chai', 'category' => 'Beverages', 'unitCost' => 13.0, 'quantity' => 1, 'total' => 13.0, 'invoice' => 9)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 9)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 9)); InvoiceItem::create(array('description' => 'Ikura', 'category' => 'Seafood', 'unitCost' => 34, 'quantity' => 1, 'total' => 34.0, 'invoice' => 9)); InvoiceItem::create(array('description' => 'Chang', 'category' => 'Beverages', 'unitCost' => 14.0, 'quantity' => 1, 'total' => 14.0, 'invoice' => 9)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 10)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 10)); InvoiceItem::create(array('description' => 'Boston Crab Meat', 'category' => 'Seafood', 'unitCost' => 25, 'quantity' => 1, 'total' => 25.0, 'invoice' => 10)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 11)); InvoiceItem::create(array('description' => 'Chai', 'category' => 'Beverages', 'unitCost' => 13.0, 'quantity' => 1, 'total' => 13.0, 'invoice' => 11)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 12)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 12)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 13)); InvoiceItem::create(array('description' => 'Ikura', 'category' => 'Seafood', 'unitCost' => 34, 'quantity' => 1, 'total' => 34.0, 'invoice' => 13)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 13)); InvoiceItem::create(array('description' => 'Chai', 'category' => 'Beverages', 'unitCost' => 13.0, 'quantity' => 1, 'total' => 13.0, 'invoice' => 13)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 14)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 14)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 15)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 15)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 15)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 16)); InvoiceItem::create(array('description' => 'Boston Crab Meat', 'category' => 'Seafood', 'unitCost' => 25, 'quantity' => 1, 'total' => 25.0, 'invoice' => 16)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 16)); InvoiceItem::create(array('description' => 'Chang', 'category' => 'Beverages', 'unitCost' => 14.0, 'quantity' => 1, 'total' => 14.0, 'invoice' => 15)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 15)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 17)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 17)); InvoiceItem::create(array('description' => 'Shichimi', 'category' => 'Condiments', 'unitCost' => 5, 'quantity' => 1, 'total' => 5.0, 'invoice' => 17)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 17)); InvoiceItem::create(array('description' => 'Chang', 'category' => 'Beverages', 'unitCost' => 14.0, 'quantity' => 1, 'total' => 14.0, 'invoice' => 17)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 18)); InvoiceItem::create(array('description' => 'Boston Crab Meat', 'category' => 'Seafood', 'unitCost' => 25, 'quantity' => 1, 'total' => 25.0, 'invoice' => 18)); InvoiceItem::create(array('description' => 'Inlagd Sill', 'category' => 'Seafood', 'unitCost' => 18, 'quantity' => 1, 'total' => 18.0, 'invoice' => 19)); InvoiceItem::create(array('description' => 'Ipoh Coffee', 'category' => 'Beverages', 'unitCost' => 12.0, 'quantity' => 1, 'total' => 12.0, 'invoice' => 19)); InvoiceItem::create(array('description' => 'Chang', 'category' => 'Beverages', 'unitCost' => 14.0, 'quantity' => 1, 'total' => 14.0, 'invoice' => 19)); InvoiceItem::create(array('description' => 'Steeleye Stout', 'category' => 'Beverages', 'unitCost' => 11.0, 'quantity' => 1, 'total' => 11.0, 'invoice' => 20)); InvoiceItem::create(array('description' => 'Ikura', 'category' => 'Seafood', 'unitCost' => 34, 'quantity' => 1, 'total' => 34.0, 'invoice' => 20)); InvoiceItem::create(array('description' => 'Pesto genovese', 'category' => 'Condiments', 'unitCost' => 7, 'quantity' => 1, 'total' => 7.0, 'invoice' => 20)); }