Merge pull request #4968 from turbo124/v5-develop

Fixes for fillable properties + other minor fixes"
This commit is contained in:
David Bomba 2021-02-23 12:18:11 +11:00 committed by GitHub
commit ffd9c10ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 53 additions and 13 deletions

View File

@ -136,7 +136,7 @@ class CompanySettings extends BaseSettings
public $tax_name3 = ''; //@TODO where do we use this?
public $tax_rate3 = 0; //@TODO where do we use this?
public $payment_type_id = '0'; //@TODO where do we use this?
public $invoice_fields = ''; //@TODO is this redundant, we store this in the custom_fields on the company?
// public $invoice_fields = ''; //@TODO is this redundant, we store this in the custom_fields on the company?
public $show_accept_invoice_terms = false; //@TODO ben to confirm
public $show_accept_quote_terms = false; //@TODO ben to confirm
@ -392,7 +392,7 @@ class CompanySettings extends BaseSettings
'invoice_number_pattern' => 'string',
'invoice_number_counter' => 'integer',
'invoice_design_id' => 'string',
'invoice_fields' => 'string',
// 'invoice_fields' => 'string',
'invoice_taxes' => 'int',
//'enabled_item_tax_rates' => 'int',
'invoice_footer' => 'string',

View File

@ -78,7 +78,6 @@
* @OA\Property(property="tax_name3", type="string", example="GST", description="The tax name"),
* @OA\Property(property="payment_type_id", type="string", example="1", description="The default payment type id"),
* @OA\Property(property="custom_fields", type="string", example="{}", description="JSON string of custom fields"),
* @OA\Property(property="invoice_fields", type="string", example="{}", description="JSON string of invoice fields"),
* @OA\Property(property="email_footer", type="string", example="A default email footer", description="The default email footer"),
* @OA\Property(property="email_sending_method", type="string", example="default", description="The email driver to use to send email, options include default, gmail"),
* @OA\Property(property="gmail_sending_user_id", type="string", example="F76sd34D", description="The hashed_id of the user account to send email from"),

View File

@ -406,9 +406,9 @@ class ProductController extends BaseController
*/
public function destroy(DestroyProductRequest $request, Product $product)
{
$product->delete();
$this->product_repo->delete($product);
return $this->itemResponse($product);
return $this->itemResponse($product->fresh());
}
/**

View File

@ -41,14 +41,11 @@ class Credit extends BaseModel
protected $presenter = CreditPresenter::class;
protected $fillable = [
'assigned_user_id',
'project_id',
'number',
'discount',
'po_number',
'date',
'due_date',
'partial_due_date',
'terms',
'public_notes',
'private_notes',
@ -59,8 +56,9 @@ class Credit extends BaseModel
'tax_name3',
'tax_rate3',
'is_amount_discount',
'footer',
'partial',
'partial_due_date',
'project_id',
'custom_value1',
'custom_value2',
'custom_value3',
@ -68,7 +66,16 @@ class Credit extends BaseModel
'line_items',
'client_id',
'footer',
'custom_surcharge1',
'custom_surcharge2',
'custom_surcharge3',
'custom_surcharge4',
'custom_surcharge_tax1',
'custom_surcharge_tax2',
'custom_surcharge_tax3',
'custom_surcharge_tax4',
'design_id',
'assigned_user_id',
'exchange_rate',
];

View File

@ -150,6 +150,16 @@ class Invoice extends BaseModel
return $this->belongsTo(Company::class);
}
public function project()
{
return $this->belongsTo(Project::class);
}
public function design()
{
return $this->belongsTo(Design::class);
}
public function user()
{
return $this->belongsTo(User::class)->withTrashed();

View File

@ -42,7 +42,6 @@ class Quote extends BaseModel
protected $touches = [];
protected $fillable = [
'assigned_user_id',
'number',
'discount',
'po_number',
@ -51,7 +50,6 @@ class Quote extends BaseModel
'terms',
'public_notes',
'private_notes',
'project_id',
'tax_name1',
'tax_rate1',
'tax_name2',
@ -61,6 +59,7 @@ class Quote extends BaseModel
'is_amount_discount',
'partial',
'partial_due_date',
'project_id',
'custom_value1',
'custom_value2',
'custom_value3',
@ -68,7 +67,16 @@ class Quote extends BaseModel
'line_items',
'client_id',
'footer',
'custom_surcharge1',
'custom_surcharge2',
'custom_surcharge3',
'custom_surcharge4',
'custom_surcharge_tax1',
'custom_surcharge_tax2',
'custom_surcharge_tax3',
'custom_surcharge_tax4',
'design_id',
'assigned_user_id',
'exchange_rate',
];

View File

@ -74,7 +74,6 @@ class RecurringInvoice extends BaseModel
'due_date',
'due_date_days',
'line_items',
'settings',
'footer',
'public_notes',
'private_notes',
@ -97,6 +96,17 @@ class RecurringInvoice extends BaseModel
'auto_bill',
'auto_bill_enabled',
'design_id',
'custom_surcharge1',
'custom_surcharge2',
'custom_surcharge3',
'custom_surcharge4',
'custom_surcharge_tax1',
'custom_surcharge_tax2',
'custom_surcharge_tax3',
'custom_surcharge_tax4',
'design_id',
'assigned_user_id',
'exchange_rate',
];
protected $casts = [

View File

@ -292,7 +292,7 @@ class BaseRepository
$model = $model->service()->applyNumber()->save();
/* Update product details if necessary */
if ($model->company->update_products !== false)
if ($model->company->update_products)
UpdateOrCreateProduct::dispatch($model->line_items, $model, $model->company);
/* Perform model specific tasks */

View File

@ -125,6 +125,9 @@ class HtmlEngine
$data['$terms'] = &$data['$entity.terms'];
$data['$view_link'] = ['value' => '<a class="button" href="'.$this->invitation->getLink().'">'.ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
$data['$view_url'] = ['value' => $this->invitation->getLink(), 'label' => ctrans('texts.view_invoice')];
if($this->entity->project()->exists())
$data['$project.name'] = ['value' => $this->entity->project->name, 'label' => ctrans('texts.project_name')];
}
if ($this->entity_string == 'quote') {
@ -154,8 +157,11 @@ class HtmlEngine
if ($this->entity->partial > 0) {
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->partial, $this->client) ?: '&nbsp;', 'label' => ctrans('texts.partial_due')];
$data['$balance_due_raw'] = ['value' => $this->entity->partial, 'label' => ctrans('texts.partial_due')];
} else {
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: '&nbsp;', 'label' => ctrans('texts.balance_due')];
$data['$balance_due_raw'] = ['value' => $this->entity->balance, 'label' => ctrans('texts.balance_due')];
}
$data['$quote.balance_due'] = $data['$balance_due'];