Skip to content

Commit

Permalink
Merge pull request #317 from cuneytsenturk/1.2-dev
Browse files Browse the repository at this point in the history
Invoice & Bill add discount style change
  • Loading branch information
cuneytsenturk committed Apr 28, 2018
2 parents ac9cd85 + 34c869b commit 4c60f56
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 24 deletions.
6 changes: 6 additions & 0 deletions app/Http/Controllers/Items/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,16 @@ public function totalItem()

$json->sub_total = money($sub_total, $currency_code, true)->format();

$json->discount_text= trans('invoices.add_discount');
$json->discount_total = '';

$json->tax_total = money($tax_total, $currency_code, true)->format();

// Apply discount to total
if ($discount) {
$json->discount_text= trans('invoices.show_discount', ['discount' => $discount]);
$json->discount_total = money($sub_total * ($discount / 100), $currency_code, true)->format();

$sub_total = $sub_total - ($sub_total * ($discount / 100));
}

Expand Down
11 changes: 8 additions & 3 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,12 @@ input[type="number"] {
width: 10%;
}

.input-group-recurring {
padding-left: 0;
padding-right: 0;
.popover-content, .discount.box-body, .discount.box-footer {
padding-left: 0 !important;
padding-right: 0 !important;
}

.discount-description {
margin-top: 6px;
margin-left: -20px;
}
4 changes: 4 additions & 0 deletions resources/lang/en-GB/bills.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

'item_name' => 'Item Name|Item Names',

'show_discount' => ':discount % Discount',
'add_discount' => 'Add Discount',
'discount_desc' => 'of subtotal',

'payment_due' => 'Payment Due',
'amount_due' => 'Amount Due',
'paid' => 'Paid',
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en-GB/invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

'item_name' => 'Item Name|Item Names',

'show_discount' => ':discount % Discount',
'add_discount' => 'Add Discount',
'discount_desc' => 'of subtotal',

'payment_due' => 'Payment Due',
'paid' => 'Paid',
'histories' => 'Histories',
Expand Down
65 changes: 60 additions & 5 deletions resources/views/expenses/bills/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
<td class="text-right"><span id="sub-total">0</span></td>
</tr>
<tr>
<td class="text-right" style="vertical-align: middle;" colspan="5"><strong>{{ trans('bills.discount') }}</strong></td>
<td class="text-right" style="vertical-align: middle;" colspan="5">
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('bills.add_discount') }}</a>
</td>
<td class="text-right">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-percent"></i></div>
{!! Form::number('discount', null, ['class' => 'form-control text-right']) !!}
</div>
<span id="discount-total"></span>
{!! Form::hidden('discount', null, ['id' => 'discount', 'class' => 'form-control text-right']) !!}
</td>
</tr>
<tr>
Expand Down Expand Up @@ -256,6 +256,58 @@ function addItem() {
});
});
$('a[rel=popover]').popover({
html: 'true',
placement: 'bottom',
title: '{{ trans('bills.discount') }}',
content: function () {
html = '<div class="discount box-body">';
html += ' <div class="col-md-6">';
html += ' <div class="input-group" id="input-discount">';
html += ' {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}';
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
html += ' </div>';
html += ' </div>';
html += ' <div class="col-md-6">';
html += ' <div class="discount-description">';
html += ' {{ trans('bills.discount_desc') }}';
html += ' </div>';
html += ' </div>';
html += '</div>';
html += '<div class="discount box-footer">';
html += ' <div class="col-md-12">';
html += ' <div class="form-group no-margin">';
html += ' {!! Form::button('<span class="fa fa-save"></span> &nbsp;' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount','class' => 'btn btn-success']) !!}';
html += ' <a href="javascript:void(0)" id="cancel-discount" class="btn btn-default"><span class="fa fa-times-circle"></span> &nbsp;{{ trans('general.cancel') }}</a>';
html += ' </div>';
html += ' </div>';
html += '</div>';
return html;
}
});
$(document).on('keyup', '#pre-discount', function(e){
e.preventDefault();
$('#discount').val($(this).val());
totalItem();
});
$(document).on('click', '#save-discount', function(){
$('a[rel=popover]').trigger('click');
});
$(document).on('click', '#cancel-discount', function(){
$('#discount').val('');
totalItem();
$('a[rel=popover]').trigger('click');
});
$(document).on('change', '#currency_code, #items tbody select', function(){
totalItem();
});
Expand Down Expand Up @@ -293,7 +345,10 @@ function totalItem() {
$('#item-total-' + key).html(value);
});
$('#discount-text').text(data.discount_text);
$('#sub-total').html(data.sub_total);
$('#discount-total').html(data.discount_total);
$('#tax-total').html(data.tax_total);
$('#grand-total').html(data.grand_total);
}
Expand Down
66 changes: 61 additions & 5 deletions resources/views/expenses/bills/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@
<td class="text-right"><span id="sub-total">0</span></td>
</tr>
<tr>
<td class="text-right" style="vertical-align: middle;" colspan="5"><strong>{{ trans('bills.discount') }}</strong></td>
<td class="text-right" style="vertical-align: middle;" colspan="5">
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('bills.add_discount') }}</a>
</td>
<td class="text-right">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-percent"></i></div>
{!! Form::number('discount', $bill->discount, ['class' => 'form-control text-right']) !!}
</div>
<span id="discount-total"></span>
{!! Form::hidden('discount', null, ['id' => 'discount', 'class' => 'form-control text-right']) !!}
</td>
</tr>
<tr>
Expand Down Expand Up @@ -289,6 +289,59 @@ function addItem() {
});
});
$('a[rel=popover]').popover({
html: 'true',
placement: 'bottom',
title: '{{ trans('bills.discount') }}',
content: function () {
html = '<div class="discount box-body">';
html += ' <div class="col-md-6">';
html += ' <div class="input-group" id="input-discount">';
html += ' {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}';
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
html += ' </div>';
html += ' </div>';
html += ' <div class="col-md-6">';
html += ' <div class="discount-description">';
html += ' {{ trans('bills.discount_desc') }}';
html += ' </div>';
html += ' </div>';
html += '</div>';
html += '<div class="discount box-footer">';
html += ' <div class="col-md-12">';
html += ' <div class="form-group no-margin">';
html += ' {!! Form::button('<span class="fa fa-save"></span> &nbsp;' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount','class' => 'btn btn-success']) !!}';
html += ' <a href="javascript:void(0)" id="cancel-discount" class="btn btn-default"><span class="fa fa-times-circle"></span> &nbsp;{{ trans('general.cancel') }}</a>';
html += ' </div>';
html += ' </div>';
html += '</div>';
return html;
}
});
$(document).on('keyup', '#pre-discount', function(e){
e.preventDefault();
$('#discount').val($(this).val());
totalItem();
});
$(document).on('click', '#save-discount', function(){
$('a[rel=popover]').trigger('click');
});
$(document).on('click', '#cancel-discount', function(){
$('#discount').val('');
totalItem();
$('a[rel=popover]').trigger('click');
});
$(document).on('change', '#currency_code, #items tbody select', function(){
totalItem();
});
Expand Down Expand Up @@ -326,7 +379,10 @@ function totalItem() {
$('#item-total-' + key).html(value);
});
$('#discount-text').text(data.discount_text);
$('#sub-total').html(data.sub_total);
$('#discount-total').html(data.discount_total);
$('#tax-total').html(data.tax_total);
$('#grand-total').html(data.grand_total);
}
Expand Down
63 changes: 57 additions & 6 deletions resources/views/incomes/invoices/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
<td class="text-right"><span id="sub-total">0</span></td>
</tr>
<tr>
<td class="text-right" style="vertical-align: middle;" colspan="5"><strong>{{ trans('invoices.discount') }}</strong></td>
<td class="text-right" style="vertical-align: middle;" colspan="5">
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('invoices.add_discount') }}</a>
</td>
<td class="text-right">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-percent"></i></div>
{!! Form::number('discount', null, ['class' => 'form-control text-right']) !!}
</div>
<span id="discount-total"></span>
{!! Form::hidden('discount', null, ['id' => 'discount', 'class' => 'form-control text-right']) !!}
</td>
</tr>
<tr>
Expand Down Expand Up @@ -257,8 +257,56 @@ function addItem() {
});
});
$(document).on('change', '#currency_code, #items tbody select', function(){
$('a[rel=popover]').popover({
html: 'true',
placement: 'bottom',
title: '{{ trans('invoices.discount') }}',
content: function () {
html = '<div class="discount box-body">';
html += ' <div class="col-md-6">';
html += ' <div class="input-group" id="input-discount">';
html += ' {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}';
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
html += ' </div>';
html += ' </div>';
html += ' <div class="col-md-6">';
html += ' <div class="discount-description">';
html += ' {{ trans('invoices.discount_desc') }}';
html += ' </div>';
html += ' </div>';
html += '</div>';
html += '<div class="discount box-footer">';
html += ' <div class="col-md-12">';
html += ' <div class="form-group no-margin">';
html += ' {!! Form::button('<span class="fa fa-save"></span> &nbsp;' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount','class' => 'btn btn-success']) !!}';
html += ' <a href="javascript:void(0)" id="cancel-discount" class="btn btn-default"><span class="fa fa-times-circle"></span> &nbsp;{{ trans('general.cancel') }}</a>';
html += ' </div>';
html += ' </div>';
html += '</div>';
return html;
}
});
$(document).on('keyup', '#pre-discount', function(e){
e.preventDefault();
$('#discount').val($(this).val());
totalItem();
});
$(document).on('click', '#save-discount', function(){
$('a[rel=popover]').trigger('click');
});
$(document).on('click', '#cancel-discount', function(){
$('#discount').val('');
totalItem();
$('a[rel=popover]').trigger('click');
});
$(document).on('keyup', '#items tbody .form-control', function(){
Expand Down Expand Up @@ -294,7 +342,10 @@ function totalItem() {
$('#item-total-' + key).html(value);
});
$('#discount-text').text(data.discount_text);
$('#sub-total').html(data.sub_total);
$('#discount-total').html(data.discount_total);
$('#tax-total').html(data.tax_total);
$('#grand-total').html(data.grand_total);
}
Expand Down

0 comments on commit 4c60f56

Please sign in to comment.