mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-02 04:34:36 -04:00
fixes for update invoice (#3303)
This commit is contained in:
parent
9a19f7fd4c
commit
af72d27a49
@ -12,14 +12,12 @@
|
|||||||
namespace App\DataMapper;
|
namespace App\DataMapper;
|
||||||
|
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
use App\DataMapper\EmailTemplateDefaults;
|
|
||||||
use App\Models\Company;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CompanySettings
|
* CompanySettings
|
||||||
*/
|
*/
|
||||||
class CompanySettings extends BaseSettings
|
|
||||||
{
|
class CompanySettings extends BaseSettings {
|
||||||
|
|
||||||
/*Group settings based on functionality*/
|
/*Group settings based on functionality*/
|
||||||
|
|
||||||
@ -29,8 +27,8 @@ class CompanySettings extends BaseSettings
|
|||||||
|
|
||||||
public $enable_client_portal_tasks = false;
|
public $enable_client_portal_tasks = false;
|
||||||
public $enable_client_portal_password = false;
|
public $enable_client_portal_password = false;
|
||||||
public $enable_client_portal = true; //implemented
|
public $enable_client_portal = true;//implemented
|
||||||
public $enable_client_portal_dashboard = true; //implemented
|
public $enable_client_portal_dashboard = true;//implemented
|
||||||
public $signature_on_pdf = false;
|
public $signature_on_pdf = false;
|
||||||
public $document_email_attachment = false;
|
public $document_email_attachment = false;
|
||||||
public $send_portal_password = false;
|
public $send_portal_password = false;
|
||||||
@ -69,8 +67,8 @@ class CompanySettings extends BaseSettings
|
|||||||
|
|
||||||
public $translations;
|
public $translations;
|
||||||
|
|
||||||
public $counter_number_applied = 'when_saved'; // when_saved , when_sent , when_paid
|
public $counter_number_applied = 'when_saved';// when_saved , when_sent , when_paid
|
||||||
public $quote_number_applied = 'when_saved'; // when_saved , when_sent
|
public $quote_number_applied = 'when_saved';// when_saved , when_sent
|
||||||
|
|
||||||
/* Counters */
|
/* Counters */
|
||||||
public $invoice_number_pattern = '';
|
public $invoice_number_pattern = '';
|
||||||
@ -100,7 +98,6 @@ class CompanySettings extends BaseSettings
|
|||||||
public $payment_number_pattern = '';
|
public $payment_number_pattern = '';
|
||||||
public $payment_number_counter = 1;
|
public $payment_number_counter = 1;
|
||||||
|
|
||||||
|
|
||||||
public $shared_invoice_quote_counter = false;
|
public $shared_invoice_quote_counter = false;
|
||||||
public $recurring_number_prefix = 'R';
|
public $recurring_number_prefix = 'R';
|
||||||
public $reset_counter_frequency_id = '0';
|
public $reset_counter_frequency_id = '0';
|
||||||
@ -132,7 +129,7 @@ class CompanySettings extends BaseSettings
|
|||||||
public $require_quote_signature = false;
|
public $require_quote_signature = false;
|
||||||
|
|
||||||
//email settings
|
//email settings
|
||||||
public $email_sending_method = 'default'; //enum 'default','gmail'
|
public $email_sending_method = 'default';//enum 'default','gmail'
|
||||||
public $gmail_sending_user_id = '0';
|
public $gmail_sending_user_id = '0';
|
||||||
|
|
||||||
public $reply_to_email = '';
|
public $reply_to_email = '';
|
||||||
@ -140,8 +137,8 @@ class CompanySettings extends BaseSettings
|
|||||||
public $pdf_email_attachment = false;
|
public $pdf_email_attachment = false;
|
||||||
public $ubl_email_attachment = false;
|
public $ubl_email_attachment = false;
|
||||||
|
|
||||||
public $email_style = 'plain'; //plain, light, dark, custom
|
public $email_style = 'plain';//plain, light, dark, custom
|
||||||
public $email_style_custom = ''; //the template itself
|
public $email_style_custom = '';//the template itself
|
||||||
public $email_subject_invoice = '';
|
public $email_subject_invoice = '';
|
||||||
public $email_subject_quote = '';
|
public $email_subject_quote = '';
|
||||||
public $email_subject_payment = '';
|
public $email_subject_payment = '';
|
||||||
@ -161,7 +158,6 @@ class CompanySettings extends BaseSettings
|
|||||||
public $email_signature = '';
|
public $email_signature = '';
|
||||||
public $enable_email_markup = true;
|
public $enable_email_markup = true;
|
||||||
|
|
||||||
|
|
||||||
public $email_subject_custom1 = '';
|
public $email_subject_custom1 = '';
|
||||||
public $email_subject_custom2 = '';
|
public $email_subject_custom2 = '';
|
||||||
public $email_subject_custom3 = '';
|
public $email_subject_custom3 = '';
|
||||||
@ -178,17 +174,19 @@ class CompanySettings extends BaseSettings
|
|||||||
public $num_days_reminder2 = 0;
|
public $num_days_reminder2 = 0;
|
||||||
public $num_days_reminder3 = 0;
|
public $num_days_reminder3 = 0;
|
||||||
|
|
||||||
public $schedule_reminder1 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
public $schedule_reminder1 = '';// (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
public $schedule_reminder2 = '';// (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date)
|
public $schedule_reminder3 = '';// (enum: after_invoice_date, before_due_date, after_due_date)
|
||||||
|
|
||||||
public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders
|
public $reminder_send_time = 32400;//number of seconds from UTC +0 to send reminders
|
||||||
|
|
||||||
public $late_fee_amount1 = 0;
|
public $late_fee_amount1 = 0;
|
||||||
public $late_fee_amount2 = 0;
|
public $late_fee_amount2 = 0;
|
||||||
public $late_fee_amount3 = 0;
|
public $late_fee_amount3 = 0;
|
||||||
|
|
||||||
public $endless_reminder_frequency_id = '0';
|
public $endless_reminder_frequency_id = '0';
|
||||||
|
public $late_fee_endless_amount = 0;
|
||||||
|
public $late_fee_endless_percent = 0;
|
||||||
|
|
||||||
public $client_online_payment_notification = true;
|
public $client_online_payment_notification = true;
|
||||||
public $client_manual_payment_notification = true;
|
public $client_manual_payment_notification = true;
|
||||||
@ -220,6 +218,8 @@ class CompanySettings extends BaseSettings
|
|||||||
public $invoice_variables = [];
|
public $invoice_variables = [];
|
||||||
|
|
||||||
public static $casts = [
|
public static $casts = [
|
||||||
|
'late_fee_endless_percent' => 'float',
|
||||||
|
'late_fee_endless_amount' => 'float',
|
||||||
'auto_email_invoice' => 'bool',
|
'auto_email_invoice' => 'bool',
|
||||||
'reminder_send_time' => 'int',
|
'reminder_send_time' => 'int',
|
||||||
'email_sending_method' => 'string',
|
'email_sending_method' => 'string',
|
||||||
@ -389,8 +389,7 @@ class CompanySettings extends BaseSettings
|
|||||||
*
|
*
|
||||||
* @return \stdClass
|
* @return \stdClass
|
||||||
*/
|
*/
|
||||||
public function __construct($obj)
|
public function __construct($obj) {
|
||||||
{
|
|
||||||
// parent::__construct($obj);
|
// parent::__construct($obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,21 +397,20 @@ class CompanySettings extends BaseSettings
|
|||||||
* Provides class defaults on init
|
* Provides class defaults on init
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public static function defaults() : \stdClass
|
public static function defaults():\stdClass {
|
||||||
{
|
|
||||||
$config = json_decode(config('ninja.settings'));
|
$config = json_decode(config('ninja.settings'));
|
||||||
|
|
||||||
$data = (object)get_class_vars(CompanySettings::class);
|
$data = (object) get_class_vars(CompanySettings::class );
|
||||||
unset($data->casts);
|
unset($data->casts);
|
||||||
unset($data->protected_fields);
|
unset($data->protected_fields);
|
||||||
|
|
||||||
$data->timezone_id = (string)config('ninja.i18n.timezone_id');
|
$data->timezone_id = (string) config('ninja.i18n.timezone_id');
|
||||||
$data->currency_id = (string)config('ninja.i18n.currency_id');
|
$data->currency_id = (string) config('ninja.i18n.currency_id');
|
||||||
$data->language_id = (string)config('ninja.i18n.language_id');
|
$data->language_id = (string) config('ninja.i18n.language_id');
|
||||||
$data->payment_terms = (int)config('ninja.i18n.payment_terms');
|
$data->payment_terms = (int) config('ninja.i18n.payment_terms');
|
||||||
$data->military_time = (bool)config('ninja.i18n.military_time');
|
$data->military_time = (bool) config('ninja.i18n.military_time');
|
||||||
$data->date_format_id = (string)config('ninja.i18n.date_format_id');
|
$data->date_format_id = (string) config('ninja.i18n.date_format_id');
|
||||||
$data->country_id = (string)config('ninja.i18n.country_id');
|
$data->country_id = (string) config('ninja.i18n.country_id');
|
||||||
$data->translations = (object) [];
|
$data->translations = (object) [];
|
||||||
$data->invoice_variables = (array) self::getInvoiceVariableDefaults();
|
$data->invoice_variables = (array) self::getInvoiceVariableDefaults();
|
||||||
|
|
||||||
@ -443,21 +441,19 @@ class CompanySettings extends BaseSettings
|
|||||||
*
|
*
|
||||||
* @param object $data The settings object to be checked
|
* @param object $data The settings object to be checked
|
||||||
*/
|
*/
|
||||||
public static function setProperties($settings) :\stdClass
|
public static function setProperties($settings):\stdClass {
|
||||||
{
|
$company_settings = (object) get_class_vars(CompanySettings::class );
|
||||||
$company_settings = (object)get_class_vars(CompanySettings::class);
|
|
||||||
|
|
||||||
foreach ($company_settings as $key => $value) {
|
foreach ($company_settings as $key => $value) {
|
||||||
if (!property_exists($settings, $key)) {
|
if (!property_exists($settings, $key)) {
|
||||||
$settings->{$key} = self::castAttribute($key, $company_settings->{$key});
|
$settings->{ $key} = self::castAttribute($key, $company_settings->{ $key});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getInvoiceVariableDefaults()
|
private static function getInvoiceVariableDefaults() {
|
||||||
{
|
|
||||||
$variables = [
|
$variables = [
|
||||||
'client_details' => [
|
'client_details' => [
|
||||||
'name',
|
'name',
|
||||||
|
@ -24,12 +24,10 @@ use App\Http\Requests\Invoice\EditInvoiceRequest;
|
|||||||
use App\Http\Requests\Invoice\ShowInvoiceRequest;
|
use App\Http\Requests\Invoice\ShowInvoiceRequest;
|
||||||
use App\Http\Requests\Invoice\StoreInvoiceRequest;
|
use App\Http\Requests\Invoice\StoreInvoiceRequest;
|
||||||
use App\Http\Requests\Invoice\UpdateInvoiceRequest;
|
use App\Http\Requests\Invoice\UpdateInvoiceRequest;
|
||||||
|
use App\Jobs\Invoice\CreateInvoicePdf;
|
||||||
use App\Jobs\Invoice\EmailInvoice;
|
use App\Jobs\Invoice\EmailInvoice;
|
||||||
|
|
||||||
use App\Jobs\Invoice\StoreInvoice;
|
use App\Jobs\Invoice\StoreInvoice;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
|
||||||
use App\Repositories\InvoiceRepository;
|
use App\Repositories\InvoiceRepository;
|
||||||
use App\Transformers\InvoiceTransformer;
|
use App\Transformers\InvoiceTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -41,6 +39,7 @@ use Illuminate\Http\Request;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class InvoiceController extends BaseController {
|
class InvoiceController extends BaseController {
|
||||||
|
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
protected $entity_type = Invoice::class ;
|
protected $entity_type = Invoice::class ;
|
||||||
@ -654,6 +653,10 @@ class InvoiceController extends BaseController {
|
|||||||
$contact = $invitation->contact;
|
$contact = $invitation->contact;
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
|
|
||||||
return response()->json($invitation_key);
|
$file_path = CreateInvoicePdf::dispatchNow($invoice, $invoice->company, $contact);
|
||||||
|
|
||||||
|
return response()->download($file_path);
|
||||||
|
|
||||||
|
//return response()->json($invitation_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,10 @@ class InvoiceRepository extends BaseRepository {
|
|||||||
|
|
||||||
if (!$inv) {
|
if (!$inv) {
|
||||||
|
|
||||||
|
if (isset($invitation['id'])) {
|
||||||
|
unset($invitation['id']);
|
||||||
|
}
|
||||||
|
|
||||||
$new_invitation = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id);
|
$new_invitation = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id);
|
||||||
$new_invitation->fill($invitation);
|
$new_invitation->fill($invitation);
|
||||||
$new_invitation->invoice_id = $invoice->id;
|
$new_invitation->invoice_id = $invoice->id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user