Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $fake = Faker\Factory::create();
     foreach (Outlet::all() as $outlet) {
         $customers = $outlet->company->customers;
         $employees = $outlet->users;
         $tax = $outlet->tax;
         $discounts = $outlet->company->discounts;
         $payments = $outlet->company->payments;
         //create order
         $orders = [];
         foreach (range(1, 100) as $i) {
             $orders[] = factory(Order::class)->create(['outlet_id' => $outlet->id, 'customer_id' => $customers->random()->id, 'user_id' => $employees->random()->id, 'payment_id' => $payments->random()->id, 'tax_id' => $tax->id, 'discount_id' => $discounts->random()->id]);
         }
         foreach ($orders as $order) {
             $variantIds = $outlet->variants->random(10)->lists('id')->toArray();
             $order->variants()->attach($variantIds, ['total' => $fake->numberBetween(10, 100), 'nego' => 0]);
         }
         //select random order to void by random employee
         foreach (range(1, 5) as $i) {
             factory(Void::class)->create(['user_id' => $employees->random()->id, 'order_id' => $orders[mt_rand(1, 99)]->id]);
         }
         //select random order to void by random employee
         foreach (range(1, 5) as $i) {
             factory(Debt::class)->create(['order_id' => $orders[mt_rand(1, 99)]->id]);
         }
     }
 }
Beispiel #2
0
 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function test_update_an_cashier()
 {
     $cashier = $this->createCashier();
     $updatecashier = factory(Cashier::class)->make();
     $id = $this->encode($cashier->id);
     $token = $this->getTokenAsOwner();
     $data = $updatecashier->toArray();
     $data['outlet_id'] = $this->encode(Outlet::findOrFail(1)->id);
     $this->put('/v1/cashiers/' . $id, $data, $token);
     $this->assertResponseStatus(200);
     $this->seeInDatabase('cashiers', ['id' => $cashier->id, 'name' => $updatecashier->name, 'phone' => $updatecashier->phone]);
 }
Beispiel #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $fake = Faker\Factory::create();
     Outlet::whereCompanyId(1)->get()->each(function ($outlet) use($fake) {
         foreach (range(1, 100) as $i) {
             $outlet->incomes()->save(new Income(['total' => $fake->numberBetween(1000, 1000000), 'note' => $fake->paragraph()]));
         }
     });
     Outlet::whereCompanyId(1)->get()->each(function ($outlet) use($fake) {
         foreach (range(1, 100) as $i) {
             $outlet->outcomes()->save(new Outcome(['total' => $fake->numberBetween(1000, 1000000), 'note' => $fake->paragraph()]));
         }
     });
 }
Beispiel #4
0
 public function test_get_stockout_from_specific_outlet()
 {
     $repo = new OutletRepository(new Outlet());
     $outlet = Outlet::all()->random();
     $owner = $this->owner();
     $stocks = $repo->getStockOutsPaginated($outlet->id, $owner);
     $data = $this->createPaginated($stocks, new StockOutTransformer());
     $token = $this->getTokenAsOwner();
     $this->get('v1/outlets/' . $this->encode($outlet->id) . '/stock-outs', $token);
     $this->assertResponseStatus(200);
     $result = $data->toArray();
     //pop the meta array
     array_pop($result);
     $this->seeJson($result);
 }
Beispiel #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $outlets = Outlet::with(['products.variants'])->get();
     //employees create stock entry, stock out, opname and purchase order
     $outlets->each(function (Outlet $outlet) {
         $variants = $outlet->variants;
         $suppliers = Supplier::whereCompanyId($outlet->company_id)->get();
         $employees = $outlet->users;
         /* --STOCK ENTRY-- */
         //create stock entry
         $entries = factory(Entry::class, 50)->create(['user_id' => $employees->random()->id, 'outlet_id' => $outlet->id]);
         //add it in stock entry
         foreach ($entries as $entry) {
             $entry->variants()->attach($variants->random(10)->lists('id')->toArray(), ['total' => rand(1, 50)]);
         }
         /* --STOCK OUT-- */
         //create stock out
         $outs = factory(Out::class, 50)->create(['user_id' => $employees->random()->id, 'outlet_id' => $outlet->id]);
         //add it in stock out
         foreach ($outs as $out) {
             $out->variants()->attach($variants->random(10)->lists('id')->toArray(), ['total' => rand(1, 50)]);
         }
         /* --OPNAME-- */
         //create stock opname
         $opnames = factory(Opname::class, 50)->create(['user_id' => $employees->random()->id, 'outlet_id' => $outlet->id]);
         //add it in stock opname
         foreach ($opnames as $opname) {
             $opname->variants()->attach($variants->random(10)->lists('id')->toArray(), ['total' => rand(1, 50)]);
         }
         /* --PURCHASE ORDER-- */
         //create stock opname
         $purchases = factory(PurchaseOrder::class, 50)->create(['supplier_id' => $suppliers->random()->id, 'outlet_id' => $outlet->id]);
         //add it in purchase order
         foreach ($purchases as $purchase) {
             $purchase->variants()->attach($variants->random(10)->lists('id')->toArray(), ['total' => rand(1, 50)]);
         }
     });
 }
Beispiel #6
0
<?php

use Sikasir\V1\Outlets\Outlet;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
get('/tes/{id}', function ($id) {
    return Outlet::where('company_id', '=', 1)->find($id)->variants()->where('variants.name', 'like', 'nihil')->get();
});
Route::group(['prefix' => 'doc'], function () {
    get('/endpoint', function () {
        return view('doc.endpoint');
    });
    get('/format', function () {
        return view('doc.format');
    });
});
Route::group(['prefix' => 'v1', 'namespace' => 'V1'], function () {
    Route::group(['namespace' => 'Auth', 'prefix' => 'auth'], function () {
        post('mobile/login', 'AuthController@mobileLogin');
        post('login', 'AuthController@login');
        post('/register', 'AuthController@signup');
        get('/refresh', 'AuthController@refresh');
    });
Beispiel #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Outlet::all()->each(function ($outlet) {
         $printers = factory(Printer::class, 3)->create(['outlet_id' => $outlet->id]);
     });
 }