diff --git a/database/factories/PaymentFactory.php b/database/factories/PaymentFactory.php index a1cb02d..7f34824 100644 --- a/database/factories/PaymentFactory.php +++ b/database/factories/PaymentFactory.php @@ -15,7 +15,7 @@ $factory->define(Payment::class, function (Faker $faker) { }, 'amount' => 10000, 'in_out' => 1, - 'type_id' => rand(1, 3), + 'type_id' => 1, 'date' => $faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'), 'description' => $faker->paragraph, 'partner_type' => Customer::class, @@ -25,10 +25,15 @@ $factory->define(Payment::class, function (Faker $faker) { ]; }); +$factory->state(Payment::class, 'customer', function (Faker $faker) { + + return []; +}); + $factory->state(Payment::class, 'vendor', function (Faker $faker) { return [ - 'in_out' => 1, + 'in_out' => 0, 'type_id' => 1, 'partner_type' => Vendor::class, 'partner_id' => function () { @@ -40,7 +45,7 @@ $factory->state(Payment::class, 'vendor', function (Faker $faker) { $factory->state(Payment::class, 'fee', function (Faker $faker) { return [ - 'in_out' => 1, + 'in_out' => 0, 'type_id' => 1, 'partner_type' => User::class, 'partner_id' => function () { diff --git a/resources/views/reports/payments/daily.blade.php b/resources/views/reports/payments/daily.blade.php index c7c0cff..d820e9c 100755 --- a/resources/views/reports/payments/daily.blade.php +++ b/resources/views/reports/payments/daily.blade.php @@ -3,7 +3,7 @@ @section('title', 'Laporan Harian : ' . dateId($date)) @section('content') - +
-| {{ $payment->partner->name }} | {{ $payment->description }} [{{ $payment->type() }}] | - {!! link_to_route('payments.show','Lihat',[$payment->id],['title' => 'Lihat Detail Pembayaran','target' => '_blank','class'=>'btn btn-info btn-xs']) !!} + {{ link_to_route('payments.show','Lihat',[$payment->id],['title' => 'Lihat Detail Pembayaran','target' => '_blank','class' => 'btn btn-info btn-xs']) }} | - in_out == 0 ? $total - $payment->amount : $total + $payment->amount?> + in_out == 0 ? $total - $payment->amount : $total + $payment->amount; ?> @empty -|||||||
| {{ trans('payment.not_found') }} | |||||||||
| {{ trans('payment.not_found') }} | Pilihan | - + @foreach(monthDateArray($year, $month) as $dateNumber) count : 0; - $cashin = $any ? $reports[$dateNumber]->cashin : 0; - $cashout = $any ? $reports[$dateNumber]->cashout : 0; $profit = $any ? $reports[$dateNumber]->profit : 0; + if ($any): ?>||||||||
|---|---|---|---|---|---|---|---|---|---|
| {{ dateId($date = $year . '-' . $month . '-' . $dateNumber) }} | -{{ $count }} | -{{ formatRp($cashin) }} | -{{ formatRp($cashout) }} | +{{ $any ? $reports[$dateNumber]->count : 0 }} | +{{ formatRp($any ? $reports[$dateNumber]->cashin : 0) }} | +{{ formatRp($any ? $reports[$dateNumber]->cashout : 0) }} | {{ formatRp($profit) }} | - {!! link_to_route( + {{ link_to_route( 'reports.payments.daily', 'Lihat Harian', ['date' => $date], @@ -68,10 +60,11 @@ 'class' => 'btn btn-info btn-xs', 'title' => 'Lihat laporan harian ' . $date ] - ) !!} + ) }} | Pilihan | - + @foreach(getMonths() as $monthNumber => $monthName) - count : 0; - $cashin = $any ? $reports[$monthNumber]->cashin : 0; - $cashout = $any ? $reports[$monthNumber]->cashout : 0; - $profit = $any ? $reports[$monthNumber]->profit : 0; - ?> +
| {{ monthId($monthNumber) }} | -{{ $count }} | -{{ formatRp($cashin) }} | -{{ formatRp($cashout) }} | -{{ formatRp($profit) }} | +{{ $any ? $reports[$monthNumber]->count : 0 }} | +{{ formatRp($any ? $reports[$monthNumber]->cashin : 0) }} | +{{ formatRp($any ? $reports[$monthNumber]->cashout : 0) }} | +{{ formatRp($profit = $any ? $reports[$monthNumber]->profit : 0) }} | - {!! link_to_route( + {{ link_to_route( 'reports.payments.monthly', 'Lihat Bulanan', ['month' => $monthNumber, 'year' => $year], [ - 'class'=>'btn btn-info btn-xs', - 'title'=>'Lihat laporan bulanan ' . monthId($monthNumber) + 'class' => 'btn btn-info btn-xs', + 'title' => 'Lihat laporan bulanan ' . monthId($monthNumber) ] - ) !!} + ) }} |
| Jumlah | +{{ trans('app.total') }} | {{ $reports->sum('count') }} | {{ formatRp($reports->sum('cashin')) }} | {{ formatRp($reports->sum('cashout')) }} | @@ -87,12 +76,12 @@ @endsection @section('ext_css') - {!! Html::style(url('assets/css/plugins/morris.css')) !!} + {{ Html::style(url('assets/css/plugins/morris.css')) }} @endsection @section('ext_js') - {!! Html::script(url('assets/js/plugins/morris/raphael.min.js')) !!} - {!! Html::script(url('assets/js/plugins/morris/morris.min.js')) !!} + {{ Html::script(url('assets/js/plugins/morris/raphael.min.js')) }} + {{ Html::script(url('assets/js/plugins/morris/morris.min.js')) }} @endsection @section('script') @@ -100,13 +89,14 @@ (function() { new Morris.Line({ element: 'yearly-chart', - data: {!! json_encode($cartData) !!}, + data: {!! collect($chartData)->toJson() !!}, xkey: 'month', ykeys: ['value'], - labels: ['Profit'], + labels: ['Profit Rp'], parseTime:false, goals: [0], goalLineColors : ['red'], + smooth: false, }); })(); diff --git a/tests/Unit/Models/PaymentTest.php b/tests/Unit/Models/PaymentTest.php index 0f9be49..ea596cd 100644 --- a/tests/Unit/Models/PaymentTest.php +++ b/tests/Unit/Models/PaymentTest.php @@ -14,29 +14,23 @@ class PaymentTest extends TestCase public function it_can_have_partner_relation_on_customer_model_for_income_payment() { $payment = factory(Payment::class)->create(); - $this->assertTrue( - $payment->partner instanceof Customer, - 'An income payment should have a App\Entities\Partners\Customer model as partner relation' - ); + $this->assertInstanceOf(Customer::class, $payment->partner); + + $payment = factory(Payment::class)->states('customer')->create(); + $this->assertInstanceOf(Customer::class, $payment->partner); } /** @test */ public function it_can_have_partner_relation_on_vendor_model_for_expanse_payment() { $payment = factory(Payment::class)->states('vendor')->create(); - $this->assertTrue( - $payment->partner instanceof Vendor, - 'An expanse payment can have a App\Entities\Partners\Vendor model as partner relation' - ); + $this->assertInstanceOf(Vendor::class, $payment->partner); } /** @test */ public function it_can_have_partner_relation_on_user_model_for_fee_payment() { $payment = factory(Payment::class)->states('fee')->create(); - $this->assertTrue( - $payment->partner instanceof User, - 'An expanse payment can have a App\Entities\Users\User model as partner relation' - ); + $this->assertInstanceOf(User::class, $payment->partner); } }|||||