mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 14:34:30 -04:00
commit
066e6aaf72
@ -1 +1 @@
|
||||
5.0.46
|
||||
5.0.47
|
@ -62,7 +62,7 @@ class SendRemindersCron extends Command
|
||||
$invoices = Invoice::where('is_deleted', 0)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||
->where('balance', '>', 0)
|
||||
->whereDate('due_date', now()->subDays(1)->startOfDay())
|
||||
->whereDate('due_date', '<=', now()->subDays(1)->startOfDay())
|
||||
->cursor();
|
||||
|
||||
$invoices->each(function ($invoice) {
|
||||
@ -74,7 +74,7 @@ class SendRemindersCron extends Command
|
||||
{
|
||||
$quotes = Quote::where('is_deleted', 0)
|
||||
->where('status_id', Quote::STATUS_SENT)
|
||||
->whereDate('due_date', now()->subDays(1)->startOfDay())
|
||||
->whereDate('due_date', '<=', now()->subDays(1)->startOfDay())
|
||||
->cursor();
|
||||
|
||||
$quotes->each(function ($quote) {
|
||||
|
@ -85,10 +85,12 @@ class StoreClientRequest extends Request
|
||||
|
||||
$input = $this->decodePrimaryKeys($input);
|
||||
|
||||
if(isset($input['group_settings_id']))
|
||||
$input['group_settings_id'] = $this->decodePrimaryKey($input['group_settings_id']);
|
||||
|
||||
//is no settings->currency_id is set then lets dive in and find either a group or company currency all the below may be redundant!!
|
||||
if (! property_exists($settings, 'currency_id') && isset($input['group_settings_id'])) {
|
||||
$input['group_settings_id'] = $this->decodePrimaryKey($input['group_settings_id']);
|
||||
|
||||
$group_settings = GroupSetting::find($input['group_settings_id']);
|
||||
|
||||
if ($group_settings && property_exists($group_settings->settings, 'currency_id') && isset($group_settings->settings->currency_id)) {
|
||||
|
@ -54,6 +54,7 @@ class StoreCreditRequest extends Request
|
||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||
|
||||
$rules['number'] = new UniqueCreditNumberRule($this->all());
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ class UpdateCreditRequest extends Request
|
||||
$rules['number'] = 'unique:credits,number,'.$this->id.',id,company_id,'.$this->credit->company_id;
|
||||
}
|
||||
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,8 @@ class StoreInvoiceRequest extends Request
|
||||
|
||||
$rules['project_id'] = ['bail', 'sometimes', new ValidProjectForClient($this->all())];
|
||||
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,8 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['number'] = 'unique:invoices,number,'.$this->id.',id,company_id,'.$this->invoice->company_id;
|
||||
}
|
||||
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class StorePaymentRequest extends Request
|
||||
$input['amount'] = $invoices_total - $credits_total;
|
||||
}
|
||||
|
||||
$input['is_manual'] = true;
|
||||
// $input['is_manual'] = true;
|
||||
|
||||
if (! isset($input['date'])) {
|
||||
$input['date'] = now()->format('Y-m-d');
|
||||
|
@ -94,6 +94,7 @@ class StoreQuoteRequest extends Request
|
||||
}
|
||||
|
||||
$rules['number'] = new UniqueQuoteNumberRule($this->all());
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ class UpdateQuoteRequest extends Request
|
||||
$rules['number'] = 'unique:quotes,number,'.$this->id.',id,company_id,'.$this->quote->company_id;
|
||||
}
|
||||
|
||||
$rules['line_items'] = 'array';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class Payment extends BaseModel
|
||||
'date',
|
||||
'transaction_reference',
|
||||
'number',
|
||||
'is_manual',
|
||||
// 'is_manual',
|
||||
'private_notes',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
|
@ -95,6 +95,7 @@ class PaymentRepository extends BaseRepository
|
||||
|
||||
/*Fill the payment*/
|
||||
$payment->fill($data);
|
||||
$payment->is_manual = true;
|
||||
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||
$payment->save();
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Services\Credit;
|
||||
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Factory\CreditInvitationFactory;
|
||||
use App\Models\Credit;
|
||||
use App\Models\CreditInvitation;
|
||||
@ -29,6 +30,13 @@ class CreateInvitations extends AbstractService
|
||||
{
|
||||
$contacts = $this->credit->client->contacts;
|
||||
|
||||
if($contacts->count() == 0){
|
||||
$this->createBlankContact();
|
||||
|
||||
$this->credit->refresh();
|
||||
$contacts = $this->credit->client->contacts;
|
||||
}
|
||||
|
||||
$contacts->each(function ($contact) {
|
||||
$invitation = CreditInvitation::whereCompanyId($this->credit->company_id)
|
||||
->whereClientContactId($contact->id)
|
||||
@ -47,4 +55,13 @@ class CreateInvitations extends AbstractService
|
||||
|
||||
return $this->credit;
|
||||
}
|
||||
|
||||
private function createBlankContact()
|
||||
{
|
||||
$new_contact = ClientContactFactory::create($this->credit->company_id, $this->credit->user_id);
|
||||
$new_contact->client_id = $this->credit->client_id;
|
||||
$new_contact->contact_key = Str::random(40);
|
||||
$new_contact->is_primary = true;
|
||||
$new_contact->save();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Services\Invoice;
|
||||
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
@ -27,7 +28,17 @@ class CreateInvitations extends AbstractService
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->invoice->client->contacts->each(function ($contact) {
|
||||
|
||||
$contacts = $this->invoice->client->contacts;
|
||||
|
||||
if($contacts->count() == 0){
|
||||
$this->createBlankContact();
|
||||
|
||||
$this->invoice->refresh();
|
||||
$contacts = $this->invoice->client->contacts;
|
||||
}
|
||||
|
||||
$contacts->each(function ($contact) {
|
||||
$invitation = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
|
||||
->whereClientContactId($contact->id)
|
||||
->whereInvoiceId($this->invoice->id)
|
||||
@ -46,4 +57,13 @@ class CreateInvitations extends AbstractService
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
private function createBlankContact()
|
||||
{
|
||||
$new_contact = ClientContactFactory::create($this->invoice->company_id, $this->invoice->user_id);
|
||||
$new_contact->client_id = $this->invoice->client_id;
|
||||
$new_contact->contact_key = Str::random(40);
|
||||
$new_contact->is_primary = true;
|
||||
$new_contact->save();
|
||||
}
|
||||
}
|
||||
|
@ -11,26 +11,41 @@
|
||||
|
||||
namespace App\Services\Quote;
|
||||
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Factory\QuoteInvitationFactory;
|
||||
use App\Models\Quote;
|
||||
use App\Models\QuoteInvitation;
|
||||
|
||||
class CreateInvitations
|
||||
{
|
||||
public function __construct()
|
||||
public $quote;
|
||||
|
||||
public function __construct(Quote $quote)
|
||||
{
|
||||
$this->quote = $quote;
|
||||
}
|
||||
|
||||
public function run($quote)
|
||||
public function run()
|
||||
{
|
||||
$quote->client->contacts->each(function ($contact) use ($quote) {
|
||||
$invitation = QuoteInvitation::whereCompanyId($quote->company_id)
|
||||
|
||||
$contacts = $this->quote->client->contacts;
|
||||
|
||||
if($contacts->count() == 0){
|
||||
$this->createBlankContact();
|
||||
|
||||
$this->quote->refresh();
|
||||
$contacts = $this->quote->client->contacts;
|
||||
}
|
||||
|
||||
$contacts->each(function ($contact){
|
||||
$invitation = QuoteInvitation::whereCompanyId($this->quote->company_id)
|
||||
->whereClientContactId($contact->id)
|
||||
->whereQuoteId($quote->id)
|
||||
->whereQuoteId($this->quote->id)
|
||||
->first();
|
||||
|
||||
if (! $invitation && $contact->send_email) {
|
||||
$ii = QuoteInvitationFactory::create($quote->company_id, $quote->user_id);
|
||||
$ii->quote_id = $quote->id;
|
||||
$ii = QuoteInvitationFactory::create($this->quote->company_id, $this->quote->user_id);
|
||||
$ii->quote_id = $this->quote->id;
|
||||
$ii->client_contact_id = $contact->id;
|
||||
$ii->save();
|
||||
} elseif ($invitation && ! $contact->send_email) {
|
||||
@ -38,6 +53,16 @@ class CreateInvitations
|
||||
}
|
||||
});
|
||||
|
||||
return $quote->fresh();
|
||||
return $this->quote->fresh();
|
||||
}
|
||||
|
||||
private function createBlankContact()
|
||||
{
|
||||
$new_contact = ClientContacstFactory::create($this->quote->company_id, $this->quote->user_id);
|
||||
$new_contact->client_id = $this->quote->client_id;
|
||||
$new_contact->contact_key = Str::random(40);
|
||||
$new_contact->is_primary = true;
|
||||
$new_contact->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class QuoteService
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
protected $quote;
|
||||
public $quote;
|
||||
|
||||
public $invoice;
|
||||
|
||||
@ -33,9 +33,7 @@ class QuoteService
|
||||
|
||||
public function createInvitations()
|
||||
{
|
||||
$create_invitation = new CreateInvitations();
|
||||
|
||||
$this->quote = $create_invitation->run($this->quote);
|
||||
$this->quote = (new CreateInvitations($this->quote))->run();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ trait CleanLineItems
|
||||
{
|
||||
public function cleanItems($items) :array
|
||||
{
|
||||
if (! isset($items)) {
|
||||
if (! isset($items) || !is_array($items)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', ''),
|
||||
'app_version' => '5.0.46',
|
||||
'app_version' => '5.0.47',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -12,5 +12,5 @@
|
||||
@endsection
|
||||
|
||||
@section('body')
|
||||
This page is empty, sad and alone.
|
||||
Coming soon.
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user