mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
2b72ff7dec
@ -56,8 +56,8 @@ class AutoBillCron
|
||||
|
||||
nlog($auto_bill_partial_invoices->count(). " partial invoices to auto bill");
|
||||
|
||||
$auto_bill_partial_invoices->cursor()->each(function ($invoice){
|
||||
$this->runAutoBiller($invoice);
|
||||
$auto_bill_partial_invoices->cursor()->each(function ($invoice) use($db){
|
||||
$this->runAutoBiller($invoice, $db);
|
||||
});
|
||||
|
||||
$auto_bill_invoices = Invoice::whereDate('due_date', '<=', now())
|
||||
@ -69,8 +69,8 @@ class AutoBillCron
|
||||
|
||||
nlog($auto_bill_invoices->count(). " full invoices to auto bill");
|
||||
|
||||
$auto_bill_invoices->cursor()->each(function ($invoice){
|
||||
$this->runAutoBiller($invoice);
|
||||
$auto_bill_invoices->cursor()->each(function ($invoice) use($db){
|
||||
$this->runAutoBiller($invoice, $db);
|
||||
});
|
||||
|
||||
|
||||
@ -89,8 +89,8 @@ class AutoBillCron
|
||||
|
||||
nlog($auto_bill_partial_invoices->count(). " partial invoices to auto bill db = {$db}");
|
||||
|
||||
$auto_bill_partial_invoices->cursor()->each(function ($invoice){
|
||||
$this->runAutoBiller($invoice);
|
||||
$auto_bill_partial_invoices->cursor()->each(function ($invoice) use($db){
|
||||
$this->runAutoBiller($invoice, $db);
|
||||
});
|
||||
|
||||
$auto_bill_invoices = Invoice::whereDate('due_date', '<=', now())
|
||||
@ -102,19 +102,20 @@ class AutoBillCron
|
||||
|
||||
nlog($auto_bill_invoices->count(). " full invoices to auto bill db = {$db}");
|
||||
|
||||
$auto_bill_invoices->cursor()->each(function ($invoice){
|
||||
$this->runAutoBiller($invoice);
|
||||
$auto_bill_invoices->cursor()->each(function ($invoice) use($db){
|
||||
$this->runAutoBiller($invoice, $db);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function runAutoBiller(Invoice $invoice)
|
||||
private function runAutoBiller(Invoice $invoice, $db)
|
||||
{
|
||||
info("Firing autobill for {$invoice->company_id} - {$invoice->number}");
|
||||
|
||||
try{
|
||||
MultiDB::setDB($db);
|
||||
$invoice->service()->autoBill()->save();
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
|
@ -89,7 +89,7 @@ class RecurringInvoicesCron
|
||||
->with('company')
|
||||
->cursor();
|
||||
|
||||
nlog(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db);
|
||||
nlog(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count());
|
||||
|
||||
$recurring_invoices->each(function ($recurring_invoice, $key) {
|
||||
nlog("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date ." Recurring #id = ". $recurring_invoice->id);
|
||||
@ -100,7 +100,7 @@ class RecurringInvoicesCron
|
||||
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
|
||||
}
|
||||
catch(\Exception $e){
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id} on db {$db}");
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -358,11 +358,11 @@ class Account extends BaseModel
|
||||
|
||||
if($this->isPaid()){
|
||||
$limit = $this->paid_plan_email_quota;
|
||||
$limit += Carbon::createFromTimestamp($this->created_at)->diffInMonths() * 50;
|
||||
$limit += Carbon::createFromTimestamp($this->created_at)->diffInMonths() * 100;
|
||||
}
|
||||
else{
|
||||
$limit = $this->free_plan_email_quota;
|
||||
$limit += Carbon::createFromTimestamp($this->created_at)->diffInMonths() * 100;
|
||||
$limit += Carbon::createFromTimestamp($this->created_at)->diffInMonths() * 50;
|
||||
}
|
||||
|
||||
return min($limit, 5000);
|
||||
|
@ -205,6 +205,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
|
||||
$invoices->each(function ($invoice) use ($payment) {
|
||||
event(new InvoiceWasPaid($invoice, $payment, $payment->company, Ninja::eventVars()));
|
||||
$invoice->service()->workFlow();
|
||||
});
|
||||
|
||||
return $payment->service()->applyNumber()->save();
|
||||
|
@ -51,6 +51,7 @@ class Charge
|
||||
*/
|
||||
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
|
||||
{
|
||||
nlog(" DB = ".$this->stripe->client->company->db);
|
||||
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
|
||||
$invoice = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->first();
|
||||
|
||||
@ -75,6 +76,10 @@ class Charge
|
||||
'description' => $description,
|
||||
];
|
||||
|
||||
nlog("Stripe tokenBilling payload");
|
||||
|
||||
nlog($data);
|
||||
|
||||
$response = $this->stripe->createPaymentIntent($data, $this->stripe->stripe_connect_auth);
|
||||
// $response = $local_stripe->paymentIntents->create($data);
|
||||
|
||||
|
@ -51,12 +51,14 @@ class AutoBillInvoice extends AbstractService
|
||||
|
||||
/* Mark the invoice as paid if there is no balance */
|
||||
if ((int)$this->invoice->balance == 0)
|
||||
return $this->invoice->service()->markPaid()->save();
|
||||
return $this->invoice->service()->markPaid()->workFlow()->save();
|
||||
|
||||
//if the credits cover the payments, we stop here, build the payment with credits and exit early
|
||||
if ($this->client->getSetting('use_credits_payment') != 'off')
|
||||
$this->applyCreditPayment();
|
||||
|
||||
$amount = 0;
|
||||
|
||||
/* Determine $amount */
|
||||
if ($this->invoice->partial > 0) {
|
||||
$is_partial = true;
|
||||
@ -68,14 +70,16 @@ class AutoBillInvoice extends AbstractService
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
info("balance remains to be paid!!");
|
||||
info("Auto Bill - balance remains to be paid!! - {$amount}");
|
||||
|
||||
/* Retrieve the Client Gateway Token */
|
||||
$gateway_token = $this->getGateway($amount);
|
||||
|
||||
/* Bail out if no payment methods available */
|
||||
if (! $gateway_token || ! $gateway_token->gateway->driver($this->client)->token_billing)
|
||||
if (! $gateway_token || ! $gateway_token->gateway->driver($this->client)->token_billing){
|
||||
nlog("Bailing out - no suitable gateway token found.");
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
/* $gateway fee */
|
||||
//$fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user