1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Multi-db fixes

This commit is contained in:
Hillel Coren 2017-05-25 20:31:58 +03:00
parent 0ca9029da4
commit b87afa8dc4
5 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ class AnalyticsListener
$invoice = $payment->invoice;
$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;
}

View File

@ -943,7 +943,7 @@ class Account extends Eloquent
*/
public function isNinjaAccount()
{
return $this->account_key === NINJA_ACCOUNT_KEY;
return strpos($this->account_key, 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx7') === 0;
}
/**

View File

@ -312,7 +312,7 @@ class BasePaymentDriver
$payment = $this->createPayment($ref, $paymentMethod);
// 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('trackEventAction', '/buy_pro_plan');
Session::flash('trackEventAmount', $payment->amount);
@ -648,7 +648,7 @@ class BasePaymentDriver
$this->createLicense($payment);
// TODO move this code
// enable pro plan for hosted users
} elseif ($accountKey == NINJA_ACCOUNT_KEY) {
} elseif ($invoice->account->isNinjaAccount()) {
foreach ($invoice->invoice_items as $invoice_item) {
// 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)) {

View File

@ -335,7 +335,7 @@ class AccountRepository
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) {
return $account;

View File

@ -278,7 +278,7 @@ class InvoiceRepository extends BaseRepository
->where('invoices.is_recurring', '=', false)
->where('invoices.is_public', '=', true)
// 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(
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),