Merge pull request #6760 from turbo124/v5-develop

Auto Bill Counter
This commit is contained in:
David Bomba 2021-10-03 21:35:10 +11:00 committed by GitHub
commit 2c641d0a69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View File

@ -40,9 +40,6 @@ class NinjaPlanController extends Controller
$account = $company->account; $account = $company->account;
nlog("Ninja Plan Controller Company key found {$company->company_key}");
if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first()) if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first())
{ {

View File

@ -75,8 +75,11 @@ class AutoBillCron
nlog($auto_bill_invoices->count(). " full invoices to auto bill"); nlog($auto_bill_invoices->count(). " full invoices to auto bill");
$auto_bill_invoices->cursor()->each(function ($invoice){ $x = 1;
$auto_bill_invoices->cursor()->each(function ($invoice) use($x){
nlog("partial auto bill counter {$x}");
$this->runAutoBiller($invoice, false); $this->runAutoBiller($invoice, false);
$x++;
}); });
@ -114,8 +117,11 @@ class AutoBillCron
nlog($auto_bill_invoices->count(). " full invoices to auto bill db = {$db}"); nlog($auto_bill_invoices->count(). " full invoices to auto bill db = {$db}");
$auto_bill_invoices->cursor()->each(function ($invoice) use($db){ $x = 1;
$auto_bill_invoices->cursor()->each(function ($invoice) use($db, $x){
nlog("auto bill counter {$x}");
$this->runAutoBiller($invoice, $db); $this->runAutoBiller($invoice, $db);
$x++;
}); });
} }

View File

@ -195,10 +195,19 @@ class CreditCard
{ {
$payment = \json_decode($response->getBody()); $payment = \json_decode($response->getBody());
$billing_address = new \Square\Models\Address();
$billing_address->setAddressLine1($this->square_driver->client->address1);
$billing_address->setAddressLine2($this->square_driver->client->address2);
$billing_address->setLocality($this->square_driver->client->city);
$billing_address->setAdministrativeDistrictLevel1($this->square_driver->client->state);
$billing_address->setPostalCode($this->square_driver->client->postal_code);
$billing_address->setCountry($this->square_driver->client->country->iso_3166_2);
$card = new \Square\Models\Card(); $card = new \Square\Models\Card();
$card->setCardholderName($this->square_driver->client->present()->name()); $card->setCardholderName($this->square_driver->client->present()->first_name(). " " .$this->square_driver->client->present()->last_name());
$card->setCustomerId($this->findOrCreateClient()); $card->setCustomerId($this->findOrCreateClient());
$card->setReferenceId(Str::random(8)); $card->setReferenceId(Str::random(8));
$card->setBillingAddress($billing_address);
$body = new \Square\Models\CreateCardRequest(Str::random(32), $payment->payment->id, $card); $body = new \Square\Models\CreateCardRequest(Str::random(32), $payment->payment->id, $card);
@ -299,7 +308,8 @@ class CreditCard
$errors = $api_response->getErrors(); $errors = $api_response->getErrors();
} }
if ($customers) {
if (property_exists($customers, 'customers')) {
return $customers->customers[0]->id; return $customers->customers[0]->id;
} }