Don’t show default tax rate until tax rates have been created

This commit is contained in:
Hillel Coren 2017-12-05 07:28:43 +02:00
parent 07f59f8076
commit 3a6b27ff9e
3 changed files with 28 additions and 1 deletions

View File

@ -389,7 +389,7 @@ class Client extends EntityModel
/** /**
* @return bool * @return bool
*/ */
public function hasAddress() public function hasAddress($shipping = false)
{ {
$fields = [ $fields = [
'address1', 'address1',
@ -401,6 +401,9 @@ class Client extends EntityModel
]; ];
foreach ($fields as $field) { foreach ($fields as $field) {
if ($shipping) {
$field = 'shipping_' . $field;
}
if ($this->$field) { if ($this->$field) {
return true; return true;
} }

View File

@ -2606,6 +2606,8 @@ $LANG = array(
'edit_times' => 'Edit Times', 'edit_times' => 'Edit Times',
'inclusive_taxes_help' => 'Include <b>taxes in the cost</b>', 'inclusive_taxes_help' => 'Include <b>taxes in the cost</b>',
'inclusive_taxes_warning' => 'Warning: existing invoices will need to be resaved', 'inclusive_taxes_warning' => 'Warning: existing invoices will need to be resaved',
'copy_shipping' => 'Copy Shipping',
'copy_billing' => 'Copy Billing',
); );

View File

@ -95,6 +95,14 @@
{!! Former::text('postal_code') !!} {!! Former::text('postal_code') !!}
{!! Former::select('country_id')->addOption('','') {!! Former::select('country_id')->addOption('','')
->fromQuery($countries, 'name', 'id') !!} ->fromQuery($countries, 'name', 'id') !!}
<div class="form-group" id="copyShippingDiv" style="display:none;">
<label for="city" class="control-label col-lg-4 col-sm-4"></label>
<div class="col-lg-8 col-sm-8">
{!! Button::normal(trans('texts.copy_shipping'))->small() !!}
</div>
</div>
</div> </div>
<div role="tabpanel" class="tab-pane" id="shipping_address"> <div role="tabpanel" class="tab-pane" id="shipping_address">
{!! Former::text('shipping_address1')->label('address1') !!} {!! Former::text('shipping_address1')->label('address1') !!}
@ -104,6 +112,13 @@
{!! Former::text('shipping_postal_code')->label('postal_code') !!} {!! Former::text('shipping_postal_code')->label('postal_code') !!}
{!! Former::select('shipping_country_id')->addOption('','') {!! Former::select('shipping_country_id')->addOption('','')
->fromQuery($countries, 'name', 'id')->label('country_id') !!} ->fromQuery($countries, 'name', 'id')->label('country_id') !!}
<div class="form-group" id="copyBillingDiv" style="display:none;">
<label for="city" class="control-label col-lg-4 col-sm-4"></label>
<div class="col-lg-8 col-sm-8">
{!! Button::normal(trans('texts.copy_billing'))->small() !!}
</div>
</div>
</div> </div>
</div> </div>
@ -290,6 +305,13 @@
$(function() { $(function() {
$('#country_id, #shipping_country_id').combobox(); $('#country_id, #shipping_country_id').combobox();
if ({{ $client->hasAddress() ? 'true' : 'false' }}) {
$('#copyBillingDiv').show();
}
if ({{ $client->hasAddress(true) ? 'true' : 'false' }}) {
$('#copyShippingDiv').show();
}
}); });
function ContactModel(data) { function ContactModel(data) {