Merge pull request #8563 from turbo124/v5-develop

minor fixes
This commit is contained in:
David Bomba 2023-06-18 05:29:42 +00:00 committed by GitHub
commit 2f97fa36fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 31 additions and 148 deletions

View File

@ -77,7 +77,6 @@ class EntityFailedSendObject
private function setTemplate()
{
// nlog($this->template);
switch ($this->template) {
case 'invoice':

View File

@ -104,7 +104,6 @@ class EntitySentObject
private function setTemplate()
{
// nlog($this->template);
switch ($this->template) {
case 'invoice':

View File

@ -527,11 +527,11 @@ class Account extends BaseModel
public function emailsSent()
{
if (is_null(Cache::get($this->key))) {
if (is_null(Cache::get("email_quota".$this->key))) {
return 0;
}
return Cache::get($this->key);
return Cache::get("email_quota".$this->key);
}
public function emailQuotaExceeded() :bool

View File

@ -45,6 +45,9 @@ use Illuminate\Support\Str;
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel count()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel create()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel insert()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereHas()
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel withTrashed()
*
* @method \App\Models\Company company()
* @method int companyId()
* @method Builder|static exclude($columns)

View File

@ -46,8 +46,8 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $email
* @property string|null $email_verified_at
* @property string|null $confirmation_code
* @property int $is_primary
* @property int $confirmed
* @property bool $is_primary
* @property bool $confirmed
* @property int|null $last_login
* @property int|null $failed_logins
* @property string|null $oauth_user_id
@ -59,8 +59,8 @@ use Laracasts\Presenter\PresentableTrait;
* @property string|null $avatar_size
* @property string $password
* @property string|null $token
* @property int $is_locked
* @property int $send_email
* @property bool $is_locked
* @property bool $send_email
* @property string|null $contact_key
* @property string|null $remember_token
* @property int|null $created_at

View File

@ -103,9 +103,9 @@ use Laracasts\Presenter\PresentableTrait;
* @property-read mixed $valid_until
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read int|null $history_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read int|null $invitations_count
* @property-read \App\Models\Invoice|null $invoice
* @property-read \App\Models\QuoteInvitation|null $invitations
* @property-read \App\Models\Project|null $project
* @property-read \App\Models\User $user
* @property-read \App\Models\Vendor|null $vendor
@ -185,50 +185,6 @@ use Laracasts\Presenter\PresentableTrait;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\QuoteInvitation> $invitations
* @mixin \Eloquent
*/
class Quote extends BaseModel

View File

@ -319,73 +319,6 @@ class Design extends BaseDesign
return $elements;
}
//@deprecated
// public function entityDetailsx(): array
// {
// if ($this->type === 'statement') {
// $s_date = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale()) . " - " . $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale());
// return [
// ['element' => 'p', 'content' => "<h2>".ctrans('texts.statement')."</h2>", 'properties' => ['data-ref' => 'statement-label']],
// ['element' => 'p', 'content' => ctrans('texts.statement_date'), 'properties' => ['data-ref' => 'statement-label'],'elements' =>
// ['element' => 'span', 'content' => "{$s_date} "]
// ],
// ['element' => 'p', 'content' => '$balance_due_label', 'properties' => ['data-ref' => 'statement-label'],'elements' =>
// ['element' => 'span', 'content' => Number::formatMoney($this->invoices->sum('balance'), $this->client)]
// ],
// ];
// }
// $variables = $this->context['pdf_variables']['invoice_details'];
// if ($this->entity instanceof Quote) {
// $variables = $this->context['pdf_variables']['quote_details'];
// if ($this->entity->partial > 0) {
// $variables[] = '$quote.balance_due';
// }
// }
// if ($this->entity instanceof Credit) {
// $variables = $this->context['pdf_variables']['credit_details'];
// }
// if ($this->vendor) {
// $variables = $this->context['pdf_variables']['purchase_order_details'];
// }
// $elements = [];
// // We don't want to show account balance or invoice total on PDF.. or any amount with currency.
// if ($this->type == self::DELIVERY_NOTE) {
// $variables = array_filter($variables, function ($m) {
// return !in_array($m, ['$invoice.balance_due', '$invoice.total']);
// });
// }
// foreach ($variables as $variable) {
// $_variable = explode('.', $variable)[1];
// $_customs = ['custom1', 'custom2', 'custom3', 'custom4'];
// /* 2/7/2022 don't show custom values if they are empty */
// $var = str_replace("custom", "custom_value", $_variable);
// if (in_array($_variable, $_customs) && !empty($this->entity->{$var})) {
// $elements[] = ['element' => 'div', 'properties' => ['style' => "display: table-row; visibility: {$this->entityVariableCheck($_variable)};"],'elements' => [
// ['element' => 'div', 'content' => $variable . '_label', 'properties' => ['class' => 'entity-details-cell', 'data-ref' => 'entity_details-' . substr($variable, 1) . '_label']],
// ['element' => 'div', 'content' => $variable, 'properties' => ['class' => 'entity-details-cell', 'data-ref' => 'entity_details-' . substr($variable, 1)]],
// ]];
// } else {
// $elements[] = ['element' => 'div', 'properties' => ['style' => "display: table-row; visibility: {$this->entityVariableCheck($variable)};"], 'elements' => [
// ['element' => 'div', 'content' => $variable . '_label', 'properties' => ['class' => 'entity-details-cell','data-ref' => 'entity_details-' . substr($variable, 1) . '_label']],
// ['element' => 'div', 'content' => $variable, 'properties' => ['class' => 'entity-details-cell','data-ref' => 'entity_details-' . substr($variable, 1)]],
// ]];
// }
// }
// return $elements;
// }
public function entityDetails(): array
{
if ($this->type === 'statement') {
@ -911,7 +844,6 @@ class Design extends BaseDesign
$variables = $this->context['pdf_variables']['total_columns'];
$elements = [
['element' => 'div', 'properties' => ['style' => 'display: flex; flex-direction: column;'], 'elements' => [
['element' => 'p', 'content' => strtr(str_replace(["labels","values"], ["",""], $_variables['values']['$entity.public_notes']), $_variables), 'properties' => ['data-ref' => 'total_table-public_notes', 'style' => 'text-align: left;']],

View File

@ -37,8 +37,6 @@ class SendEmail
*/
public function run()
{
nlog($this->reminder_template);
nlog("is there a template");
if (! $this->reminder_template) {
$this->reminder_template = $this->quote->calculateTemplate('quote');

View File

@ -11,18 +11,19 @@
namespace App\Services\Report;
use App\Libraries\Currency\Conversion\CurrencyApi;
use App\Libraries\MultiDB;
use App\Models\Company;
use App\Models\Currency;
use App\Models\Expense;
use App\Models\Payment;
use App\Utils\Ninja;
use App\Utils\Number;
use League\Csv\Writer;
use App\Models\Company;
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Currency;
use App\Libraries\MultiDB;
use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Str;
use League\Csv\Writer;
use App\Libraries\Currency\Conversion\CurrencyApi;
class ProfitLoss
{
@ -279,8 +280,6 @@ class ProfitLoss
->with(['company', 'client'])
->cursor()
->each(function ($payment) {
$company = $payment->company;
$client = $payment->client;
$map = new \stdClass;
$amount_payment_paid = 0;
@ -293,8 +292,8 @@ class ProfitLoss
$tax_amount_credit_converted = $tax_amount_credit_converted = 0;
foreach ($payment->paymentables as $pivot) {
if ($pivot->paymentable instanceof \App\Models\Invoice) {
$invoice = $pivot->paymentable;
if ($pivot->paymentable_type == 'invoices') {
$invoice = Invoice::withTrashed()->find($pivot->paymentable_id);
$amount_payment_paid += $pivot->amount - $pivot->refunded;
$amount_payment_paid_converted += $amount_payment_paid / ($payment->exchange_rate ?: 1);
@ -303,7 +302,7 @@ class ProfitLoss
$tax_amount_converted += (($amount_payment_paid / $invoice->amount) * $invoice->total_taxes) / $payment->exchange_rate;
}
if ($pivot->paymentable instanceof \App\Models\Credit) {
if ($pivot->paymentable_type == 'credits') {
$amount_credit_paid += $pivot->amount - $pivot->refunded;
$amount_credit_paid_converted += $amount_payment_paid / ($payment->exchange_rate ?: 1);

View File

@ -156,15 +156,17 @@ class Ninja
public static function triggerForwarding(string $company_key, string $email)
{
try {
Http::withHeaders([
$x = Http::withHeaders([
'X-API-HOSTED-SECRET' => config('ninja.ninja_hosted_secret'),
])->post(config('ninja.license_url').'/api/v1/enable_forwarding', [
'account_key' => $company_key,
'email' => $email,
]);
nlog($x->body());
}
catch (\Exception $e) {
nlog("attempt forwarding for{$email} - {$company_key}");
nlog("Attempt forwarding for {$email} - {$company_key} Failed");
}
}

View File

@ -194,8 +194,8 @@ class Number
/**
* Formats a given value based on the clients currency AND country.
*
* @param floatval $value The number to be formatted
* @param $entity
* @param float $value The number to be formatted
* @param mixed $entity
* @return string The formatted value
*/
public static function formatMoneyNoRounding($value, $entity) :string

View File

@ -278,9 +278,9 @@ class PaymentHtmlEngine
/**
* generateLabelsAndValues
*
* @return void
* @return array
*/
public function generateLabelsAndValues()
public function generateLabelsAndValues(): array
{
$data = [];

View File

@ -288,11 +288,6 @@ class SystemHealth
return $result;
}
private static function checkDbConnection()
{
return DB::connection()->getPdo();
}
public static function testMailServer($request = null)
{
if ($request->driver == 'log') {

View File

@ -126,7 +126,7 @@ class AccountEmailQuotaTest extends TestCase
$account->save();
Cache::put($account->key, 3000);
Cache::put("email_quota".$account->key, 3000);
$count = $account->emailsSent();