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 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']);
|
$product = Product::findProductByKey($item['product_key']);
|
||||||
if ($product) {
|
if ($product) {
|
||||||
if (!$item['cost']) {
|
if (is_null($item['cost'])) {
|
||||||
$item['cost'] = $product->cost;
|
$item['cost'] = $product->cost;
|
||||||
}
|
}
|
||||||
if (!$item['notes']) {
|
if (is_null($item['notes'])) {
|
||||||
$item['notes'] = $product->notes;
|
$item['notes'] = $product->notes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,14 @@ use Event;
|
|||||||
use App;
|
use App;
|
||||||
use App\Events\UserSettingsChanged;
|
use App\Events\UserSettingsChanged;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Laracasts\Presenter\PresentableTrait;
|
||||||
|
|
||||||
class Account extends Eloquent
|
class Account extends Eloquent
|
||||||
{
|
{
|
||||||
|
use PresentableTrait;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $presenter = 'App\Ninja\Presenters\AccountPresenter';
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
protected $hidden = ['ip'];
|
protected $hidden = ['ip'];
|
||||||
|
|
||||||
@ -132,6 +136,15 @@ class Account extends Eloquent
|
|||||||
return !$this->language_id || $this->language_id == DEFAULT_LANGUAGE;
|
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()
|
public function getDisplayName()
|
||||||
{
|
{
|
||||||
if ($this->name) {
|
if ($this->name) {
|
||||||
|
@ -32,20 +32,6 @@ class Contact extends EntityModel
|
|||||||
return PERSON_CONTACT;
|
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()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->getDisplayName();
|
return $this->getDisplayName();
|
||||||
|
@ -91,6 +91,7 @@ class ContactMailer extends Mailer
|
|||||||
'entityType' => $invoice->getEntityType(),
|
'entityType' => $invoice->getEntityType(),
|
||||||
'invoiceId' => $invoice->id,
|
'invoiceId' => $invoice->id,
|
||||||
'invitation' => $invitation,
|
'invitation' => $invitation,
|
||||||
|
'account' => $account,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($account->attatchPDF()) {
|
if ($account->attatchPDF()) {
|
||||||
@ -137,11 +138,12 @@ class ContactMailer extends Mailer
|
|||||||
'account' => $account,
|
'account' => $account,
|
||||||
'client' => $client,
|
'client' => $client,
|
||||||
'invitation' => $invitation,
|
'invitation' => $invitation,
|
||||||
'amount' => $payment->amount
|
'amount' => $payment->amount,
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'body' => $this->processVariables($emailTemplate, $variables)
|
'body' => $this->processVariables($emailTemplate, $variables),
|
||||||
|
'account' => $account,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($account->attatchPDF()) {
|
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 = Invoice::createNew($invoice);
|
||||||
$clone->balance = $invoice->amount;
|
$clone->balance = $invoice->amount;
|
||||||
|
|
||||||
// if the invoice prefix is diff than quote prefix, use the same number for the invoice
|
// if the invoice prefix is diff than quote prefix, use the same number for the invoice (if it's available)
|
||||||
if (($account->invoice_number_prefix || $account->quote_number_prefix)
|
$invoiceNumber = false;
|
||||||
&& $account->invoice_number_prefix != $account->quote_number_prefix
|
if ($account->hasInvoicePrefix() && $account->share_counter) {
|
||||||
&& $account->share_counter) {
|
|
||||||
|
|
||||||
$invoiceNumber = $invoice->invoice_number;
|
$invoiceNumber = $invoice->invoice_number;
|
||||||
if ($account->quote_number_prefix && strpos($invoiceNumber, $account->quote_number_prefix) === 0) {
|
if ($account->quote_number_prefix && strpos($invoiceNumber, $account->quote_number_prefix) === 0) {
|
||||||
$invoiceNumber = substr($invoiceNumber, strlen($account->quote_number_prefix));
|
$invoiceNumber = substr($invoiceNumber, strlen($account->quote_number_prefix));
|
||||||
}
|
}
|
||||||
$clone->invoice_number = $account->invoice_number_prefix.$invoiceNumber;
|
$invoiceNumber = $account->invoice_number_prefix . $invoiceNumber;
|
||||||
} else {
|
if (Invoice::scope()->withTrashed()->whereInvoiceNumber($invoiceNumber)->first()) {
|
||||||
$clone->invoice_number = $account->getNextInvoiceNumber($invoice);
|
$invoiceNumber = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$clone->invoice_number = $invoiceNumber ?: $account->getNextInvoiceNumber($clone);
|
||||||
|
|
||||||
foreach ([
|
foreach ([
|
||||||
'client_id',
|
'client_id',
|
||||||
|
@ -26,7 +26,7 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'account_key' => $account->account_key,
|
'account_key' => $account->account_key,
|
||||||
'name' => $account->name,
|
'name' => $account->present()->name,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ class UserAccountTransformer extends TransformerAbstract
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'account_key' => $user->account->account_key,
|
'account_key' => $user->account->account_key,
|
||||||
'name' => $user->account->name,
|
'name' => $user->account->present()->name,
|
||||||
'token' => $user->account->getToken($this->tokenName),
|
'token' => $user->account->getToken($this->tokenName),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,8 @@
|
|||||||
"meebio/omnipay-secure-trading": "dev-master",
|
"meebio/omnipay-secure-trading": "dev-master",
|
||||||
"justinbusschau/omnipay-secpay": "~2.0",
|
"justinbusschau/omnipay-secpay": "~2.0",
|
||||||
"labs7in0/omnipay-wechat": "dev-master",
|
"labs7in0/omnipay-wechat": "dev-master",
|
||||||
"collizo4sky/omnipay-wepay": "~1.0"
|
"collizo4sky/omnipay-wepay": "~1.0",
|
||||||
|
"laracasts/presenter": "dev-master"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~4.0",
|
"phpunit/phpunit": "~4.0",
|
||||||
|
@ -14,7 +14,7 @@ class UserTableSeeder extends Seeder
|
|||||||
Eloquent::unguard();
|
Eloquent::unguard();
|
||||||
|
|
||||||
$account = Account::create([
|
$account = Account::create([
|
||||||
'name' => 'Test Account',
|
//'name' => 'Test Account',
|
||||||
'account_key' => str_random(RANDOM_KEY_LENGTH),
|
'account_key' => str_random(RANDOM_KEY_LENGTH),
|
||||||
'timezone_id' => 1,
|
'timezone_id' => 1,
|
||||||
]);
|
]);
|
||||||
|
@ -907,5 +907,6 @@ return array(
|
|||||||
'restore_recurring_invoice' => 'Restore Recurring Invoice',
|
'restore_recurring_invoice' => 'Restore Recurring Invoice',
|
||||||
'restored_recurring_invoice' => 'Successfully restored recurring invoice',
|
'restored_recurring_invoice' => 'Successfully restored recurring invoice',
|
||||||
'archived' => 'Archived',
|
'archived' => 'Archived',
|
||||||
|
'untitled_account' => 'Untitled Company',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
"description":"View your {{ $entityType }}",
|
"description":"View your {{ $entityType }}",
|
||||||
"action": {
|
"action": {
|
||||||
"@type": "ViewAction",
|
"@type": "ViewAction",
|
||||||
"url": "{{{ $link }}}",
|
"url": "{!! $link !!}",
|
||||||
"name": "View {{ $entityType }}"
|
"name": "View {{ $entityType }}"
|
||||||
},
|
},
|
||||||
"publisher": {
|
"publisher": {
|
||||||
"@type": "Organization",
|
"@type": "Organization",
|
||||||
"name": "Invoice Ninja",
|
"name": "Invoice Ninja",
|
||||||
"url": "{{{ NINJA_WEB_URL }}}"
|
"url": "{!! NINJA_WEB_URL !!}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</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 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">
|
<div class="col-lg-8 col-lg-offset-4">
|
||||||
<label class="checkbox" data-bind="attr: {for: $index() + '_check'}" onclick="refreshPDF(true)">
|
<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>
|
<span data-bind="html: email.display"></span>
|
||||||
</label>
|
</label>
|
||||||
<span data-bind="html: $data.view_as_recipient"></span>
|
<span data-bind="html: $data.view_as_recipient"></span>
|
||||||
@ -612,7 +613,7 @@
|
|||||||
for (var j=0; j<client.contacts.length; j++) {
|
for (var j=0; j<client.contacts.length; j++) {
|
||||||
var contact = client.contacts[j];
|
var contact = client.contacts[j];
|
||||||
var contactName = getContactDisplayName(contact);
|
var contactName = getContactDisplayName(contact);
|
||||||
if (contact.is_primary) {
|
if (contact.is_primary === '1') {
|
||||||
contact.send_invoice = true;
|
contact.send_invoice = true;
|
||||||
}
|
}
|
||||||
if (clientName != contactName) {
|
if (clientName != contactName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user