Added 'apply credit' action

This commit is contained in:
Hillel Coren 2015-11-04 09:48:47 +02:00
parent 029e740a6c
commit 72c7cbb237
24 changed files with 81 additions and 40 deletions

View File

@ -4,6 +4,7 @@ use Datatable;
use Input;
use Redirect;
use Session;
use URL;
use Utils;
use View;
use Validator;
@ -67,7 +68,9 @@ class CreditController extends BaseController
<ul class="dropdown-menu" role="menu">';
if (!$model->deleted_at || $model->deleted_at == '0000-00-00') {
$str .= '<li><a href="javascript:archiveEntity('.$model->public_id.')">'.trans('texts.archive_credit').'</a></li>';
$str .= '<li><a href="'.URL::to('payments/create/'.$model->client_public_id).'?paymentTypeId=1">'.trans('texts.apply_credit').'</a></li>
<li class="divider"></li>
<li><a href="javascript:archiveEntity('.$model->public_id.')">'.trans('texts.archive_credit').'</a></li>';
} else {
$str .= '<li><a href="javascript:restoreEntity('.$model->public_id.')">'.trans('texts.restore_credit').'</a></li>';
}

View File

@ -118,6 +118,7 @@ class PaymentController extends BaseController
'url' => "payments",
'title' => trans('texts.new_payment'),
'paymentTypes' => Cache::get('paymentTypes'),
'paymentTypeId' => Input::get('paymentTypeId'),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
return View::make('payments.edit', $data);

View File

@ -29,6 +29,7 @@ class SaveInvoiceRequest extends Request
$rules = [
'client.contacts' => 'valid_contacts',
'invoice_items' => 'valid_invoice_items',
'invoice_number' => 'required|unique:invoices,invoice_number,'.$invoiceId.',id,account_id,'.Auth::user()->account_id,
'discount' => 'positive',
];

View File

@ -331,6 +331,7 @@ if (!defined('CONTACT_EMAIL')) {
define('MAX_NUM_CLIENTS', 100);
define('MAX_NUM_CLIENTS_PRO', 20000);
define('MAX_NUM_CLIENTS_LEGACY', 500);
define('MAX_INVOICE_AMOUNT', 10000000);
define('LEGACY_CUTOFF', 57800);
define('ERROR_DELAY', 3);

View File

@ -163,6 +163,15 @@ class AppServiceProvider extends ServiceProvider {
}
return true;
});
Validator::extend('valid_invoice_items', function($attribute, $value, $parameters) {
$total = 0;
foreach ($value as $item) {
$total += $item['qty'] * $item['cost'];
}
return $total <= MAX_INVOICE_AMOUNT;
});
}
/**

View File

@ -31627,6 +31627,7 @@ function GetPdfMake(invoice, javascript, callback) {
}
}
// only show the footer on the last page
if (key === 'footer') {
return function(page, pages) {
return page === pages ? val : '';
@ -31676,6 +31677,7 @@ function GetPdfMake(invoice, javascript, callback) {
doc.save = function(fileName) {
this.download(fileName);
};
return doc;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -78,6 +78,8 @@ return array(
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -76,6 +76,8 @@ return array(
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -891,5 +891,7 @@ return array(
'quote_footer' => 'Quote Footer',
'free' => 'Free',
'quote_is_approved' => 'This quote is approved',
'quote_is_approved' => 'This quote is approved',
'apply_credit' => 'Apply Credit',
);

View File

@ -72,9 +72,10 @@ return array(
"positive" => "The :attribute must be greater than zero.",
"has_credit" => "The client does not have enough credit.",
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => 'All of the contacts must have either an email or name',
"less_than" => "The :attribute must be less than :value",
"has_counter" => "The value must contain {\$counter}",
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -75,6 +75,8 @@ return array(
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -75,6 +75,8 @@ return array(
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -76,6 +76,8 @@ return array(
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -76,6 +76,8 @@ return array(
"notmasked" => "Les valeurs sont masquées",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -75,6 +75,8 @@ return array(
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -74,6 +74,8 @@ return array(
"notmasked" => "Verdiene er skjult",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -76,6 +76,8 @@ return array(
"notmasked" => "De waarden zijn verborgen",
"less_than" => 'Het :attribute moet minder zijn dan :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -74,6 +74,8 @@ return array(
"notmasked" => "Os valores são mascarados",
"less_than" => ':attribute deve ser menor que :value',
"has_counter" => 'O valor deve conter {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -78,6 +78,8 @@ return [
"notmasked" => "The values are masked",
"less_than" => 'The :attribute must be less than :value',
"has_counter" => 'The value must contain {$counter}',
"valid_contacts" => "All of the contacts must have either an email or name",
"valid_invoice_items" => "The invoice exceeds the maximum amount",
/*
|--------------------------------------------------------------------------

View File

@ -15,6 +15,10 @@
@stop
@section('content')
@if ($errors->first('invoice_items'))
<div class="alert alert-danger">{{ trans($errors->first('invoice_items')) }}</div>
@endif
@if ($invoice->id)
<ol class="breadcrumb">
@if ($invoice->is_recurring)
@ -204,7 +208,7 @@
<input type="text" data-bind="value: tax().name, attr: {name: 'invoice_items[' + $index() + '][tax_name]'}" style="display:none">
<input type="text" data-bind="value: tax().rate, attr: {name: 'invoice_items[' + $index() + '][tax_rate]'}" style="display:none">
</td>
<td style="text-align:right;padding-top:9px !important">
<td style="text-align:right;padding-top:9px !important" nowrap>
<div class="line-total" data-bind="text: totals.total"></div>
</td>
<td style="cursor:pointer" class="hide-border td-icon">

View File

@ -26,6 +26,10 @@
{!! Former::select('client')->addOption('', '')->addGroupClass('client-select') !!}
{!! Former::select('invoice')->addOption('', '')->addGroupClass('invoice-select') !!}
{!! Former::text('amount') !!}
@if (isset($paymentTypeId) && $paymentTypeId)
{!! Former::populateField('payment_type_id', $paymentTypeId) !!}
@endif
@endif
@if (!$payment || !$payment->account_gateway_id)