Example #1
0
 /**
  * @covers FireflyIII\Repositories\Bill\BillRepository::destroy
  */
 public function testDestroy()
 {
     $bill = FactoryMuffin::create('FireflyIII\\Models\\Bill');
     $accountId = $bill->id;
     $this->object->destroy($bill);
     // cannot find bill:
     $this->assertCount(0, Bill::whereId($accountId)->whereNotNull('deleted_at')->get());
 }
Example #2
0
 /**
  * @param Bill  $bill
  * @param array $data
  *
  * @return Bill
  */
 public function update(Bill $bill, array $data)
 {
     $bill->name = $data['name'];
     $bill->match = $data['match'];
     $bill->amount_min = $data['amount_min'];
     $bill->amount_max = $data['amount_max'];
     $bill->date = $data['date'];
     $bill->repeat_freq = $data['repeat_freq'];
     $bill->skip = $data['skip'];
     $bill->automatch = $data['automatch'];
     $bill->active = $data['active'];
     $bill->save();
     return $bill;
 }
 /**
  * @param $name
  *
  * @return Bill|null
  */
 protected function findBill($name)
 {
     /** @var Bill $bill */
     foreach (Bill::get() as $bill) {
         if ($bill->name == $name && $this->user->id == $bill->user_id) {
             return $bill;
             break;
         }
     }
     return null;
 }
Example #4
0
 /**
  * @param $name
  *
  * @return Bill|null
  */
 protected function findBill($name)
 {
     // account
     $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
     /** @var Bill $bill */
     foreach (Bill::get() as $bill) {
         if ($bill->name == $name && $user->id == $bill->user_id) {
             return $bill;
             break;
         }
     }
     return null;
 }
Example #5
0
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('currency', function ($value) {
    if (Auth::check()) {
        $object = TransactionCurrency::find($value);
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('bill', function ($value) {
    if (Auth::check()) {
        $object = Bill::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Route::bind('budget', function ($value) {
    if (Auth::check()) {
        $object = Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();
        if ($object) {
            return $object;
        }
    }
    throw new NotFoundHttpException();
});
Example #6
0
 /**
  * @param User $user
  */
 public static function createBills(User $user)
 {
     Bill::create(['name' => 'Rent', 'match' => 'rent,land,lord', 'amount_min' => 795, 'amount_max' => 805, 'user_id' => $user->id, 'date' => '2015-01-01', 'active' => 1, 'automatch' => 1, 'repeat_freq' => 'monthly', 'skip' => 0]);
     Bill::create(['name' => 'Health insurance', 'match' => 'zilveren,kruis,health', 'amount_min' => 120, 'amount_max' => 140, 'user_id' => $user->id, 'date' => '2015-01-01', 'active' => 1, 'automatch' => 1, 'repeat_freq' => 'monthly', 'skip' => 0]);
 }