mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add throttling
This commit is contained in:
parent
2c765d5187
commit
755b366c81
@ -72,11 +72,15 @@ class WePayFailureNotification extends Notification
|
||||
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$ip = "";
|
||||
|
||||
if(request())
|
||||
$ip = request()->getClientIp();
|
||||
|
||||
return (new SlackMessage)
|
||||
->success()
|
||||
->from(ctrans('texts.notification_bot'))
|
||||
->image('https://app.invoiceninja.com/favicon.png')
|
||||
->content("New WePay ACH Failure from Company ID: ". $this->company_id);
|
||||
->content("New WePay ACH Failure from Company ID: {$this->company_id} IP: {$ip}" );
|
||||
}
|
||||
}
|
||||
|
@ -162,43 +162,48 @@ class ProfitLoss
|
||||
->cursor();
|
||||
|
||||
|
||||
if($this->is_tax_included)
|
||||
return $this->calculateExpensesWithTaxes($expenses);
|
||||
|
||||
return $this->calculateExpensesWithoutTaxes($expenses);
|
||||
return $this->calculateExpenses($expenses);
|
||||
|
||||
}
|
||||
|
||||
private function calculateExpensesWithTaxes($expenses)
|
||||
{
|
||||
|
||||
foreach($expenses as $expense)
|
||||
{
|
||||
|
||||
if(!$expense->calculate_tax_by_amount && !$expense->uses_inclusive_taxes)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function calculateExpensesWithoutTaxes($expenses)
|
||||
{
|
||||
$total = 0;
|
||||
$converted_total = 0;
|
||||
|
||||
$data = [];
|
||||
|
||||
|
||||
foreach($expenses as $expense)
|
||||
{
|
||||
$total += $expense->amount;
|
||||
$converted_total += $this->getConvertedTotal($expense);
|
||||
}
|
||||
$data[] = [
|
||||
'total' => $expense->amount,
|
||||
'converted_total' => $this->getConvertedTotal($expense->amount, $expense->exchange_rate),
|
||||
'tax' => $this->getTax($expense),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
private function getConvertedTotal($expense)
|
||||
}
|
||||
|
||||
private function getTax($expense)
|
||||
{
|
||||
return round($expense->amount * $expense->exchange_rate,2);
|
||||
$amount = $expense->amount;
|
||||
|
||||
//is amount tax
|
||||
|
||||
if($expense->calculate_tax_by_amount)
|
||||
{
|
||||
$total_tax = $expense->tax_amount1 + $expense->tax_amount2 + $expense->tax_amount3;
|
||||
}
|
||||
|
||||
|
||||
return ($amount - ($amount / (1 + ($tax_rate / 100))));
|
||||
|
||||
}
|
||||
|
||||
private function getConvertedTotal($amount, $exchange_rate)
|
||||
{
|
||||
return round($amount * $exchange_rate,2);
|
||||
}
|
||||
|
||||
private function expenseCalcWithTax()
|
||||
|
@ -19,11 +19,11 @@ Route::group(['middleware' => ['throttle:300,1', 'api_secret_check']], function
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['throttle:10,1','api_secret_check','email_db']], function () {
|
||||
Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit');
|
||||
Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit')->middleware('throttle:20,1');;
|
||||
Route::post('api/v1/reset_password', 'Auth\ForgotPasswordController@sendResetLinkEmail');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['throttle:300,1', 'api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () {
|
||||
Route::group(['middleware' => ['throttle:100,1', 'api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () {
|
||||
Route::post('check_subdomain', 'SubdomainController@index')->name('check_subdomain');
|
||||
Route::get('ping', 'PingController@index')->name('ping');
|
||||
Route::get('health_check', 'PingController@health')->name('health_check');
|
||||
@ -152,7 +152,7 @@ Route::group(['middleware' => ['throttle:300,1', 'api_db', 'token_auth', 'locale
|
||||
Route::post('recurring_quotes/bulk', 'RecurringQuoteController@bulk')->name('recurring_quotes.bulk');
|
||||
Route::put('recurring_quotes/{recurring_quote}/upload', 'RecurringQuoteController@upload');
|
||||
|
||||
Route::post('refresh', 'Auth\LoginController@refresh');
|
||||
Route::post('refresh', 'Auth\LoginController@refresh')->middleware('throttle:20,1');
|
||||
|
||||
Route::post('reports/clients', 'Reports\ClientReportController');
|
||||
Route::post('reports/contacts', 'Reports\ClientContactReportController');
|
||||
|
Loading…
x
Reference in New Issue
Block a user