diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 4e3e88fb9558..881542cf0758 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -227,7 +227,7 @@ class CreateSingleAccount extends Command $settings = $client->settings; $settings->currency_id = "1"; - $settings->use_credits_payment = "always"; +// $settings->use_credits_payment = "always"; $client->settings = $settings; diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index ff940e422d0b..3aadd6cea67f 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -258,8 +258,10 @@ class CompanySettings extends BaseSettings public $client_portal_allow_over_payment = false; //@implemented public $use_credits_payment = 'off'; //always, option, off //@implemented + public $hide_empty_columns_on_pdf = false; public static $casts = [ + 'hide_empty_columns_on_pdf' => 'bool', 'enable_reminder_endless' => 'bool', 'use_credits_payment' => 'string', 'recurring_invoice_number_pattern' => 'string', diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 92ade15daf0b..96d1e6157937 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -151,7 +151,7 @@ class InvoiceItemSum $key = str_replace(' ', '', $tax_name.$tax_rate); - $group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name.' '.$tax_rate.'%']; + $group_tax = ['key' => $key, 'total' => $tax_total, 'tax_name' => $tax_name.' '.floatval($tax_rate).'%']; $this->tax_collection->push(collect($group_tax)); } diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 07ef2ab6fe7f..badd39f055ac 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -111,19 +111,19 @@ class InvoiceSum if ($this->invoice->tax_rate1 > 0) { $tax = $this->taxer($this->total, $this->invoice->tax_rate1); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.$this->invoice->tax_rate1.'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.floatval($this->invoice->tax_rate1).'%', 'total' => $tax]; } if ($this->invoice->tax_rate2 > 0) { $tax = $this->taxer($this->total, $this->invoice->tax_rate2); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.$this->invoice->tax_rate2.'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.floatval($this->invoice->tax_rate2).'%', 'total' => $tax]; } if ($this->invoice->tax_rate3 > 0) { $tax = $this->taxer($this->total, $this->invoice->tax_rate3); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.$this->invoice->tax_rate3.'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax]; } return $this; diff --git a/app/Helpers/Invoice/InvoiceSumInclusive.php b/app/Helpers/Invoice/InvoiceSumInclusive.php index 5bd51e400216..a3b77684e4ab 100644 --- a/app/Helpers/Invoice/InvoiceSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceSumInclusive.php @@ -122,19 +122,19 @@ class InvoiceSumInclusive $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.$this->invoice->tax_rate1.'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.floatval($this->invoice->tax_rate1).'%', 'total' => $tax]; } if ($this->invoice->tax_rate2 > 0) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.$this->invoice->tax_rate2.'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.floatval($this->invoice->tax_rate2).'%', 'total' => $tax]; } if ($this->invoice->tax_rate3 > 0) { $tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount); $this->total_taxes += $tax; - $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.$this->invoice->tax_rate3.'%', 'total' => $tax]; + $this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax]; } return $this; diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index ecf65659aa07..4ac2e8d4ba35 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -205,6 +205,9 @@ class PaymentController extends Controller $credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'off' ? 0 : $first_invoice->client->service()->getCreditBalance(); $starting_invoice_amount = $first_invoice->amount; +nlog($credit_totals); +nlog($first_invoice->client->getSetting('use_credits_payment')); + if ($gateway) { $first_invoice->service()->addGatewayFee($gateway, $payment_method_id, $invoice_totals)->save(); } diff --git a/app/Models/Company.php b/app/Models/Company.php index f13ec767538a..575d92138a62 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -45,7 +45,6 @@ class Company extends BaseModel protected $presenter = CompanyPresenter::class; protected $fillable = [ - 'hide_empty_columns_on_pdf', 'calculate_expense_tax_by_amount', 'invoice_expense_documents', 'invoice_task_documents', @@ -378,6 +377,11 @@ class Company extends BaseModel return $this->hasMany(SystemLog::class)->orderBy('id', 'DESC')->take(50); } + public function system_log_relation() + { + return $this->hasMany(SystemLog::class)->orderBy('id', 'DESC'); + } + public function tokens_hashed() { return $this->hasMany(CompanyToken::class); diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 5284485a0e60..93c376f786c4 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -11,6 +11,7 @@ namespace App\Models; +use App\Models\GatewayType; use App\PaymentDrivers\BasePaymentDriver; use App\Utils\Number; use Illuminate\Database\Eloquent\SoftDeletes; @@ -58,10 +59,12 @@ class CompanyGateway extends BaseModel 16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover'], ]; - // public function getFeesAndLimitsAttribute() - // { - // return json_decode($this->attributes['fees_and_limits']); - // } + public $gateway_consts = [ + '38f2c48af60c7dd69e04248cbb24c36e' => 300, + 'd14dd26a37cecc30fdd65700bfb55b23' => 301, + '3758e7f7c6f4cecf0f4f348b9a00f456' => 304, + '3b6621f970ab18887c4f6dca78d3f8bb' => 305, + ]; protected $touches = []; @@ -70,6 +73,15 @@ class CompanyGateway extends BaseModel return self::class; } + public function system_logs() + { + + return $this->company + ->system_log_relation + ->where('type_id', $this->gateway_consts[$this->gateway->key]) + ->take(50); + } + public function company() { return $this->belongsTo(Company::class); diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index 085797d2a04c..9a18837687ec 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -161,8 +161,6 @@ class PayPalExpressPaymentDriver extends BaseDriver $data = $response->getData(); - nlog($data); - PaymentFailureMailer::dispatch($this->client, $response->getMessage(), $this->client->company, $this->payment_hash->data->amount); $message = [ diff --git a/app/Transformers/CompanyGatewayTransformer.php b/app/Transformers/CompanyGatewayTransformer.php index 2b03ebc4111c..6e5e0bd029f4 100644 --- a/app/Transformers/CompanyGatewayTransformer.php +++ b/app/Transformers/CompanyGatewayTransformer.php @@ -12,6 +12,8 @@ namespace App\Transformers; use App\Models\CompanyGateway; +use App\Models\SystemLog; +use App\Transformers\SystemLogTransformer; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\SoftDeletes; use stdClass; @@ -33,6 +35,7 @@ class CompanyGatewayTransformer extends EntityTransformer * @var array */ protected $availableIncludes = [ + 'system_logs', 'gateway', ]; @@ -81,4 +84,11 @@ class CompanyGatewayTransformer extends EntityTransformer return $this->includeItem($company_gateway->gateway, $transformer, Gateway::class); } + + public function includeSystemLogs(CompanyGateway $company_gateway) + { + $transformer = new SystemLogTransformer($this->serializer); + + return $this->includeCollection($company_gateway->system_logs(), $transformer, SystemLog::class); + } } diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index d194d71ef3f4..86c08e2bad2c 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -149,7 +149,7 @@ class CompanyTransformer extends EntityTransformer 'default_task_is_date_based' => (bool)$company->default_task_is_date_based, 'enable_product_discount' => (bool)$company->enable_product_discount, 'calculate_expense_tax_by_amount' =>(bool)$company->calculate_expense_tax_by_amount, - 'hide_empty_columns_on_pdf' => (bool) $company->hide_empty_columns_on_pdf, + 'hide_empty_columns_on_pdf' => false, //@deprecate ]; } diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 1d61c3fb7d6a..76fae1e5e15a 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -604,7 +604,7 @@ trait MakesInvoiceValues if ($item->is_amount_discount) { $data[$key][$table_type.'.discount'] = Number::formatMoney($item->discount, $this->client); } else { - $data[$key][$table_type.'.discount'] = $item->discount.'%'; + $data[$key][$table_type.'.discount'] = floatval($item->discount).'%'; } } else { $data[$key][$table_type.'.discount'] = ''; diff --git a/database/migrations/2021_01_05_013203_improve_decimal_resolution.php b/database/migrations/2021_01_05_013203_improve_decimal_resolution.php index aa04b64e7e6b..72cccfd524dd 100644 --- a/database/migrations/2021_01_05_013203_improve_decimal_resolution.php +++ b/database/migrations/2021_01_05_013203_improve_decimal_resolution.php @@ -144,6 +144,9 @@ class ImproveDecimalResolution extends Migration $table->integer('status_order')->nullable(); }); + Schema::table('companies', function (Blueprint $table) { + $table->dropColumn('hide_empty_columns_on_pdf'); + }); } /**