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

Task 125 #759

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions Core/Controller/EditImpuesto.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,13 @@ public function getPageData()

return $pagedata;
}

/**
* Load views
*/
protected function createViews()
{
parent::createViews();
$this->addListView('ListImpuestoZona', 'ImpuestoZona', 'zone-tax', 'fas fa-percent');
}
}
23 changes: 17 additions & 6 deletions Core/Model/Almacen.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ class Almacen extends Base\Address
*/
public $telefono;

/**
* Removed warehouse from database.
*
* @return bool
*/
public function delete()
{
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-warehouse'));
return false;
}

return parent::delete();
}

/**
*
* @return string
Expand All @@ -72,7 +87,7 @@ public function install()
}

/**
* Returns True if is the default wharehouse for the company.
* Returns True if this is the default wharehouse.
*
* @return bool
*/
Expand Down Expand Up @@ -121,10 +136,6 @@ public function test()
$this->nombre = Utils::noHtml($this->nombre);
$this->telefono = Utils::noHtml($this->telefono);

if (empty($this->codalmacen)) {
return false;
}

return parent::test();
return empty($this->codalmacen) ? false : parent::test();
}
}
19 changes: 17 additions & 2 deletions Core/Model/Divisa.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2013-2018 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2013-2019 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand Down Expand Up @@ -86,7 +86,22 @@ public function clear()
}

/**
* Returns True if is the default currency for the company.
* Removed currency from database.
*
* @return bool
*/
public function delete()
{
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-currency'));
return false;
}

return parent::delete();
}

/**
* Returns True if this is the default currency.
*
* @return bool
*/
Expand Down
15 changes: 13 additions & 2 deletions Core/Model/Empresa.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ public function clear()
}

/**
* Removes company from database.
*
* @return bool
*/
public function delete()
{
if ($this->idempresa == AppSettings::get('default', 'idempresa')) {
self::$miniLog->alert('you-cant-not-remove-default-company');
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-company'));
return false;
}

Expand All @@ -171,6 +172,16 @@ public function install()
. "'" . self::$regimenIVA->defaultValue() . "');";
}

/**
* Returns True if this is the default company.
*
* @return bool
*/
public function isDefault()
{
return $this->idempresa === (int) AppSettings::get('default', 'idempresa');
}

/**
* Returns the name of the column that is the model's primary key.
*
Expand Down
26 changes: 26 additions & 0 deletions Core/Model/FormaPago.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
namespace FacturaScripts\Core\Model;

use FacturaScripts\Core\App\AppSettings;
use FacturaScripts\Core\Base\Utils;

/**
Expand Down Expand Up @@ -107,6 +108,21 @@ public function clear()
$this->tipovencimiento = 'days';
}

/**
* Removes payment method from database.
*
* @return bool
*/
public function delete()
{
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-payment-method'));
return false;
}

return parent::delete();
}

/**
*
* @return string
Expand All @@ -119,6 +135,16 @@ public function install()
return parent::install();
}

/**
* Returns True if this is the default payment method.
*
* @return bool
*/
public function isDefault()
{
return $this->codpago === AppSettings::get('default', 'codpago');
}

/**
* Returns the name of the column that is the primary key of the model.
*
Expand Down
19 changes: 17 additions & 2 deletions Core/Model/Impuesto.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2013-2018 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2013-2019 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand Down Expand Up @@ -83,7 +83,22 @@ public function clear()
}

/**
* Returns True if is the default tax for the user.
* Removes tax from database.
*
* @return bool
*/
public function delete()
{
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-tax'));
return false;
}

return parent::delete();
}

/**
* Returns True if this is the default tax.
*
* @return bool
*/
Expand Down
19 changes: 17 additions & 2 deletions Core/Model/Pais.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* This file is part of FacturaScripts
* Copyright (C) 2013-2019 Carlos Garcia Gomez <carlos@facturascripts.com>
* Copyright (C) 2013-2019 Carlos Garcia Gomez <carlos@facturascripts.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Expand Down Expand Up @@ -55,7 +55,22 @@ class Pais extends Base\ModelClass
public $nombre;

/**
* Returns True if the country is the default of the company.
* Removed country from database.
*
* @return bool
*/
public function delete()
{
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-country'));
return false;
}

return parent::delete();
}

/**
* Returns True if this the default country.
*
* @return bool
*/
Expand Down
17 changes: 16 additions & 1 deletion Core/Model/Serie.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ public function clear()
$this->siniva = false;
}

/**
* Removed payment method from database.
*
* @return bool
*/
public function delete()
{
if ($this->isDefault()) {
self::$miniLog->alert(self::$i18n->trans('cant-delete-default-serie'));
return false;
}

return parent::delete();
}

/**
*
* @return string
Expand All @@ -87,7 +102,7 @@ public function install()
}

/**
* Returns True if is the default serie for the company.
* Returns True if this is the default serie.
*
* @return bool
*/
Expand Down