mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 06:32:40 +01:00
Fixes for company gateways
This commit is contained in:
parent
455e9a8e1d
commit
2f478158e9
@ -717,6 +717,10 @@ class InvoiceController extends BaseController
|
|||||||
else
|
else
|
||||||
$this->reminder_template = $invoice->calculateTemplate();
|
$this->reminder_template = $invoice->calculateTemplate();
|
||||||
|
|
||||||
|
//touch reminder1,2,3_sent + last_sent here if the email is a reminder.
|
||||||
|
|
||||||
|
$invoice->service()->touchReminder($this->reminder_template)->save();
|
||||||
|
|
||||||
$invoice->invitations->load('contact.client.country','invoice.client.country','invoice.company')->each(function ($invitation) use ($invoice) {
|
$invoice->invitations->load('contact.client.country','invoice.client.country','invoice.company')->each(function ($invitation) use ($invoice) {
|
||||||
|
|
||||||
$email_builder = (new InvoiceEmail())->build($invitation, $this->reminder_template);
|
$email_builder = (new InvoiceEmail())->build($invitation, $this->reminder_template);
|
||||||
|
@ -43,12 +43,12 @@ class StoreCompanyGatewayRequest extends Request
|
|||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
||||||
|
|
||||||
$default_gateway_fields = json_decode($gateway->fields);
|
$default_gateway_fields = json_decode($gateway->fields);
|
||||||
|
|
||||||
/*Force gateway properties */
|
/*Force gateway properties */
|
||||||
if(isset($input['config']))
|
if(isset($input['config']) && is_object(json_decode($input['config'])))
|
||||||
{
|
{
|
||||||
foreach(json_decode($input['config']) as $key => $value) {
|
foreach(json_decode($input['config']) as $key => $value) {
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class UpdateCompanyGatewayRequest extends Request
|
|||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
/*Force gateway properties */
|
/*Force gateway properties */
|
||||||
if(isset($input['config']) && $input['gateway_key'])
|
if(isset($input['config']) && is_object(json_decode($input['config'])) && array_key_exists('gateway_key', $input))
|
||||||
{
|
{
|
||||||
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
$gateway = Gateway::where('key', $input['gateway_key'])->first();
|
||||||
$default_gateway_fields = json_decode($gateway->fields);
|
$default_gateway_fields = json_decode($gateway->fields);
|
||||||
|
@ -215,6 +215,7 @@ class InvoiceService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Set partial value and due date to null*/
|
||||||
public function clearPartial()
|
public function clearPartial()
|
||||||
{
|
{
|
||||||
$this->invoice->partial = null;
|
$this->invoice->partial = null;
|
||||||
@ -223,6 +224,7 @@ class InvoiceService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Update the partial amount of a invoice*/
|
||||||
public function updatePartial($amount)
|
public function updatePartial($amount)
|
||||||
{
|
{
|
||||||
$this->invoice->partial += $amount;
|
$this->invoice->partial += $amount;
|
||||||
@ -230,6 +232,31 @@ class InvoiceService
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*When a reminder is sent we want to touch the dates they were sent*/
|
||||||
|
public function touchReminder(string $reminder_template)
|
||||||
|
{
|
||||||
|
switch ($reminder_template) {
|
||||||
|
case 'reminder1':
|
||||||
|
$this->invoice->reminder1_sent = now()->format('Y-m-d');
|
||||||
|
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
|
||||||
|
break;
|
||||||
|
case 'reminder2':
|
||||||
|
$this->invoice->reminder2_sent = now()->format('Y-m-d');
|
||||||
|
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
|
||||||
|
break;
|
||||||
|
case 'reminder3':
|
||||||
|
$this->invoice->reminder3_sent = now()->format('Y-m-d');
|
||||||
|
$this->invoice->reminder_last_sent = now()->format('Y-m-d');
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
# code...
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user