Merge branch 'develop' of https://github.com/turbo124/invoiceninja into develop

This commit is contained in:
David Bomba 2016-03-14 09:02:59 +11:00
commit de8a7c2c0d
7 changed files with 68 additions and 28 deletions

View File

@ -34,7 +34,6 @@ install:
# these providers require referencing git commit's which cause Travis to fail
- sed -i '/mollie/d' composer.json
- sed -i '/2checkout/d' composer.json
- sed -i '/omnipay-neteller/d' composer.json
- travis_retry composer install --prefer-dist;
before_script:

View File

@ -36,6 +36,7 @@ class AccountApiController extends BaseAPIController
public function register(RegisterRequest $request)
{
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
$user = $account->users()->first();

View File

@ -2,7 +2,11 @@
use Auth;
use App\Http\Requests\Request;
use Illuminate\Http\Request as InputRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Factory;
use App\Libraries\Utils;
use Response;
class RegisterRequest extends Request
{
@ -11,6 +15,13 @@ class RegisterRequest extends Request
*
* @return bool
*/
public function __construct(InputRequest $req)
{
$this->req = $req;
}
public function authorize()
{
return true;
@ -23,6 +34,7 @@ class RegisterRequest extends Request
*/
public function rules()
{
$rules = [
'email' => 'required|unique:users',
'first_name' => 'required',
@ -32,4 +44,24 @@ class RegisterRequest extends Request
return $rules;
}
public function response(array $errors)
{
/* If the user is not validating from a mobile app - pass through parent::response */
if(!isset($this->req->api_secret))
return parent::response($errors);
/* If the user is validating from a mobile app - pass through first error string and return error */
foreach($errors as $error) {
foreach ($error as $key => $value) {
$message['error'] = ['message'=>$value];
$message = json_encode($message, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($message, 400, $headers);
}
}
}
}

View File

@ -1,82 +1,84 @@
<?php namespace app\Listeners;
use Auth;
use Utils;
use App\Events\ClientWasCreated;
use App\Events\QuoteWasCreated;
use App\Events\InvoiceWasCreated;
use App\Events\CreditWasCreated;
use App\Events\PaymentWasCreated;
use App\Events\VendorWasCreated;
use App\Events\ExpenseWasCreated;
use App\Ninja\Transformers\InvoiceTransformer;
use App\Ninja\Transformers\ClientTransformer;
use App\Ninja\Transformers\PaymentTransformer;
use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use App\Ninja\Serializers\ArraySerializer;
class SubscriptionListener
{
public function createdClient(ClientWasCreated $event)
{
if ( ! Auth::check()) {
return;
}
$transformer = new ClientTransformer(Auth::user()->account);
$transformer = new ClientTransformer($event->client->account);
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client, $transformer);
}
public function createdQuote(QuoteWasCreated $event)
{
if ( ! Auth::check()) {
return;
}
$transformer = new InvoiceTransformer(Auth::user()->account);
$transformer = new InvoiceTransformer($event->quote->account);
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT);
}
public function createdPayment(PaymentWasCreated $event)
{
if ( ! Auth::check()) {
return;
}
$transformer = new PaymentTransformer(Auth::user()->account);
$transformer = new PaymentTransformer($event->payment->account);
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]);
}
public function createdCredit(CreditWasCreated $event)
{
if ( ! Auth::check()) {
return;
}
//$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit);
}
public function createdInvoice(InvoiceWasCreated $event)
{
if ( ! Auth::check()) {
return;
}
$transformer = new InvoiceTransformer(Auth::user()->account);
$transformer = new InvoiceTransformer($event->invoice->account);
$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT);
}
public function createdCredit(CreditWasCreated $event)
{
//$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit);
}
public function createdVendor(VendorWasCreated $event)
{
//$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor);
}
public function createdExpense(ExpenseWasCreated $event)
{
//$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_EXPENSE, $event->expense);
}
private function checkSubscriptions($activityTypeId, $entity, $transformer, $include = '')
{
$subscription = $entity->account->getSubscription($activityTypeId);
if ($subscription) {
$manager = new Manager();
$manager->setSerializer(new ArraySerializer());
$manager->parseIncludes($include);
$resource = new Item($entity, $transformer, $entity->getEntityType());
$data = $manager->createData($resource)->toArray();
// For legacy Zapier support
if (isset($data['client_id'])) {
$data['client_name'] = $entity->client->getDisplayName();
}
Utils::notifyZapier($subscription, $data);
}
}
}
}

View File

@ -79,7 +79,8 @@ class InvoiceService extends BaseService
public function approveQuote($quote, $invitation = null)
{
$account = Auth::user()->account;
$account = $quote->account;
if (!$quote->is_quote || $quote->quote_invoice_id) {
return null;
}

View File

@ -1,4 +1,5 @@
<?php
use App\Models\Gateway;
use App\Models\PaymentTerm;
use App\Models\Currency;
@ -6,11 +7,13 @@ use App\Models\DateFormat;
use App\Models\DatetimeFormat;
use App\Models\InvoiceDesign;
use App\Models\Country;
class PaymentLibrariesSeeder extends Seeder
{
public function run()
{
Eloquent::unguard();
$gateways = [
['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2],
['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2],
@ -46,6 +49,7 @@ class PaymentLibrariesSeeder extends Seeder
['name' => 'WeChat Express', 'provider' => 'WeChat_Express', 'payment_library_id' => 1],
['name' => 'WePay', 'provider' => 'WePay', 'payment_library_id' => 1],
];
foreach ($gateways as $gateway) {
$record = Gateway::where('name', '=', $gateway['name'])->first();
if ($record) {
@ -55,5 +59,6 @@ class PaymentLibrariesSeeder extends Seeder
Gateway::create($gateway);
}
}
}
}
}

View File

@ -1121,7 +1121,7 @@ return array(
'all_pages_header' => 'Show header on',
'all_pages_footer' => 'Show footer on',
'invoice_currency' => 'Rechnungs-Währung',
'enable_https' => 'Wir empfehlen dringend HTTPS zu verwendne, um Kreditkarten online zu akzeptieren.',
'enable_https' => 'Wir empfehlen dringend HTTPS zu verwenden, um Kreditkarten online zu akzeptieren.',
'quote_issued_to' => 'Quote issued to',
'show_currency_code' => 'Währungscode',
'trial_message' => 'Your account will receive a free two week trial of our pro plan.',