Fixes for autobill

This commit is contained in:
David Bomba 2020-10-14 21:45:26 +11:00
parent 99920389b4
commit 0ec89c18ac
3 changed files with 6 additions and 3 deletions

View File

@ -34,7 +34,7 @@ class UpdateGroupSettingRequest extends Request
{
$rules['settings'] = new ValidClientGroupSettingsRule();
$rules['name'] = 'unique:group_settings,name,'.$this->id.',id,company_id,'.$this->group_setting->company_id;
// $rules['name'] = 'unique:group_settings,name,'.$this->id.',id,company_id,'.$this->group_setting->company_id;
return $rules;
}

View File

@ -21,9 +21,12 @@ use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\StripePaymentDriver;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
class Charge
{
use MakesHash;
/** @var StripePaymentDriver */
public $stripe;
@ -39,7 +42,7 @@ class Charge
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
$invoice = sInvoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->first();
$invoice = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->first();
if ($invoice) {
$description = "Invoice {$invoice->number} for {$amount} for client {$this->stripe->client->present()->name()}";

View File

@ -84,7 +84,7 @@ class AutoBillInvoice extends AbstractService
/* Build payment hash */
$payment_hash = PaymentHash::create([
'hash' => Str::random(128),
'data' => ['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount],
'data' => [['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount]],
'fee_total' => $fee,
'fee_invoice_id' => $this->invoice->id,
]);