1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Merge pull request #8517 from turbo124/v5-develop

v5.5.120
This commit is contained in:
David Bomba 2023-05-24 14:47:56 +10:00 committed by GitHub
commit f29bdcbb8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 272 additions and 107 deletions

View File

@ -1 +1 @@
5.5.119
5.5.120

View File

@ -124,15 +124,16 @@ class TaskStatusController extends BaseController
*/
public function update(UpdateTaskStatusRequest $request, TaskStatus $task_status)
{
$task_status->fill($request->all());
$reorder = $task_status->isDirty('status_order');
$task_status->save();
if ($reorder)
$this->task_status_repo->reorder($task_status);
return $this->itemResponse($task_status->fresh());
}
/**

View File

@ -106,12 +106,12 @@ class UpdateOrCreateProduct implements ShouldQueue
$product->quantity = isset($item->quantity) ? $item->quantity : 0;
}
$product->tax_name1 = isset($item->tax_name1) ? $item->tax_name1 : '';
$product->tax_rate1 = isset($item->tax_rate1) ? $item->tax_rate1 : 0;
$product->tax_name2 = isset($item->tax_name2) ? $item->tax_name2 : '';
$product->tax_rate2 = isset($item->tax_rate2) ? $item->tax_rate2 : 0;
$product->tax_name3 = isset($item->tax_name3) ? $item->tax_name3 : '';
$product->tax_rate3 = isset($item->tax_rate3) ? $item->tax_rate3 : 0;
// $product->tax_name1 = isset($item->tax_name1) ? $item->tax_name1 : '';
// $product->tax_rate1 = isset($item->tax_rate1) ? $item->tax_rate1 : 0;
// $product->tax_name2 = isset($item->tax_name2) ? $item->tax_name2 : '';
// $product->tax_rate2 = isset($item->tax_rate2) ? $item->tax_rate2 : 0;
// $product->tax_name3 = isset($item->tax_name3) ? $item->tax_name3 : '';
// $product->tax_rate3 = isset($item->tax_rate3) ? $item->tax_rate3 : 0;
if (isset($item->custom_value1) && strlen($item->custom_value1) >=1) {
$product->custom_value1 = $item->custom_value1;

View File

@ -11,18 +11,19 @@
namespace App\PaymentDrivers;
use App\Exceptions\SystemError;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Invoice;
use App\Models\Payment;
use App\Utils\CurlUtils;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\PayTrace\CreditCard;
use App\Utils\CurlUtils;
use App\Exceptions\SystemError;
use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash;
use App\Models\ClientGatewayToken;
use App\PaymentDrivers\PayTrace\CreditCard;
use App\Http\Requests\Payments\PaymentWebhookRequest;
class PaytracePaymentDriver extends BaseDriver
{
@ -125,10 +126,20 @@ class PaytracePaymentDriver extends BaseDriver
{
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
$_invoice = collect($payment_hash->data->invoices)->first();
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
if ($invoice) {
$invoice_id = ctrans('texts.invoice_number').'# '.$invoice->number;
}
$invoice_id = ctrans('texts.invoice_number').'# '.substr($payment_hash->hash, 0, 6);
$data = [
'customer_id' => $cgt->token,
'integrator_id' => $this->company_gateway->getConfigField('integratorId'),
'amount' => $amount,
'invoice_id' => $invoice_id,
];
$response = $this->gatewayRequest('/v1/transactions/sale/by_customer', $data);
@ -173,7 +184,10 @@ class PaytracePaymentDriver extends BaseDriver
/*Helpers*/
private function generateAuthHeaders()
{
$url = 'https://api.paytrace.com/oauth/token';
$api_endpoint = $this->company_gateway->getConfigField('testMode') ? 'https://api.sandbox.paytrace.com' : 'https://api.paytrace.com';
$url = "{$api_endpoint}/oauth/token";
$data = [
'grant_type' => 'password',
'username' => $this->company_gateway->getConfigField('username'),
@ -197,9 +211,12 @@ class PaytracePaymentDriver extends BaseDriver
public function getAuthToken()
{
$api_endpoint = $this->company_gateway->getConfigField('testMode') ? 'https://api.sandbox.paytrace.com' : 'https://api.paytrace.com';
$headers = $this->generateAuthHeaders();
$response = CurlUtils::post('https://api.paytrace.com/v1/payment_fields/token/create', [], $headers);
$response = CurlUtils::post("{$api_endpoint}/v1/payment_fields/token/create", [], $headers);
$response = json_decode($response);
@ -212,7 +229,10 @@ class PaytracePaymentDriver extends BaseDriver
public function gatewayRequest($uri, $data, $headers = false)
{
$base_url = "https://api.paytrace.com{$uri}";
$api_endpoint = $this->company_gateway->getConfigField('testMode') ? 'https://api.sandbox.paytrace.com' : 'https://api.paytrace.com';
$base_url = "{$api_endpoint}{$uri}";
$headers = $this->generateAuthHeaders();

View File

@ -617,7 +617,7 @@ class StripePaymentDriver extends BaseDriver
'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision, $this->client->currency()),
], $meta);
if ($response->status == $response::STATUS_SUCCEEDED) {
if (in_array($response->status, [$response::STATUS_SUCCEEDED, 'pending'])) {
SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all()], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client, $this->client->company);
return [
@ -712,6 +712,11 @@ class StripePaymentDriver extends BaseDriver
}
if ($payment) {
if(isset($transaction['payment_method_details']['au_becs_debit'])) {
$payment->transaction_reference = $transaction['id'];
}
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->save();
}

View File

@ -45,8 +45,8 @@ class TaskStatusRepository extends BaseRepository
$new_status = $task_status ? $task_status->id : null;
Task::where('status_id', $task_status->id)
->where('company_id', $task_status->company_id)
->update(['status_id' => $new_status]);
->where('company_id', $task_status->company_id)
->update(['status_id' => $new_status]);
parent::archive($task_status);
@ -57,14 +57,30 @@ class TaskStatusRepository extends BaseRepository
public function reorder(TaskStatus $task_status)
{
TaskStatus::query()
->where('company_id', $task_status->company_id)
->orderByRaw('ISNULL(status_order), status_order ASC')
->orderBy('updated_at', 'DESC')
->cursor()
->each(function ($task_status, $index) {
$task_status->update(['status_order' => $index+1]);
});
TaskStatus::where('company_id', $task_status->company_id)
->where('id', '!=', $task_status->id)
->orderByRaw('ISNULL(status_order), status_order ASC')
->cursor()
->each(function ($ts, $key) use($task_status){
if($ts->status_order < $task_status->status_order) {
$ts->status_order--;
$ts->save();
} elseif($ts->status_order >= $task_status->status_order) {
$ts->status_order ++;
$ts->save();
}
});
TaskStatus::where('company_id', $task_status->company_id)
->orderByRaw('ISNULL(status_order), status_order ASC')
->cursor()
->each(function ($ts, $key) {
$ts->status_order = $key+1;
$ts->save();
});
}
}

View File

@ -168,14 +168,10 @@ class EmailDefaults
*/
private function setBody(): self
{
if ($this->template == 'email.template.custom') {
$this->email->email_object->body = (str_replace('$body', $this->email->email_object->body, $this->email->email_object->settings->email_style_custom));
return $this;
}
if ($this->email->email_object->body) {
if (strlen($this->email->email_object->body) > 3) {
// A Custom Message has been set in the email screen.
return $this;
// return $this;
} elseif (strlen($this->email->email_object->settings?->{$this->email->email_object->email_template_body}) > 3) {
// A body has been saved in the settings.
$this->email->email_object->body = $this->email->email_object->settings?->{$this->email->email_object->email_template_body};
@ -183,7 +179,13 @@ class EmailDefaults
// Default template to be used
$this->email->email_object->body = EmailTemplateDefaults::getDefaultTemplate($this->email->email_object->email_template_body, $this->locale);
}
if ($this->template == 'email.template.custom') {
$this->email->email_object->body = (str_replace('$body', $this->email->email_object->body, str_replace(["\r","\n"], "", $this->email->email_object->settings->email_style_custom)));
}
return $this;
}
/**

View File

@ -91,6 +91,7 @@ class RecurringInvoiceTransformer extends EntityTransformer
'date' => $invoice->date ?: '',
'last_sent_date' => $invoice->last_sent_date ?: '',
'next_send_date' => $invoice->next_send_date_client ?: '',
'next_send_datetime' => $invoice->next_send_date ?: '',
'due_date' => $invoice->due_date ?: '',
'terms' => $invoice->terms ?: '',
'public_notes' => $invoice->public_notes ?: '',

View File

@ -114,7 +114,8 @@ class HtmlEngine
$data['$company_logo_size'] = ['value' => $this->resolveCompanyLogoSize(), 'label' => ''];
$data['$show_shipping_address'] = ['value' => $this->settings?->show_shipping_address ? 'flex' : 'none', 'label' => ''];
$data['$show_shipping_address_block'] = ['value' => $this->settings?->show_shipping_address ? 'block' : 'none', 'label' => ''];
$data['$show_shipping_address_visibility'] = ['value' => $this->settings?->show_shipping_address ? 'visible' : 'hidden', 'label' => ''];
// $data['$show_shipping_address_visibility'] = ['value' => $this->settings?->show_shipping_address ? 'visible' : 'hidden', 'label' => ''];
$data['$show_shipping_address_visibility'] = ['value' => $this->settings?->show_shipping_address ? 1 : 0, 'label' => ''];
$data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => ''];

View File

@ -76,7 +76,7 @@ trait CleanLineItems
}
if (array_key_exists('id', $item)) {
if (array_key_exists('id', $item) || array_key_exists('_id', $item)) {
unset($item['id']);
}

View File

@ -15,8 +15,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.5.119',
'app_tag' => '5.5.119',
'app_version' => '5.5.120',
'app_tag' => '5.5.120',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''),

View File

@ -20,6 +20,8 @@ return new class extends Migration
$table->text('origin_tax_data')->nullable();
});
\Illuminate\Support\Facades\Artisan::call('ninja:design-update');
}
/**

View File

@ -28,46 +28,82 @@ var PayTraceCreditCard = /*#__PURE__*/function () {
key: "creditCardStyles",
get: function get() {
return {
font_color: '#111827',
border_color: 'rgba(210,214,220,1)',
label_color: '#111827',
label_size: '12pt',
background_color: 'white',
border_style: 'solid',
font_size: '15pt',
height: '30px',
width: '100%'
'font_color': '#000',
'border_color': '#a1b1c9',
'border_style': 'dotted',
'font_size': '13pt',
'input_border_radius': '3px',
'input_border_width': '1px',
'input_font': 'Times New Roman, arial, fantasy',
'input_font_weight': '400',
'input_margin': '5px 0px 5px 0px',
'input_padding': '0px 5px 0px 5px',
'label_color': '#a0aec0',
'label_size': '16px',
'label_width': '150px',
'label_font': 'Times New Roman, sans-serif, serif',
'label_font_weight': 'light',
'label_margin': '5px 0px 0px 0px',
'label_padding': '0px 5px 0px 5px',
'background_color': 'white',
'height': '30px',
'width': '370px',
'padding_bottom': '0px'
};
}
}, {
key: "codeStyles",
get: function get() {
return {
font_color: '#111827',
border_color: 'rgba(210,214,220,1)',
label_color: '#111827',
label_size: '12pt',
background_color: 'white',
border_style: 'solid',
font_size: '15pt',
height: '30px',
width: '300px'
'font_color': '#000',
'border_color': '#a1b1c9',
'border_style': 'dotted',
'font_size': '13pt',
'input_border_radius': '2px',
'input_border_width': '1px',
'input_font': 'serif, cursive, fantasy',
'input_font_weight': '700',
'input_margin': '5px 0px 5px 20px',
'input_padding': '0px 5px 0px 5px',
'label_color': '#a0aec0',
'label_size': '16px',
'label_width': '150px',
'label_font': 'sans-serif, arial, serif',
'label_font_weight': 'bold',
'label_margin': '5px 0px 0px 20px',
'label_padding': '2px 5px 2px 5px',
'background_color': 'white',
'height': '30px',
'width': '150px',
'padding_bottom': '2px'
};
}
}, {
key: "expStyles",
get: function get() {
return {
font_color: '#111827',
border_color: 'rgba(210,214,220,1)',
label_color: '#111827',
label_size: '12pt',
background_color: 'white',
border_style: 'solid',
font_size: '15pt',
height: '30px',
width: '85px',
type: 'dropdown'
'font_color': '#000',
'border_color': '#a1b1c9',
'border_style': 'dashed',
'font_size': '12pt',
'input_border_radius': '0px',
'input_border_width': '2px',
'input_font': 'arial, cursive, fantasy',
'input_font_weight': '400',
'input_margin': '5px 0px 5px 0px',
'input_padding': '0px 5px 0px 5px',
'label_color': '#a0aec0',
'label_size': '16px',
'label_width': '150px',
'label_font': 'arial, fantasy, serif',
'label_font_weight': 'normal',
'label_margin': '5px 0px 0px 0px',
'label_padding': '2px 5px 2px 5px',
'background_color': 'white',
'height': '30px',
'width': '85px',
'padding_bottom': '2px',
'type': 'dropdown'
};
}
}, {

View File

@ -29,10 +29,10 @@ var PDF = /*#__PURE__*/function () {
this.context = canvas.getContext('2d');
this.currentPage = 1;
this.maxPages = 1;
this.currentScale = 1.25;
this.currentScale = 1;
this.currentScaleText = document.getElementById('zoom-level');
if (matchMedia('only screen and (max-width: 480px)').matches) {
this.currentScale = 1.25;
this.currentScale = 1;
}
this.currentScaleText.textContent = this.currentScale * 100 + '%';
}
@ -135,6 +135,24 @@ var PDF = /*#__PURE__*/function () {
viewport: viewport
});
this.setPagesInViewport();
/* document.addEventListener("webviewerloaded", function () {
PDFViewerApplication.initializedPromise.then(function () {
PDFViewerApplication.eventBus.on("pagerendered", function handler(event) {
try {
if (window.chrome && !/Edge/.test(navigator.userAgent) && !event.source.__rerendered) {
console.log("Chrome-like browser detected, re-rendering page %d for the first time.", event.pageNumber);
var currentScale = event.source.scale;
event.source.__rerendered = true;
event.source.update(currentScale * 0.99);
event.source.update(currentScale);
}
} catch (e) {
console.error(e);
}
});
});
}); */
case 14:
case "end":
return _context.stop();

View File

@ -19,14 +19,14 @@
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=b483e14d15000c04edfe4c9c80fb97c9",
"/js/setup/setup.js": "/js/setup/setup.js?id=086b9e114b0b9ee01f909d686f489162",
"/js/clients/payments/card-js.min.js": "/js/clients/payments/card-js.min.js?id=cf50b5ba1fcd1d184bf0c10d710672c8",
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=40f4f82b01d751c284337279b92b9297",
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=c9593b44d66f89874d13f99bc3e6ff33",
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=bc6756a5ef373ffab30373a6b689d5d4",
"/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=a9c53bbbced7b1f09cae117f667638cf",
"/js/clients/payments/braintree-credit-card.js": "/js/clients/payments/braintree-credit-card.js?id=e0020a4104a2d88c21e47ec6679de7ef",
"/js/clients/payments/braintree-paypal.js": "/js/clients/payments/braintree-paypal.js?id=881f15cb83dc9d0412625da80f094912",
"/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=b8b588f18e7c692faa44b598f3f1bde0",
"/js/clients/payment_methods/wepay-bank-account.js": "/js/clients/payment_methods/wepay-bank-account.js?id=e984eca06a662d2e8a8e01cae085794c",
"/js/clients/payments/paytrace-credit-card.js": "/js/clients/payments/paytrace-credit-card.js?id=5ff9cc69d2923a89c05412bff3a8c862",
"/js/clients/payments/paytrace-credit-card.js": "/js/clients/payments/paytrace-credit-card.js?id=800e95b9c19d54e844338d619e87c9dc",
"/js/clients/payments/mollie-credit-card.js": "/js/clients/payments/mollie-credit-card.js?id=2f72b969507e6135b5c52a65522ab3ae",
"/js/clients/payments/eway-credit-card.js": "/js/clients/payments/eway-credit-card.js?id=0d1c8957b02c5601b7d57c39740bff75",
"/js/clients/payment_methods/braintree-ach.js": "/js/clients/payment_methods/braintree-ach.js?id=2f8e5af9ba5ce266d2ee49b084fbe291",

View File

@ -17,44 +17,80 @@ class PayTraceCreditCard {
get creditCardStyles() {
return {
font_color: '#111827',
border_color: 'rgba(210,214,220,1)',
label_color: '#111827',
label_size: '12pt',
background_color: 'white',
border_style: 'solid',
font_size: '15pt',
height: '30px',
width: '100%',
'font_color': '#000',
'border_color': '#a1b1c9',
'border_style': 'dotted',
'font_size': '13pt',
'input_border_radius': '3px',
'input_border_width': '1px',
'input_font': 'Times New Roman, arial, fantasy',
'input_font_weight': '400',
'input_margin': '5px 0px 5px 0px',
'input_padding': '0px 5px 0px 5px',
'label_color': '#a0aec0',
'label_size': '16px',
'label_width': '150px',
'label_font': 'Times New Roman, sans-serif, serif',
'label_font_weight': 'light',
'label_margin': '5px 0px 0px 0px',
'label_padding': '0px 5px 0px 5px',
'background_color': 'white',
'height': '30px',
'width': '370px',
'padding_bottom': '0px'
};
}
get codeStyles() {
return {
font_color: '#111827',
border_color: 'rgba(210,214,220,1)',
label_color: '#111827',
label_size: '12pt',
background_color: 'white',
border_style: 'solid',
font_size: '15pt',
height: '30px',
width: '300px',
'font_color': '#000',
'border_color': '#a1b1c9',
'border_style': 'dotted',
'font_size': '13pt',
'input_border_radius': '2px',
'input_border_width': '1px',
'input_font': 'serif, cursive, fantasy',
'input_font_weight': '700',
'input_margin': '5px 0px 5px 20px',
'input_padding': '0px 5px 0px 5px',
'label_color': '#a0aec0',
'label_size': '16px',
'label_width': '150px',
'label_font': 'sans-serif, arial, serif',
'label_font_weight': 'bold',
'label_margin': '5px 0px 0px 20px',
'label_padding': '2px 5px 2px 5px',
'background_color': 'white',
'height': '30px',
'width': '150px',
'padding_bottom': '2px'
};
}
get expStyles() {
return {
font_color: '#111827',
border_color: 'rgba(210,214,220,1)',
label_color: '#111827',
label_size: '12pt',
background_color: 'white',
border_style: 'solid',
font_size: '15pt',
height: '30px',
width: '85px',
type: 'dropdown',
'font_color': '#000',
'border_color': '#a1b1c9',
'border_style': 'dashed',
'font_size': '12pt',
'input_border_radius': '0px',
'input_border_width': '2px',
'input_font': 'arial, cursive, fantasy',
'input_font_weight': '400',
'input_margin': '5px 0px 5px 0px',
'input_padding': '0px 5px 0px 5px',
'label_color': '#a0aec0',
'label_size': '16px',
'label_width': '150px',
'label_font': 'arial, fantasy, serif',
'label_font_weight': 'normal',
'label_margin': '5px 0px 0px 0px',
'label_padding': '2px 5px 2px 5px',
'background_color': 'white',
'height': '30px',
'width': '85px',
'padding_bottom': '2px',
'type': 'dropdown'
};
}

View File

@ -15,11 +15,11 @@ class PDF {
this.context = canvas.getContext('2d');
this.currentPage = 1;
this.maxPages = 1;
this.currentScale = 1.25;
this.currentScale = 1;
this.currentScaleText = document.getElementById('zoom-level');
if (matchMedia('only screen and (max-width: 480px)').matches) {
this.currentScale = 1.25;
this.currentScale = 1;
}
this.currentScaleText.textContent = this.currentScale * 100 + '%';
@ -131,6 +131,24 @@ class PDF {
});
this.setPagesInViewport();
/* document.addEventListener("webviewerloaded", function () {
PDFViewerApplication.initializedPromise.then(function () {
PDFViewerApplication.eventBus.on("pagerendered", function handler(event) {
try {
if (window.chrome && !/Edge/.test(navigator.userAgent) && !event.source.__rerendered) {
console.log("Chrome-like browser detected, re-rendering page %d for the first time.", event.pageNumber);
var currentScale = event.source.scale;
event.source.__rerendered = true;
event.source.update(currentScale * 0.99);
event.source.update(currentScale);
}
} catch (e) {
console.error(e);
}
});
});
}); */
}
}

View File

@ -96,7 +96,7 @@
}
#shipping-details {
visibility: $show_shipping_address_visibility;
opacity: $show_shipping_address_visibility;
flex-direction: column;
line-height: var(--line-height);
white-space: nowrap;

View File

@ -1,5 +1,6 @@
@php
$mobile = stripos(request()->server('HTTP_USER_AGENT'), 'Android') || stripos(request()->server('HTTP_USER_AGENT'), 'iPhone') || stripos(request()->server('HTTP_USER_AGENT'), 'iPod') || stripos(request()->server('HTTP_USER_AGENT'), 'iPad');
//$mobile = stripos(request()->server('HTTP_USER_AGENT'), 'Android') || stripos(request()->server('HTTP_USER_AGENT'), 'iPhone') || stripos(request()->server('HTTP_USER_AGENT'), 'iPod') || stripos(request()->server('HTTP_USER_AGENT'), 'iPad');
$mobile = false;
@endphp
@push('head')

View File

@ -32,6 +32,10 @@
@endsection
@section('gateway_footer')
<script src="https://protect.paytrace.com/js/protect.min.js"></script>
@if($gateway->company_gateway->getConfigField('testMode'))
<script src='https://protect.sandbox.paytrace.com/js/protect.min.js'></script>
@else
<script src='https://protect.paytrace.com/js/protect.min.js'></script>
@endif
<script src="{{ asset('js/clients/payments/paytrace-credit-card.js') }}"></script>
@endsection

View File

@ -59,6 +59,10 @@
@endsection
@section('gateway_footer')
@if($gateway->company_gateway->getConfigField('testMode'))
<script src='https://protect.sandbox.paytrace.com/js/protect.min.js'></script>
@else
<script src='https://protect.paytrace.com/js/protect.min.js'></script>
@endif
<script src="{{ asset('js/clients/payments/paytrace-credit-card.js') }}"></script>
@endsection