mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Multi-db fixes
This commit is contained in:
parent
0ca9029da4
commit
b87afa8dc4
@ -23,7 +23,7 @@ class AnalyticsListener
|
|||||||
$invoice = $payment->invoice;
|
$invoice = $payment->invoice;
|
||||||
$account = $payment->account;
|
$account = $payment->account;
|
||||||
|
|
||||||
if (! in_array($account->account_key, [NINJA_ACCOUNT_KEY, NINJA_LICENSE_ACCOUNT_KEY])) {
|
if ($account->isNinjaAccount() || $account->account_key == NINJA_LICENSE_ACCOUNT_KEY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ class Account extends Eloquent
|
|||||||
*/
|
*/
|
||||||
public function isNinjaAccount()
|
public function isNinjaAccount()
|
||||||
{
|
{
|
||||||
return $this->account_key === NINJA_ACCOUNT_KEY;
|
return strpos($this->account_key, 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx7') === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,7 +312,7 @@ class BasePaymentDriver
|
|||||||
$payment = $this->createPayment($ref, $paymentMethod);
|
$payment = $this->createPayment($ref, $paymentMethod);
|
||||||
|
|
||||||
// TODO move this to stripe driver
|
// TODO move this to stripe driver
|
||||||
if ($this->invitation->invoice->account->account_key == NINJA_ACCOUNT_KEY) {
|
if ($this->invitation->invoice->account->isNinjaAccount()) {
|
||||||
Session::flash('trackEventCategory', '/account');
|
Session::flash('trackEventCategory', '/account');
|
||||||
Session::flash('trackEventAction', '/buy_pro_plan');
|
Session::flash('trackEventAction', '/buy_pro_plan');
|
||||||
Session::flash('trackEventAmount', $payment->amount);
|
Session::flash('trackEventAmount', $payment->amount);
|
||||||
@ -648,7 +648,7 @@ class BasePaymentDriver
|
|||||||
$this->createLicense($payment);
|
$this->createLicense($payment);
|
||||||
// TODO move this code
|
// TODO move this code
|
||||||
// enable pro plan for hosted users
|
// enable pro plan for hosted users
|
||||||
} elseif ($accountKey == NINJA_ACCOUNT_KEY) {
|
} elseif ($invoice->account->isNinjaAccount()) {
|
||||||
foreach ($invoice->invoice_items as $invoice_item) {
|
foreach ($invoice->invoice_items as $invoice_item) {
|
||||||
// Hacky, but invoices don't have meta fields to allow us to store this easily
|
// Hacky, but invoices don't have meta fields to allow us to store this easily
|
||||||
if (1 == preg_match('/^Plan - (.+) \((.+)\)$/', $invoice_item->product_key, $matches)) {
|
if (1 == preg_match('/^Plan - (.+) \((.+)\)$/', $invoice_item->product_key, $matches)) {
|
||||||
|
@ -335,7 +335,7 @@ class AccountRepository
|
|||||||
|
|
||||||
public function getNinjaAccount()
|
public function getNinjaAccount()
|
||||||
{
|
{
|
||||||
$account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first();
|
$account = Account::where('account_key', 'LIKE', substr(NINJA_ACCOUNT_KEY, 0, 30) . '%')->orderBy('id')->first();
|
||||||
|
|
||||||
if ($account) {
|
if ($account) {
|
||||||
return $account;
|
return $account;
|
||||||
|
@ -278,7 +278,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
->where('invoices.is_recurring', '=', false)
|
->where('invoices.is_recurring', '=', false)
|
||||||
->where('invoices.is_public', '=', true)
|
->where('invoices.is_public', '=', true)
|
||||||
// Only show paid invoices for ninja accounts
|
// Only show paid invoices for ninja accounts
|
||||||
->whereRaw(sprintf("((accounts.account_key != '%s' and accounts.account_key != '%s') or invoices.invoice_status_id = %d)", env('NINJA_LICENSE_ACCOUNT_KEY'), NINJA_ACCOUNT_KEY, INVOICE_STATUS_PAID))
|
->whereRaw(sprintf("((accounts.account_key != '%s' and accounts.account_key not like '%s') or invoices.invoice_status_id = %d)", env('NINJA_LICENSE_ACCOUNT_KEY'), substr(NINJA_ACCOUNT_KEY, 0, 30), INVOICE_STATUS_PAID))
|
||||||
->select(
|
->select(
|
||||||
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
|
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
|
||||||
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),
|
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user