mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-02 19:04:33 -04:00
Fixes for Payment Previews
This commit is contained in:
parent
db68bfe4d0
commit
5ffe3028ed
@ -329,4 +329,18 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generateLabelsAndValues()
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
$values = $this->makePaymentVariables();
|
||||||
|
|
||||||
|
foreach ($values as $key => $value) {
|
||||||
|
$data['values'][$key] = $value['value'];
|
||||||
|
$data['labels'][$key.'_label'] = $value['label'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@
|
|||||||
namespace App\Utils;
|
namespace App\Utils;
|
||||||
|
|
||||||
use App\DataMapper\EmailTemplateDefaults;
|
use App\DataMapper\EmailTemplateDefaults;
|
||||||
|
use App\Mail\Engine\PaymentEmailEngine;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
|
use App\Models\Payment;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
use App\Models\PurchaseOrderInvitation;
|
use App\Models\PurchaseOrderInvitation;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
@ -188,6 +190,8 @@ class TemplateEngine
|
|||||||
{
|
{
|
||||||
if (in_array($this->entity, ['purchaseOrder', 'purchase_order']))
|
if (in_array($this->entity, ['purchaseOrder', 'purchase_order']))
|
||||||
$this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
$this->labels_and_values = (new VendorHtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||||
|
elseif($this->entity == 'payment')
|
||||||
|
$this->labels_and_values = (new PaymentEmailEngine($this->entity_obj, $this->entity_obj->client->contacts->first()))->generateLabelsAndValues();
|
||||||
else
|
else
|
||||||
$this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
$this->labels_and_values = (new HtmlEngine($this->entity_obj->invitations->first()))->generateLabelsAndValues();
|
||||||
|
|
||||||
@ -267,6 +271,8 @@ class TemplateEngine
|
|||||||
{
|
{
|
||||||
if (!$this->entity && $this->template && str_contains($this->template, 'purchase_order'))
|
if (!$this->entity && $this->template && str_contains($this->template, 'purchase_order'))
|
||||||
$this->entity = 'purchaseOrder';
|
$this->entity = 'purchaseOrder';
|
||||||
|
elseif(str_contains($this->template, 'payment'))
|
||||||
|
$this->entity = 'payment';
|
||||||
|
|
||||||
DB::connection(config('database.default'))->beginTransaction();
|
DB::connection(config('database.default'))->beginTransaction();
|
||||||
|
|
||||||
@ -285,6 +291,40 @@ class TemplateEngine
|
|||||||
'send_email' => true,
|
'send_email' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($this->entity == 'payment') {
|
||||||
|
|
||||||
|
|
||||||
|
$this->entity_obj = Payment::factory()->create([
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'company_id' => auth()->user()->company()->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'amount' => 10,
|
||||||
|
'applied' => 10,
|
||||||
|
'refunded' => 5,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$invoice = Invoice::factory()->create([
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'company_id' => auth()->user()->company()->id,
|
||||||
|
'client_id' => $client->id,
|
||||||
|
'amount' => 10,
|
||||||
|
'balance' => 10,
|
||||||
|
'number' => rand(1,10000)
|
||||||
|
]);
|
||||||
|
|
||||||
|
$invitation = InvoiceInvitation::factory()->create([
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'company_id' => auth()->user()->company()->id,
|
||||||
|
'invoice_id' => $invoice->id,
|
||||||
|
'client_contact_id' => $contact->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->entity_obj->invoices()->attach($invoice->id, [
|
||||||
|
'amount' => 10,
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->entity || $this->entity == 'invoice') {
|
if (!$this->entity || $this->entity == 'invoice') {
|
||||||
$this->entity_obj = Invoice::factory()->create([
|
$this->entity_obj = Invoice::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
@ -315,8 +355,6 @@ class TemplateEngine
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->entity == 'purchaseOrder') {
|
if ($this->entity == 'purchaseOrder') {
|
||||||
|
|
||||||
$vendor = Vendor::factory()->create([
|
$vendor = Vendor::factory()->create([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user