1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 06:32:40 +01:00

Merge pull request #8071 from turbo124/v5-develop

Quote filters for expired and upcoming
This commit is contained in:
David Bomba 2022-12-13 19:42:38 +11:00 committed by GitHub
commit 542cb6b729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 119 additions and 36 deletions

View File

@ -80,7 +80,13 @@ class QuoteFilters extends QueryFilters
if (in_array('expired', $status_parameters)) {
$this->builder->where('status_id', Quote::STATUS_SENT)
->where('due_date', '<=', now()->toDateString());
->where('due_date', '>=', now()->toDateString());
}
if (in_array('upcoming', $status_parameters)) {
$this->builder->where('status_id', Quote::STATUS_SENT)
->where('due_date', '<=', now()->toDateString())
->orderBy('due_date', 'DESC');
}
return $this->builder;

View File

@ -687,7 +687,7 @@ class BankIntegrationController extends BaseController
auth()->user()->account->bank_integrations->each(function ($bank_integration) {
ProcessBankTransactions::dispatchSync(auth()->user()->account->bank_integration_account_id, $bank_integration);
(new ProcessBankTransactions(auth()->user()->account->bank_integration_account_id, $bank_integration))->handle();
});

View File

@ -195,6 +195,7 @@ class BillingPortalPurchasev2 extends Component
public $login;
public $float_amount_total;
public $payment_started = false;
public $valid_coupon = false;
public function mount()
{
@ -308,10 +309,14 @@ class BillingPortalPurchasev2 extends Component
public function handleCoupon()
{
if($this->coupon == $this->subscription->promo_code)
if($this->coupon == $this->subscription->promo_code) {
$this->buildBundle();
else
$this->valid_coupon = true;
}
else{
$this->discount = 0;
$this->valid_coupon = false;
}
}
@ -332,6 +337,9 @@ class BillingPortalPurchasev2 extends Component
$total = $p->price * $qty;
$this->bundle->push([
'description' => $p->notes,
'product_key' => $p->product_key,
'unit_cost' => $p->price,
'product' => nl2br(substr($p->notes, 0, 50)),
'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id),
'total' => $total,
@ -348,6 +356,9 @@ class BillingPortalPurchasev2 extends Component
$total = $p->price * $qty;
$this->bundle->push([
'description' => $p->notes,
'product_key' => $p->product_key,
'unit_cost' => $p->price,
'product' => nl2br(substr($p->notes, 0, 50)),
'price' => Number::formatMoney($total, $this->subscription->company),
'total' => $total,
@ -375,6 +386,9 @@ class BillingPortalPurchasev2 extends Component
$this->bundle->push([
'description' => $p->notes,
'product_key' => $p->product_key,
'unit_cost' => $p->price,
'product' => nl2br(substr($p->notes, 0, 50)),
'price' => Number::formatMoney($total, $this->subscription->company).' / '. RecurringInvoice::frequencyForKey($this->subscription->frequency_id),
'total' => $total,
@ -398,6 +412,9 @@ class BillingPortalPurchasev2 extends Component
return;
$this->bundle->push([
'description' => $p->notes,
'product_key' => $p->product_key,
'unit_cost' => $p->price,
'product' => nl2br(substr($p->notes, 0, 50)),
'price' => Number::formatMoney($total, $this->subscription->company),
'total' => $total,
@ -503,19 +520,19 @@ class BillingPortalPurchasev2 extends Component
{
$this->payment_started = true;
// $data = [
// 'client_id' => $this->contact->client->id,
// 'date' => now()->format('Y-m-d'),
// 'invitations' => [[
// 'key' => '',
// 'client_contact_id' => $this->contact->hashed_id,
// ]],
// 'user_input_promo_code' => $this->coupon,
// 'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon,
// // 'quantity' => $this->quantity,
// ];
$data = [
'client_id' => $this->contact->client->id,
'date' => now()->format('Y-m-d'),
'invitations' => [[
'key' => '',
'client_contact_id' => $this->contact->hashed_id,
]],
'user_input_promo_code' => $this->coupon,
'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon,
// 'quantity' => $this->quantity,
];
// $is_eligible = $this->subscription->service()->isEligible($this->contact);
$is_eligible = $this->subscription->service()->isEligible($this->contact);
// if (is_array($is_eligible) && $is_eligible['message'] != 'Success') {
// $this->steps['not_eligible'] = true;
@ -525,14 +542,14 @@ class BillingPortalPurchasev2 extends Component
// return;
// }
// $this->invoice = $this->subscription
// ->service()
// ->createInvoice($data, $this->quantity)
// ->service()
// ->markSent()
// ->fillDefaults()
// ->adjustInventory()
// ->save();
$this->invoice = $this->subscription
->service()
->createInvoiceV2($this->bundle, $this->contact->client_id, $this->valid_coupon)
->service()
// ->markSent()
->fillDefaults()
->adjustInventory()
->save();
// Cache::put($this->hash, [
// 'subscription_id' => $this->subscription->id,

View File

@ -110,7 +110,7 @@ class Csv extends BaseImport implements ImportInterface
nlog("bank matching co id = {$this->company->id}");
BankMatchingService::dispatchSync($this->company->id, $this->company->db);
(new BankMatchingService($this->company->id, $this->company->db))->handle();
}

View File

@ -426,14 +426,14 @@ class NinjaMailerJob implements ShouldQueue
private function logMailError($errors, $recipient_object)
{
SystemLogger::dispatchSync(
(new SystemLogger(
$errors,
SystemLog::CATEGORY_MAIL,
SystemLog::EVENT_MAIL_SEND,
SystemLog::TYPE_FAILURE,
$recipient_object,
$this->nmo->company
);
))->handle();
$job_failure = new EmailFailure($this->nmo->company->company_key);
$job_failure->string_metric5 = 'failed_email';

View File

@ -60,7 +60,7 @@ class BankTransactionSync implements ShouldQueue
$account->bank_integrations()->where('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account){
ProcessBankTransactions::dispatchSync($account->bank_integration_account_id, $bank_integration);
(new ProcessBankTransactions($account->bank_integration_account_id, $bank_integration))->handle();
});

View File

@ -142,13 +142,13 @@ class ProcessPostmarkWebhook implements ShouldQueue
$this->invitation->opened_date = now();
$this->invitation->save();
SystemLogger::dispatchSync($this->request,
(new SystemLogger($this->request,
SystemLog::CATEGORY_MAIL,
SystemLog::EVENT_MAIL_OPENED,
SystemLog::TYPE_WEBHOOK_RESPONSE,
$this->invitation->contact->client,
$this->invitation->company
);
))->handle();
}
@ -171,13 +171,13 @@ class ProcessPostmarkWebhook implements ShouldQueue
$this->invitation->email_status = 'delivered';
$this->invitation->save();
SystemLogger::dispatchSync($this->request,
(new SystemLogger($this->request,
SystemLog::CATEGORY_MAIL,
SystemLog::EVENT_MAIL_DELIVERY,
SystemLog::TYPE_WEBHOOK_RESPONSE,
$this->invitation->contact->client,
$this->invitation->company
);
))->handle();
}
// {
@ -219,7 +219,7 @@ class ProcessPostmarkWebhook implements ShouldQueue
LightLogs::create($bounce)->send();
SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);
(new SystemLogger($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle();
// if(config('ninja.notification.slack'))
// $this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja();
@ -265,7 +265,7 @@ class ProcessPostmarkWebhook implements ShouldQueue
LightLogs::create($spam)->send();
SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company);
(new SystemLogger($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle();
if(config('ninja.notification.slack'))
$this->invitation->company->notification(new EmailSpamNotification($this->invitation->company->account))->ninja();

View File

@ -127,7 +127,7 @@ class RecurringService
if($this->recurring_entity instanceof RecurringInvoice && $this->recurring_entity->status_id == RecurringInvoice::STATUS_DRAFT){
$this->start()->save();
SendRecurring::dispatchSync($this->recurring_entity, $this->recurring_entity->company->db);
(new SendRecurring($this->recurring_entity, $this->recurring_entity->company->db))->handle();
}
$this->recurring_entity = $this->recurring_entity->fresh();

View File

@ -704,6 +704,41 @@ class SubscriptionService
}
public function createInvoiceV2($bundle, $client_id, $valid_coupon = false)
{
$invoice_repo = new InvoiceRepository();
$subscription_repo = new SubscriptionRepository();
$invoice = InvoiceFactory::create($this->subscription->company_id, $this->subscription->user_id);
$invoice->subscription_id = $this->subscription->id;
$invoice->client_id = $client_id;
$line_items = $bundle->map(function ($item){
$line_item = new InvoiceItem;
$line_item->product_key = $item['product_key'];
$line_item->quantity = $item['qty'];
$line_item->cost = $item['unit_cost'];
$line_item->notes = $item['description'];
return $line_item;
})->toArray();
nlog($line_items);
$invoice->line_items = $line_items;
if($valid_coupon){
$invoice->discount = $this->subscription->promo_discount;
$invoice->is_amount_discount = $this->subscription->is_amount_discount;
}
return $invoice_repo->save([], $invoice);
}
/**
* Generates the first invoice when a subscription is purchased
*

View File

@ -4898,6 +4898,8 @@ $LANG = array(
'otp_code_message' => 'Enter the code emailed.',
'otp_code_subject' => 'Your one time passcode code',
'otp_code_body' => 'Your one time passcode is :code',
'delete_tax_rate' => 'Delete Tax Rate',
'restore_tax_rate' => 'Restore Tax Rate',
);
return $LANG;

View File

@ -7,8 +7,31 @@
{{ $subscription->name }}
</h1>
</div>
<form wire:submit.prevent="submit">
@if(isset($invoice))
<div class="flex items-center mt-4 text-sm">
<form action="{{ route('client.payments.process', ['hash' => $hash, 'sidebar' => 'hidden']) }}"
method="post"
id="payment-method-form">
@csrf
@if($invoice instanceof \App\Models\Invoice)
<input type="hidden" name="invoices[]" value="{{ $invoice->hashed_id }}">
<input type="hidden" name="payable_invoices[0][amount]"
value="{{ $invoice->partial > 0 ? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency()) : \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency()) }}">
<input type="hidden" name="payable_invoices[0][invoice_id]"
value="{{ $invoice->hashed_id }}">
@endif
<input type="hidden" name="action" value="payment">
<input type="hidden" name="company_gateway_id" value=""/>
<input type="hidden" name="payment_method_id" value=""/>
</form>
</div>
@endif
<form wire:submit.prevent="submit">
<!-- Recurring Plan Products-->
<ul role="list" class="-my-6 divide-y divide-gray-200">
@if(!empty($subscription->recurring_product_ids))