mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
automerge
This commit is contained in:
commit
d49f2fe9c9
@ -214,13 +214,13 @@ class InvoiceApiController extends Controller
|
||||
}
|
||||
|
||||
// if only the product key is set we'll load the cost and notes
|
||||
if ($item['product_key'] && (!$item['cost'] || !$item['notes'])) {
|
||||
if ($item['product_key'] && (is_null($item['cost']) || is_null($item['notes']))) {
|
||||
$product = Product::findProductByKey($item['product_key']);
|
||||
if ($product) {
|
||||
if (!$item['cost']) {
|
||||
if (is_null($item['cost'])) {
|
||||
$item['cost'] = $product->cost;
|
||||
}
|
||||
if (!$item['notes']) {
|
||||
if (is_null($item['notes'])) {
|
||||
$item['notes'] = $product->notes;
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,14 @@ use Event;
|
||||
use App;
|
||||
use App\Events\UserSettingsChanged;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
|
||||
class Account extends Eloquent
|
||||
{
|
||||
use PresentableTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $presenter = 'App\Ninja\Presenters\AccountPresenter';
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $hidden = ['ip'];
|
||||
|
||||
@ -132,6 +136,15 @@ class Account extends Eloquent
|
||||
return !$this->language_id || $this->language_id == DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
public function hasInvoicePrefix()
|
||||
{
|
||||
if ( ! $this->invoice_number_prefix && ! $this->quote_number_prefix) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->invoice_number_prefix != $this->quote_number_prefix;
|
||||
}
|
||||
|
||||
public function getDisplayName()
|
||||
{
|
||||
if ($this->name) {
|
||||
|
@ -32,20 +32,6 @@ class Contact extends EntityModel
|
||||
return PERSON_CONTACT;
|
||||
}
|
||||
|
||||
/*
|
||||
public function getLastLogin()
|
||||
{
|
||||
if ($this->last_login == '0000-00-00 00:00:00')
|
||||
{
|
||||
return '---';
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->last_login->format('m/d/y h:i a');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->getDisplayName();
|
||||
|
@ -91,6 +91,7 @@ class ContactMailer extends Mailer
|
||||
'entityType' => $invoice->getEntityType(),
|
||||
'invoiceId' => $invoice->id,
|
||||
'invitation' => $invitation,
|
||||
'account' => $account,
|
||||
];
|
||||
|
||||
if ($account->attatchPDF()) {
|
||||
@ -137,11 +138,12 @@ class ContactMailer extends Mailer
|
||||
'account' => $account,
|
||||
'client' => $client,
|
||||
'invitation' => $invitation,
|
||||
'amount' => $payment->amount
|
||||
'amount' => $payment->amount,
|
||||
];
|
||||
|
||||
$data = [
|
||||
'body' => $this->processVariables($emailTemplate, $variables)
|
||||
'body' => $this->processVariables($emailTemplate, $variables),
|
||||
'account' => $account,
|
||||
];
|
||||
|
||||
if ($account->attatchPDF()) {
|
||||
|
12
app/Ninja/Presenters/AccountPresenter.php
Normal file
12
app/Ninja/Presenters/AccountPresenter.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php namespace App\Ninja\Presenters;
|
||||
|
||||
use Laracasts\Presenter\Presenter;
|
||||
|
||||
class AccountPresenter extends Presenter {
|
||||
|
||||
public function name()
|
||||
{
|
||||
return $this->entity->name ?: trans('texts.untitled_account');
|
||||
}
|
||||
|
||||
}
|
@ -348,19 +348,19 @@ class InvoiceRepository extends BaseRepository
|
||||
$clone = Invoice::createNew($invoice);
|
||||
$clone->balance = $invoice->amount;
|
||||
|
||||
// if the invoice prefix is diff than quote prefix, use the same number for the invoice
|
||||
if (($account->invoice_number_prefix || $account->quote_number_prefix)
|
||||
&& $account->invoice_number_prefix != $account->quote_number_prefix
|
||||
&& $account->share_counter) {
|
||||
|
||||
// if the invoice prefix is diff than quote prefix, use the same number for the invoice (if it's available)
|
||||
$invoiceNumber = false;
|
||||
if ($account->hasInvoicePrefix() && $account->share_counter) {
|
||||
$invoiceNumber = $invoice->invoice_number;
|
||||
if ($account->quote_number_prefix && strpos($invoiceNumber, $account->quote_number_prefix) === 0) {
|
||||
$invoiceNumber = substr($invoiceNumber, strlen($account->quote_number_prefix));
|
||||
}
|
||||
$clone->invoice_number = $account->invoice_number_prefix.$invoiceNumber;
|
||||
} else {
|
||||
$clone->invoice_number = $account->getNextInvoiceNumber($invoice);
|
||||
$invoiceNumber = $account->invoice_number_prefix . $invoiceNumber;
|
||||
if (Invoice::scope()->withTrashed()->whereInvoiceNumber($invoiceNumber)->first()) {
|
||||
$invoiceNumber = false;
|
||||
}
|
||||
}
|
||||
$clone->invoice_number = $invoiceNumber ?: $account->getNextInvoiceNumber($clone);
|
||||
|
||||
foreach ([
|
||||
'client_id',
|
||||
|
@ -26,7 +26,7 @@ class AccountTransformer extends TransformerAbstract
|
||||
{
|
||||
return [
|
||||
'account_key' => $account->account_key,
|
||||
'name' => $account->name,
|
||||
'name' => $account->present()->name,
|
||||
];
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ class UserAccountTransformer extends TransformerAbstract
|
||||
{
|
||||
return [
|
||||
'account_key' => $user->account->account_key,
|
||||
'name' => $user->account->name,
|
||||
'name' => $user->account->present()->name,
|
||||
'token' => $user->account->getToken($this->tokenName),
|
||||
];
|
||||
}
|
||||
|
@ -58,7 +58,8 @@
|
||||
"meebio/omnipay-secure-trading": "dev-master",
|
||||
"justinbusschau/omnipay-secpay": "~2.0",
|
||||
"labs7in0/omnipay-wechat": "dev-master",
|
||||
"collizo4sky/omnipay-wepay": "~1.0"
|
||||
"collizo4sky/omnipay-wepay": "~1.0",
|
||||
"laracasts/presenter": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
|
@ -14,7 +14,7 @@ class UserTableSeeder extends Seeder
|
||||
Eloquent::unguard();
|
||||
|
||||
$account = Account::create([
|
||||
'name' => 'Test Account',
|
||||
//'name' => 'Test Account',
|
||||
'account_key' => str_random(RANDOM_KEY_LENGTH),
|
||||
'timezone_id' => 1,
|
||||
]);
|
||||
|
@ -907,5 +907,6 @@ return array(
|
||||
'restore_recurring_invoice' => 'Restore Recurring Invoice',
|
||||
'restored_recurring_invoice' => 'Successfully restored recurring invoice',
|
||||
'archived' => 'Archived',
|
||||
'untitled_account' => 'Untitled Company',
|
||||
|
||||
);
|
||||
|
@ -5,13 +5,13 @@
|
||||
"description":"View your {{ $entityType }}",
|
||||
"action": {
|
||||
"@type": "ViewAction",
|
||||
"url": "{{{ $link }}}",
|
||||
"url": "{!! $link !!}",
|
||||
"name": "View {{ $entityType }}"
|
||||
},
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": "Invoice Ninja",
|
||||
"url": "{{{ NINJA_WEB_URL }}}"
|
||||
"url": "{!! NINJA_WEB_URL !!}"
|
||||
}
|
||||
}
|
||||
</script>
|
@ -77,7 +77,8 @@
|
||||
<div style="display:none" class="form-group" data-bind="visible: contacts().length > 0 && (contacts()[0].email() || contacts()[0].first_name()), foreach: contacts">
|
||||
<div class="col-lg-8 col-lg-offset-4">
|
||||
<label class="checkbox" data-bind="attr: {for: $index() + '_check'}" onclick="refreshPDF(true)">
|
||||
<input type="checkbox" value="1" data-bind="checked: send_invoice, attr: {id: $index() + '_check'}">
|
||||
<input type="hidden" value="0" data-bind="attr: {name: 'client[contacts][' + $index() + '][send_invoice]'}">
|
||||
<input type="checkbox" value="1" data-bind="checked: send_invoice, attr: {id: $index() + '_check', name: 'client[contacts][' + $index() + '][send_invoice]'}">
|
||||
<span data-bind="html: email.display"></span>
|
||||
</label>
|
||||
<span data-bind="html: $data.view_as_recipient"></span>
|
||||
@ -612,7 +613,7 @@
|
||||
for (var j=0; j<client.contacts.length; j++) {
|
||||
var contact = client.contacts[j];
|
||||
var contactName = getContactDisplayName(contact);
|
||||
if (contact.is_primary) {
|
||||
if (contact.is_primary === '1') {
|
||||
contact.send_invoice = true;
|
||||
}
|
||||
if (clientName != contactName) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user