Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency code settings #64

Merged
merged 2 commits into from
May 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Http/Controllers/Auth/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function update(Request $request)
'name' => 'required|max:60',
'email' => 'required|max:255|unique:users,email,'.auth()->id(),
'account_start_date' => 'nullable|date',
'currency_code' => 'required|string|max:3',
]);

auth()->user()->update($userData);
Expand Down
2 changes: 1 addition & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'api_token', 'account_start_date',
'name', 'email', 'password', 'api_token', 'account_start_date', 'currency_code',
];

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddCurrencyCodeOnUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('currency_code', 3)->default('IDR')->after('account_start_date');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['currency_code']);
});
}
}
1 change: 1 addition & 0 deletions resources/lang/en/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'is_active' => 'User Status',
'registered_at' => 'Registered at',
'account_start_date' => 'Account Start Date',
'currency_code' => 'Currency Code',

// Relations
'groups' => 'Member List',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/id/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'is_active' => 'Status User',
'registered_at' => 'Terdaftar sejak',
'account_start_date' => 'Akun Mulai Digunakan',
'currency_code' => 'Kode Mata Uang',

// Relations
'groups' => 'List Member',
Expand Down
1 change: 1 addition & 0 deletions resources/views/auth/profile/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{!! FormField::text('name', ['required' => true, 'label' => __('user.name')]) !!}
{!! FormField::email('email', ['required' => true, 'label' => __('user.email')]) !!}
{!! FormField::text('account_start_date', ['label' => __('user.account_start_date')]) !!}
{!! FormField::text('currency_code', ['label' => __('user.currency_code')]) !!}
</div>
<div class="panel-footer">
{{ Form::submit(__('user.profile_update'), ['class' => 'btn btn-success']) }}
Expand Down
1 change: 1 addition & 0 deletions resources/views/auth/profile/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<tr><td>{{ __('user.name') }}</td><td>{{ $user->name }}</td></tr>
<tr><td>{{ __('user.email') }}</td><td>{{ $user->email }}</td></tr>
<tr><td>{{ __('user.account_start_date') }}</td><td>{{ $user->account_start_date }}</td></tr>
<tr><td>{{ __('user.currency_code') }}</td><td>{{ $user->currency_code }}</td></tr>
</tbody>
</table>
<div class="panel-footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="col-md-4">
<div class="form-group required {{ $errors->has('amount') ? 'has-error' : '' }}">
<label for="amount" class="control-label">{{ __('transaction.amount') }}</label>
<div class="input-group"><span class="input-group-addon">Rp</span>
<div class="input-group"><span class="input-group-addon">{{ auth()->user()->currency_code }}</span>
<input class="form-control text-right" name="amount" type="number" id="amount" min="0" value="{{ isset($editableTransaction) ? round($editableTransaction->amount, 0) : old('amount') }}" required>
</div>
{!! $errors->first('amount', '<span class="help-block small">:message</span>') !!}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="col-md-4">
<div class="form-group required {{ $errors->has('amount') ? 'has-error' : '' }}">
<label for="amount" class="control-label">{{ __('transaction.amount') }}</label>
<div class="input-group"><span class="input-group-addon">Rp</span>
<div class="input-group"><span class="input-group-addon">{{ auth()->user()->currency_code }}</span>
<input class="form-control text-right" name="amount" type="number" id="amount" min="0" value="{{ isset($editableTransaction) ? round($editableTransaction->amount, 0) : old('amount') }}" required>
</div>
{!! $errors->first('amount', '<span class="help-block small">:message</span>') !!}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/reports/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('report.graph') }} {{ $year }}</h3></div>
<div class="panel-body">
<strong>{{ 'Rp' }}</strong>
<strong>{{ auth()->user()->currency_code }}</strong>
<div id="yearly-chart" style="height: 250px;"></div>
<div class="text-center"><strong>{{ __('time.month') }}</strong></div>
</div>
Expand Down Expand Up @@ -94,7 +94,7 @@
data: {!! collect($chartData)->toJson() !!},
xkey: 'month',
ykeys: ['income', 'spending', 'difference'],
labels: ["{{ __('transaction.income') }} {{ 'Rp' }}", "{{ __('transaction.spending') }} {{ 'Rp' }}", "{{ __('transaction.difference') }} {{ 'Rp' }}"],
labels: ["{{ __('transaction.income') }} {{ auth()->user()->currency_code }}", "{{ __('transaction.spending') }} {{ auth()->user()->currency_code }}", "{{ __('transaction.difference') }} {{ auth()->user()->currency_code }}"],
parseTime:false,
lineColors: ['green', 'orange', 'blue'],
goals: [0],
Expand Down
6 changes: 3 additions & 3 deletions resources/views/transactions/forms.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="col-md-6">
<div class="form-group required {{ $errors->has('amount') ? 'has-error' : '' }}">
<label for="amount" class="control-label">{{ __('transaction.amount') }}</label>
<div class="input-group"><span class="input-group-addon">Rp</span>
<div class="input-group"><span class="input-group-addon">{{ auth()->user()->currency_code }}</span>
<input class="form-control text-right" name="amount" type="number" id="amount" min="0" value="{{ old('amount') }}" required>
</div>
{!! $errors->first('amount', '<span class="help-block small">:message</span>') !!}
Expand Down Expand Up @@ -59,7 +59,7 @@
<div class="col-md-6">
<div class="form-group required {{ $errors->has('amount') ? 'has-error' : '' }}">
<label for="amount" class="control-label">{{ __('transaction.amount') }}</label>
<div class="input-group"><span class="input-group-addon">Rp</span>
<div class="input-group"><span class="input-group-addon">{{ auth()->user()->currency_code }}</span>
<input class="form-control text-right" name="amount" type="number" id="amount" min="0" value="{{ old('amount') }}" required>
</div>
@if ($errors->has('amount'))
Expand Down Expand Up @@ -102,7 +102,7 @@
<div class="col-md-4">
<div class="form-group required {{ $errors->has('amount') ? 'has-error' : '' }}">
<label for="amount" class="control-label">{{ __('transaction.amount') }}</label>
<div class="input-group"><span class="input-group-addon">Rp</span>
<div class="input-group"><span class="input-group-addon">{{ auth()->user()->currency_code }}</span>
<input class="form-control text-right" name="amount" type="number" id="amount" min="0" value="{{ isset($editableTransaction) ? round($editableTransaction->amount, 0) : old('amount') }}" required>
</div>
@if ($errors->has('amount'))
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/Auth/UserProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,20 @@ public function user_can_update_their_profile_data()
'name' => 'User Baru',
'email' => '[email protected]',
'account_start_date' => '2016-06-01',
'currency_code' => 'USD',
]);

$this->seeRouteIs('profile.show');
$this->seeText(__('user.profile_updated'));
$this->seeText('User Baru');
$this->seeText('USD');

$this->seeInDatabase('users', [
'id' => $user->id,
'name' => 'User Baru',
'email' => '[email protected]',
'account_start_date' => '2016-06-01',
'currency_code' => 'USD',
]);
}
}