mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 01:54:36 -04:00
Only one notification per invoice, per product
This commit is contained in:
parent
4691ca29c1
commit
7964069e5b
@ -19,6 +19,7 @@ use Illuminate\Contracts\Validation\Rule;
|
|||||||
class BlackListRule implements Rule
|
class BlackListRule implements Rule
|
||||||
{
|
{
|
||||||
private array $blacklist = [
|
private array $blacklist = [
|
||||||
|
'ckptr.com',
|
||||||
'pretreer.com',
|
'pretreer.com',
|
||||||
'candassociates.com',
|
'candassociates.com',
|
||||||
'vusra.com',
|
'vusra.com',
|
||||||
|
@ -31,6 +31,8 @@ class AdjustProductInventory implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, UserNotifies;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, UserNotifies;
|
||||||
|
|
||||||
|
private array $notified_products = [];
|
||||||
|
|
||||||
public function __construct(public Company $company, public Invoice $invoice, public $old_invoice = [])
|
public function __construct(public Company $company, public Invoice $invoice, public $old_invoice = [])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -56,18 +58,6 @@ class AdjustProductInventory implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
// foreach ($this->invoice->line_items as $item) {
|
|
||||||
// $p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->first();
|
|
||||||
|
|
||||||
// if (! $p) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $p->in_stock_quantity += $item->quantity;
|
|
||||||
|
|
||||||
// $p->saveQuietly();
|
|
||||||
// }
|
|
||||||
|
|
||||||
collect($this->invoice->line_items)->filter(function ($item) {
|
collect($this->invoice->line_items)->filter(function ($item) {
|
||||||
return $item->type_id == '1';
|
return $item->type_id == '1';
|
||||||
})->each(function ($i) {
|
})->each(function ($i) {
|
||||||
@ -147,11 +137,13 @@ class AdjustProductInventory implements ShouldQueue
|
|||||||
$nmo->company = $this->company;
|
$nmo->company = $this->company;
|
||||||
$nmo->settings = $this->company->settings;
|
$nmo->settings = $this->company->settings;
|
||||||
|
|
||||||
|
/** @var \App\Models\CompanyUser $cu */
|
||||||
$this->company->company_users->each(function ($cu) use ($product, $nmo, $notification_level) {
|
$this->company->company_users->each(function ($cu) use ($product, $nmo, $notification_level) {
|
||||||
if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user'])) {
|
if ($this->checkNotificationExists($cu, $product, ['inventory_all', 'inventory_user', 'inventory_threshold_all', 'inventory_threshold_user']) && (! in_array($product->id, $this->notified_products))) {
|
||||||
$nmo->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level, $cu->portalType()))->build());
|
$nmo->mailable = new NinjaMailer((new InventoryNotificationObject($product, $notification_level, $cu->portalType()))->build());
|
||||||
$nmo->to_user = $cu->user;
|
$nmo->to_user = $cu->user;
|
||||||
NinjaMailerJob::dispatch($nmo);
|
NinjaMailerJob::dispatch($nmo);
|
||||||
|
$this->notified_products[] = $product->id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -157,4 +157,4 @@ class SystemMaintenance implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -69,7 +69,7 @@ class InventoryNotificationObject
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
'url' => $this->product->portalUrl($this->use_react_url),
|
'url' => $this->product->portalUrl($this->use_react_url),
|
||||||
'button' => $this->use_react_url ? ctrans('texts.product_library') : ctrans('ninja.app_url'),
|
'button' => ctrans('texts.view'),
|
||||||
'signature' => $this->product->company->settings->email_signature,
|
'signature' => $this->product->company->settings->email_signature,
|
||||||
'logo' => $this->product->company->present()->logo(),
|
'logo' => $this->product->company->present()->logo(),
|
||||||
'settings' => $this->product->company->settings,
|
'settings' => $this->product->company->settings,
|
||||||
|
@ -273,7 +273,6 @@ class EmailDefaults
|
|||||||
return $this;
|
return $this;
|
||||||
// return $this->email->email_object->cc;
|
// return $this->email->email_object->cc;
|
||||||
// return [
|
// return [
|
||||||
|
|
||||||
// ];
|
// ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user