Exemplo n.º 1
0
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     $this->amount = floatval($this->amount);
     $pay = new Pay();
     $pay->amount = $this->amount;
     $pay->type = $this->type;
     $pay->user_id = $this->requestor_id;
     if (!$pay->save()) {
         return false;
     }
     if ($pay->type == Pay::TYPE_GATHERED) {
         $this->recordTithe();
     }
     $this->recordCredits();
     return true;
 }
Exemplo n.º 2
0
 /**
  * Testing 1 2 3...
  *
  * @return void
  */
 public function testAll()
 {
     $user = factory(User::class)->create();
     $up = new UserProperty();
     $up->user_id = $user->id;
     $up->key = UserProperty::KEY_TITHE_PERCENTAGE;
     $up->value = '10';
     $this->assertTrue($up->save());
     $pay = new Pay();
     $pay->user_id = $user->id;
     $pay->amount = 5000;
     $this->assertTrue($pay->save());
     $tithe = new Tithe();
     $tithe->user_id = $user->id;
     $tithe->setPoolAmount($pay->amount);
     $tithe->setAmount();
     $tithe->status = Tithe::STATUS_STORED;
     $this->assertTrue($tithe->save());
     $tithe = Tithe::find($tithe->id);
     $this->assertNotNull($tithe);
     $this->assertEquals(5000, $tithe->pool_amount);
     $this->assertEquals(500, $tithe->amount);
 }