Skip to content

Commit

Permalink
Merge pull request #9468 from turbo124/v5-develop
Browse files Browse the repository at this point in the history
v5.8.50
  • Loading branch information
turbo124 committed Apr 19, 2024
2 parents 3f1079e + d1b94fa commit 51ab86a
Show file tree
Hide file tree
Showing 40 changed files with 1,066 additions and 810 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
@@ -1 +1 @@
5.8.49
5.8.50
4 changes: 3 additions & 1 deletion app/Console/Commands/DemoMode.php
Expand Up @@ -110,7 +110,9 @@ private function createSmallAccount()

$this->info('Creating Small Account and Company');

$account = Account::factory()->create();
$account = Account::factory()->create([
"set_react_as_default_ap" => 0,
]);
$company = Company::factory()->create([
'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'),
Expand Down
191 changes: 189 additions & 2 deletions app/DataProviders/EDocRules.php
Expand Up @@ -79,9 +79,66 @@ private function FatturaPADefaults()
[
"key"=> "RiferimentoNumeroLinea",
"validation" => [
"string","min:1","max:10","required"
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
]
],
[
"key"=> "IdDocumento",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "Data",
"validation" => [
"string","date","required",
"type" => "date",
"resource" => "",
"required" => true,
],
],
[
"key"=> "NumItem",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCommessaConvenzione",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCUP",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCIG",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
],
],
[
Expand All @@ -90,13 +147,143 @@ private function FatturaPADefaults()
"type" => "object",
"resource" => "DatiOrdineAcquisto",
"required" => false,
"children" => [
[
"key"=> "RiferimentoNumeroLinea",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "IdDocumento",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "Data",
"validation" => [
"string","date","required",
"type" => "date",
"resource" => "",
"required" => true,
],
],
[
"key"=> "NumItem",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCommessaConvenzione",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCUP",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCIG",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
],
],
[
"key" => "DatiAnagraficiVettore",
"label" => "Dati Anagrafici Vettore",
"type" => "object",
"resource" => "DatiAnagraficiVettore",
"required" => false,
"children" => [
[
"key"=> "RiferimentoNumeroLinea",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "IdDocumento",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "Data",
"validation" => [
"string","date","required",
"type" => "date",
"resource" => "",
"required" => true,
],
],
[
"key"=> "NumItem",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCommessaConvenzione",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCUP",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
[
"key"=> "CodiceCIG",
"validation" => [
"string","min:1","max:10","required",
"type" => "string",
"resource" => "",
"required" => true,
],
],
],
],
];
}
Expand Down
11 changes: 7 additions & 4 deletions app/Helpers/Invoice/InvoiceSum.php
Expand Up @@ -227,12 +227,15 @@ public function getPurchaseOrder()

public function getRecurringInvoice()
{
$this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
$this->invoice->total_taxes = $this->getTotalTaxes();
$this->invoice->balance = $this->formatValue($this->getTotal(), $this->precision);

// $this->invoice->amount = $this->formatValue($this->getTotal(), $this->precision);
// $this->invoice->total_taxes = $this->getTotalTaxes();

$this->setCalculatedAttributes();
$this->invoice->balance = $this->invoice->amount;
$this->invoice->saveQuietly();

// $this->invoice->saveQuietly();

return $this->invoice;
}

Expand Down
10 changes: 9 additions & 1 deletion app/Helpers/Mail/GmailTransport.php
Expand Up @@ -70,7 +70,15 @@ protected function doSend(SentMessage $message): void
/* Need to slow down */
if ($e->getCode() == '429') {
nlog("429 google - retrying ");
$service->users_messages->send('me', $body, []);

sleep(rand(3,8));

try {
$service->users_messages->send('me', $body, []);
} catch(\Google\Service\Exception $e) {

}

}
}
}
Expand Down
9 changes: 8 additions & 1 deletion app/Helpers/Mail/Office365MailTransport.php
Expand Up @@ -54,12 +54,19 @@ protected function doSend(SentMessage $message): void
->setReturnType(\Microsoft\Graph\Model\Message::class)
->execute();
} catch (\Exception $e) {
sleep(5);

sleep(rand(5,10));

try {
$graphMessage = $graph->createRequest('POST', '/users/'.$symfony_message->getFrom()[0]->getAddress().'/sendmail')
->attachBody(base64_encode($bcc_list.$message->toString()))
->addHeaders(['Content-Type' => 'text/plain'])
->setReturnType(\Microsoft\Graph\Model\Message::class)
->execute();
} catch (\Exception $e) {

}

}
}

Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/ClientController.php
Expand Up @@ -401,6 +401,12 @@ public function reactivateEmail(ReactivateClientEmailRequest $request, string $b
}

$bounce_id = $resolved_bounce_id;

$record = $log->log;
$record['ID'] = '';
$log->log = $record;
$log->save();

}

$postmark = new PostmarkClient(config('services.postmark.token'));
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Requests/Request.php
Expand Up @@ -45,6 +45,10 @@ public function globalRules($rules)
$merge_rules = [];

foreach ($this->all() as $key => $value) {

if($key == 'user')
continue;

if (method_exists($this, $key)) {
$merge_rules = $this->{$key}($rules);
}
Expand Down
1 change: 0 additions & 1 deletion app/Http/Requests/Task/StoreTaskRequest.php
Expand Up @@ -92,7 +92,6 @@ public function rules()
$rules['file'] = $this->fileValidation();
}


return $this->globalRules($rules);
}

Expand Down
3 changes: 0 additions & 3 deletions app/Http/Requests/Task/UpdateTaskRequest.php
Expand Up @@ -137,9 +137,6 @@ public function prepareForValidation()
$input['time_log'] = json_encode([]);
}

if(isset($input['user']))
unset($input['user']);

$this->replace($input);
}

Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/Mail/NinjaMailerJob.php
Expand Up @@ -48,7 +48,6 @@ class NinjaMailerJob implements ShouldQueue
use MakesHash;

public $tries = 4; //number of retries

public $deleteWhenMissingModels = true;

/** @var null|\App\Models\Company $company **/
Expand Down Expand Up @@ -223,7 +222,7 @@ public function handle()
}

/* Releasing immediately does not add in the backoff */
sleep(rand(0, 3));
sleep(rand(5, 10));

$this->release($this->backoff()[$this->attempts() - 1]);
}
Expand Down
11 changes: 7 additions & 4 deletions app/Mail/Engine/PaymentEmailEngine.php
Expand Up @@ -17,6 +17,7 @@
use App\Models\Account;
use App\Models\Payment;
use Illuminate\Support\Str;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesDates;
use App\Jobs\Entity\CreateRawPdf;
use Illuminate\Support\Facades\App;
Expand All @@ -28,7 +29,8 @@
class PaymentEmailEngine extends BaseEmailEngine
{
use MakesDates;

use MakesHash;

public $client;

/** @var \App\Models\Payment $payment */
Expand Down Expand Up @@ -97,11 +99,12 @@ public function build()
->setViewLink('')
->setViewText('');


if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {

$template_in_use = false;

if($this->is_refund && strlen($this->payment->client->getSetting('payment_refund_design_id')) > 2) {
if($this->is_refund && \App\Models\Design::where('id', $this->decodePrimaryKey($this->payment->client->getSetting('payment_refund_design_id')))->where('is_template', true)->exists()) {
$pdf = (new TemplateAction(
[$this->payment->hashed_id],
$this->payment->client->getSetting('payment_refund_design_id'),
Expand All @@ -118,7 +121,7 @@ public function build()
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
$template_in_use = true;

} elseif(!$this->is_refund && strlen($this->payment->client->getSetting('payment_receipt_design_id')) > 2) {
} elseif(!$this->is_refund && \App\Models\Design::where('id', $this->decodePrimaryKey($this->payment->client->getSetting('payment_receipt_design_id')))->where('is_template', true)->exists()) {
$pdf = (new TemplateAction(
[$this->payment->hashed_id],
$this->payment->client->getSetting('payment_receipt_design_id'),
Expand Down

0 comments on commit 51ab86a

Please sign in to comment.