1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 22:22:32 +01:00

Merge pull request #7525 from turbo124/v5-develop

v5.3.97
This commit is contained in:
David Bomba 2022-06-09 18:14:00 +10:00 committed by GitHub
commit eda88c6043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
354 changed files with 1565 additions and 385 deletions

View File

@ -1 +1 @@
5.3.96
5.3.97

View File

@ -108,6 +108,7 @@ class CreateSingleAccount extends Command
'default_password_timeout' => 30*60000,
'portal_mode' => 'domain',
'portal_domain' => 'http://ninja.test:8000',
'track_inventory' => true
]);
$settings = $company->settings;

View File

@ -61,10 +61,13 @@ class EmailTemplateDefaults
break;
case 'email_template_custom3':
return self::emailInvoiceTemplate();
case 'email_template_purchase_order':
return self::emailPurchaseOrderSubject();
break;
/* Subject */
case 'email_subject_purchase_order':
return self::emailPurchaseOrderSubject();
case 'email_subject_invoice':
return self::emailInvoiceSubject();
break;
@ -152,6 +155,20 @@ class EmailTemplateDefaults
return ctrans('texts.payment_subject');
}
public static function emailPurchaseOrderSubject()
{
return ctrans('texts.purchase_order_subject', ['number' => '$number']);
}
public static function emailPurchaseOrderTemplate()
{
$purchase_order_message = '<p>$vendor<br><br>'.self::transformText('purchase_order_message').'</p><div class="center">$view_button</div>';
return $purchase_order_message;
}
public static function emailPaymentTemplate()
{
$payment_message = '<p>$client<br><br>'.self::transformText('payment_message').'<br><br>$invoices</p><div class="center">$view_button</div>';

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
use App\Models\Company;
use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasArchived.
*/
class PurchaseOrderWasArchived
{
use SerializesModels;
/**
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param PurchaseOrder $purchase_order
* @param Company $company
* @param array $event_vars
*/
public function __construct(PurchaseOrder $purchase_order, Company $company, array $event_vars)
{
$this->purchase_order = $purchase_order;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
use App\Models\Company;
use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasCreated.
*/
class PurchaseOrderWasCreated
{
use SerializesModels;
/**
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param PurchaseOrder $purchase_order
* @param Company $company
* @param array $event_vars
*/
public function __construct(PurchaseOrder $purchase_order, Company $company, array $event_vars)
{
$this->purchase_order = $purchase_order;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
use App\Models\Company;
use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasDeleted.
*/
class PurchaseOrderWasDeleted
{
use SerializesModels;
/**
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param PurchaseOrder $purchase_order
* @param Company $company
* @param array $event_vars
*/
public function __construct(PurchaseOrder $purchase_order, Company $company, array $event_vars)
{
$this->purchase_order = $purchase_order;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
use App\Models\Company;
use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasEmailed.
*/
class PurchaseOrderWasEmailed
{
use SerializesModels;
/**
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param PurchaseOrder $purchase_order
* @param Company $company
* @param array $event_vars
*/
public function __construct(PurchaseOrder $purchase_order, Company $company, array $event_vars)
{
$this->purchase_order = $purchase_order;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
use App\Models\Company;
use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasRestored.
*/
class PurchaseOrderWasRestored
{
use SerializesModels;
/**
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
public $fromDeleted;
/**
* Create a new event instance.
*
* @param PurchaseOrder $purchase_order
* @param Company $company
* @param array $event_vars
*/
public function __construct(PurchaseOrder $purchase_order, $fromDeleted, Company $company, array $event_vars)
{
$this->purchase_order = $purchase_order;
$this->fromDeleted = $fromDeleted;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
use App\Models\Company;
use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasUpdated.
*/
class PurchaseOrderWasUpdated
{
use SerializesModels;
/**
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param PurchaseOrder $purchase_order
* @param Company $company
* @param array $event_vars
*/
public function __construct(PurchaseOrder $purchase_order, Company $company, array $event_vars)
{
$this->purchase_order = $purchase_order;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -1,5 +1,13 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Events\PurchaseOrder;
@ -8,20 +16,21 @@ use App\Models\PurchaseOrder;
use Illuminate\Queue\SerializesModels;
/**
* Class PurchaseOrderWasMarkedSent.
* Class PurchaseOrderWasViewed.
*/
class PurchaseOrderWasMarkedSent
class PurchaseOrderWasViewed
{
use SerializesModels;
/**
* @var \App\Models\PurchaseOrder
* @var PurchaseOrder
*/
public $purchase_order;
public $company;
public $event_vars;
/**
* Create a new event instance.
*

View File

@ -225,6 +225,7 @@ class InvoiceController extends BaseController
$invoice = $invoice->service()
->fillDefaults()
->triggeredActions($request)
->adjustInventory()
->save();
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
@ -414,9 +415,14 @@ class InvoiceController extends BaseController
return response()->json(['message' => ctrans('texts.locked_invoice')], 403);
}
$old_invoice = $invoice->line_items;
$invoice = $this->invoice_repo->save($request->all(), $invoice);
$invoice->service()->triggeredActions($request)->touchPdf();
$invoice->service()
->triggeredActions($request)
->touchPdf()
->adjustInventory($old_invoice);
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));

View File

@ -12,6 +12,8 @@
namespace App\Http\Controllers;
use App\Events\PurchaseOrder\PurchaseOrderWasCreated;
use App\Events\PurchaseOrder\PurchaseOrderWasUpdated;
use App\Factory\PurchaseOrderFactory;
use App\Filters\PurchaseOrderFilters;
use App\Http\Requests\PurchaseOrder\ActionPurchaseOrderRequest;
@ -26,6 +28,7 @@ use App\Models\Client;
use App\Models\PurchaseOrder;
use App\Repositories\PurchaseOrderRepository;
use App\Transformers\PurchaseOrderTransformer;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Response;
@ -182,6 +185,8 @@ class PurchaseOrderController extends BaseController
->fillDefaults()
->save();
event(new PurchaseOrderWasCreated($purchase_order, $purchase_order->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
return $this->itemResponse($purchase_order);
}
/**
@ -352,6 +357,8 @@ class PurchaseOrderController extends BaseController
$purchase_order = $this->purchase_order_repository->save($request->all(), $purchase_order);
event(new PurchaseOrderWasUpdated($purchase_order, $purchase_order->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
return $this->itemResponse($purchase_order);
}
/**
@ -470,7 +477,7 @@ class PurchaseOrderController extends BaseController
$purchase_orders = PurchaseOrder::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
if (! $invoices) {
if (! $purchase_orders) {
return response()->json(['message' => 'No Purchase Orders Found']);
}

View File

@ -362,6 +362,7 @@ class BillingPortalPurchase extends Component
->service()
->markSent()
->fillDefaults()
->adjustInventory()
->save();
Cache::put($this->hash, [

View File

@ -38,10 +38,13 @@ class StoreProductRequest extends Request
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
}
$rules['cost'] = 'numeric';
$rules['price'] = 'numeric';
$rules['quantity'] = 'numeric';
$rules['cost'] = 'sometimes|numeric';
$rules['price'] = 'sometimes|numeric';
$rules['quantity'] = 'sometimes|numeric';
$rules['in_stock_quantity'] = 'sometimes|numeric';
$rules['stock_notification_threshold'] = 'sometimes|numeric';
$rules['stock_notification'] = 'sometimes|bool';
return $rules;
}

View File

@ -44,6 +44,9 @@ class UpdateProductRequest extends Request
$rules['cost'] = 'numeric';
$rules['price'] = 'numeric';
$rules['quantity'] = 'numeric';
$rules['in_stock_quantity'] = 'sometimes|numeric';
$rules['stock_notification_threshold'] = 'sometimes|numeric';
$rules['stock_notification'] = 'sometimes|bool';
return $rules;
}
@ -60,6 +63,13 @@ class UpdateProductRequest extends Request
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
}
if(array_key_exists('in_stock_quantity', $input) && request()->has('update_in_stock_quantity') && request()->input('update_in_stock_quantity') == 'true'){
}
elseif(array_key_exists('in_stock_quantity', $input)){
unset($input['in_stock_quantity']);
}
$this->replace($input);
}
}

View File

@ -71,6 +71,7 @@ class BaseTransformer
$client_id_search = $this->company
->clients()
->where('is_deleted', false)
->where('id_number', $client_name);
if ($client_id_search->count() >= 1) {
@ -79,6 +80,7 @@ class BaseTransformer
$client_name_search = $this->company
->clients()
->where('is_deleted', false)
->where('name', $client_name);
if ($client_name_search->count() >= 1) {
@ -86,10 +88,11 @@ class BaseTransformer
}
}
if (!empty($client_email)) {
$contacts = ClientContact::where(
'company_id',
$this->company->id
)->where('email', $client_email);
$contacts = ClientContact::whereHas('client', function($query){
$query->where('is_deleted', false);
})
->where('company_id', $this->company->id)
->where('email', $client_email);
if ($contacts->count() >= 1) {
return $contacts->first()->client_id;
@ -109,6 +112,7 @@ class BaseTransformer
{
return $this->company
->clients()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -124,6 +128,7 @@ class BaseTransformer
{
return $this->company
->vendors()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -139,6 +144,7 @@ class BaseTransformer
{
return $this->company
->projects()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -154,6 +160,7 @@ class BaseTransformer
{
return $this->company
->products()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $key)),
])
@ -186,6 +193,7 @@ class BaseTransformer
{
$client = $this->company
->clients()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -203,6 +211,7 @@ class BaseTransformer
{
$product = $this->company
->products()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`product_key`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $key)),
])
@ -273,6 +282,7 @@ class BaseTransformer
$tax_rate = $this->company
->tax_rates()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -292,6 +302,7 @@ class BaseTransformer
$tax_rate = $this->company
->tax_rates()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -341,6 +352,7 @@ class BaseTransformer
{
$invoice = $this->company
->invoices()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $invoice_number)),
])
@ -358,6 +370,7 @@ class BaseTransformer
{
return $this->company
->invoices()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $invoice_number)),
])
@ -371,6 +384,7 @@ class BaseTransformer
{
return $this->company
->expenses()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $expense_number)),
])
@ -386,6 +400,7 @@ class BaseTransformer
{
return $this->company
->quotes()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $quote_number)),
])
@ -401,6 +416,7 @@ class BaseTransformer
{
$invoice = $this->company
->invoices()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`number`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $invoice_number)),
])
@ -418,6 +434,7 @@ class BaseTransformer
{
$vendor = $this->company
->vendors()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -452,6 +469,7 @@ class BaseTransformer
{
$ec = $this->company
->expense_categories()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])
@ -486,6 +504,7 @@ class BaseTransformer
{
$project = $this->company
->projects()
->where('is_deleted', false)
->whereRaw("LOWER(REPLACE(`name`, ' ' ,'')) = ?", [
strtolower(str_replace(' ', '', $name)),
])

View File

@ -11,7 +11,11 @@
namespace App\Jobs\Inventory;
use App\Jobs\Mail\NinjaMailer;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Libraries\MultiDB;
use App\Mail\Admin\InventoryNotificationObject;
use App\Models\Company;
use App\Models\Invoice;
use App\Models\Product;
@ -20,10 +24,9 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
//todo - ensure we are MultiDB Aware in dispatched jobs
class AdjustProductInventory implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
@ -34,9 +37,8 @@ class AdjustProductInventory implements ShouldQueue
public array $old_invoice;
public function __construct(Company $company, Invoice $invoice, array $old_invoice = [])
public function __construct(Company $company, Invoice $invoice, ?array $old_invoice = [])
{
$this->company = $company;
$this->invoice = $invoice;
$this->old_invoice = $old_invoice;
@ -53,12 +55,18 @@ class AdjustProductInventory implements ShouldQueue
MultiDB::setDb($this->company->db);
if(count($this->old_invoice) > 0)
return $this->existingInventoryAdjustment();
$this->existingInventoryAdjustment();
return $this->newInventoryAdjustment();
}
public function middleware()
{
return [new WithoutOverlapping($this->company->company_key)];
}
private function newInventoryAdjustment()
{
@ -68,16 +76,18 @@ class AdjustProductInventory implements ShouldQueue
{
$p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->where('in_stock_quantity', '>', 0)->first();
$p->in_stock_quantity -= $item->quantity;
$p->save();
//check threshols and notify user
if(!$p)
continue;
$p->in_stock_quantity -= $item->quantity;
$p->saveQuietly();
if($p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold)
$this->notifyStockLevels($p, 'product');
elseif($this->company->stock_notification_threshold && $p->in_stock_quantity <= $this->company->stock_notification_threshold){
elseif($this->company->stock_notification_threshold && $p->in_stock_quantity <= $this->company->stock_notification_threshold)
$this->notifyStocklevels($p, 'company');
}
}
}
@ -85,11 +95,31 @@ class AdjustProductInventory implements ShouldQueue
private function existingInventoryAdjustment()
{
foreach($this->old_invoice 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();
}
}
private function notifyStocklevels(Product $product, string $notification_level)
{
$nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer( (new InventoryNotificationObject($product, $notification_level))->build() );
$nmo->company = $this->company;
$nmo->settings = $this->company->settings;
$nmo->to_user = $this->company->owner();
NinjaMailerJob::dispatch($nmo);
}
}

View File

@ -87,6 +87,7 @@ class SendRecurring implements ShouldQueue
->applyNumber()
//->createInvitations() //need to only link invitations to those in the recurring invoice
->fillDefaults()
->adjustInventory()
->save();
}

View File

@ -89,6 +89,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\UploadedFile;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
@ -187,6 +188,11 @@ class Import implements ShouldQueue
$this->resources = $resources;
}
public function middleware()
{
return [new WithoutOverlapping($this->company->account->key)];
}
/**
* Execute the job.
*

View File

@ -127,8 +127,7 @@ class PaymentNotification implements ShouldQueue
*/
private function sendAnalytics($data)
{
nlog($data);
$data = utf8_encode($data);
$curl = curl_init();

View File

@ -0,0 +1,58 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class CreatePurchaseOrderActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->purchase_order->user_id;
$fields->user_id = $user_id;
$fields->purchase_order_id = $event->purchase_order->id;
$fields->vendor_id = $event->purchase_order->vendor_id;
$fields->company_id = $event->purchase_order->company_id;
$fields->activity_type_id = Activity::CREATE_PURCHASE_ORDER;
$this->activity_repo->save($fields, $event->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class PurchaseOrderArchivedActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->purchase_order->user_id;
$fields->user_id = $user_id;
$fields->purchase_order_id = $event->purchase_order->id;
$fields->vendor_id = $event->purchase_order->vendor_id;
$fields->company_id = $event->purchase_order->company_id;
$fields->activity_type_id = Activity::ARCHIVE_PURCHASE_ORDER;
$this->activity_repo->save($fields, $event->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class PurchaseOrderDeletedActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->purchase_order->user_id;
$fields->user_id = $user_id;
$fields->purchase_order_id = $event->purchase_order->id;
$fields->vendor_id = $event->purchase_order->vendor_id;
$fields->company_id = $event->purchase_order->company_id;
$fields->activity_type_id = Activity::DELETE_PURCHASE_ORDER;
$this->activity_repo->save($fields, $event->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Invoice Ninja (https://purchase_orderninja.com).
*
* @link https://github.com/purchase_orderninja/purchase_orderninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://purchase_orderninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class PurchaseOrderEmailActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->invitation->purchase_order->user_id;
$fields->user_id = $user_id;
$fields->purchase_order_id = $event->invitation->purchase_order->id;
$fields->company_id = $event->invitation->purchase_order->company_id;
$fields->vendor_contact_id = $event->invitation->purchase_order->vendor_contact_id;
$fields->vendor_id = $event->invitation->purchase_order->vendor_id;
$fields->activity_type_id = Activity::EMAIL_PURCHASE_ORDER;
$this->activity_repo->save($fields, $event->invitation->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class PurchaseOrderRestoredActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->purchase_order->user_id;
$fields->user_id = $user_id;
$fields->purchase_order_id = $event->purchase_order->id;
$fields->vendor_id = $event->purchase_order->vendor_id;
$fields->company_id = $event->purchase_order->company_id;
$fields->activity_type_id = Activity::RESTORE_PURCHASE_ORDER;
$this->activity_repo->save($fields, $event->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class PurchaseOrderViewedActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->invitation->purchase_order->user_id;
$event->invitation->purchase_order->service()->markSent()->save();
$fields->user_id = $user_id;
$fields->company_id = $event->invitation->company_id;
$fields->activity_type_id = Activity::VIEW_PURCHASE_ORDER;
$fields->vendor_id = $event->invitation->purchase_order->vendor_id;
$fields->vendor_contact_id = $event->invitation->vendor_contact_id;
$fields->invitation_id = $event->invitation->id;
$fields->purchase_order_id = $event->invitation->purchase_order_id;
$this->activity_repo->save($fields, $event->invitation->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,58 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Listeners\PurchaseOrder;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class UpdatePurchaseOrderActivity implements ShouldQueue
{
protected $activity_repo;
public $delay = 5;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDB($event->company->db);
$fields = new stdClass;
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->purchase_order->user_id;
$fields->user_id = $user_id;
$fields->vendor_id = $event->purchase_order->vendor_id;
$fields->company_id = $event->purchase_order->company_id;
$fields->activity_type_id = Activity::UPDATE_PURCHASE_ORDER;
$fields->purchase_order_id = $event->purchase_order->id;
$this->activity_repo->save($fields, $event->purchase_order, $event->event_vars);
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Mail\Admin;
use App\Mail\Engine\PaymentEmailEngine;
use App\Models\Company;
use App\Models\Product;
use App\Utils\Ninja;
use App\Utils\Number;
use Illuminate\Support\Facades\App;
use stdClass;
class InventoryNotificationObject
{
public Product $product;
public Company $company;
public $settings;
public string $notification_level;
public function __construct(Product $product, string $notification_level)
{
$this->product = $product;
$this->company = $product->company;
$this->settings = $this->company->settings;
}
public function build()
{
App::forgetInstance('translator');
/* Init a new copy of the translator*/
$t = app('translator');
/* Set the locale*/
App::setLocale($this->company->getLocale());
/* Set customized translations _NOW_ */
$t->replace(Ninja::transformTranslations($this->company->settings));
$mail_obj = new stdClass;
$mail_obj->amount = $this->getAmount();
$mail_obj->subject = $this->getSubject();
$mail_obj->data = $this->getData();
$mail_obj->markdown = 'email.admin.generic';
$mail_obj->tag = $this->company->company_key;
return $mail_obj;
}
private function getAmount()
{
return $this->product->in_stock_quantity;
}
private function getSubject()
{
return
ctrans(
'texts.inventory_notification_subject',
['product' => $this->product->product_key . ": " . $this->product->notes]
);
}
private function getData()
{
$data = [
'title' => $this->getSubject(),
'content' => ctrans(
'texts.inventory_notification_body',
['amount' => $this->getAmount(),
'product' => $this->product->product_key . ": " . $this->product->notes,
]
),
'url' => config('ninja.app_url'),
'button' => ctrans('texts.login'),
'signature' => $this->settings->email_signature,
'logo' => $this->company->present()->logo(),
'settings' => $this->settings,
'whitelabel' => $this->company->account->isPaid() ? true : false,
];
return $data;
}
}

View File

@ -109,6 +109,14 @@ class Activity extends StaticModel
const DELETE_RECURRING_EXPENSE = 123;
const RESTORE_RECURRING_EXPENSE = 124;
const CREATE_PURCHASE_ORDER = 130;
const UPDATE_PURCHASE_ORDER = 131;
const ARCHIVE_PURCHASE_ORDER = 132;
const DELETE_PURCHASE_ORDER = 133;
const RESTORE_PURCHASE_ORDER = 134;
const EMAIL_PURCHASE_ORDER = 135;
const VIEW_PURCHASE_ORDER = 136;
protected $casts = [
'is_system' => 'boolean',
'updated_at' => 'timestamp',

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\GoCardless;

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\GoCardless;

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\GoCardless;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers;

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Mollie;

View File

@ -8,7 +8,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Razorpay;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers;

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Stripe;

View File

@ -61,6 +61,13 @@ use App\Events\Payment\PaymentWasRestored;
use App\Events\Payment\PaymentWasUpdated;
use App\Events\Payment\PaymentWasVoided;
use App\Events\PurchaseOrder\PurchaseOrderWasMarkedSent;
use App\Events\PurchaseOrder\PurchaseOrderWasArchived;
use App\Events\PurchaseOrder\PurchaseOrderWasCreated;
use App\Events\PurchaseOrder\PurchaseOrderWasDeleted;
use App\Events\PurchaseOrder\PurchaseOrderWasEmailed;
use App\Events\PurchaseOrder\PurchaseOrderWasRestored;
use App\Events\PurchaseOrder\PurchaseOrderWasUpdated;
use App\Events\PurchaseOrder\PurchaseOrderWasViewed;
use App\Events\Quote\QuoteWasApproved;
use App\Events\Quote\QuoteWasArchived;
use App\Events\Quote\QuoteWasCreated;
@ -171,6 +178,13 @@ use App\Listeners\Payment\PaymentEmailFailureActivity;
use App\Listeners\Payment\PaymentEmailedActivity;
use App\Listeners\Payment\PaymentNotification;
use App\Listeners\Payment\PaymentRestoredActivity;
use App\Listeners\PurchaseOrder\CreatePurchaseOrderActivity;
use App\Listeners\PurchaseOrder\PurchaseOrderArchivedActivity;
use App\Listeners\PurchaseOrder\PurchaseOrderDeletedActivity;
use App\Listeners\PurchaseOrder\PurchaseOrderEmailActivity;
use App\Listeners\PurchaseOrder\PurchaseOrderRestoredActivity;
use App\Listeners\PurchaseOrder\PurchaseOrderViewedActivity;
use App\Listeners\PurchaseOrder\UpdatePurchaseOrderActivity;
use App\Listeners\Quote\QuoteApprovedActivity;
use App\Listeners\Quote\QuoteApprovedNotification;
use App\Listeners\Quote\QuoteApprovedWebhook;
@ -436,6 +450,27 @@ class EventServiceProvider extends ServiceProvider
PaymentWasEmailedAndFailed::class => [
PaymentEmailFailureActivity::class,
],
PurchaseOrderWasArchived::class => [
PurchaseOrderArchivedActivity::class,
],
PurchaseOrderWasCreated::class => [
CreatePurchaseOrderActivity::class,
],
PurchaseOrderWasDeleted::class => [
PurchaseOrderDeletedActivity::class,
],
PurchaseOrderWasEmailed::class => [
PurchaseOrderEmailActivity::class,
],
PurchaseOrderWasRestored::class => [
PurchaseOrderRestoredActivity::class,
],
PurchaseOrderWasUpdated::class => [
UpdatePurchaseOrderActivity::class,
],
PurchaseOrderWasViewed::class => [
PurchaseOrderViewedActivity::class,
],
CompanyDocumentsDeleted::class => [
DeleteCompanyDocuments::class,
],
@ -558,9 +593,7 @@ class EventServiceProvider extends ServiceProvider
],
VendorWasUpdated::class => [
VendorUpdatedActivity::class,
],
PurchaseOrderWasMarkedSent::class => [
],
]
];

View File

@ -565,10 +565,11 @@ class InvoiceService
return $this;
}
public function adjustInventory()
public function adjustInventory($old_invoice = [])
{
if($this->invoice->company->track_inventory)
AdjustProductInventory::dispatch($this->invoice->company, $this->invoice, null);
AdjustProductInventory::dispatchNow($this->invoice->company, $this->invoice, $old_invoice);
return $this;
}

View File

@ -50,8 +50,7 @@ class UpdateReminder extends AbstractService
$date_collection = collect();
if (is_null($this->invoice->reminder1_sent) &&
$this->settings->schedule_reminder1 == 'after_invoice_date' &&
$this->settings->enable_reminder1) {
$this->settings->schedule_reminder1 == 'after_invoice_date') {
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays($this->settings->num_days_reminder1)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -59,8 +58,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder1_sent) &&
$this->settings->schedule_reminder1 == 'before_due_date' &&
$this->settings->enable_reminder1) {
$this->settings->schedule_reminder1 == 'before_due_date') {
$reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->subDays($this->settings->num_days_reminder1)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -68,8 +66,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder1_sent) &&
$this->settings->schedule_reminder1 == 'after_due_date' &&
$this->settings->enable_reminder1) {
$this->settings->schedule_reminder1 == 'after_due_date') {
$reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->addDays($this->settings->num_days_reminder1)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -77,8 +74,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder2_sent) &&
$this->settings->schedule_reminder2 == 'after_invoice_date' &&
$this->settings->enable_reminder2) {
$this->settings->schedule_reminder2 == 'after_invoice_date') {
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays($this->settings->num_days_reminder2)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -86,8 +82,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder2_sent) &&
$this->settings->schedule_reminder2 == 'before_due_date' &&
$this->settings->enable_reminder2) {
$this->settings->schedule_reminder2 == 'before_due_date') {
$reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->subDays($this->settings->num_days_reminder2)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -95,8 +90,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder2_sent) &&
$this->settings->schedule_reminder2 == 'after_due_date' &&
$this->settings->enable_reminder2) {
$this->settings->schedule_reminder2 == 'after_due_date') {
$reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->addDays($this->settings->num_days_reminder2)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -104,8 +98,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder3_sent) &&
$this->settings->schedule_reminder3 == 'after_invoice_date' &&
$this->settings->enable_reminder3) {
$this->settings->schedule_reminder3 == 'after_invoice_date') {
$reminder_date = Carbon::parse($this->invoice->date)->startOfDay()->addDays($this->settings->num_days_reminder3)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -113,8 +106,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder3_sent) &&
$this->settings->schedule_reminder3 == 'before_due_date' &&
$this->settings->enable_reminder3) {
$this->settings->schedule_reminder3 == 'before_due_date') {
$reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->subDays($this->settings->num_days_reminder3)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))
@ -122,8 +114,7 @@ class UpdateReminder extends AbstractService
}
if (is_null($this->invoice->reminder3_sent) &&
$this->settings->schedule_reminder3 == 'after_due_date' &&
$this->settings->enable_reminder3) {
$this->settings->schedule_reminder3 == 'after_due_date') {
$reminder_date = Carbon::parse($this->invoice->due_date)->startOfDay()->addDays($this->settings->num_days_reminder3)->addSeconds($offset);
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date)))

View File

@ -11,8 +11,6 @@
namespace App\Services\PurchaseOrder;
use App\Events\PurchaseOrder\PurchaseOrderWasMarkedSent;
use App\Models\PurchaseOrder;
use App\Utils\Ninja;
@ -46,8 +44,6 @@ class MarkSent
// ->touchPdf()
->save();
event(new PurchaseOrderWasMarkedSent($this->purchase_order, $this->purchase_order->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
return $this->purchase_order;
}
}

View File

@ -70,6 +70,7 @@ class ConvertQuote
$invoice->service()
->fillDefaults()
->adjustInventory()
->save();
$quote->invoice_id = $invoice->id;

View File

@ -89,7 +89,7 @@ class PurchaseOrderTransformer extends EntityTransformer
'custom_surcharge_tax3' => (bool)$purchase_order->custom_surcharge_tax3,
'custom_surcharge_tax4' => (bool)$purchase_order->custom_surcharge_tax4,
'line_items' => $purchase_order->line_items ?: (array)[],
'entity_type' => 'credit',
'entity_type' => 'purchase_order',
'exchange_rate' => (float)$purchase_order->exchange_rate,
'paid_to_date' => (float)$purchase_order->paid_to_date,
'subscription_id' => $this->encodePrimaryKey($purchase_order->subscription_id),

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.3.96',
'app_tag' => '5.3.96',
'app_version' => '5.3.97',
'app_tag' => '5.3.97',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Database\Factories;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/

View File

@ -7,7 +7,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
use App\Models\Gateway;

View File

@ -6,7 +6,7 @@
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
use Illuminate\Database\Migrations\Migration;

View File

@ -1,5 +1,13 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

View File

@ -4,9 +4,9 @@
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
* @license https://www.elastic.co/licensing/elastic-license
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

View File

@ -1,5 +1,13 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,13 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
use App\Models\RecurringExpense;
use App\Models\RecurringInvoice;
use Carbon\Carbon;
@ -9,12 +17,16 @@ use Illuminate\Support\Facades\Schema;
class SetRecurringClientTimestamp extends Migration
{
/**
* Run the migrations.
*
*/
public function up()
{
set_time_limit(0);
Schema::table('recurring_invoices', function (Blueprint $table) {
$table->datetime('next_send_date_client')->nullable();
});
@ -24,7 +36,7 @@ class SetRecurringClientTimestamp extends Migration
});
RecurringInvoice::whereNotNull('next_send_date')->cursor()->each(function ($recurring_invoice){
RecurringInvoice::withTrashed()->whereNotNull('next_send_date')->cursor()->each(function ($recurring_invoice){
// $offset = $recurring_invoice->client->timezone_offset();
// $re = Carbon::parse($recurring_invoice->next_send_date)->subSeconds($offset)->format('Y-m-d');
@ -34,7 +46,7 @@ class SetRecurringClientTimestamp extends Migration
});
RecurringExpense::whereNotNull('next_send_date')->cursor()->each(function ($recurring_expense){
RecurringExpense::withTrashed()->whereNotNull('next_send_date')->cursor()->each(function ($recurring_expense){
$recurring_expense->next_send_date_client = $recurring_expense->next_send_date;
$recurring_expense->saveQuietly();
});

View File

@ -1,5 +1,13 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
use App\Models\Company;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
@ -14,6 +22,8 @@ class CreatePurchaseOrderInvitationsTable extends Migration
*/
public function up()
{
set_time_limit(0);
Schema::create('purchase_order_invitations', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('company_id');
@ -47,6 +57,10 @@ class CreatePurchaseOrderInvitationsTable extends Migration
$table->unsignedInteger('client_id')->nullable()->change();
});
Schema::table('activities', function (Blueprint $table) {
$table->unsignedInteger('purchase_order_id')->nullable();
$table->unsignedInteger('vendor_contact_id')->nullable();
});
Company::cursor()->each(function ($company){
@ -60,6 +74,8 @@ class CreatePurchaseOrderInvitationsTable extends Migration
$settings->purchase_order_number_counter = 1; //@implemented
$settings->email_subject_purchase_order = '';
$settings->email_template_purchase_order = '';
$settings->require_purchase_order_signature = false;
$company->settings = $settings;
$company->save();
});
@ -74,4 +90,5 @@ class CreatePurchaseOrderInvitationsTable extends Migration
public function down()
{
}
}
}

Some files were not shown because too many files have changed in this diff Show More