mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
Bug fixes
This commit is contained in:
parent
14152fd3f1
commit
9603c43277
@ -22,7 +22,6 @@ class ImportController extends BaseController
|
||||
{
|
||||
$source = Input::get('source');
|
||||
$files = [];
|
||||
$skipped = [];
|
||||
|
||||
foreach (ImportService::$entityTypes as $entityType) {
|
||||
if (Input::file("{$entityType}_file")) {
|
||||
@ -38,8 +37,8 @@ class ImportController extends BaseController
|
||||
$data = $this->importService->mapCSV($files);
|
||||
return View::make('accounts.import_map', ['data' => $data]);
|
||||
} else {
|
||||
$skipped = $this->importService->import($source, $files);
|
||||
return $this->showResult($skipped);
|
||||
$results = $this->importService->import($source, $files);
|
||||
return $this->showResult($results);
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
Utils::logError($exception);
|
||||
@ -52,11 +51,10 @@ class ImportController extends BaseController
|
||||
{
|
||||
$map = Input::get('map');
|
||||
$headers = Input::get('headers');
|
||||
$skipped = [];
|
||||
|
||||
try {
|
||||
$skipped = $this->importService->importCSV($map, $headers);
|
||||
return $this->showResult($skipped);
|
||||
$results = $this->importService->importCSV($map, $headers);
|
||||
return $this->showResult($results);
|
||||
} catch (Exception $exception) {
|
||||
Utils::logError($exception);
|
||||
Session::flash('error', $exception->getMessage());
|
||||
@ -64,16 +62,29 @@ class ImportController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function showResult($skipped)
|
||||
private function showResult($results)
|
||||
{
|
||||
if (count($skipped)) {
|
||||
$message = trans('texts.failed_to_import');
|
||||
foreach ($skipped as $skip) {
|
||||
$message .= '<br/>' . json_encode($skip);
|
||||
$message = '';
|
||||
$skipped = [];
|
||||
|
||||
foreach ($results as $entityType => $entityResults) {
|
||||
if ($count = count($entityResults[RESULT_SUCCESS])) {
|
||||
$message .= trans("texts.created_{$entityType}s", ['count' => $count]) . '<br/>';
|
||||
}
|
||||
if (count($entityResults[RESULT_FAILURE])) {
|
||||
$skipped = array_merge($skipped, $entityResults[RESULT_FAILURE]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($skipped)) {
|
||||
$message .= '<p/>' . trans('texts.failed_to_import') . '<br/>';
|
||||
foreach ($skipped as $skip) {
|
||||
$message .= json_encode($skip) . '<br/>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($message) {
|
||||
Session::flash('warning', $message);
|
||||
} else {
|
||||
Session::flash('message', trans('texts.imported_file'));
|
||||
}
|
||||
|
||||
return Redirect::to('/settings/' . ACCOUNT_IMPORT_EXPORT);
|
||||
|
@ -512,21 +512,20 @@ class PaymentController extends BaseController
|
||||
|
||||
try {
|
||||
if (method_exists($gateway, 'completePurchase')
|
||||
&& !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)
|
||||
&& !$accountGateway->isGateway(GATEWAY_MOLLIE)) { // TODO: implement webhook
|
||||
&& !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)) {
|
||||
$details = $this->paymentService->getPaymentDetails($invitation, $accountGateway);
|
||||
$response = $gateway->completePurchase($details)->send();
|
||||
$response = $this->paymentService->completePurchase($gateway, $accountGateway, $details, $token);
|
||||
$ref = $response->getTransactionReference() ?: $token;
|
||||
|
||||
if ($response->isSuccessful()) {
|
||||
if ($response->isCancelled()) {
|
||||
// do nothing
|
||||
} elseif ($response->isSuccessful()) {
|
||||
$payment = $this->paymentService->createPayment($invitation, $ref, $payerId);
|
||||
Session::flash('message', trans('texts.applied_payment'));
|
||||
|
||||
return Redirect::to($invitation->getLink());
|
||||
} else {
|
||||
$this->error('offsite', $response->getMessage(), $accountGateway);
|
||||
return Redirect::to($invitation->getLink());
|
||||
}
|
||||
return Redirect::to($invitation->getLink());
|
||||
} else {
|
||||
$payment = $this->paymentService->createPayment($invitation, $token, $payerId);
|
||||
Session::flash('message', trans('texts.applied_payment'));
|
||||
|
@ -63,7 +63,6 @@ Route::get('/auth_unlink', 'Auth\AuthController@authUnlink');
|
||||
Route::post('/hook/email_bounced', 'AppController@emailBounced');
|
||||
Route::post('/hook/email_opened', 'AppController@emailOpened');
|
||||
|
||||
|
||||
// Laravel auth routes
|
||||
get('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@getRegister'));
|
||||
post('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@postRegister'));
|
||||
|
@ -25,6 +25,7 @@ class ContactMailer extends Mailer
|
||||
'firstName',
|
||||
'invoice',
|
||||
'quote',
|
||||
'dueDate',
|
||||
'viewLink',
|
||||
'viewButton',
|
||||
'paymentLink',
|
||||
@ -234,6 +235,7 @@ class ContactMailer extends Mailer
|
||||
'$invoice' => $invoice->invoice_number,
|
||||
'$quote' => $invoice->invoice_number,
|
||||
'$link' => $invitation->getLink(),
|
||||
'$dueDate' => $account->formatDate($invoice->due_date),
|
||||
'$viewLink' => $invitation->getLink(),
|
||||
'$viewButton' => HTML::emailViewButton($invitation->getLink(), $invoice->getEntityType()),
|
||||
'$paymentLink' => $invitation->getLink('payment'),
|
||||
|
@ -75,10 +75,12 @@ class ClientRepository extends BaseRepository
|
||||
$client->fill($data);
|
||||
$client->save();
|
||||
|
||||
/*
|
||||
if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
|
||||
return $client;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
$first = true;
|
||||
$contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
|
||||
$contactIds = [];
|
||||
|
@ -317,6 +317,7 @@ class InvoiceRepository extends BaseRepository
|
||||
$total -= $invoice->discount;
|
||||
} else {
|
||||
$total *= (100 - $invoice->discount) / 100;
|
||||
$total = round($total, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,35 +56,39 @@ class ImportService
|
||||
|
||||
public function import($source, $files)
|
||||
{
|
||||
$skipped = [];
|
||||
$results = [];
|
||||
$imported_files = null;
|
||||
|
||||
foreach ($files as $entityType => $file) {
|
||||
$result = $this->execute($source, $entityType, $file);
|
||||
$skipped = array_merge($skipped, $result);
|
||||
$results[$entityType] = $this->execute($source, $entityType, $file);
|
||||
}
|
||||
|
||||
return $skipped;
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function execute($source, $entityType, $file)
|
||||
{
|
||||
$skipped = [];
|
||||
$results = [
|
||||
RESULT_SUCCESS => [],
|
||||
RESULT_FAILURE => [],
|
||||
];
|
||||
|
||||
Excel::load($file, function ($reader) use ($source, $entityType, &$skipped) {
|
||||
Excel::load($file, function ($reader) use ($source, $entityType, &$results) {
|
||||
$this->checkData($entityType, count($reader->all()));
|
||||
$maps = $this->createMaps();
|
||||
|
||||
$reader->each(function ($row) use ($source, $entityType, $maps, &$skipped) {
|
||||
$reader->each(function ($row) use ($source, $entityType, $maps, &$results) {
|
||||
$result = $this->saveData($source, $entityType, $row, $maps);
|
||||
|
||||
if ( ! $result) {
|
||||
$skipped[] = $row;
|
||||
if ($result) {
|
||||
$results[RESULT_SUCCESS][] = $result;
|
||||
} else {
|
||||
$results[RESULT_FAILURE][] = $row;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return $skipped;
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function saveData($source, $entityType, $row, $maps)
|
||||
@ -346,19 +350,21 @@ class ImportService
|
||||
|
||||
public function importCSV($maps, $headers)
|
||||
{
|
||||
$skipped = [];
|
||||
$results = [];
|
||||
|
||||
foreach ($maps as $entityType => $map) {
|
||||
$result = $this->executeCSV($entityType, $map, $headers[$entityType]);
|
||||
$skipped = array_merge($skipped, $result);
|
||||
$result[$entityType] = $this->executeCSV($entityType, $map, $headers[$entityType]);
|
||||
}
|
||||
|
||||
return $skipped;
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function executeCSV($entityType, $map, $hasHeaders)
|
||||
{
|
||||
$skipped = [];
|
||||
$results = [
|
||||
RESULT_SUCCESS => [],
|
||||
RESULT_FAILURE => [],
|
||||
];
|
||||
$source = IMPORT_CSV;
|
||||
|
||||
$data = Session::get("{$entityType}-data");
|
||||
@ -374,14 +380,16 @@ class ImportService
|
||||
$row = $this->convertToObject($entityType, $row, $map);
|
||||
$result = $this->saveData($source, $entityType, $row, $maps);
|
||||
|
||||
if ( ! $result) {
|
||||
$skipped[] = $row;
|
||||
if ($result) {
|
||||
$results[RESULT_SUCCESS][] = $result;
|
||||
} else {
|
||||
$results[RESULT_FAILURE][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
Session::forget("{$entityType}-data");
|
||||
|
||||
return $skipped;
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function convertToObject($entityType, $data, $map)
|
||||
|
@ -224,6 +224,17 @@ class PaymentService extends BaseService
|
||||
return $payment;
|
||||
}
|
||||
|
||||
public function completePurchase($gateway, $accountGateway, $details, $token)
|
||||
{
|
||||
if ($accountGateway->isGateway(GATEWAY_MOLLIE)) {
|
||||
$details['transactionReference'] = $token;
|
||||
$response = $gateway->fetchTransaction($details)->send();
|
||||
return $gateway->fetchTransaction($details)->send();
|
||||
} else {
|
||||
return $gateway->completePurchase($details)->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function autoBillInvoice($invoice)
|
||||
{
|
||||
$client = $invoice->client;
|
||||
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
@ -88,7 +88,7 @@ return array(
|
||||
'company_details' => 'Company Details',
|
||||
'online_payments' => 'Online Payments',
|
||||
'notifications' => 'Email Notifications',
|
||||
'import_export' => 'Import/Export',
|
||||
'import_export' => 'Import/Export/Cancel',
|
||||
'done' => 'Done',
|
||||
'save' => 'Save',
|
||||
'create' => 'Create',
|
||||
@ -212,7 +212,7 @@ return array(
|
||||
|
||||
// application messages
|
||||
'created_client' => 'Successfully created client',
|
||||
'created_clients' => 'Successfully created :count clients',
|
||||
'created_clients' => 'Successfully created :count client(s)',
|
||||
'updated_settings' => 'Successfully updated settings',
|
||||
'removed_logo' => 'Successfully removed logo',
|
||||
'sent_message' => 'Successfully sent message',
|
||||
@ -980,5 +980,7 @@ return array(
|
||||
'button_confirmation_message' => 'Click to confirm your email address.',
|
||||
'confirm' => 'Confirm',
|
||||
'email_preferences' => 'Email Preferences',
|
||||
|
||||
|
||||
'created_invoices' => 'Successfully created :count invoice(s)',
|
||||
|
||||
);
|
||||
|
@ -97,7 +97,7 @@
|
||||
|
||||
<div class="modal-footer" style="margin-top: 0px">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.go_back') }}</button>
|
||||
<button type="button" class="btn btn-primary" onclick="confirmCancel()">{{ trans('texts.cancel_account') }}</button>
|
||||
<button type="button" class="btn btn-danger" onclick="confirmCancel()">{{ trans('texts.cancel_account') }}</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -184,13 +184,14 @@
|
||||
var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!};
|
||||
var vals = [
|
||||
{!! json_encode($emailFooter) !!},
|
||||
"{{ Auth::user()->account->getDisplayName() }}",
|
||||
"{{ $account->getDisplayName() }}",
|
||||
"Client Name",
|
||||
formatMoney(100),
|
||||
"Contact Name",
|
||||
"First Name",
|
||||
"0001",
|
||||
"0001",
|
||||
"{{ $account->formatDate($account->getDateTime()) }}",
|
||||
"{{ URL::to('/view/...') }}",
|
||||
'{!! HTML::flatButton('view_invoice', '#0b4d78') !!}',
|
||||
"{{ URL::to('/payment/...') }}",
|
||||
|
@ -71,7 +71,7 @@
|
||||
<div class="panel panel-default dashboard" style="height:320px">
|
||||
<div class="panel-heading" style="background-color:#0b4d78 !important">
|
||||
<h3 class="panel-title in-bold-white">
|
||||
<i class="glyphicon glyphicon-exclamation-sign"></i> {{ trans('texts.notifications') }}
|
||||
<i class="glyphicon glyphicon-exclamation-sign"></i> {{ trans('texts.activity') }}
|
||||
<div class="pull-right" style="font-size:14px;padding-top:4px">
|
||||
{{ trans_choice('texts.invoices_sent', $invoicesSent) }}
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
|
||||
<body style="min-height: 700px; color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: 12px; -webkit-text-size-adjust: none; -ms-text-size-adjust: none; background: #F4F5F5; margin: 0; padding: 0;"
|
||||
<body style="min-height: 600px; color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: 12px; -webkit-text-size-adjust: none; -ms-text-size-adjust: none; background: #F4F5F5; margin: 0; padding: 0;"
|
||||
alink="#FF0000" link="#FF0000" bgcolor="#F4F5F5" text="#000000" yahoo="fix">
|
||||
@yield('markup')
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="body_style" style="min-height: 700px; color: #2E2B2B; font-family: Helvetica, sans-serif; font-size: 16px;
|
||||
<div id="body_style" style="min-height: 600px; color: #2E2B2B; font-family: Helvetica, sans-serif; font-size: 16px;
|
||||
background: #F4F5F5; padding: 0px 15px;">
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" width="600" align="center">
|
||||
|
@ -6,7 +6,7 @@
|
||||
@else
|
||||
<title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}</title>
|
||||
<meta name="description" content="{{ isset($description) ? $description : trans('texts.app_description') }}" />
|
||||
<link href="{{ asset('favicon-v2.png') }}" rel="shortcut icon">
|
||||
<link href="{{ asset('favicon-v2.png') }}" rel="shortcut icon" type="image/png">
|
||||
@endif
|
||||
|
||||
<!-- Source: https://github.com/hillelcoren/invoice-ninja -->
|
||||
|
@ -66,7 +66,7 @@
|
||||
$('#dbTestResult').html('Working...').css('color', 'black');
|
||||
|
||||
// Send / Test Information
|
||||
$.post( "/setup", data, function( data ) {
|
||||
$.post( "{{ URL::to('/setup') }}", data, function( data ) {
|
||||
var color = 'red';
|
||||
if(data == 'Success'){
|
||||
color = 'green';
|
||||
@ -86,7 +86,7 @@
|
||||
$('#mailTestResult').html('Working...').css('color', 'black');
|
||||
|
||||
// Send / Test Information
|
||||
$.post( "/setup", data, function( data ) {
|
||||
$.post( "{{ URL::to('/setup') }}", data, function( data ) {
|
||||
var color = 'red';
|
||||
if(data == 'Sent'){
|
||||
color = 'green';
|
||||
|
Loading…
Reference in New Issue
Block a user