mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
8a51b0cd9b
@ -1 +1 @@
|
|||||||
5.3.66
|
5.3.67
|
@ -74,7 +74,7 @@ class CheckData extends Command
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=}';
|
protected $signature = 'ninja:check-data {--database=} {--fix=} {--client_id=} {--vendor_id=} {--paid_to_date=} {--client_balance=} {--ledger_balance=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -102,7 +102,7 @@ class CheckData extends Command
|
|||||||
config(['database.default' => $database]);
|
config(['database.default' => $database]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->checkInvoiceBalances();
|
$this->checkInvoiceBalances();
|
||||||
$this->checkInvoiceBalancesNew();
|
$this->checkInvoiceBalancesNew();
|
||||||
//$this->checkInvoicePayments();
|
//$this->checkInvoicePayments();
|
||||||
|
|
||||||
@ -482,6 +482,7 @@ class CheckData extends Command
|
|||||||
payments.id = paymentables.payment_id
|
payments.id = paymentables.payment_id
|
||||||
WHERE paymentable_type = ?
|
WHERE paymentable_type = ?
|
||||||
AND paymentables.deleted_at is NULL
|
AND paymentables.deleted_at is NULL
|
||||||
|
AND payments.amount > 0
|
||||||
AND payments.is_deleted = 0
|
AND payments.is_deleted = 0
|
||||||
AND payments.client_id = ?;
|
AND payments.client_id = ?;
|
||||||
"), [App\Models\Credit::class, $client->id] );
|
"), [App\Models\Credit::class, $client->id] );
|
||||||
@ -499,9 +500,11 @@ class CheckData extends Command
|
|||||||
{
|
{
|
||||||
$client = Client::withTrashed()->find($_client->client_id);
|
$client = Client::withTrashed()->find($_client->client_id);
|
||||||
|
|
||||||
|
$credits_from_reversal = Credit::withTrashed()->where('client_id', $client->id)->where('is_deleted', 0)->whereNotNull('invoice_id')->sum('amount');
|
||||||
|
|
||||||
$credits_used_for_payments = $this->clientCreditPaymentables($client);
|
$credits_used_for_payments = $this->clientCreditPaymentables($client);
|
||||||
|
|
||||||
$total_paid_to_date = $_client->payments_applied + $credits_used_for_payments[0]->credit_payment;
|
$total_paid_to_date = $_client->payments_applied + $credits_used_for_payments[0]->credit_payment - $credits_from_reversal;
|
||||||
|
|
||||||
if(round($total_paid_to_date,2) != round($_client->client_paid_to_date,2)){
|
if(round($total_paid_to_date,2) != round($_client->client_paid_to_date,2)){
|
||||||
|
|
||||||
@ -736,7 +739,7 @@ ORDER BY clients.id;
|
|||||||
$this->logMessage($client_object->present()->name.' - '.$client_object->id." - calculated client balances do not match Invoice Balances = {$invoice_balance} - Client Balance = ".rtrim($client['client_balance'], '0'). " Ledger balance = {$ledger->balance}");
|
$this->logMessage($client_object->present()->name.' - '.$client_object->id." - calculated client balances do not match Invoice Balances = {$invoice_balance} - Client Balance = ".rtrim($client['client_balance'], '0'). " Ledger balance = {$ledger->balance}");
|
||||||
|
|
||||||
|
|
||||||
if($this->option('client_balance')){
|
if($this->option('ledger_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client_object->id} " . $client_object->present()->name.' - '.$client_object->number." Fixing {$client_object->balance} to {$invoice_balance}");
|
$this->logMessage("# {$client_object->id} " . $client_object->present()->name.' - '.$client_object->number." Fixing {$client_object->balance} to {$invoice_balance}");
|
||||||
$client_object->balance = $invoice_balance;
|
$client_object->balance = $invoice_balance;
|
||||||
@ -853,18 +856,16 @@ ORDER BY clients.id;
|
|||||||
|
|
||||||
foreach (Client::where('is_deleted', 0)->where('clients.updated_at', '>', now()->subDays(2))->cursor() as $client) {
|
foreach (Client::where('is_deleted', 0)->where('clients.updated_at', '>', now()->subDays(2))->cursor() as $client) {
|
||||||
$invoice_balance = $client->invoices()->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
$invoice_balance = $client->invoices()->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||||
$credit_balance = $client->credits()->where('is_deleted', false)->sum('balance');
|
|
||||||
|
|
||||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||||
|
|
||||||
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
if ($ledger && number_format($ledger->balance, 4) != number_format($client->balance, 4)) {
|
||||||
$this->wrong_balances++;
|
$this->wrong_balances++;
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}");
|
||||||
|
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
|
|
||||||
|
|
||||||
if($this->option('client_balance')){
|
if($this->option('ledger_balance')){
|
||||||
|
|
||||||
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
$this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->balance} to {$invoice_balance}");
|
||||||
$client->balance = $invoice_balance;
|
$client->balance = $invoice_balance;
|
||||||
@ -879,7 +880,7 @@ ORDER BY clients.id;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logMessage("{$this->wrong_balances} clients with incorrect balances");
|
$this->logMessage("{$this->wrong_balances} clients with incorrect ledger balances");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkLogoFiles()
|
private function checkLogoFiles()
|
||||||
@ -1011,6 +1012,27 @@ ORDER BY clients.id;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* //used to set a company owner on the company_users table
|
||||||
|
|
||||||
|
$c = Company::whereDoesntHave('company_users', function ($query){
|
||||||
|
$query->where('is_owner', true)->withTrashed();
|
||||||
|
})->cursor()->each(function ($company){
|
||||||
|
|
||||||
|
if(!$company->company_users()->exists()){
|
||||||
|
echo "No company users AT ALL {$company->id}\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
$cu = $company->company_users()->orderBy('id', 'ASC')->orderBy('is_admin', 'ASC')->first();
|
||||||
|
echo "{$company->id} - {$cu->id} \n";
|
||||||
|
$cu->is_owner=true;
|
||||||
|
$cu->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
/* query if we want to company company ledger to client balance
|
/* query if we want to company company ledger to client balance
|
||||||
$results = \DB::select( \DB::raw("
|
$results = \DB::select( \DB::raw("
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\DataMapper\ClientRegistrationFields;
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
use App\DataMapper\FeesAndLimits;
|
use App\DataMapper\FeesAndLimits;
|
||||||
use App\Events\Invoice\InvoiceWasCreated;
|
use App\Events\Invoice\InvoiceWasCreated;
|
||||||
@ -115,6 +116,7 @@ class CreateSingleAccount extends Command
|
|||||||
$settings->invoice_footer = 'Default invoice footer';
|
$settings->invoice_footer = 'Default invoice footer';
|
||||||
|
|
||||||
$company->settings = $settings;
|
$company->settings = $settings;
|
||||||
|
$company->client_registration_fields = ClientRegistrationFields::generate();
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
$account->default_company_id = $company->id;
|
$account->default_company_id = $company->id;
|
||||||
|
@ -64,7 +64,7 @@ class Kernel extends ConsoleKernel
|
|||||||
|
|
||||||
$schedule->job(new RecurringExpensesCron)->dailyAt('00:10')->withoutOverlapping();
|
$schedule->job(new RecurringExpensesCron)->dailyAt('00:10')->withoutOverlapping();
|
||||||
|
|
||||||
$schedule->job(new AutoBillCron)->dailyAt('00:30')->withoutOverlapping();
|
$schedule->job(new AutoBillCron)->dailyAt('12:20')->withoutOverlapping();
|
||||||
|
|
||||||
$schedule->job(new SchedulerCheck)->daily()->withoutOverlapping();
|
$schedule->job(new SchedulerCheck)->daily()->withoutOverlapping();
|
||||||
|
|
||||||
|
51
app/DataMapper/Analytics/TrialFinished.php
Normal file
51
app/DataMapper/Analytics/TrialFinished.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?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\DataMapper\Analytics;
|
||||||
|
|
||||||
|
use Turbo124\Beacon\ExampleMetric\GenericCounter;
|
||||||
|
|
||||||
|
class TrialFinished extends GenericCounter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The type of Sample.
|
||||||
|
*
|
||||||
|
* Monotonically incrementing counter
|
||||||
|
*
|
||||||
|
* - counter
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type = 'counter';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the counter.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name = 'account.trial_finished';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The datetime of the counter measurement.
|
||||||
|
*
|
||||||
|
* date("Y-m-d H:i:s")
|
||||||
|
*
|
||||||
|
* @var DateTime
|
||||||
|
*/
|
||||||
|
public $datetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The increment amount... should always be
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $metric = 0;
|
||||||
|
}
|
51
app/DataMapper/Analytics/TrialStarted.php
Normal file
51
app/DataMapper/Analytics/TrialStarted.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?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\DataMapper\Analytics;
|
||||||
|
|
||||||
|
use Turbo124\Beacon\ExampleMetric\GenericCounter;
|
||||||
|
|
||||||
|
class TrialStarted extends GenericCounter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The type of Sample.
|
||||||
|
*
|
||||||
|
* Monotonically incrementing counter
|
||||||
|
*
|
||||||
|
* - counter
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type = 'counter';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the counter.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name = 'account.trial_started';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The datetime of the counter measurement.
|
||||||
|
*
|
||||||
|
* date("Y-m-d H:i:s")
|
||||||
|
*
|
||||||
|
* @var DateTime
|
||||||
|
*/
|
||||||
|
public $datetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The increment amount... should always be
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $metric = 0;
|
||||||
|
}
|
@ -66,7 +66,7 @@ class CompanySettings extends BaseSettings
|
|||||||
public $auto_convert_quote = true; //@implemented
|
public $auto_convert_quote = true; //@implemented
|
||||||
public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send?
|
public $auto_email_invoice = true; //@only used for Recurring Invoices, if set to false, we never send?
|
||||||
|
|
||||||
public $entity_send_time = 0;
|
public $entity_send_time = 6;
|
||||||
|
|
||||||
public $inclusive_taxes = false; //@implemented
|
public $inclusive_taxes = false; //@implemented
|
||||||
public $quote_footer = ''; //@implmented
|
public $quote_footer = ''; //@implmented
|
||||||
|
@ -123,7 +123,7 @@ class EmailTemplateDefaults
|
|||||||
|
|
||||||
public static function emailInvoiceTemplate()
|
public static function emailInvoiceTemplate()
|
||||||
{
|
{
|
||||||
$invoice_message = '<p>'.self::transformText('invoice_message').'</p><div class="center">$view_button</div>';
|
$invoice_message = '<p>$client<br><br>'.self::transformText('invoice_message').'</p><div class="center">$view_button</div>';
|
||||||
|
|
||||||
return $invoice_message;
|
return $invoice_message;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ class EmailTemplateDefaults
|
|||||||
|
|
||||||
public static function emailQuoteTemplate()
|
public static function emailQuoteTemplate()
|
||||||
{
|
{
|
||||||
$quote_message = '<p>'.self::transformText('quote_message').'</p><div class="center">$view_button</div>';
|
$quote_message = '<p>$client<br><br>'.self::transformText('quote_message').'</p><div class="center">$view_button</div>';
|
||||||
|
|
||||||
return $quote_message;
|
return $quote_message;
|
||||||
}
|
}
|
||||||
@ -147,21 +147,21 @@ class EmailTemplateDefaults
|
|||||||
|
|
||||||
public static function emailPaymentTemplate()
|
public static function emailPaymentTemplate()
|
||||||
{
|
{
|
||||||
$payment_message = '<p>'.self::transformText('payment_message').'</p><div class="center">$view_button</div>';
|
$payment_message = '<p>$client<br><br>'.self::transformText('payment_message').'<br><br>$invoices</p><div class="center">$view_button</div>';
|
||||||
|
|
||||||
return $payment_message;
|
return $payment_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function emailCreditTemplate()
|
public static function emailCreditTemplate()
|
||||||
{
|
{
|
||||||
$credit_message = '<p>'.self::transformText('credit_message').'</p><div class="center">$view_button</div>';
|
$credit_message = '<p>$client<br><br>'.self::transformText('credit_message').'</p><div class="center">$view_button</div>';
|
||||||
|
|
||||||
return $credit_message;
|
return $credit_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function emailPaymentPartialTemplate()
|
public static function emailPaymentPartialTemplate()
|
||||||
{
|
{
|
||||||
$payment_message = '<p>'.self::transformText('payment_message').'</p><div class="center">$view_button</div>';
|
$payment_message = '<p>$client<br><br>'.self::transformText('payment_message').'<br><br>$invoices</p><div class="center">$view_button</div>';
|
||||||
|
|
||||||
return $payment_message;
|
return $payment_message;
|
||||||
}
|
}
|
||||||
|
100
app/DataMapper/Transactions/BaseTransaction.php
Normal file
100
app/DataMapper/Transactions/BaseTransaction.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BaseTransaction.
|
||||||
|
*/
|
||||||
|
class BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_MARK_PAID;
|
||||||
|
|
||||||
|
public array $model = [
|
||||||
|
'client_id',
|
||||||
|
'invoice_id',
|
||||||
|
'payment_id',
|
||||||
|
'credit_id',
|
||||||
|
'client_balance',
|
||||||
|
'client_paid_to_date',
|
||||||
|
'client_credit_balance',
|
||||||
|
'invoice_balance',
|
||||||
|
'invoice_amount',
|
||||||
|
'invoice_partial',
|
||||||
|
'invoice_paid_to_date',
|
||||||
|
'invoice_status',
|
||||||
|
'payment_amount',
|
||||||
|
'payment_applied',
|
||||||
|
'payment_refunded',
|
||||||
|
'payment_status',
|
||||||
|
'paymentables',
|
||||||
|
'event_id',
|
||||||
|
'timestamp',
|
||||||
|
'payment_request',
|
||||||
|
'metadata',
|
||||||
|
'credit_balance',
|
||||||
|
'credit_amount',
|
||||||
|
'credit_status',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function transform(array $data) :array
|
||||||
|
{
|
||||||
|
// $invoice = $data['invoice'];
|
||||||
|
// $payment = $data['payment'];
|
||||||
|
// $client = $data['client'];
|
||||||
|
// $credit = $data['credit'];
|
||||||
|
// $payment_request = $data['payment']['payment_request'];
|
||||||
|
// $metadata = $data['metadata'];
|
||||||
|
|
||||||
|
return array_merge(
|
||||||
|
$data['invoice'],
|
||||||
|
$data['payment'],
|
||||||
|
$data['client'],
|
||||||
|
$data['credit'],
|
||||||
|
$data['metadata'],
|
||||||
|
['event_id' => $this->event_id, 'timestamp' =>time()],
|
||||||
|
);
|
||||||
|
// return [
|
||||||
|
// 'event_id' => $this->event_id,
|
||||||
|
// 'client_id' => $client?->id,
|
||||||
|
// 'invoice_id' => $invoice?->id,
|
||||||
|
// 'payment_id' => $payment?->id,
|
||||||
|
// 'credit_id' => $credit?->creditid,
|
||||||
|
// 'client_balance' => $client?->balance,
|
||||||
|
// 'client_paid_to_date' => $client?->paid_to_date,
|
||||||
|
// 'client_credit_balance' => $client?->credit_balance,
|
||||||
|
// 'invoice_balance' => $invoice?->balance,
|
||||||
|
// 'invoice_amount' => $invoice?->amount,
|
||||||
|
// 'invoice_partial' => $invoice?->partial,
|
||||||
|
// 'invoice_paid_to_date' => $invoice?->paid_to_date,
|
||||||
|
// 'invoice_status' => $invoice?->status_id,
|
||||||
|
// 'payment_amount' => $payment?->amount,
|
||||||
|
// 'payment_applied' => $payment?->applied,
|
||||||
|
// 'payment_refunded' => $payment?->refunded,
|
||||||
|
// 'payment_status' => $payment?->status_id,
|
||||||
|
// 'paymentables' => $payment?->paymentables,
|
||||||
|
// 'payment_request' => $payment_request,
|
||||||
|
// 'metadata' => $metadata,
|
||||||
|
// 'credit_balance' => $credit?->balance,
|
||||||
|
// 'credit_amount' => $credit?->amount,
|
||||||
|
// 'credit_status' => $credit?->status_id,
|
||||||
|
// 'timestamp' => time(),
|
||||||
|
// ];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
28
app/DataMapper/Transactions/ClientStatusTransaction.php
Normal file
28
app/DataMapper/Transactions/ClientStatusTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClientStatusTransaction.
|
||||||
|
*/
|
||||||
|
class ClientStatusTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::CLIENT_STATUS;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GatewayPaymentMadeTransaction.
|
||||||
|
*/
|
||||||
|
class GatewayPaymentMadeTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::GATEWAY_PAYMENT_MADE;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/InvoiceCancelledTransaction.php
Normal file
28
app/DataMapper/Transactions/InvoiceCancelledTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceCancelledTransaction.
|
||||||
|
*/
|
||||||
|
class InvoiceCancelledTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_CANCELLED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/InvoiceDeletedTransaction.php
Normal file
28
app/DataMapper/Transactions/InvoiceDeletedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceDeletedTransaction.
|
||||||
|
*/
|
||||||
|
class InvoiceDeletedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_DELETED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/InvoiceFeeAppliedTransaction.php
Normal file
28
app/DataMapper/Transactions/InvoiceFeeAppliedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceFeeAppliedTransaction.
|
||||||
|
*/
|
||||||
|
class InvoiceFeeAppliedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_FEE_APPLIED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/InvoicePaymentTransaction.php
Normal file
28
app/DataMapper/Transactions/InvoicePaymentTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoicePaymentTransaction.
|
||||||
|
*/
|
||||||
|
class InvoicePaymentTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_PAYMENT_APPLIED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/InvoiceReversalTransaction.php
Normal file
28
app/DataMapper/Transactions/InvoiceReversalTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceReversalTransaction.
|
||||||
|
*/
|
||||||
|
class InvoiceReversalTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_REVERSED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/InvoiceUpdatedTransaction.php
Normal file
28
app/DataMapper/Transactions/InvoiceUpdatedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceUpdatedTransaction.
|
||||||
|
*/
|
||||||
|
class InvoiceUpdatedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_UPDATED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/MarkPaidTransaction.php
Normal file
28
app/DataMapper/Transactions/MarkPaidTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BaseTransaction.
|
||||||
|
*/
|
||||||
|
class MarkPaidTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::INVOICE_MARK_PAID;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/PaymentAppliedTransaction.php
Normal file
28
app/DataMapper/Transactions/PaymentAppliedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentAppliedTransaction.
|
||||||
|
*/
|
||||||
|
class PaymentAppliedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::PAYMENT_APPLIED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/PaymentDeletedTransaction.php
Normal file
28
app/DataMapper/Transactions/PaymentDeletedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentDeletedTransaction.
|
||||||
|
*/
|
||||||
|
class PaymentDeletedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::PAYMENT_DELETED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/PaymentFailedTransaction.php
Normal file
28
app/DataMapper/Transactions/PaymentFailedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentFailedTransaction.
|
||||||
|
*/
|
||||||
|
class PaymentFailedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::PAYMENT_FAILED;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/PaymentMadeTransaction.php
Normal file
28
app/DataMapper/Transactions/PaymentMadeTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentMadeTransaction.
|
||||||
|
*/
|
||||||
|
class PaymentMadeTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::PAYMENT_MADE;
|
||||||
|
|
||||||
|
}
|
28
app/DataMapper/Transactions/PaymentRefundedTransaction.php
Normal file
28
app/DataMapper/Transactions/PaymentRefundedTransaction.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentRefundedTransaction.
|
||||||
|
*/
|
||||||
|
class PaymentRefundedTransaction extends BaseTransaction implements TransactionInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public $event_id = TransactionEvent::PAYMENT_REFUND;
|
||||||
|
|
||||||
|
}
|
17
app/DataMapper/Transactions/TransactionInterface.php
Normal file
17
app/DataMapper/Transactions/TransactionInterface.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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\DataMapper\Transactions;
|
||||||
|
|
||||||
|
interface TransactionInterface
|
||||||
|
{
|
||||||
|
public function transform(array $data) :array;
|
||||||
|
}
|
@ -28,7 +28,7 @@ class CreditFactory
|
|||||||
$credit->terms = '';
|
$credit->terms = '';
|
||||||
$credit->public_notes = '';
|
$credit->public_notes = '';
|
||||||
$credit->private_notes = '';
|
$credit->private_notes = '';
|
||||||
$credit->date = null;
|
$credit->date = now()->format('Y-m-d');
|
||||||
$credit->due_date = null;
|
$credit->due_date = null;
|
||||||
$credit->partial_due_date = null;
|
$credit->partial_due_date = null;
|
||||||
$credit->is_deleted = false;
|
$credit->is_deleted = false;
|
||||||
|
@ -27,7 +27,7 @@ class InvoiceFactory
|
|||||||
$invoice->terms = '';
|
$invoice->terms = '';
|
||||||
$invoice->public_notes = '';
|
$invoice->public_notes = '';
|
||||||
$invoice->private_notes = '';
|
$invoice->private_notes = '';
|
||||||
$invoice->date = null;
|
$invoice->date = now()->format('Y-m-d');
|
||||||
$invoice->due_date = null;
|
$invoice->due_date = null;
|
||||||
$invoice->partial_due_date = null;
|
$invoice->partial_due_date = null;
|
||||||
$invoice->is_deleted = false;
|
$invoice->is_deleted = false;
|
||||||
|
@ -27,7 +27,7 @@ class QuoteFactory
|
|||||||
$quote->terms = '';
|
$quote->terms = '';
|
||||||
$quote->public_notes = '';
|
$quote->public_notes = '';
|
||||||
$quote->private_notes = '';
|
$quote->private_notes = '';
|
||||||
$quote->date = null;
|
$quote->date = now()->format('Y-m-d');
|
||||||
$quote->due_date = null;
|
$quote->due_date = null;
|
||||||
$quote->partial_due_date = null;
|
$quote->partial_due_date = null;
|
||||||
$quote->is_deleted = false;
|
$quote->is_deleted = false;
|
||||||
|
@ -89,9 +89,6 @@ class InvoiceItemSumInclusive
|
|||||||
{
|
{
|
||||||
$this->setLineTotal($this->item->cost * $this->item->quantity);
|
$this->setLineTotal($this->item->cost * $this->item->quantity);
|
||||||
|
|
||||||
//11-02-2022
|
|
||||||
// $this->setLineTotal($this->formatValue($this->item->cost, $this->currency->precision) * $this->formatValue($this->item->quantity, $this->currency->precision));
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +168,8 @@ class InvoiceItemSumInclusive
|
|||||||
|
|
||||||
public function setLineTotal($total)
|
public function setLineTotal($total)
|
||||||
{
|
{
|
||||||
|
$this->item->gross_line_total = $total;
|
||||||
|
|
||||||
$this->item->line_total = $total;
|
$this->item->line_total = $total;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -764,7 +764,8 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
$this->buildCache();
|
$this->buildCache();
|
||||||
|
|
||||||
return view('index.index', $data);
|
return response()->view('index.index', $data)->header('X-Frame-Options', 'SAMEORIGIN', false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect('/setup');
|
return redirect('/setup');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\ClientPortal;
|
namespace App\Http\Controllers\ClientPortal;
|
||||||
|
|
||||||
|
use App\DataMapper\Analytics\TrialStarted;
|
||||||
use App\Factory\RecurringInvoiceFactory;
|
use App\Factory\RecurringInvoiceFactory;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\ClientPortal\Uploads\StoreUploadRequest;
|
use App\Http\Requests\ClientPortal\Uploads\StoreUploadRequest;
|
||||||
@ -32,6 +33,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Turbo124\Beacon\Facades\LightLogs;
|
||||||
|
|
||||||
class NinjaPlanController extends Controller
|
class NinjaPlanController extends Controller
|
||||||
{
|
{
|
||||||
@ -134,7 +136,7 @@ class NinjaPlanController extends Controller
|
|||||||
// $account = auth()->guard('contact')->user()->company->account;
|
// $account = auth()->guard('contact')->user()->company->account;
|
||||||
if(auth()->guard('contact')->user()->client->custom_value2){
|
if(auth()->guard('contact')->user()->client->custom_value2){
|
||||||
MultiDB::findAndSetDbByAccountKey(auth()->guard('contact')->user()->client->custom_value2);
|
MultiDB::findAndSetDbByAccountKey(auth()->guard('contact')->user()->client->custom_value2);
|
||||||
$account = Account::where('key', auth()->guard('contact')->user()->client->custom_value2);
|
$account = Account::where('key', auth()->guard('contact')->user()->client->custom_value2)->first();
|
||||||
$account->trial_started = now();
|
$account->trial_started = now();
|
||||||
$account->trial_plan = 'pro';
|
$account->trial_plan = 'pro';
|
||||||
$account->save();
|
$account->save();
|
||||||
@ -159,11 +161,15 @@ class NinjaPlanController extends Controller
|
|||||||
$recurring_invoice->next_send_date = now()->addDays(14)->format('Y-m-d');
|
$recurring_invoice->next_send_date = now()->addDays(14)->format('Y-m-d');
|
||||||
|
|
||||||
$recurring_invoice->save();
|
$recurring_invoice->save();
|
||||||
$recurring_invoice = $recurring_invoice->calc()->getRecurringInvoice();
|
$r = $recurring_invoice->calc()->getRecurringInvoice();
|
||||||
|
|
||||||
$recurring_invoice->service()->start();
|
$recurring_invoice->service()->start()->save();
|
||||||
|
|
||||||
return redirect('https://invoicing.co');
|
LightLogs::create(new TrialStarted())
|
||||||
|
->increment()
|
||||||
|
->queue();
|
||||||
|
|
||||||
|
return $this->render('plan.trial_confirmed', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +186,7 @@ class NinjaPlanController extends Controller
|
|||||||
|
|
||||||
public function plan()
|
public function plan()
|
||||||
{
|
{
|
||||||
|
// return $this->trial();
|
||||||
//harvest the current plan
|
//harvest the current plan
|
||||||
$data = [];
|
$data = [];
|
||||||
$data['late_invoice'] = false;
|
$data['late_invoice'] = false;
|
||||||
|
@ -29,11 +29,13 @@ use App\Http\Requests\Invoice\UploadInvoiceRequest;
|
|||||||
use App\Jobs\Entity\EmailEntity;
|
use App\Jobs\Entity\EmailEntity;
|
||||||
use App\Jobs\Invoice\StoreInvoice;
|
use App\Jobs\Invoice\StoreInvoice;
|
||||||
use App\Jobs\Invoice\ZipInvoices;
|
use App\Jobs\Invoice\ZipInvoices;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Jobs\Util\UnlinkFile;
|
use App\Jobs\Util\UnlinkFile;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Repositories\InvoiceRepository;
|
use App\Repositories\InvoiceRepository;
|
||||||
use App\Transformers\InvoiceTransformer;
|
use App\Transformers\InvoiceTransformer;
|
||||||
use App\Transformers\QuoteTransformer;
|
use App\Transformers\QuoteTransformer;
|
||||||
@ -224,6 +226,16 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $invoice->transaction_event(),
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_UPDATED, $transaction, $invoice->company->db);
|
||||||
|
|
||||||
return $this->itemResponse($invoice);
|
return $this->itemResponse($invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,6 +417,16 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $invoice->transaction_event(),
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_UPDATED, $transaction, $invoice->company->db);
|
||||||
|
|
||||||
return $this->itemResponse($invoice);
|
return $this->itemResponse($invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +685,7 @@ class InvoiceController extends BaseController
|
|||||||
return $this->errorResponse(['message' => ctrans('texts.invoice_cannot_be_marked_paid')], 400);
|
return $this->errorResponse(['message' => ctrans('texts.invoice_cannot_be_marked_paid')], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = $invoice->service()->markPaid();
|
$invoice = $invoice->service()->markPaid()->save();
|
||||||
|
|
||||||
if (! $bulk) {
|
if (! $bulk) {
|
||||||
return $this->itemResponse($invoice);
|
return $this->itemResponse($invoice);
|
||||||
@ -935,6 +957,9 @@ class InvoiceController extends BaseController
|
|||||||
if ($request->has('documents'))
|
if ($request->has('documents'))
|
||||||
$this->saveDocuments($request->file('documents'), $invoice);
|
$this->saveDocuments($request->file('documents'), $invoice);
|
||||||
|
|
||||||
|
if ($request->has('file'))
|
||||||
|
$this->saveDocuments($request->file('documents'), $invoice);
|
||||||
|
|
||||||
return $this->itemResponse($invoice->fresh());
|
return $this->itemResponse($invoice->fresh());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -672,8 +672,7 @@ class QuoteController extends BaseController
|
|||||||
return $this->itemResponse($quote);
|
return $this->itemResponse($quote);
|
||||||
break;
|
break;
|
||||||
case 'approve':
|
case 'approve':
|
||||||
//make sure it hasn't already been approved!!
|
if (!in_array($quote->status_id, [Quote::STATUS_SENT, Quote::STATUS_DRAFT]) ) {
|
||||||
if ($quote->status_id != Quote::STATUS_SENT) {
|
|
||||||
return response()->json(['message' => ctrans('texts.quote_unapprovable')], 400);
|
return response()->json(['message' => ctrans('texts.quote_unapprovable')], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ class RequiredClientInfo extends Component
|
|||||||
*/
|
*/
|
||||||
public $contact;
|
public $contact;
|
||||||
|
|
||||||
|
public $client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -64,6 +66,36 @@ class RequiredClientInfo extends Component
|
|||||||
// 'contact_phone' => 'phone',
|
// 'contact_phone' => 'phone',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $client_address_array = [
|
||||||
|
'address1',
|
||||||
|
'address2',
|
||||||
|
'city',
|
||||||
|
'state',
|
||||||
|
'postal_code',
|
||||||
|
'country_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'client.address1' => '',
|
||||||
|
'client.address2' => '',
|
||||||
|
'client.city' => '',
|
||||||
|
'client.state' => '',
|
||||||
|
'client.postal_code' => '',
|
||||||
|
'client.country_id' => '',
|
||||||
|
'client.shipping_address1' => '',
|
||||||
|
'client.shipping_address2' => '',
|
||||||
|
'client.shipping_city' => '',
|
||||||
|
'client.shipping_state' => '',
|
||||||
|
'client.shipping_postal_code' => '',
|
||||||
|
'client.shipping_country_id' => '',
|
||||||
|
'contact.first_name' => '',
|
||||||
|
'contact.last_name' => '',
|
||||||
|
'contact.email' => '',
|
||||||
|
'client.name' => '',
|
||||||
|
'client.website' => '',
|
||||||
|
'client.phone' => '',
|
||||||
|
];
|
||||||
|
|
||||||
public $show_form = false;
|
public $show_form = false;
|
||||||
|
|
||||||
public $company;
|
public $company;
|
||||||
@ -71,6 +103,13 @@ class RequiredClientInfo extends Component
|
|||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
|
$this->client = $this->contact->client;
|
||||||
|
|
||||||
|
count($this->fields) > 0
|
||||||
|
? $this->checkFields()
|
||||||
|
: $this->show_form = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleSubmit(array $data): bool
|
public function handleSubmit(array $data): bool
|
||||||
@ -141,8 +180,7 @@ class RequiredClientInfo extends Component
|
|||||||
$_field = $this->mappings[$field['name']];
|
$_field = $this->mappings[$field['name']];
|
||||||
|
|
||||||
if (Str::startsWith($field['name'], 'client_')) {
|
if (Str::startsWith($field['name'], 'client_')) {
|
||||||
if (empty($this->contact->client->{$_field}) || is_null($this->contact->client->{$_field})) {
|
if (empty($this->contact->client->{$_field}) || is_null($this->contact->client->{$_field}) || in_array($_field, $this->client_address_array)) {
|
||||||
// if (empty($this->contact->client->{$_field}) || is_null($this->contact->client->{$_field}) || $this->contact->client->{$_field} == 840) {
|
|
||||||
$this->show_form = true;
|
$this->show_form = true;
|
||||||
} else {
|
} else {
|
||||||
$this->fields[$index]['filled'] = true;
|
$this->fields[$index]['filled'] = true;
|
||||||
@ -151,7 +189,6 @@ class RequiredClientInfo extends Component
|
|||||||
|
|
||||||
if (Str::startsWith($field['name'], 'contact_')) {
|
if (Str::startsWith($field['name'], 'contact_')) {
|
||||||
if (empty($this->contact->{$_field}) || is_null($this->contact->{$_field})) {
|
if (empty($this->contact->{$_field}) || is_null($this->contact->{$_field})) {
|
||||||
// if ((empty($this->contact->{$_field}) || is_null($this->contact->{$_field})) || $this->contact->client->{$_field} == 840) {
|
|
||||||
$this->show_form = true;
|
$this->show_form = true;
|
||||||
} else {
|
} else {
|
||||||
$this->fields[$index]['filled'] = true;
|
$this->fields[$index]['filled'] = true;
|
||||||
@ -193,10 +230,6 @@ class RequiredClientInfo extends Component
|
|||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
count($this->fields) > 0
|
|
||||||
? $this->checkFields()
|
|
||||||
: $this->show_form = false;
|
|
||||||
|
|
||||||
return render('components.livewire.required-client-info');
|
return render('components.livewire.required-client-info');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,16 @@ class StoreInvoiceRequest extends Request
|
|||||||
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
$rules['documents'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->input('file') && is_array($this->input('file'))) {
|
||||||
|
$documents = count($this->input('file'));
|
||||||
|
|
||||||
|
foreach (range(0, $documents) as $index) {
|
||||||
|
$rules['file.'.$index] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
||||||
|
}
|
||||||
|
} elseif ($this->input('file')) {
|
||||||
|
$rules['file'] = 'file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:20000';
|
||||||
|
}
|
||||||
|
|
||||||
$rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
$rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||||
// $rules['client_id'] = ['required', Rule::exists('clients')->where('company_id', auth()->user()->company()->id)];
|
// $rules['client_id'] = ['required', Rule::exists('clients')->where('company_id', auth()->user()->company()->id)];
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace App\Http\Requests\Invoice;
|
|||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Http\ValidationRules\Invoice\InvoiceBalanceSanity;
|
use App\Http\ValidationRules\Invoice\InvoiceBalanceSanity;
|
||||||
use App\Http\ValidationRules\Invoice\LockedInvoiceRule;
|
use App\Http\ValidationRules\Invoice\LockedInvoiceRule;
|
||||||
|
use App\Http\ValidationRules\Project\ValidProjectForClient;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Utils\Traits\ChecksEntityStatus;
|
use App\Utils\Traits\ChecksEntityStatus;
|
||||||
use App\Utils\Traits\CleanLineItems;
|
use App\Utils\Traits\CleanLineItems;
|
||||||
@ -59,6 +60,7 @@ class UpdateInvoiceRequest extends Request
|
|||||||
|
|
||||||
$rules['line_items'] = 'array';
|
$rules['line_items'] = 'array';
|
||||||
$rules['discount'] = 'sometimes|numeric';
|
$rules['discount'] = 'sometimes|numeric';
|
||||||
|
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||||
|
|
||||||
// if($this->input('status_id') != Invoice::STATUS_DRAFT)
|
// if($this->input('status_id') != Invoice::STATUS_DRAFT)
|
||||||
// $rules['balance'] = new InvoiceBalanceSanity($this->invoice, $this->all());
|
// $rules['balance'] = new InvoiceBalanceSanity($this->invoice, $this->all());
|
||||||
|
@ -33,6 +33,9 @@ class UploadInvoiceRequest extends Request
|
|||||||
if($this->input('documents'))
|
if($this->input('documents'))
|
||||||
$rules['documents'] = 'file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000';
|
$rules['documents'] = 'file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000';
|
||||||
|
|
||||||
|
if($this->input('file'))
|
||||||
|
$rules['file'] = 'file|mimes:csv,png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Http\Requests\RecurringInvoice;
|
namespace App\Http\Requests\RecurringInvoice;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Http\ValidationRules\Project\ValidProjectForClient;
|
||||||
use App\Http\ValidationRules\Recurring\UniqueRecurringInvoiceNumberRule;
|
use App\Http\ValidationRules\Recurring\UniqueRecurringInvoiceNumberRule;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\RecurringInvoice;
|
use App\Models\RecurringInvoice;
|
||||||
@ -55,6 +56,8 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
|
|
||||||
$rules['frequency_id'] = 'required|integer|digits_between:1,12';
|
$rules['frequency_id'] = 'required|integer|digits_between:1,12';
|
||||||
|
|
||||||
|
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||||
|
|
||||||
$rules['number'] = new UniqueRecurringInvoiceNumberRule($this->all());
|
$rules['number'] = new UniqueRecurringInvoiceNumberRule($this->all());
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
@ -80,6 +83,11 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
$input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']);
|
$input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('project_id', $input) && is_string($input['project_id'])) {
|
||||||
|
$input['project_id'] = $this->decodePrimaryKey($input['project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($input['client_contacts'])) {
|
if (isset($input['client_contacts'])) {
|
||||||
foreach ($input['client_contacts'] as $key => $contact) {
|
foreach ($input['client_contacts'] as $key => $contact) {
|
||||||
if (! array_key_exists('send_email', $contact) || ! array_key_exists('id', $contact)) {
|
if (! array_key_exists('send_email', $contact) || ! array_key_exists('id', $contact)) {
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Http\Requests\RecurringInvoice;
|
namespace App\Http\Requests\RecurringInvoice;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Http\ValidationRules\Project\ValidProjectForClient;
|
||||||
use App\Utils\Traits\ChecksEntityStatus;
|
use App\Utils\Traits\ChecksEntityStatus;
|
||||||
use App\Utils\Traits\CleanLineItems;
|
use App\Utils\Traits\CleanLineItems;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -51,6 +52,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
if($this->number)
|
if($this->number)
|
||||||
$rules['number'] = Rule::unique('recurring_invoices')->where('company_id', auth()->user()->company()->id)->ignore($this->recurring_invoice->id);
|
$rules['number'] = Rule::unique('recurring_invoices')->where('company_id', auth()->user()->company()->id)->ignore($this->recurring_invoice->id);
|
||||||
|
|
||||||
|
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
@ -59,16 +61,6 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
// foreach($this->input('documents') as $document)
|
|
||||||
// {
|
|
||||||
// if($document instanceof UploadedFile){
|
|
||||||
// nlog("i am an uploaded file");
|
|
||||||
// nlog($document);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// nlog($document);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||||
}
|
}
|
||||||
@ -81,6 +73,11 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('project_id', $input) && is_string($input['project_id'])) {
|
||||||
|
$input['project_id'] = $this->decodePrimaryKey($input['project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($input['invitations'])) {
|
if (isset($input['invitations'])) {
|
||||||
foreach ($input['invitations'] as $key => $value) {
|
foreach ($input['invitations'] as $key => $value) {
|
||||||
if (is_numeric($input['invitations'][$key]['id'])) {
|
if (is_numeric($input['invitations'][$key]['id'])) {
|
||||||
|
11
app/Http/Requests/Vendor/StoreVendorRequest.php
vendored
11
app/Http/Requests/Vendor/StoreVendorRequest.php
vendored
@ -36,14 +36,19 @@ class StoreVendorRequest extends Request
|
|||||||
|
|
||||||
/* Ensure we have a client name, and that all emails are unique*/
|
/* Ensure we have a client name, and that all emails are unique*/
|
||||||
//$rules['name'] = 'required|min:1';
|
//$rules['name'] = 'required|min:1';
|
||||||
$rules['id_number'] = 'unique:vendors,id_number,'.$this->id.',id,company_id,'.$this->company_id;
|
// $rules['id_number'] = 'unique:vendors,id_number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
|
||||||
//$rules['settings'] = new ValidVendorGroupSettingsRule();
|
//$rules['settings'] = new ValidVendorGroupSettingsRule();
|
||||||
$rules['contacts.*.email'] = 'nullable|distinct';
|
|
||||||
|
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
|
||||||
|
|
||||||
if (isset($this->number)) {
|
if (isset($this->number)) {
|
||||||
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
|
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (isset($this->id_number)) {
|
||||||
|
// $rules['id_number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id);
|
||||||
|
// }
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +64,7 @@ class StoreVendorRequest extends Request
|
|||||||
public function messages()
|
public function messages()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
// 'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
||||||
//'required' => trans('validation.required', ['attribute' => 'email']),
|
//'required' => trans('validation.required', ['attribute' => 'email']),
|
||||||
'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
|
'contacts.*.email.required' => ctrans('validation.email', ['attribute' => 'email']),
|
||||||
];
|
];
|
||||||
|
@ -40,11 +40,11 @@ class UpdateVendorRequest extends Request
|
|||||||
if($this->number)
|
if($this->number)
|
||||||
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id)->ignore($this->vendor->id);
|
$rules['number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id)->ignore($this->vendor->id);
|
||||||
|
|
||||||
if($this->id_number)
|
// if($this->id_number)
|
||||||
$rules['id_number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id)->ignore($this->vendor->id);
|
// $rules['id_number'] = Rule::unique('vendors')->where('company_id', auth()->user()->company()->id)->ignore($this->vendor->id);
|
||||||
|
|
||||||
$rules['contacts.*.email'] = 'nullable|distinct';
|
$rules['contacts.*.email'] = 'nullable|distinct';
|
||||||
|
// $rules['id_number'] = 'unique:vendors,id_number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ class CompanyExport implements ShouldQueue
|
|||||||
$this->export_data['invoices'] = $this->company->invoices()->orderBy('number', 'DESC')->cursor()->map(function ($invoice){
|
$this->export_data['invoices'] = $this->company->invoices()->orderBy('number', 'DESC')->cursor()->map(function ($invoice){
|
||||||
|
|
||||||
$invoice = $this->transformBasicEntities($invoice);
|
$invoice = $this->transformBasicEntities($invoice);
|
||||||
$invoice = $this->transformArrayOfKeys($invoice, ['recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id']);
|
$invoice = $this->transformArrayOfKeys($invoice, ['recurring_id','client_id', 'vendor_id', 'project_id', 'design_id', 'subscription_id','project_id']);
|
||||||
|
|
||||||
return $invoice->makeVisible(['id',
|
return $invoice->makeVisible(['id',
|
||||||
'private_notes',
|
'private_notes',
|
||||||
|
116
app/Jobs/Ninja/TransactionLog.php
Normal file
116
app/Jobs/Ninja/TransactionLog.php
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<?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\Jobs\Ninja;
|
||||||
|
|
||||||
|
use App\DataMapper\Transactions\ClientStatusTransaction;
|
||||||
|
use App\DataMapper\Transactions\GatewayPaymentMadeTransaction;
|
||||||
|
use App\DataMapper\Transactions\InvoiceCancelledTransaction;
|
||||||
|
use App\DataMapper\Transactions\InvoiceDeletedTransaction;
|
||||||
|
use App\DataMapper\Transactions\InvoiceFeeAppliedTransaction;
|
||||||
|
use App\DataMapper\Transactions\InvoicePaymentTransaction;
|
||||||
|
use App\DataMapper\Transactions\InvoiceReversalTransaction;
|
||||||
|
use App\DataMapper\Transactions\InvoiceUpdatedTransaction;
|
||||||
|
use App\DataMapper\Transactions\MarkPaidTransaction;
|
||||||
|
use App\DataMapper\Transactions\PaymentAppliedTransaction;
|
||||||
|
use App\DataMapper\Transactions\PaymentDeletedTransaction;
|
||||||
|
use App\DataMapper\Transactions\PaymentFailedTransaction;
|
||||||
|
use App\DataMapper\Transactions\PaymentMadeTransaction;
|
||||||
|
use App\DataMapper\Transactions\PaymentRefundedTransaction;
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class TransactionLog implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
private array $payload;
|
||||||
|
|
||||||
|
private string $db;
|
||||||
|
|
||||||
|
private array $data;
|
||||||
|
|
||||||
|
private $event;
|
||||||
|
|
||||||
|
private $event_transformer;
|
||||||
|
|
||||||
|
private array $transformer_array = [
|
||||||
|
TransactionEvent::INVOICE_MARK_PAID => MarkPaidTransaction::class, //
|
||||||
|
TransactionEvent::INVOICE_UPDATED => InvoiceUpdatedTransaction::class, //
|
||||||
|
TransactionEvent::INVOICE_DELETED => InvoiceDeletedTransaction::class, //
|
||||||
|
TransactionEvent::INVOICE_PAYMENT_APPLIED => InvoicePaymentTransaction::class,
|
||||||
|
TransactionEvent::INVOICE_CANCELLED => InvoiceCancelledTransaction::class,
|
||||||
|
TransactionEvent::INVOICE_REVERSED => InvoiceReversalTransaction::class, //
|
||||||
|
TransactionEvent::INVOICE_FEE_APPLIED => InvoiceFeeAppliedTransaction::class, //
|
||||||
|
TransactionEvent::PAYMENT_MADE => PaymentMadeTransaction::class, //
|
||||||
|
TransactionEvent::GATEWAY_PAYMENT_MADE => GatewayPaymentMadeTransaction::class, //
|
||||||
|
TransactionEvent::PAYMENT_APPLIED => PaymentAppliedTransaction::class,
|
||||||
|
TransactionEvent::PAYMENT_REFUND => PaymentRefundedTransaction::class, //
|
||||||
|
TransactionEvent::PAYMENT_FAILED => PaymentFailedTransaction::class,
|
||||||
|
TransactionEvent::PAYMENT_DELETED => PaymentDeletedTransaction::class, //
|
||||||
|
TransactionEvent::CLIENT_STATUS => ClientStatusTransaction::class, //
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($event, $data, $db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
$this->event = $event;
|
||||||
|
$this->data = $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
// if(!Ninja::isHosted())
|
||||||
|
// return;
|
||||||
|
|
||||||
|
$this->setTransformer();
|
||||||
|
|
||||||
|
$this->payload = $this->event_transformer->transform($this->data);
|
||||||
|
|
||||||
|
$this->persist();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function setTransformer()
|
||||||
|
{
|
||||||
|
$class = $this->transformer_array[$this->event];
|
||||||
|
|
||||||
|
$this->event_transformer = new $class();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function persist()
|
||||||
|
{
|
||||||
|
MultiDB::setDB($this->db);
|
||||||
|
|
||||||
|
TransactionEvent::create($this->payload);
|
||||||
|
}
|
||||||
|
}
|
@ -650,6 +650,7 @@ class Import implements ShouldQueue
|
|||||||
if(array_key_exists('updated_at', $modified))
|
if(array_key_exists('updated_at', $modified))
|
||||||
$client->updated_at = Carbon::parse($modified['updated_at']);
|
$client->updated_at = Carbon::parse($modified['updated_at']);
|
||||||
|
|
||||||
|
$client->country_id = array_key_exists('country_id', $modified) ? $modified['country_id'] : $this->company->settings->country_id;
|
||||||
$client->save(['timestamps' => false]);
|
$client->save(['timestamps' => false]);
|
||||||
$client->fresh();
|
$client->fresh();
|
||||||
|
|
||||||
|
@ -47,6 +47,9 @@ class InvitationViewedListener implements ShouldQueue
|
|||||||
$entity_name = lcfirst(class_basename($event->entity));
|
$entity_name = lcfirst(class_basename($event->entity));
|
||||||
$invitation = $event->invitation;
|
$invitation = $event->invitation;
|
||||||
|
|
||||||
|
if($entity_name == 'recurringInvoice')
|
||||||
|
return;
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo = new NinjaMailerObject;
|
||||||
$nmo->mailable = new NinjaMailer( (new EntityViewedObject($invitation, $entity_name))->build() );
|
$nmo->mailable = new NinjaMailer( (new EntityViewedObject($invitation, $entity_name))->build() );
|
||||||
$nmo->company = $invitation->company;
|
$nmo->company = $invitation->company;
|
||||||
|
@ -153,7 +153,7 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
|
|
||||||
public function gateway_tokens()
|
public function gateway_tokens()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ClientGatewayToken::class);
|
return $this->hasMany(ClientGatewayToken::class)->orderBy('is_default', 'ASC');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function expenses()
|
public function expenses()
|
||||||
@ -840,4 +840,17 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
|
|
||||||
return $offset;
|
return $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function transaction_event()
|
||||||
|
{
|
||||||
|
$client = $this->fresh();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'client_balance' => $client->balance ?: 0,
|
||||||
|
'client_paid_to_date' => $client->paid_to_date ?: 0,
|
||||||
|
'client_credit_balance' => $client->credit_balance ?: 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,8 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function owner()
|
public function owner()
|
||||||
{
|
{
|
||||||
return $this->company_users->where('is_owner', true)->first()->user;
|
return $this->company_users()->withTrashed()->where('is_owner', true)->first()->user;
|
||||||
|
//return $this->company_users->where('is_owner', true)->first()->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolveRouteBinding($value, $field = null)
|
public function resolveRouteBinding($value, $field = null)
|
||||||
|
@ -302,4 +302,16 @@ class Credit extends BaseModel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function transaction_event()
|
||||||
|
{
|
||||||
|
|
||||||
|
$credit = $this->fresh();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'credit_id' => $credit->id,
|
||||||
|
'credit_amount' => $credit->amount ?: 0,
|
||||||
|
'credit_balance' => $credit->balance ?: 0,
|
||||||
|
'credit_status' => $credit->status_id ?: 1,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class Gateway extends StaticModel
|
|||||||
case 20:
|
case 20:
|
||||||
return [
|
return [
|
||||||
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
|
GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true],
|
||||||
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable','charge.succeeded']],
|
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable','charge.succeeded','payment_intent.succeeded']],
|
||||||
GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
|
GatewayType::ALIPAY => ['refund' => false, 'token_billing' => false],
|
||||||
GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false],
|
GatewayType::APPLE_PAY => ['refund' => false, 'token_billing' => false],
|
||||||
GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], //Stripe
|
GatewayType::SOFORT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], //Stripe
|
||||||
|
@ -232,6 +232,11 @@ class Invoice extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Expense::class);
|
return $this->hasMany(Expense::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function expense()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Expense::class);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Service entry points.
|
* Service entry points.
|
||||||
*/
|
*/
|
||||||
@ -535,4 +540,19 @@ class Invoice extends BaseModel
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function transaction_event()
|
||||||
|
{
|
||||||
|
|
||||||
|
$invoice = $this->fresh();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'invoice_id' => $invoice->id,
|
||||||
|
'invoice_amount' => $invoice->amount ?: 0,
|
||||||
|
'invoice_partial' => $invoice->partial ?: 0,
|
||||||
|
'invoice_balance' => $invoice->balance ?: 0,
|
||||||
|
'invoice_paid_to_date' => $invoice->paid_to_date ?: 0,
|
||||||
|
'invoice_status' => $invoice->status_id ?: 1,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,4 +324,19 @@ class Payment extends BaseModel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function transaction_event()
|
||||||
|
{
|
||||||
|
$payment = $this->fresh();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'payment_id' => $payment->id,
|
||||||
|
'payment_amount' => $payment->amount ?: 0,
|
||||||
|
'payment_applied' => $payment->applied ?: 0,
|
||||||
|
'payment_refunded' => $payment->refunded ?: 0,
|
||||||
|
'payment_status' => $payment->status_id ?: 1,
|
||||||
|
'paymentables' => $payment->paymentables->toArray(),
|
||||||
|
'payment_request' => request() ? request()->all() : [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
46
app/Models/TransactionEvent.php
Normal file
46
app/Models/TransactionEvent.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?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\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Bank.
|
||||||
|
*/
|
||||||
|
class TransactionEvent extends StaticModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public $guarded = ['id'];
|
||||||
|
|
||||||
|
public $casts = [
|
||||||
|
'metadata' => 'array',
|
||||||
|
'payment_request' => 'array',
|
||||||
|
'paymentables' => 'array',
|
||||||
|
];
|
||||||
|
|
||||||
|
public const INVOICE_MARK_PAID = 1;
|
||||||
|
public const INVOICE_UPDATED = 2;
|
||||||
|
public const INVOICE_DELETED = 3;
|
||||||
|
public const INVOICE_PAYMENT_APPLIED = 4;
|
||||||
|
public const INVOICE_CANCELLED = 5;
|
||||||
|
public const INVOICE_FEE_APPLIED = 6;
|
||||||
|
public const INVOICE_REVERSED = 7;
|
||||||
|
|
||||||
|
public const PAYMENT_MADE = 100;
|
||||||
|
public const PAYMENT_APPLIED = 101;
|
||||||
|
public const PAYMENT_REFUND = 102;
|
||||||
|
public const PAYMENT_FAILED = 103;
|
||||||
|
public const GATEWAY_PAYMENT_MADE = 104;
|
||||||
|
public const PAYMENT_DELETED = 105;
|
||||||
|
|
||||||
|
public const CLIENT_STATUS = 200;
|
||||||
|
}
|
@ -20,6 +20,7 @@ use App\Jobs\Mail\NinjaMailer;
|
|||||||
use App\Jobs\Mail\NinjaMailerJob;
|
use App\Jobs\Mail\NinjaMailerJob;
|
||||||
use App\Jobs\Mail\NinjaMailerObject;
|
use App\Jobs\Mail\NinjaMailerObject;
|
||||||
use App\Jobs\Mail\PaymentFailedMailer;
|
use App\Jobs\Mail\PaymentFailedMailer;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Mail\Admin\ClientPaymentFailureObject;
|
use App\Mail\Admin\ClientPaymentFailureObject;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
@ -32,6 +33,7 @@ use App\Models\Payment;
|
|||||||
use App\Models\PaymentHash;
|
use App\Models\PaymentHash;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Services\Subscription\SubscriptionService;
|
use App\Services\Subscription\SubscriptionService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -317,11 +319,23 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->withTrashed()->get();
|
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->withTrashed()->get();
|
||||||
|
|
||||||
$invoices->each(function ($invoice) use ($fee_total) {
|
$invoices->each(function ($invoice) use ($fee_total) {
|
||||||
|
|
||||||
if (collect($invoice->line_items)->contains('type_id', '3')) {
|
if (collect($invoice->line_items)->contains('type_id', '3')) {
|
||||||
$invoice->service()->toggleFeesPaid()->save();
|
$invoice->service()->toggleFeesPaid()->save();
|
||||||
$invoice->client->service()->updateBalance($fee_total)->save();
|
$invoice->client->service()->updateBalance($fee_total)->save();
|
||||||
$invoice->ledger()->updateInvoiceBalance($fee_total, "Gateway fee adjustment for invoice {$invoice->number}");
|
$invoice->ledger()->updateInvoiceBalance($fee_total, "Gateway fee adjustment for invoice {$invoice->number}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $invoice->transaction_event(),
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_FEE_APPLIED, $transaction, $invoice->company->db);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,9 +146,21 @@ class CreditCard
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$invoice_numbers = '';
|
||||||
|
|
||||||
|
if($this->eway_driver->payment_hash->data)
|
||||||
|
$invoice_numbers = collect($this->eway_driver->payment_hash->data->invoices)->pluck('invoice_number')->implode(',');
|
||||||
|
|
||||||
|
$amount = array_sum(array_column($this->eway_driver->payment_hash->invoices(), 'amount')) + $this->eway_driver->payment_hash->fee_total;
|
||||||
|
|
||||||
|
$description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->eway_driver->client->present()->name()}";
|
||||||
|
|
||||||
$transaction = [
|
$transaction = [
|
||||||
'Payment' => [
|
'Payment' => [
|
||||||
'TotalAmount' => $this->convertAmountForEway(),
|
'TotalAmount' => $this->convertAmountForEway(),
|
||||||
|
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
||||||
|
'InvoiceNumber' => $invoice_numbers,
|
||||||
|
'InvoiceReference' => $description,
|
||||||
],
|
],
|
||||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
||||||
'SecuredCardData' => $request->input('securefieldcode'),
|
'SecuredCardData' => $request->input('securefieldcode'),
|
||||||
@ -225,12 +237,22 @@ class CreditCard
|
|||||||
{
|
{
|
||||||
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
||||||
|
|
||||||
|
|
||||||
|
if($this->eway_driver->payment_hash->data)
|
||||||
|
$invoice_numbers = collect($this->eway_driver->payment_hash->data->invoices)->pluck('invoice_number')->implode(',');
|
||||||
|
|
||||||
|
$description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->eway_driver->client->present()->name()}";
|
||||||
|
|
||||||
$transaction = [
|
$transaction = [
|
||||||
'Customer' => [
|
'Customer' => [
|
||||||
'TokenCustomerID' => $token,
|
'TokenCustomerID' => $token,
|
||||||
],
|
],
|
||||||
'Payment' => [
|
'Payment' => [
|
||||||
'TotalAmount' => $this->convertAmountForEway($amount),
|
'TotalAmount' => $this->convertAmountForEway($amount),
|
||||||
|
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
||||||
|
'InvoiceNumber' => $invoice_numbers,
|
||||||
|
'InvoiceDescription' => $description,
|
||||||
|
'InvoiceReference' => $description,
|
||||||
],
|
],
|
||||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
||||||
];
|
];
|
||||||
|
@ -43,6 +43,14 @@ class Token
|
|||||||
|
|
||||||
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
||||||
|
|
||||||
|
|
||||||
|
$invoice_numbers = '';
|
||||||
|
|
||||||
|
if($this->eway_driver->payment_hash->data)
|
||||||
|
$invoice_numbers = collect($this->eway_driver->payment_hash->data->invoices)->pluck('invoice_number')->implode(',');
|
||||||
|
|
||||||
|
$description = "Invoices: {$invoice_numbers} for {$amount} for client {$this->eway_driver->client->present()->name()}";
|
||||||
|
|
||||||
$this->eway_driver->payment_hash = $payment_hash;
|
$this->eway_driver->payment_hash = $payment_hash;
|
||||||
|
|
||||||
$transaction = [
|
$transaction = [
|
||||||
@ -51,6 +59,10 @@ class Token
|
|||||||
],
|
],
|
||||||
'Payment' => [
|
'Payment' => [
|
||||||
'TotalAmount' => $this->eway_driver->convertAmount($amount),
|
'TotalAmount' => $this->eway_driver->convertAmount($amount),
|
||||||
|
'CurrencyCode' => $this->eway_driver->client->currency()->code,
|
||||||
|
'InvoiceNumber' => $invoice_numbers,
|
||||||
|
'InvoiceDescription' => $description,
|
||||||
|
'InvoiceReference' => $description,
|
||||||
],
|
],
|
||||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
'TransactionType' => \Eway\Rapid\Enum\TransactionType::RECURRING,
|
||||||
];
|
];
|
||||||
|
@ -154,6 +154,7 @@ class ACSS
|
|||||||
'interval_description' => 'when any invoice becomes due',
|
'interval_description' => 'when any invoice becomes due',
|
||||||
'transaction_type' => 'personal' // TODO: check if is company or personal https://stripe.com/docs/payments/acss-debit
|
'transaction_type' => 'personal' // TODO: check if is company or personal https://stripe.com/docs/payments/acss-debit
|
||||||
],
|
],
|
||||||
|
'verification_method' => 'instant',
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
], $this->stripe->stripe_connect_auth);
|
], $this->stripe->stripe_connect_auth);
|
||||||
@ -183,7 +184,7 @@ class ACSS
|
|||||||
$this->stripe->payment_hash->save();
|
$this->stripe->payment_hash->save();
|
||||||
|
|
||||||
if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') {
|
if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') {
|
||||||
$this->storePaymentMethod($gateway_response);
|
// $this->storePaymentMethod($gateway_response);
|
||||||
return $this->processSuccessfulPayment($gateway_response->id);
|
return $this->processSuccessfulPayment($gateway_response->id);
|
||||||
}
|
}
|
||||||
return $this->processUnsuccessfulPayment();
|
return $this->processUnsuccessfulPayment();
|
||||||
@ -243,12 +244,13 @@ class ACSS
|
|||||||
|
|
||||||
private function storePaymentMethod($intent)
|
private function storePaymentMethod($intent)
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
|
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
|
||||||
|
|
||||||
$payment_meta = new \stdClass;
|
$payment_meta = new \stdClass;
|
||||||
$payment_meta->brand = (string) \sprintf('%s (%s)', $method->au_becs_debit->bank_code, ctrans('texts.acss'));
|
$payment_meta->brand = (string) $method->acss_debit->bank_name;
|
||||||
$payment_meta->last4 = (string) $method->au_becs_debit->last4;
|
$payment_meta->last4 = (string) $method->acss_debit->last4;
|
||||||
$payment_meta->state = 'authorized';
|
$payment_meta->state = 'authorized';
|
||||||
$payment_meta->type = GatewayType::ACSS;
|
$payment_meta->type = GatewayType::ACSS;
|
||||||
|
|
||||||
|
@ -76,11 +76,9 @@ class ImportCustomers
|
|||||||
|
|
||||||
$account = $this->stripe->company_gateway->company->account;
|
$account = $this->stripe->company_gateway->company->account;
|
||||||
|
|
||||||
if(!$account->isPaidHostedClient() && Client::where('company_id', $this->stripe->company_gateway->company_id)->count() > config('ninja.quotas.free.clients'))
|
if(Ninja::isHosted() && !$account->isPaidHostedClient() && Client::where('company_id', $this->stripe->company_gateway->company_id)->count() > config('ninja.quotas.free.clients'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// nlog("search Stripe for {$customer->id}");
|
|
||||||
|
|
||||||
$existing_customer_token = $this->stripe
|
$existing_customer_token = $this->stripe
|
||||||
->company_gateway
|
->company_gateway
|
||||||
->client_gateway_tokens()
|
->client_gateway_tokens()
|
||||||
@ -104,9 +102,6 @@ class ImportCustomers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nlog("inserting a customer");
|
|
||||||
//nlog($customer);
|
|
||||||
|
|
||||||
$client = ClientFactory::create($this->stripe->company_gateway->company_id, $this->stripe->company_gateway->user_id);
|
$client = ClientFactory::create($this->stripe->company_gateway->company_id, $this->stripe->company_gateway->user_id);
|
||||||
|
|
||||||
if($customer->address)
|
if($customer->address)
|
||||||
|
@ -33,33 +33,10 @@ class UpdatePaymentMethods
|
|||||||
$this->stripe = $stripe;
|
$this->stripe = $stripe;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function run()
|
|
||||||
// {
|
|
||||||
// $this->stripe->init();
|
|
||||||
|
|
||||||
// $this->stripe
|
|
||||||
// ->company_gateway
|
|
||||||
// ->client_gateway_tokens
|
|
||||||
// ->each(function ($token){
|
|
||||||
|
|
||||||
|
|
||||||
// // $bank_accounts = Customer::allSources(
|
|
||||||
// // $token->gateway_customer_reference,
|
|
||||||
// // ['object' => 'bank_account', 'limit' => 300]
|
|
||||||
// // );
|
|
||||||
|
|
||||||
// // foreach($bank_accounts as $bank_account)
|
|
||||||
// // {
|
|
||||||
// // $this->addOrUpdateBankAccount($bank_account, $token);
|
|
||||||
// // }
|
|
||||||
// // $this->processCustomer($token->gateway_customer_reference);
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function updateMethods(Customer $customer, Client $client)
|
public function updateMethods(Customer $customer, Client $client)
|
||||||
{
|
{
|
||||||
|
$this->stripe->client = $client;
|
||||||
|
|
||||||
$card_methods = PaymentMethod::all([
|
$card_methods = PaymentMethod::all([
|
||||||
'customer' => $customer->id,
|
'customer' => $customer->id,
|
||||||
'type' => 'card',
|
'type' => 'card',
|
||||||
@ -93,37 +70,52 @@ class UpdatePaymentMethods
|
|||||||
$this->addOrUpdateCard($method, $customer->id, $client, GatewayType::SOFORT);
|
$this->addOrUpdateCard($method, $customer->id, $client, GatewayType::SOFORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//$this->importBankAccounts($customer, $client);
|
$this->importBankAccounts($customer, $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function importBankAccounts($customer, $client)
|
private function importBankAccounts($customer, $client)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$sources = $customer->sources;
|
||||||
|
|
||||||
|
foreach($sources->data as $method)
|
||||||
|
{
|
||||||
|
|
||||||
|
$token_exists = ClientGatewayToken::where([
|
||||||
|
'gateway_customer_reference' => $customer->id,
|
||||||
|
'token' => $method->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'company_id' => $client->company_id,
|
||||||
|
])->exists();
|
||||||
|
|
||||||
|
/* Already exists return */
|
||||||
|
if($token_exists)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$payment_meta = new \stdClass;
|
||||||
|
$payment_meta->brand = (string) \sprintf('%s (%s)', $method->bank_name, ctrans('texts.ach'));
|
||||||
|
$payment_meta->last4 = (string) $method->last4;
|
||||||
|
$payment_meta->type = GatewayType::BANK_TRANSFER;
|
||||||
|
$payment_meta->state = $method->status;
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'payment_meta' => $payment_meta,
|
||||||
|
'token' => $method->id,
|
||||||
|
'payment_method_id' => GatewayType::BANK_TRANSFER,
|
||||||
|
];
|
||||||
|
|
||||||
|
$additional_data = ['gateway_customer_reference' => $customer->id];
|
||||||
|
|
||||||
|
if($customer->default_source === $method->id)
|
||||||
|
$additional_data = ['gateway_customer_reference' => $customer->id, 'is_default', 1];
|
||||||
|
|
||||||
|
$this->stripe->storeGatewayToken($data, $additional_data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private function addOrUpdateBankAccount($bank_account, $customer_reference, Client $client)
|
|
||||||
// {
|
|
||||||
// $token_exists = ClientGatewayToken::where([
|
|
||||||
// 'gateway_customer_reference' => $customer_reference,
|
|
||||||
// 'token' => $bank_account->id,
|
|
||||||
// ])->exists();
|
|
||||||
|
|
||||||
// /* Already exists return */
|
|
||||||
// if($token_exists)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// $cgt = ClientGatewayTokenFactory::create($client->company_id);
|
|
||||||
// $cgt->client_id = $client->id;
|
|
||||||
// $cgt->token = $bank_account->id;
|
|
||||||
// $cgt->gateway_customer_reference = $customer_reference;
|
|
||||||
// $cgt->company_gateway_id = $this->stripe->company_gateway->id;
|
|
||||||
// $cgt->gateway_type_id = GatewayType::BANK_TRANSFER;
|
|
||||||
// $cgt->meta = new \stdClass;
|
|
||||||
// $cgt->routing_number = $bank_account->routing_number;
|
|
||||||
// $cgt->save();
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
private function addOrUpdateCard(PaymentMethod $method, $customer_reference, Client $client, $type_id)
|
private function addOrUpdateCard(PaymentMethod $method, $customer_reference, Client $client, $type_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -533,12 +533,10 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
//payment_intent.succeeded - this will confirm or cancel the payment
|
//payment_intent.succeeded - this will confirm or cancel the payment
|
||||||
if($request->type === 'payment_intent.succeeded'){
|
if($request->type === 'payment_intent.succeeded'){
|
||||||
PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(10);
|
PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(10);
|
||||||
// PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id);
|
|
||||||
return response()->json([], 200);
|
return response()->json([], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->type === 'charge.succeeded') {
|
if ($request->type === 'charge.succeeded') {
|
||||||
// if ($request->type === 'charge.succeeded' || $request->type === 'payment_intent.succeeded') {
|
|
||||||
|
|
||||||
foreach ($request->data as $transaction) {
|
foreach ($request->data as $transaction) {
|
||||||
|
|
||||||
|
@ -222,6 +222,9 @@ class BaseRepository
|
|||||||
if (array_key_exists('documents', $data))
|
if (array_key_exists('documents', $data))
|
||||||
$this->saveDocuments($data['documents'], $model);
|
$this->saveDocuments($data['documents'], $model);
|
||||||
|
|
||||||
|
if (array_key_exists('file', $data))
|
||||||
|
$this->saveDocuments($data['file'], $model);
|
||||||
|
|
||||||
/* If invitations are present we need to filter existing invitations with the new ones */
|
/* If invitations are present we need to filter existing invitations with the new ones */
|
||||||
if (isset($data['invitations'])) {
|
if (isset($data['invitations'])) {
|
||||||
$invitations = collect($data['invitations']);
|
$invitations = collect($data['invitations']);
|
||||||
|
@ -14,11 +14,13 @@ namespace App\Repositories;
|
|||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
use App\Events\Payment\PaymentWasDeleted;
|
use App\Events\Payment\PaymentWasDeleted;
|
||||||
use App\Jobs\Credit\ApplyCreditPayment;
|
use App\Jobs\Credit\ApplyCreditPayment;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Libraries\Currency\Conversion\CurrencyApi;
|
use App\Libraries\Currency\Conversion\CurrencyApi;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\SavesDocuments;
|
use App\Utils\Traits\SavesDocuments;
|
||||||
@ -94,11 +96,8 @@ class PaymentRepository extends BaseRepository {
|
|||||||
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
||||||
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
||||||
|
|
||||||
// if ($data['amount'] == $_credit_totals) {
|
$client->service()->updatePaidToDate($_credit_totals)->save();
|
||||||
// $data['amount'] = 0;
|
|
||||||
// } else {
|
|
||||||
$client->service()->updatePaidToDate($_credit_totals)->save();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -181,10 +180,19 @@ class PaymentRepository extends BaseRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$payment->applied += ($invoice_totals - $credit_totals); //wont work because - check tests
|
$payment->applied += ($invoice_totals - $credit_totals); //wont work because - check tests
|
||||||
// $payment->applied += $invoice_totals; //wont work because - check tests
|
|
||||||
|
|
||||||
$payment->save();
|
$payment->save();
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => [],
|
||||||
|
'payment' => $payment->transaction_event(),
|
||||||
|
'client' => $payment->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::PAYMENT_MADE, $transaction, $payment->company->db);
|
||||||
|
|
||||||
return $payment->fresh();
|
return $payment->fresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,4 +182,50 @@ class TaskRepository extends BaseRepository
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function start(Task $task)
|
||||||
|
{
|
||||||
|
if(strlen($task->time_log) < 5)
|
||||||
|
{
|
||||||
|
$log = [];
|
||||||
|
|
||||||
|
$log = array_merge($log, [[time(),0]]);
|
||||||
|
$task->time_log = json_encode($log);
|
||||||
|
$task->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$log = json_decode($task->time_log,true);;
|
||||||
|
|
||||||
|
$last = end($log);
|
||||||
|
|
||||||
|
if($last[1] !== 0){
|
||||||
|
|
||||||
|
$new = [time(), 0];
|
||||||
|
$log = array_merge($log, [$new]);
|
||||||
|
$task->time_log = json_encode($log);
|
||||||
|
$task->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stop(Task $task)
|
||||||
|
{
|
||||||
|
$log = json_decode($task->time_log,true);;
|
||||||
|
|
||||||
|
$last = end($log);
|
||||||
|
|
||||||
|
if($last[1] === 0){
|
||||||
|
|
||||||
|
$last[1] = time();
|
||||||
|
|
||||||
|
array_pop($log);
|
||||||
|
$log = array_merge($log, [$last]);
|
||||||
|
|
||||||
|
$task->time_log = json_encode($log);
|
||||||
|
$task->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,21 +28,27 @@ class ClientService
|
|||||||
|
|
||||||
public function updateBalance(float $amount)
|
public function updateBalance(float $amount)
|
||||||
{
|
{
|
||||||
$this->client->balance += $amount;
|
// $this->client->balance += $amount;
|
||||||
|
|
||||||
|
$this->client->increment('balance', $amount);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePaidToDate(float $amount)
|
public function updatePaidToDate(float $amount)
|
||||||
{
|
{
|
||||||
$this->client->paid_to_date += $amount;
|
// $this->client->paid_to_date += $amount;
|
||||||
|
|
||||||
|
$this->client->increment('paid_to_date', $amount);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adjustCreditBalance(float $amount)
|
public function adjustCreditBalance(float $amount)
|
||||||
{
|
{
|
||||||
$this->client->credit_balance += $amount;
|
// $this->client->credit_balance += $amount;
|
||||||
|
|
||||||
|
$this->client->increment('credit_balance', $amount);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,16 @@ class CreditService
|
|||||||
->attach($this->credit->id, ['amount' => $adjustment]);
|
->attach($this->credit->id, ['amount' => $adjustment]);
|
||||||
|
|
||||||
//reduce client paid_to_date by $this->credit->balance amount
|
//reduce client paid_to_date by $this->credit->balance amount
|
||||||
$this->credit
|
// $this->credit
|
||||||
->client
|
// ->client
|
||||||
->service()
|
// ->service()
|
||||||
->updatePaidToDate($adjustment)
|
// ->updatePaidToDate($adjustment)
|
||||||
->save();
|
// ->save();
|
||||||
|
|
||||||
|
$client = $this->credit->client->fresh();
|
||||||
|
$client->service()
|
||||||
|
->updatePaidToDate($adjustment)
|
||||||
|
->save();
|
||||||
|
|
||||||
event('eloquent.created: App\Models\Payment', $payment);
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
@ -162,21 +167,24 @@ class CreditService
|
|||||||
|
|
||||||
public function adjustBalance($adjustment)
|
public function adjustBalance($adjustment)
|
||||||
{
|
{
|
||||||
$this->credit->balance += $adjustment;
|
// $this->credit->balance += $adjustment;
|
||||||
|
$this->credit->increment('balance', $adjustment);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePaidToDate($adjustment)
|
public function updatePaidToDate($adjustment)
|
||||||
{
|
{
|
||||||
$this->credit->paid_to_date += $adjustment;
|
// $this->credit->paid_to_date += $adjustment;
|
||||||
|
$this->credit->increment('paid_to_date', $adjustment);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBalance($adjustment)
|
public function updateBalance($adjustment)
|
||||||
{
|
{
|
||||||
$this->credit->balance -= $adjustment;
|
// $this->credit->balance -= $adjustment;
|
||||||
|
$this->credit->decrement('balance', $adjustment);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
|
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
|
|
||||||
class ApplyPayment extends AbstractService
|
class ApplyPayment extends AbstractService
|
||||||
@ -128,6 +130,16 @@ class ApplyPayment extends AbstractService
|
|||||||
|
|
||||||
$this->invoice->service()->applyNumber()->workFlow()->save();
|
$this->invoice->service()->applyNumber()->workFlow()->save();
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $this->invoice->transaction_event(),
|
||||||
|
'payment' => $this->payment->transaction_event(),
|
||||||
|
'client' => $this->invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_PAYMENT_APPLIED, $transaction, $this->invoice->company->db);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,8 +189,8 @@ class AutoBillInvoice extends AbstractService
|
|||||||
->adjustCreditBalance($amount * -1)
|
->adjustCreditBalance($amount * -1)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$this->invoice->ledger()
|
$this->invoice->ledger() //09-03-2022
|
||||||
->updateInvoiceBalance($amount * -1, "Invoice {$this->invoice->number} payment using Credit {$current_credit->number}")
|
// ->updateInvoiceBalance($amount * -1, "Invoice {$this->invoice->number} payment using Credit {$current_credit->number}")
|
||||||
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
use App\Events\Invoice\InvoiceWasCancelled;
|
use App\Events\Invoice\InvoiceWasCancelled;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
@ -52,6 +54,16 @@ class HandleCancellation extends AbstractService
|
|||||||
|
|
||||||
event(new InvoiceWasCancelled($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new InvoiceWasCancelled($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $this->invoice->transaction_event(),
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $this->invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_CANCELLED, $transaction, $this->invoice->company->db);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,13 @@ use App\Events\Invoice\InvoiceWasReversed;
|
|||||||
use App\Factory\CreditFactory;
|
use App\Factory\CreditFactory;
|
||||||
use App\Factory\InvoiceItemFactory;
|
use App\Factory\InvoiceItemFactory;
|
||||||
use App\Helpers\Invoice\InvoiceSum;
|
use App\Helpers\Invoice\InvoiceSum;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\Paymentable;
|
use App\Models\Paymentable;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
@ -136,6 +138,16 @@ class HandleReversal extends AbstractService
|
|||||||
|
|
||||||
event(new InvoiceWasReversed($this->invoice, $this->invoice->company, Ninja::eventVars()));
|
event(new InvoiceWasReversed($this->invoice, $this->invoice->company, Ninja::eventVars()));
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $this->invoice->transaction_event(),
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $this->invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_REVERSED, $transaction, $this->invoice->company->db);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
//create a ledger row for this with the resulting Credit ( also include an explanation in the notes section )
|
//create a ledger row for this with the resulting Credit ( also include an explanation in the notes section )
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,10 @@ class InvoiceService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->invoice->balance += $balance_adjustment;
|
// $this->invoice->balance += $balance_adjustment;
|
||||||
|
|
||||||
|
$this->invoice->increment('balance', $balance_adjustment);
|
||||||
|
|
||||||
|
|
||||||
if (round($this->invoice->balance,2) == 0 && !$is_draft) {
|
if (round($this->invoice->balance,2) == 0 && !$is_draft) {
|
||||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||||
@ -160,7 +163,10 @@ class InvoiceService
|
|||||||
|
|
||||||
public function updatePaidToDate($adjustment)
|
public function updatePaidToDate($adjustment)
|
||||||
{
|
{
|
||||||
$this->invoice->paid_to_date += $adjustment;
|
// $this->invoice->paid_to_date += $adjustment;
|
||||||
|
|
||||||
|
$this->invoice->increment('paid_to_date', $adjustment);
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -381,7 +387,8 @@ class InvoiceService
|
|||||||
/*Update the partial amount of a invoice*/
|
/*Update the partial amount of a invoice*/
|
||||||
public function updatePartial($amount)
|
public function updatePartial($amount)
|
||||||
{
|
{
|
||||||
$this->invoice->partial += $amount;
|
// $this->invoice->partial += $amount;
|
||||||
|
$this->invoice->increment('partial', $amount);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@ -47,6 +49,16 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
->adjustBalance()
|
->adjustBalance()
|
||||||
->adjustLedger();
|
->adjustLedger();
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $this->invoice->transaction_event(),
|
||||||
|
'payment' => $this->invoice->payments()->exists() ? $this->invoice->payments()->first()->transaction_event() : [],
|
||||||
|
'client' => $this->invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => ['total_payments' => $this->total_payments, 'balance_adjustment' => $this->balance_adjustment, 'adjustment_amount' => $this->adjustment_amount],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_DELETED, $transaction, $this->invoice->company->db);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,11 +140,6 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
|
|
||||||
$this->balance_adjustment = $this->invoice->balance;
|
$this->balance_adjustment = $this->invoice->balance;
|
||||||
|
|
||||||
//$this->total_payments = $this->invoice->payments->sum('amount - refunded');
|
|
||||||
|
|
||||||
// nlog("adjustment amount = {$this->adjustment_amount}");
|
|
||||||
// nlog("total payments = {$this->total_payments}");
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,12 @@ use App\Events\Invoice\InvoiceWasPaid;
|
|||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
use App\Factory\PaymentFactory;
|
use App\Factory\PaymentFactory;
|
||||||
use App\Jobs\Invoice\InvoiceWorkflowSettings;
|
use App\Jobs\Invoice\InvoiceWorkflowSettings;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Jobs\Payment\EmailPayment;
|
use App\Jobs\Payment\EmailPayment;
|
||||||
use App\Libraries\Currency\Conversion\CurrencyApi;
|
use App\Libraries\Currency\Conversion\CurrencyApi;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
use App\Services\Client\ClientService;
|
use App\Services\Client\ClientService;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
@ -110,6 +112,16 @@ class MarkPaid extends AbstractService
|
|||||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $this->invoice->transaction_event(),
|
||||||
|
'payment' => $payment->transaction_event(),
|
||||||
|
'client' => $this->invoice->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::INVOICE_MARK_PAID, $transaction, $this->invoice->company->db);
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,17 +34,20 @@ class UpdateBalance extends AbstractService
|
|||||||
if ($this->invoice->is_deleted) {
|
if ($this->invoice->is_deleted) {
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
nlog("invoice id = {$this->invoice->id}");
|
|
||||||
nlog("invoice balance = {$this->invoice->balance}");
|
|
||||||
nlog("invoice adjustment = {$this->balance_adjustment}");
|
|
||||||
|
|
||||||
$this->invoice->balance += floatval($this->balance_adjustment);
|
nlog("invoice id = {$this->invoice->id}");
|
||||||
|
nlog("invoice balance = {$this->invoice->balance}");
|
||||||
|
nlog("invoice adjustment = {$this->balance_adjustment}");
|
||||||
|
|
||||||
|
// $this->invoice->balance += floatval($this->balance_adjustment);
|
||||||
|
|
||||||
|
$this->invoice->increment('balance', floatval($this->balance_adjustment));
|
||||||
|
|
||||||
if ($this->invoice->balance == 0 && !$this->is_draft) {
|
if ($this->invoice->balance == 0 && !$this->is_draft) {
|
||||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlog("final balance = {$this->invoice->balance}");
|
nlog("final balance = {$this->invoice->balance}");
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
namespace App\Services\Payment;
|
namespace App\Services\Payment;
|
||||||
|
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Repositories\ActivityRepository;
|
use App\Repositories\ActivityRepository;
|
||||||
|
|
||||||
class DeletePayment
|
class DeletePayment
|
||||||
@ -82,6 +84,8 @@ class DeletePayment
|
|||||||
|
|
||||||
$net_deletable = $paymentable_invoice->pivot->amount - $paymentable_invoice->pivot->refunded;
|
$net_deletable = $paymentable_invoice->pivot->amount - $paymentable_invoice->pivot->refunded;
|
||||||
|
|
||||||
|
$client = $this->payment->client->fresh();
|
||||||
|
|
||||||
nlog("net deletable amount - refunded = {$net_deletable}");
|
nlog("net deletable amount - refunded = {$net_deletable}");
|
||||||
|
|
||||||
if(!$paymentable_invoice->is_deleted)
|
if(!$paymentable_invoice->is_deleted)
|
||||||
@ -95,17 +99,16 @@ class DeletePayment
|
|||||||
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
|
->updateInvoiceBalance($net_deletable, "Adjusting invoice {$paymentable_invoice->number} due to deletion of Payment {$this->payment->number}")
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
$paymentable_invoice->client
|
$client = $client->service()
|
||||||
->service()
|
->updateBalance($net_deletable)
|
||||||
->updateBalance($net_deletable)
|
->save();
|
||||||
// ->updatePaidToDate($net_deletable * -1)
|
|
||||||
->save();
|
|
||||||
|
|
||||||
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
if ($paymentable_invoice->balance == $paymentable_invoice->amount) {
|
||||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
$paymentable_invoice->service()->setStatus(Invoice::STATUS_SENT)->save();
|
||||||
} else {
|
} else {
|
||||||
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();
|
$paymentable_invoice->service()->setStatus(Invoice::STATUS_PARTIAL)->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -118,19 +121,36 @@ class DeletePayment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $paymentable_invoice->transaction_event(),
|
||||||
|
'payment' => $this->payment->transaction_event(),
|
||||||
|
'client' => $client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::PAYMENT_DELETED, $transaction, $paymentable_invoice->company->db);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
|
|
||||||
/* If there are no invoices - then we need to still adjust the total client->paid_to_date amount*/
|
$this->payment
|
||||||
|
->client
|
||||||
|
->service()
|
||||||
|
->updatePaidToDate(($this->payment->amount - $this->payment->refunded)*-1)
|
||||||
|
->save();
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => [],
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $this->payment->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::CLIENT_STATUS, $transaction, $this->payment->company->db);
|
||||||
|
|
||||||
$this->payment
|
|
||||||
->client
|
|
||||||
->service()
|
|
||||||
->updatePaidToDate(($this->payment->amount - $this->payment->refunded)*-1)
|
|
||||||
->save();
|
|
||||||
|
|
||||||
// }
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,12 @@ namespace App\Services\Payment;
|
|||||||
use App\Exceptions\PaymentRefundFailed;
|
use App\Exceptions\PaymentRefundFailed;
|
||||||
use App\Factory\CreditFactory;
|
use App\Factory\CreditFactory;
|
||||||
use App\Factory\InvoiceItemFactory;
|
use App\Factory\InvoiceItemFactory;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Repositories\ActivityRepository;
|
use App\Repositories\ActivityRepository;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
@ -51,7 +53,7 @@ class RefundPayment
|
|||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
return $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
|
$this->payment = $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
|
||||||
->setStatus() //sets status of payment
|
->setStatus() //sets status of payment
|
||||||
//->reversePayment()
|
//->reversePayment()
|
||||||
//->buildCreditNote() //generate the credit note
|
//->buildCreditNote() //generate the credit note
|
||||||
@ -61,6 +63,18 @@ class RefundPayment
|
|||||||
->adjustInvoices()
|
->adjustInvoices()
|
||||||
->processGatewayRefund() //process the gateway refund if needed
|
->processGatewayRefund() //process the gateway refund if needed
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => [],
|
||||||
|
'payment' => $this->payment->transaction_event(),
|
||||||
|
'client' => $this->payment->client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $this->payment->company->db);
|
||||||
|
|
||||||
|
return $this->payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -256,27 +270,51 @@ class RefundPayment
|
|||||||
|
|
||||||
$adjustment_amount += $refunded_invoice['amount'];
|
$adjustment_amount += $refunded_invoice['amount'];
|
||||||
$client->balance += $refunded_invoice['amount'];
|
$client->balance += $refunded_invoice['amount'];
|
||||||
//$client->paid_to_date -= $refunded_invoice['amount'];//todo refund balancing
|
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
//todo adjust ledger balance here? or after and reference the credit and its total
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $invoice->transaction_event(),
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $invoice->company->db);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $ledger_string = "Refund for Invoice {$invoice->number} for amount " . $refunded_invoice['amount']; //todo
|
|
||||||
|
|
||||||
// $this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string);
|
|
||||||
|
|
||||||
$client = $this->payment->client->fresh();
|
$client = $this->payment->client->fresh();
|
||||||
|
|
||||||
$client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save();
|
$client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save();
|
||||||
|
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => [],
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $client->company->db);
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount.
|
//if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount.
|
||||||
|
|
||||||
$client = $this->payment->client->fresh();
|
$client = $this->payment->client->fresh();
|
||||||
|
|
||||||
$client->service()->updatePaidToDate(-1 * $this->total_refund)->save();
|
$client->service()->updatePaidToDate(-1 * $this->total_refund)->save();
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => [],
|
||||||
|
'payment' => [],
|
||||||
|
'client' => $client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $client->company->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -13,9 +13,11 @@ namespace App\Services\Payment;
|
|||||||
|
|
||||||
use App\Events\Invoice\InvoiceWasUpdated;
|
use App\Events\Invoice\InvoiceWasUpdated;
|
||||||
use App\Jobs\Invoice\InvoiceWorkflowSettings;
|
use App\Jobs\Invoice\InvoiceWorkflowSettings;
|
||||||
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentHash;
|
use App\Models\PaymentHash;
|
||||||
|
use App\Models\TransactionEvent;
|
||||||
use App\Utils\Ninja;
|
use App\Utils\Ninja;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
@ -88,6 +90,17 @@ class UpdateInvoicePayment
|
|||||||
|
|
||||||
$this->payment->applied += $paid_amount;
|
$this->payment->applied += $paid_amount;
|
||||||
|
|
||||||
|
$transaction = [
|
||||||
|
'invoice' => $invoice->transaction_event(),
|
||||||
|
'payment' => $this->payment->transaction_event(),
|
||||||
|
'client' => $client->transaction_event(),
|
||||||
|
'credit' => [],
|
||||||
|
'metadata' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
TransactionLog::dispatch(TransactionEvent::GATEWAY_PAYMENT_MADE, $transaction, $invoice->company->db);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Remove the event updater from within the loop to prevent race conditions */
|
/* Remove the event updater from within the loop to prevent race conditions */
|
||||||
|
@ -174,6 +174,16 @@ class HtmlEngine
|
|||||||
$data['$approveButton'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.approve')];
|
$data['$approveButton'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.approve')];
|
||||||
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
|
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_quote')];
|
||||||
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.quote_date')];
|
$data['$date'] = ['value' => $this->translateDate($this->entity->date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.quote_date')];
|
||||||
|
|
||||||
|
if($this->entity->project) {
|
||||||
|
$data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project_name')];
|
||||||
|
$data['$invoice.project'] = &$data['$project.name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->entity->vendor) {
|
||||||
|
$data['$invoice.vendor'] = ['value' => $this->entity->vendor->present()->name(), 'label' => ctrans('texts.vendor_name')];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->entity_string == 'credit') {
|
if ($this->entity_string == 'credit') {
|
||||||
@ -317,6 +327,7 @@ class HtmlEngine
|
|||||||
$data['$website'] = ['value' => $this->client->present()->website() ?: ' ', 'label' => ctrans('texts.website')];
|
$data['$website'] = ['value' => $this->client->present()->website() ?: ' ', 'label' => ctrans('texts.website')];
|
||||||
$data['$phone'] = ['value' => $this->client->present()->phone() ?: ' ', 'label' => ctrans('texts.phone')];
|
$data['$phone'] = ['value' => $this->client->present()->phone() ?: ' ', 'label' => ctrans('texts.phone')];
|
||||||
$data['$country'] = ['value' => isset($this->client->country->name) ? ctrans('texts.country_' . $this->client->country->name) : '', 'label' => ctrans('texts.country')];
|
$data['$country'] = ['value' => isset($this->client->country->name) ? ctrans('texts.country_' . $this->client->country->name) : '', 'label' => ctrans('texts.country')];
|
||||||
|
$data['$country_2'] = ['value' => isset($this->client->country) ? $this->client->country->iso_3166_2 : '', 'label' => ctrans('texts.country')];
|
||||||
$data['$email'] = ['value' => isset($this->contact) ? $this->contact->email : 'no contact email on record', 'label' => ctrans('texts.email')];
|
$data['$email'] = ['value' => isset($this->contact) ? $this->contact->email : 'no contact email on record', 'label' => ctrans('texts.email')];
|
||||||
$data['$client_name'] = ['value' => $this->entity->present()->clientName() ?: ' ', 'label' => ctrans('texts.client_name')];
|
$data['$client_name'] = ['value' => $this->entity->present()->clientName() ?: ' ', 'label' => ctrans('texts.client_name')];
|
||||||
$data['$client.name'] = &$data['$client_name'];
|
$data['$client.name'] = &$data['$client_name'];
|
||||||
@ -392,6 +403,7 @@ class HtmlEngine
|
|||||||
$data['$company.state'] = ['value' => $this->settings->state ?: ' ', 'label' => ctrans('texts.state')];
|
$data['$company.state'] = ['value' => $this->settings->state ?: ' ', 'label' => ctrans('texts.state')];
|
||||||
$data['$company.postal_code'] = ['value' => $this->settings->postal_code ?: ' ', 'label' => ctrans('texts.postal_code')];
|
$data['$company.postal_code'] = ['value' => $this->settings->postal_code ?: ' ', 'label' => ctrans('texts.postal_code')];
|
||||||
$data['$company.country'] = ['value' => $this->getCountryName(), 'label' => ctrans('texts.country')];
|
$data['$company.country'] = ['value' => $this->getCountryName(), 'label' => ctrans('texts.country')];
|
||||||
|
$data['$company.country_2'] = ['value' => $this->getCountryCode(), 'label' => ctrans('texts.country')];
|
||||||
$data['$company.phone'] = ['value' => $this->settings->phone ?: ' ', 'label' => ctrans('texts.phone')];
|
$data['$company.phone'] = ['value' => $this->settings->phone ?: ' ', 'label' => ctrans('texts.phone')];
|
||||||
$data['$company.email'] = ['value' => $this->settings->email ?: ' ', 'label' => ctrans('texts.email')];
|
$data['$company.email'] = ['value' => $this->settings->email ?: ' ', 'label' => ctrans('texts.email')];
|
||||||
$data['$company.vat_number'] = ['value' => $this->settings->vat_number ?: ' ', 'label' => ctrans('texts.vat_number')];
|
$data['$company.vat_number'] = ['value' => $this->settings->vat_number ?: ' ', 'label' => ctrans('texts.vat_number')];
|
||||||
@ -617,6 +629,17 @@ class HtmlEngine
|
|||||||
return ' ';
|
return ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function getCountryCode() :string
|
||||||
|
{
|
||||||
|
$country = Country::find($this->settings->country_id);
|
||||||
|
|
||||||
|
if ($country) {
|
||||||
|
return ctrans('texts.country_' . $country->iso_3166_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Due to the way we are compiling the blade template we
|
* Due to the way we are compiling the blade template we
|
||||||
* have no ability to iterate, so in the case
|
* have no ability to iterate, so in the case
|
||||||
|
@ -45,6 +45,7 @@ trait SavesDocuments
|
|||||||
$is_public
|
$is_public
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveDocument($document, $entity, $is_public = true)
|
public function saveDocument($document, $entity, $is_public = true)
|
||||||
|
@ -31,7 +31,7 @@ class TranslationHelper
|
|||||||
return Cache::get('countries')->each(function ($country) {
|
return Cache::get('countries')->each(function ($country) {
|
||||||
$country->name = ctrans('texts.country_'.$country->name);
|
$country->name = ctrans('texts.country_'.$country->name);
|
||||||
})->sortBy(function ($country) {
|
})->sortBy(function ($country) {
|
||||||
return $country->name;
|
return $country->iso_3166_2;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => '5.3.66',
|
'app_version' => '5.3.67',
|
||||||
'app_tag' => '5.3.66',
|
'app_tag' => '5.3.67',
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
@ -4,7 +4,8 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class Onboarding extends Migration
|
//class Onboarding extends Migration
|
||||||
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@ -34,4 +35,4 @@ class Onboarding extends Migration
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
58
database/migrations/2022_03_09_053508_transaction_events.php
Normal file
58
database/migrations/2022_03_09_053508_transaction_events.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class TransactionEvents extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('transaction_events', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->unsignedInteger('client_id')->index();
|
||||||
|
$table->unsignedInteger('invoice_id');
|
||||||
|
$table->unsignedInteger('payment_id');
|
||||||
|
$table->unsignedInteger('credit_id');
|
||||||
|
$table->decimal('client_balance', 16, 4)->default(0);
|
||||||
|
$table->decimal('client_paid_to_date', 16, 4)->default(0);
|
||||||
|
$table->decimal('client_credit_balance', 16, 4)->default(0);
|
||||||
|
$table->decimal('invoice_balance', 16, 4)->default(0);
|
||||||
|
$table->decimal('invoice_amount', 16, 4)->default(0);
|
||||||
|
$table->decimal('invoice_partial', 16, 4)->default(0);
|
||||||
|
$table->decimal('invoice_paid_to_date', 16, 4)->default(0);
|
||||||
|
$table->unsignedInteger('invoice_status')->nullable();
|
||||||
|
$table->decimal('payment_amount', 16, 4)->default(0);
|
||||||
|
$table->decimal('payment_applied', 16, 4)->default(0);
|
||||||
|
$table->decimal('payment_refunded', 16, 4)->default(0);
|
||||||
|
$table->unsignedInteger('payment_status')->nullable();
|
||||||
|
$table->mediumText('paymentables')->nullable();
|
||||||
|
$table->unsignedInteger('event_id');
|
||||||
|
$table->unsignedInteger('timestamp');
|
||||||
|
$table->mediumText('payment_request')->nullable();
|
||||||
|
$table->mediumText('metadata')->nullable();
|
||||||
|
$table->decimal('credit_balance', 16, 4)->default(0);
|
||||||
|
$table->decimal('credit_amount', 16, 4)->default(0);
|
||||||
|
$table->unsignedInteger('credit_status')->nullable();
|
||||||
|
|
||||||
|
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade')->onUpdate('cascade');
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
@ -38,7 +38,7 @@
|
|||||||
"/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=e240b907ad163cac04c0",
|
"/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=e240b907ad163cac04c0",
|
||||||
"/js/clients/payments/stripe-browserpay.js": "/js/clients/payments/stripe-browserpay.js?id=71e49866d66a6d85b88a",
|
"/js/clients/payments/stripe-browserpay.js": "/js/clients/payments/stripe-browserpay.js?id=71e49866d66a6d85b88a",
|
||||||
"/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=765874308d4374726b25",
|
"/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=765874308d4374726b25",
|
||||||
"/css/app.css": "/css/app.css?id=41b6a44f816ac830ea05",
|
"/css/app.css": "/css/app.css?id=3e08340d820da80e900b",
|
||||||
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad",
|
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad",
|
||||||
"/vendor/clipboard.min.js": "/vendor/clipboard.min.js?id=ad98572d415d2f245284"
|
"/vendor/clipboard.min.js": "/vendor/clipboard.min.js?id=ad98572d415d2f245284"
|
||||||
}
|
}
|
||||||
|
4
public/vendor/livewire/livewire.js
vendored
4
public/vendor/livewire/livewire.js
vendored
File diff suppressed because one or more lines are too long
2
public/vendor/livewire/livewire.js.map
vendored
2
public/vendor/livewire/livewire.js.map
vendored
File diff suppressed because one or more lines are too long
2
public/vendor/livewire/manifest.json
vendored
2
public/vendor/livewire/manifest.json
vendored
@ -1 +1 @@
|
|||||||
{"/livewire.js":"/livewire.js?id=9a36ebbddb8dd0aa91b1"}
|
{"/livewire.js":"/livewire.js?id=940557fc56b15ccb9a2d"}
|
@ -1,6 +1,6 @@
|
|||||||
{!! ctrans('texts.migration_failed_label') !!}
|
{!! ctrans('texts.migration_failed_label') !!}
|
||||||
|
|
||||||
{!! ctrans('texts.migration_failed') }} {{ $company->present()->name() !!}
|
{!! ctrans('texts.migration_failed') !!} {!! $company->present()->name() !!}
|
||||||
|
|
||||||
@if(\App\Utils\Ninja::isSelfHost() || $is_system)
|
@if(\App\Utils\Ninja::isSelfHost() || $is_system)
|
||||||
{!! $exception->getMessage() !!}
|
{!! $exception->getMessage() !!}
|
@ -1,4 +1,4 @@
|
|||||||
@if ($entity->documents->count() > 0 || $entity->company->documents->count() > 0)
|
@if ($entity->documents->count() > 0 || $entity->company->documents->count() > 0 || ($entity->expense->exists() && $entity->expense->invoice_documents))
|
||||||
<div class="bg-white shadow sm:rounded-lg my-4">
|
<div class="bg-white shadow sm:rounded-lg my-4">
|
||||||
<div class="px-4 py-5 sm:p-6">
|
<div class="px-4 py-5 sm:p-6">
|
||||||
<div class="sm:flex sm:items-start sm:justify-between">
|
<div class="sm:flex sm:items-start sm:justify-between">
|
||||||
@ -41,6 +41,27 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@if($entity->expense->exists() && $entity->expense->invoice_documents)
|
||||||
|
@foreach ($entity->expense->documents as $document)
|
||||||
|
<div class="inline-flex items-center space-x-1">
|
||||||
|
<a href="{{ route('client.documents.show', $document->hashed_id) }}" target="_blank"
|
||||||
|
class="block text-sm button-link text-primary">{{ Illuminate\Support\Str::limit($document->name, 40) }}</a>
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||||
|
class="text-primary h-6 w-4">
|
||||||
|
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
|
||||||
|
<polyline points="15 3 21 3 21 9"></polyline>
|
||||||
|
<line x1="10" y1="14" x2="21" y2="3"></line>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
@if (!$loop->last)
|
||||||
|
<span>—</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
{{ $payment_method->formatDateTimestamp($payment_method->created_at, $client->date_format()) }}
|
{{ $payment_method->formatDateTimestamp($payment_method->created_at, $client->date_format()) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||||
{{ ctrans("texts.{$payment_method->gateway_type->alias}") }}
|
{{ App\Models\GatewayType::getAlias($payment_method->gateway_type_id) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
<td class="px-6 py-4 whitespace-nowrap text-sm leading-5 text-gray-500">
|
||||||
{{ ucfirst(optional($payment_method->meta)->brand) }}
|
{{ ucfirst(optional($payment_method->meta)->brand) }}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
@if(!array_key_exists('filled', $field))
|
@if(!array_key_exists('filled', $field))
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => $field['label']])
|
@component('portal.ninja2020.components.general.card-element', ['title' => $field['label']])
|
||||||
@if($field['name'] == 'client_country_id' || $field['name'] == 'client_shipping_country_id')
|
@if($field['name'] == 'client_country_id' || $field['name'] == 'client_shipping_country_id')
|
||||||
<select id="client_country" class="input w-full form-select" name="{{ $field['name'] }}">
|
<select id="client_country" class="input w-full form-select" name="{{ $field['name'] }}" wire:model="{{ str_replace(["client_","_line_","contact_"], ["client.","","contact."], $field['name']) }}">
|
||||||
<option value="none"></option>
|
<option value="none"></option>
|
||||||
|
|
||||||
@foreach($countries as $country)
|
@foreach($countries as $country)
|
||||||
@ -25,7 +25,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
@else
|
@else
|
||||||
<input class="input w-full" type="{{ $field['type'] ?? 'text' }}" name="{{ $field['name'] }}">
|
<input class="input w-full" type="{{ $field['type'] ?? 'text' }}" name="{{ $field['name'] }}" wire:model="{{ str_replace(["client_","_line_","contact_"], ["client.","","contact."], $field['name']) }}">
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if(session()->has('validation_errors') && array_key_exists($field['name'], session('validation_errors')))
|
@if(session()->has('validation_errors') && array_key_exists($field['name'], session('validation_errors')))
|
||||||
|
@ -52,6 +52,12 @@
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
document.getElementById('pay-now').addEventListener('click', function () {
|
document.getElementById('pay-now').addEventListener('click', function () {
|
||||||
|
|
||||||
|
let payNowButton = document.getElementById('pay-now');
|
||||||
|
payNowButton.disabled = true;
|
||||||
|
payNowButton.querySelector('svg').classList.remove('hidden');
|
||||||
|
payNowButton.querySelector('span').classList.add('hidden');
|
||||||
|
|
||||||
document.getElementById('server-response').submit();
|
document.getElementById('server-response').submit();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Pre-authorized debit payments', 'card_title' => 'Pre-authorized debit payments'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Pre-authorized debit payments', 'card_title' => 'Pre-authorized debit payments'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
@ -21,6 +28,9 @@
|
|||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')])
|
||||||
{{ ctrans('texts.acss') }} ({{ ctrans('texts.bank_transfer') }})
|
{{ ctrans('texts.acss') }} ({{ ctrans('texts.bank_transfer') }})
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
|
@include('portal.ninja2020.gateways.stripe.acss.acss')
|
||||||
|
|
||||||
@include('portal.ninja2020.gateways.includes.pay_now')
|
@include('portal.ninja2020.gateways.includes.pay_now')
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bancontact', 'card_title' => 'Bancontact'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Bancontact', 'card_title' => 'Bancontact'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
|
||||||
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'BECS', 'card_title' => 'BECS'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'BECS', 'card_title' => 'BECS'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
|
||||||
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
|
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
<meta name="customer" content="{{ $customer }}">
|
<meta name="customer" content="{{ $customer }}">
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'EPS', 'card_title' => 'EPS'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'EPS', 'card_title' => 'EPS'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
|
||||||
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
|
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'FPX', 'card_title' => 'FPX'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'FPX', 'card_title' => 'FPX'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
|
||||||
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
|
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'GiroPay', 'card_title' => 'GiroPay'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'GiroPay', 'card_title' => 'GiroPay'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'iDeal', 'card_title' => 'iDeal'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'iDeal', 'card_title' => 'iDeal'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Przelewy24', 'card_title' => 'Przelewy24'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Przelewy24', 'card_title' => 'Przelewy24'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
<meta name="return-url" content="{{ $return_url }}">
|
<meta name="return-url" content="{{ $return_url }}">
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'SEPA', 'card_title' => 'SEPA'])
|
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'SEPA', 'card_title' => 'SEPA'])
|
||||||
|
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta name="stripe-publishable-key" content="{{ $gateway->getPublishableKey() }}">
|
@if($gateway->company_gateway->getConfigField('account_id'))
|
||||||
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
|
||||||
|
<meta name="stripe-publishable-key" content="{{ config('ninja.ninja_stripe_publishable_key') }}">
|
||||||
|
@else
|
||||||
|
<meta name="stripe-publishable-key" content="{{ $gateway->company_gateway->getPublishableKey() }}">
|
||||||
|
@endif
|
||||||
<meta name="amount" content="{{ $stripe_amount }}">
|
<meta name="amount" content="{{ $stripe_amount }}">
|
||||||
<meta name="country" content="{{ $country }}">
|
<meta name="country" content="{{ $country }}">
|
||||||
<meta name="customer" content="{{ $customer }}">
|
<meta name="customer" content="{{ $customer }}">
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
<div class="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||||
<div class="flex w-full rounded-md shadow-sm sm:ml-3 sm:w-auto">
|
<div class="flex w-full rounded-md shadow-sm sm:ml-3 sm:w-auto">
|
||||||
<form action="{{ route('client.payment_methods.destroy', [$payment_method->hashed_id, 'method' => $payment_method->gateway_type->id]) }}" method="post">
|
<form action="{{ route('client.payment_methods.destroy', [$payment_method->hashed_id, 'method' => $payment_method->gateway_type_id]) }}" method="post">
|
||||||
@csrf
|
@csrf
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
<button type="submit" onclick="setTimeout(() => this.disabled = true, 0); return true;" class="button button-danger button-block" dusk="confirm-payment-removal">
|
<button type="submit" onclick="setTimeout(() => this.disabled = true, 0); return true;" class="button button-danger button-block" dusk="confirm-payment-removal">
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user