Merge pull request #7091 from turbo124/v5-develop

Update language for bank transfers
This commit is contained in:
David Bomba 2022-01-05 17:30:39 +11:00 committed by GitHub
commit 3ac9c2f286
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 215 additions and 8 deletions

View File

@ -304,6 +304,7 @@ class MigrationController extends BaseController
App::forgetInstance('translator'); App::forgetInstance('translator');
$t = app('translator'); $t = app('translator');
$t->replace(Ninja::transformTranslations($user->account->companies()->first()->settings)); $t->replace(Ninja::transformTranslations($user->account->companies()->first()->settings));
App::setLocale($user->account->companies()->first()->getLocale());
if(!$existing_company && $company_count >=10) { if(!$existing_company && $company_count >=10) {

View File

@ -20,6 +20,8 @@ use App\Models\InvoiceInvitation;
use App\Models\QuoteInvitation; use App\Models\QuoteInvitation;
use App\Models\RecurringInvoiceInvitation; use App\Models\RecurringInvoiceInvitation;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\Notifications\Ninja\EmailBounceNotification;
use App\Notifications\Ninja\EmailSpamNotification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Turbo124\Beacon\Facades\LightLogs; use Turbo124\Beacon\Facades\LightLogs;
@ -173,6 +175,10 @@ class PostMarkController extends BaseController
LightLogs::create($bounce)->queue(); LightLogs::create($bounce)->queue();
SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);
if(config('ninja.notification.slack'))
$this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja();
} }
// { // {
@ -215,6 +221,10 @@ class PostMarkController extends BaseController
LightLogs::create($spam)->queue(); LightLogs::create($spam)->queue();
SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); SystemLogger::dispatch($request->all(), SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);
if(config('ninja.notification.slack'))
$this->invitation->company->notification(new EmailSpamNotification($this->invitation->company->account))->ninja();
} }
private function discoverInvitation($message_id) private function discoverInvitation($message_id)

View File

@ -21,6 +21,7 @@ use App\Http\Requests\Token\StoreTokenRequest;
use App\Http\Requests\Token\UpdateTokenRequest; use App\Http\Requests\Token\UpdateTokenRequest;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Repositories\TokenRepository; use App\Repositories\TokenRepository;
use App\Transformers\CompanyTokenHashedTransformer;
use App\Transformers\CompanyTokenTransformer; use App\Transformers\CompanyTokenTransformer;
use App\Utils\Traits\ChecksEntityStatus; use App\Utils\Traits\ChecksEntityStatus;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -93,6 +94,8 @@ class TokenController extends BaseController
*/ */
public function index(TokenFilters $filters) public function index(TokenFilters $filters)
{ {
$this->entity_transformer = CompanyTokenHashedTransformer::class;
$tokens = CompanyToken::filter($filters); $tokens = CompanyToken::filter($filters);
return $this->listResponse($tokens); return $this->listResponse($tokens);
@ -205,6 +208,8 @@ class TokenController extends BaseController
*/ */
public function edit(EditTokenRequest $request, CompanyToken $token) public function edit(EditTokenRequest $request, CompanyToken $token)
{ {
$this->entity_transformer = CompanyTokenHashedTransformer::class;
return $this->itemResponse($token); return $this->itemResponse($token);
} }
@ -265,6 +270,8 @@ class TokenController extends BaseController
return $request->disallowUpdate(); return $request->disallowUpdate();
} }
$this->entity_transformer = CompanyTokenHashedTransformer::class;
$token = $this->token_repo->save($request->all(), $token); $token = $this->token_repo->save($request->all(), $token);
return $this->itemResponse($token->fresh()); return $this->itemResponse($token->fresh());
@ -419,6 +426,8 @@ class TokenController extends BaseController
//may not need these destroy routes as we are using actions to 'archive/delete' //may not need these destroy routes as we are using actions to 'archive/delete'
$token->delete(); $token->delete();
$this->entity_transformer = CompanyTokenHashedTransformer::class;
return $this->itemResponse($token); return $this->itemResponse($token);
} }
@ -475,6 +484,9 @@ class TokenController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$this->entity_transformer = CompanyTokenHashedTransformer::class;
$action = request()->input('action'); $action = request()->input('action');
$ids = request()->input('ids'); $ids = request()->input('ids');

View File

@ -335,11 +335,12 @@ class CompanyImport implements ShouldQueue
} }
} }
if($this->company->account->isFreeHostedClient() && $client_count = count($this->getObject('clients', true)) > config('ninja.quotas.free.clients')){ if($this->company->account->isFreeHostedClient() && (count($this->getObject('clients', true)) > config('ninja.quotas.free.clients')) ){
nlog("client quota busted"); nlog("client quota busted");
$client_limit = config('ninja.quotas.free.clients'); $client_limit = config('ninja.quotas.free.clients');
$client_count = count($this->getObject('clients', true));
$this->message = "You are attempting to import ({$client_count}) clients, your current plan allows a total of ({$client_limit})"; $this->message = "You are attempting to import ({$client_count}) clients, your current plan allows a total of ({$client_limit})";

View File

@ -135,7 +135,7 @@ class SendRecurring implements ShouldQueue
if ($invitation->contact && !$invitation->contact->trashed() && strlen($invitation->contact->email) >=1 && $invoice->client->getSetting('auto_email_invoice')) { if ($invitation->contact && !$invitation->contact->trashed() && strlen($invitation->contact->email) >=1 && $invoice->client->getSetting('auto_email_invoice')) {
try{ try{
EmailEntity::dispatch($invitation, $invoice->company)->delay(now()->addSeconds(1)); EmailEntity::dispatch($invitation, $invoice->company);
} }
catch(\Exception $e) { catch(\Exception $e) {
nlog($e->getMessage()); nlog($e->getMessage());

View File

@ -101,6 +101,7 @@ class Invoice extends BaseModel
'updated_at' => 'timestamp', 'updated_at' => 'timestamp',
'created_at' => 'timestamp', 'created_at' => 'timestamp',
'deleted_at' => 'timestamp', 'deleted_at' => 'timestamp',
'is_deleted' => 'bool',
]; ];
protected $with = []; protected $with = [];

View File

@ -0,0 +1,88 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Notifications\Ninja;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class EmailBounceNotification extends Notification
{
/**
* Create a new notification instance.
*
* @return void
*/
protected $account;
public function __construct($account)
{
$this->account = $account;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return MailMessage
*/
public function toMail($notifiable)
{
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toSlack($notifiable)
{
$content = "Email bounce notification for Account {$this->account->key} \n";
$owner = $this->account->companies()->first()->owner();
$content .= "Owner {$owner->present()->name() } | {$owner->email}";
return (new SlackMessage)
->success()
->from(ctrans('texts.notification_bot'))
->image('https://app.invoiceninja.com/favicon.png')
->content($content);
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Notifications\Ninja;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class EmailSpamNotification extends Notification
{
/**
* Create a new notification instance.
*
* @return void
*/
protected $account;
public function __construct($account)
{
$this->account = $account;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return MailMessage
*/
public function toMail($notifiable)
{
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toSlack($notifiable)
{
$content = "Email SPAM notification for Account {$this->account->key} \n";
$owner = $this->account->companies()->first()->owner();
$content .= "Owner {$owner->present()->name() } | {$owner->email}";
return (new SlackMessage)
->success()
->from(ctrans('texts.notification_bot'))
->image('https://app.invoiceninja.com/favicon.png')
->content($content);
}
}

View File

@ -47,9 +47,13 @@ class PaymentRepository extends BaseRepository {
*/ */
public function save(array $data, Payment $payment): ?Payment public function save(array $data, Payment $payment): ?Payment
{ {
if ($payment->amount >= 0) { // if ($payment->amount >= 0) {
// return $this->applyPayment($data, $payment);
// }
return $this->applyPayment($data, $payment); return $this->applyPayment($data, $payment);
}
return $payment; return $payment;
} }
@ -80,8 +84,8 @@ class PaymentRepository extends BaseRepository {
$client->service()->updatePaidToDate($data['amount'])->save(); $client->service()->updatePaidToDate($data['amount'])->save();
} }
elseif($data['amount'] >0){ // elseif($data['amount'] >0){
else{
//this fixes an edge case with unapplied payments //this fixes an edge case with unapplied payments
$client->service()->updatePaidToDate($data['amount'])->save(); $client->service()->updatePaidToDate($data['amount'])->save();
} }

View File

@ -105,6 +105,7 @@ class AutoBillInvoice extends AbstractService
$fee = 0; $fee = 0;
/* Build payment hash */ /* Build payment hash */
$payment_hash = PaymentHash::create([ $payment_hash = PaymentHash::create([
'hash' => Str::random(64), 'hash' => Str::random(64),
'data' => ['invoices' => [['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount, 'invoice_number' => $this->invoice->number]]], 'data' => ['invoices' => [['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount, 'invoice_number' => $this->invoice->number]]],
@ -123,7 +124,8 @@ class AutoBillInvoice extends AbstractService
->tokenBilling($gateway_token, $payment_hash); ->tokenBilling($gateway_token, $payment_hash);
} }
catch(\Exception $e){ catch(\Exception $e){
nlog($e->getMessage()); nlog("payment NOT captured for ". $this->invoice->number . " with error " . $e->getMessage());
// nlog($e->getMessage());
} }
if($payment){ if($payment){

View File

@ -4342,7 +4342,7 @@ $LANG = array(
'payment_type_instant_bank_pay' => 'Instant Bank Pay', 'payment_type_instant_bank_pay' => 'Instant Bank Pay',
'payment_type_iDEAL' => 'iDEAL', 'payment_type_iDEAL' => 'iDEAL',
'payment_type_Przelewy24' => 'Przelewy24', 'payment_type_Przelewy24' => 'Przelewy24',
'payment_type_Mollie Bank Transfer' => 'Bank Transfer', 'payment_type_Mollie Bank Transfer' => 'Mollie Bank Transfer',
'payment_type_KBC/CBC' => 'KBC/CBC', 'payment_type_KBC/CBC' => 'KBC/CBC',
'payment_type_Instant Bank Pay' => 'Instant Bank Pay', 'payment_type_Instant Bank Pay' => 'Instant Bank Pay',
'payment_type_Hosted Page' => 'Hosted Page', 'payment_type_Hosted Page' => 'Hosted Page',