Inheritance: extends Domain\BaseModel
Esempio n. 1
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $student = Student::find($model->student_id);
         $recipient = BilletAssignor::first();
         $model->payer = $student->getPayer();
         $model->recipient = $recipient->getRecipient();
         $model->new_due_date = $model->due_date->toDateString();
         $model->payment_of_fine = $recipient->payment_of_fine;
         $model->interest = $recipient->interest;
         $model->is_interest = $recipient->is_interest;
         $model->days_protest = $recipient->days_protest;
         $model->bank = $recipient->bank;
         $model->agency = $recipient->agency;
         $model->digit_agency = $recipient->digit_agency;
         $model->account = $recipient->account;
         $model->digit_account = $recipient->digit_account;
         $model->wallet = $recipient->wallet;
         $model->agreement = $recipient->agreement;
         $model->portfolio_change = $recipient->portfolio_change;
         $model->range = $recipient->range;
         $model->client_id = $recipient->client_id;
         $model->ios = $recipient->ios;
         $model->kind_document = $recipient->kind_document;
     });
     static::updating(function ($model) {
         //
     });
 }
 public function createBillet($student, $refer)
 {
     $due_date = substr($refer, 0, 4) . '-' . substr($refer, -2) . '-';
     $recipient = BilletAssignor::first();
     $data = ['student_id' => $student->id, 'due_date' => $due_date . $student->day_of_payment, 'amount' => $student->monthly_payment, 'agency' => $recipient->agency, 'digit_agency' => $recipient->digit_agency, 'account' => $recipient->account, 'digit_account' => $recipient->digit_account, 'wallet' => $recipient->wallet, 'agreement' => $recipient->agreement, 'portfolio_change' => $recipient->portfolio_change, 'instruction01' => $recipient->instruction01, 'instruction02' => $recipient->instruction02, 'instruction03' => $recipient->instruction03, 'instruction04' => $recipient->instruction04, 'instruction05' => $recipient->instruction05, 'refer' => $refer, 'note' => 'Fatura gerada automaticamente'];
     $billet = new Billet();
     $billet->fill($data);
     $billet->save();
     return $billet;
 }
Esempio n. 3
0
 public function test_create_billet()
 {
     $billet = factory(Billet::class)->create();
     $this->assertInstanceOf(Billet::class, $billet);
     $this->assertInstanceOf(Student::class, $billet->student);
     $this->assertInstanceOf(Carbon::class, $billet->created_at);
     $this->assertInstanceOf(Carbon::class, $billet->updated_at);
     $this->assertInstanceOf(Carbon::class, $billet->due_date);
     $this->assertInstanceOf(Carbon::class, $billet->new_due_date);
     $recipient = BilletAssignor::first();
     $this->seeInDatabase('billets', ['id' => $billet->id, 'payment_of_fine' => $recipient->payment_of_fine, 'interest' => $recipient->interest, 'is_interest' => $recipient->is_interest, 'days_protest' => $recipient->days_protest]);
 }
 public function test_update_by_post()
 {
     //Sets
     $faker = BilletAssignor::first();
     if (is_null($faker)) {
         $faker = factory(BilletAssignor::class)->create();
     }
     $billetAssignor = ['name' => 'Cedente', 'cnpj' => $faker->cnpj, 'postcode' => $faker->postcode, 'street' => $faker->street, 'number' => $faker->number, 'district' => $faker->district, 'city' => $faker->city, 'state' => $faker->state, 'bank' => $faker->bank, 'agency' => $faker->agency, 'digit_agency' => $faker->digit_agency, 'account' => $faker->account, 'digit_account' => $faker->digit_account, 'wallet' => $faker->wallet, 'agreement' => $faker->agreement, 'acceptance' => $faker->acceptance];
     $this->post('api/v1/billet/assignor/', $billetAssignor);
     $original = json_decode($this->response->getContent(), true);
     $this->seeStatusCode(200);
     $this->seeJson(['name' => 'Cedente']);
     $this->assertEquals($original['id'], $faker->id);
     $this->seeInDatabase('billet_assignors', ['id' => $original['id']]);
 }
Esempio n. 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Schedule::truncate();
     Billet::truncate();
     BilletAssignor::truncate();
     Classroom::truncate();
     ClassroomMatter::truncate();
     Config::truncate();
     Employee::truncate();
     Lesson::truncate();
     Matter::truncate();
     Schedule::truncate();
     Student::truncate();
     Teacher::truncate();
     factory(BilletAssignor::class, 1)->create();
     factory(Billet::class, 5)->create();
     $allClassrooms = factory(Classroom::class, 10)->create();
     factory(ClassroomMatter::class, 10)->create();
     factory(Config::class, 10)->create();
     $employee = factory(Employee::class)->create();
     factory(Lesson::class, 40)->create();
     $matters = factory(Matter::class, 10)->create();
     factory(Schedule::class, 3)->create();
     $student = factory(Student::class)->create();
     $teacher = factory(Teacher::class)->create();
     factory(User::class, 1)->create(['username' => 'funcionario', 'password' => bcrypt('funcionario123'), 'owner_type' => Employee::class, 'owner_id' => $employee->id]);
     factory(User::class, 1)->create(['username' => 'aluno', 'password' => bcrypt('aluno123'), 'owner_type' => Student::class, 'owner_id' => $student->id]);
     factory(User::class, 1)->create(['username' => 'professor', 'password' => bcrypt('professor123'), 'owner_type' => Teacher::class, 'owner_id' => $teacher->id]);
     $classrooms = factory(Classroom::class, 3)->create(['teacher_id' => $teacher->id]);
     $classrooms->each(function ($classroom) use($student, $matters) {
         $classroom->students()->attach($student);
         $matters->random(3)->each(function ($matter) use($classroom) {
             $classroom->matters()->attach($matter);
         });
     });
     $allClassrooms->random(3)->each(function ($classroom) use($student, $matters, $teacher) {
         $classroom->teacher()->associate($teacher);
         $classroom->students()->attach($student);
         $matters->random(3)->each(function ($matter) use($classroom) {
             $classroom->matters()->attach($matter);
         });
     });
     factory(User::class, 30)->create();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
 public function test_store_by_post_filed_dont_exists_assignor()
 {
     $student = factory(Student::class)->create();
     BilletAssignor::where('id', '>=', 1)->delete();
     $billet = ['amount' => 50, 'student_id' => $student->id, 'refer' => 201615];
     $return = $this->post('api/v1/billet/', $billet);
     $this->seeStatusCode(403);
     $this->see("There isn't a transferor, must create a transferor to be able to create billet.");
 }
Esempio n. 7
0
use Domain\Billet\Billet;
use Domain\Billet\BilletAssignor;
use Domain\Classroom\Classroom;
use Domain\Classroom\ClassroomMatter;
use Domain\Config\Config;
use Domain\Employee\Employee;
use Domain\Lesson\Lesson;
use Domain\Matter\Matter;
use Domain\Schedule\Schedule;
use Domain\Student\Student;
use Domain\Teacher\Teacher;
use Domain\User\User;
$factory->define(Billet::class, function (Faker\Generator $faker) {
    $faker->addProvider(new Faker\Provider\DateTime($faker));
    $student = factory(Student::class)->create();
    $recipient = BilletAssignor::first();
    if (is_null($recipient)) {
        $recipient = factory(BilletAssignor::class)->create();
    }
    return ['student_id' => $student->id, 'due_date' => $faker->date, 'amount' => $faker->randomDigit(3), 'number' => $faker->unique()->randomDigit(10), 'document_number' => $faker->unique()->randomDigit(10), 'statement01' => $faker->sentence(5), 'statement02' => $faker->sentence(5), 'statement03' => $faker->sentence(5), 'statement04' => $faker->sentence(5), 'statement05' => $faker->sentence(5), 'instruction01' => $faker->sentence(5), 'instruction02' => $faker->sentence(5), 'instruction03' => $faker->sentence(5), 'instruction04' => $faker->sentence(5), 'instruction05' => $faker->sentence(5), 'acceptance' => $faker->randomElement([0, 1]), 'kind_document' => $recipient->kind_document, 'payer' => json_encode(['nome' => $student->responsible, 'endereco' => $student->street . ', ' . $student->number . ' ' . $student->complement, 'cep' => $student->postcode, 'uf' => $student->stateAbbr, 'cidade' => $student->city, 'documento' => $student->cpf_responsible]), 'recipient' => json_encode(['nome' => $recipient->name, 'endereco' => $recipient->street . ', ' . $recipient->number . ' ' . $recipient->complement, 'cep' => $recipient->postcode, 'uf' => $recipient->stateAbbr, 'cidade' => $recipient->city, 'documento' => $recipient->cnpj]), 'bank' => $recipient->bank, 'agency' => $recipient->agency, 'digit_agency' => $recipient->digit_agency, 'account' => $recipient->account, 'digit_account' => $recipient->digit_account, 'wallet' => $recipient->wallet, 'agreement' => $recipient->agreement, 'acceptance' => $recipient->acceptance, 'payment_of_fine' => $recipient->payment_of_fine, 'interest' => $recipient->interest, 'is_interest' => $recipient->is_interest, 'days_protest' => $recipient->days_protest, 'refer' => date_format($faker->dateTimeBetween('now', '+1 year'), 'Ym'), 'note' => $faker->sentence(5)];
});
$factory->define(BilletAssignor::class, function (Faker\Generator $faker) {
    $faker->addProvider(new Faker\Provider\pt_BR\Address($faker));
    $faker->addProvider(new Faker\Provider\pt_BR\Company($faker));
    $faker->addProvider(new Faker\Provider\pt_BR\Person($faker));
    $bank = $faker->randomElement(['bb', 'bradesco', 'caixa', 'hsbc', 'itau', 'santander']);
    switch ($bank) {
        case 'bb':
            $wallet = ['11', '12', '15', '16', '17', '18', '31', '51'];
            break;
        case 'bradesco':
Esempio n. 8
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return BilletAssignor::exists();
 }