mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #5155 from turbo124/v5-develop
Billing subscription - invoice generation
This commit is contained in:
commit
e3d056ab0b
@ -12,6 +12,7 @@
|
||||
|
||||
namespace App\Jobs\Entity;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Credit;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\Design;
|
||||
@ -118,6 +119,9 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
$entity_design_id = $this->entity->design_id ? $this->entity->design_id : $this->decodePrimaryKey($this->entity->client->getSetting($entity_design_id));
|
||||
|
||||
if(!$this->company->account->hasFeature(Account::FEATURE_DIFFERENT_DESIGNS))
|
||||
$entity_design_id = 2;
|
||||
|
||||
$design = Design::find($entity_design_id);
|
||||
$html = new HtmlEngine($this->invitation);
|
||||
|
||||
|
@ -11,7 +11,11 @@
|
||||
|
||||
namespace App\Services\BillingSubscription;
|
||||
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Models\ClientSubscription;
|
||||
use App\Models\Product;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
|
||||
class BillingSubscriptionService
|
||||
{
|
||||
@ -23,10 +27,21 @@ class BillingSubscriptionService
|
||||
$this->billing_subscription = $billing_subscription;
|
||||
}
|
||||
|
||||
public function createInvoice($payment_hash)
|
||||
public function createInvoice($data)
|
||||
{
|
||||
//create the invoice if necessary ie. only is a payment was actually processed
|
||||
|
||||
|
||||
$invoice_repo = new InvoiceRepository();
|
||||
|
||||
// $data = [
|
||||
// 'client_id' =>,
|
||||
// 'date' => Y-m-d,
|
||||
// 'invitations' => [
|
||||
// 'client_contact_id' => hashed_id
|
||||
// ],
|
||||
// 'line_items' => [],
|
||||
// ];
|
||||
|
||||
$invoice = $invoice_repo->save($data, InvoiceFactory::create($billing_subscription->company_id, $billing_subscription->user_id));
|
||||
/*
|
||||
|
||||
If trial_enabled -> return early
|
||||
@ -39,6 +54,30 @@ class BillingSubscriptionService
|
||||
1. Is this a recurring product?
|
||||
2. What is the quantity? ie is this a multi seat product ( does this mean we need this value stored in the client sub?)
|
||||
*/
|
||||
|
||||
return $invoice;
|
||||
|
||||
}
|
||||
|
||||
private function createLineItems($quantity)
|
||||
{
|
||||
$line_items = [];
|
||||
|
||||
$product = $this->billing_subscription->product;
|
||||
|
||||
$item = new InvoiceItem;
|
||||
$item->quantity = $quantity;
|
||||
$item->product_key = $product->product_key;
|
||||
$item->notes = $product->notes;
|
||||
$item->cost = $product->price;
|
||||
//$item->type_id need to switch whether the subscription is a service or product
|
||||
|
||||
$line_items[] = $item;
|
||||
|
||||
|
||||
//do we have a promocode? enter this as a line item.
|
||||
|
||||
return $line_items;
|
||||
}
|
||||
|
||||
private function convertInvoiceToRecurring()
|
||||
|
Loading…
Reference in New Issue
Block a user