mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improvements to OFX
This commit is contained in:
parent
05e5ae1167
commit
967c503134
@ -154,6 +154,9 @@ if (! defined('APP_NAME')) {
|
||||
define('DEFAULT_BODY_FONT', 1); // Roboto
|
||||
define('DEFAULT_SEND_RECURRING_HOUR', 8);
|
||||
|
||||
define('DEFAULT_BANK_OFX_VERSION', 102);
|
||||
define('DEFAULT_BANK_APP_VERSION', 2500);
|
||||
|
||||
define('IMPORT_CSV', 'CSV');
|
||||
define('IMPORT_JSON', 'JSON');
|
||||
define('IMPORT_FRESHBOOKS', 'FreshBooks');
|
||||
|
@ -97,10 +97,18 @@ class BankAccountController extends BaseController
|
||||
$username = Crypt::decrypt($username);
|
||||
$bankId = $bankAccount->bank_id;
|
||||
} else {
|
||||
$bankId = Input::get('bank_id');
|
||||
$bankAccount = new BankAccount;
|
||||
$bankAccount->bank_id = Input::get('bank_id');
|
||||
}
|
||||
|
||||
return json_encode($this->bankAccountService->loadBankAccounts($bankId, $username, $password, $publicId));
|
||||
$bankAccount->app_version = Input::get('app_version');
|
||||
$bankAccount->ofx_version = Input::get('ofx_version');
|
||||
|
||||
if ($publicId) {
|
||||
$bankAccount->save();
|
||||
}
|
||||
|
||||
return json_encode($this->bankAccountService->loadBankAccounts($bankAccount, $username, $password, $publicId));
|
||||
}
|
||||
|
||||
public function store(CreateBankAccountRequest $request)
|
||||
@ -111,7 +119,7 @@ class BankAccountController extends BaseController
|
||||
$username = trim(Input::get('bank_username'));
|
||||
$password = trim(Input::get('bank_password'));
|
||||
|
||||
return json_encode($this->bankAccountService->loadBankAccounts($bankId, $username, $password, true));
|
||||
return json_encode($this->bankAccountService->loadBankAccounts($bankAccount, $username, $password, true));
|
||||
}
|
||||
|
||||
public function importExpenses($bankId)
|
||||
|
@ -90,6 +90,8 @@ class Login
|
||||
public $bank;
|
||||
public $id;
|
||||
public $pass;
|
||||
public $ofxVersion;
|
||||
public $appVersion;
|
||||
|
||||
public function __construct($bank, $id, $pass)
|
||||
{
|
||||
@ -103,7 +105,7 @@ class Login
|
||||
$ofxRequest =
|
||||
"OFXHEADER:100\n".
|
||||
"DATA:OFXSGML\n".
|
||||
"VERSION:102\n".
|
||||
"VERSION:" . $this->ofxVersion . "\n".
|
||||
"SECURITY:NONE\n".
|
||||
"ENCODING:USASCII\n".
|
||||
"CHARSET:1252\n".
|
||||
@ -124,7 +126,7 @@ class Login
|
||||
'<FID>'.$this->bank->fid."\n".
|
||||
"</FI>\n".
|
||||
"<APPID>QWIN\n".
|
||||
"<APPVER>2500\n".
|
||||
"<APPVER>" . $this->appVersion . "\n".
|
||||
"</SONRQ>\n".
|
||||
"</SIGNONMSGSRQV1>\n".
|
||||
"<SIGNUPMSGSRQV1>\n".
|
||||
@ -173,7 +175,7 @@ class Account
|
||||
$ofxRequest =
|
||||
"OFXHEADER:100\n".
|
||||
"DATA:OFXSGML\n".
|
||||
"VERSION:102\n".
|
||||
"VERSION:" . $this->login->ofxVersion . "\n".
|
||||
"SECURITY:NONE\n".
|
||||
"ENCODING:USASCII\n".
|
||||
"CHARSET:1252\n".
|
||||
@ -193,7 +195,7 @@ class Account
|
||||
'<FID>'.$this->login->bank->fid."\n".
|
||||
"</FI>\n".
|
||||
"<APPID>QWIN\n".
|
||||
"<APPVER>2500\n".
|
||||
"<APPVER>" . $this->login->appVersion . "\n".
|
||||
"</SONRQ>\n".
|
||||
"</SIGNONMSGSRQV1>\n";
|
||||
if ($this->type == 'BANK') {
|
||||
|
@ -10,11 +10,21 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class BankAccount extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'bank_id',
|
||||
'app_version',
|
||||
'ofx_version',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -31,8 +31,8 @@ class BankAccountRepository extends BaseRepository
|
||||
public function save($input)
|
||||
{
|
||||
$bankAccount = BankAccount::createNew();
|
||||
$bankAccount->bank_id = $input['bank_id'];
|
||||
$bankAccount->username = Crypt::encrypt(trim($input['bank_username']));
|
||||
$bankAccount->fill($input);
|
||||
|
||||
$account = \Auth::user()->account;
|
||||
$account->bank_accounts()->save($bankAccount);
|
||||
|
@ -14,6 +14,7 @@ use App\Ninja\Repositories\VendorRepository;
|
||||
use Hash;
|
||||
use stdClass;
|
||||
use Utils;
|
||||
use Carbon;
|
||||
|
||||
/**
|
||||
* Class BankAccountService.
|
||||
@ -74,6 +75,7 @@ class BankAccountService extends BaseService
|
||||
$expenses = Expense::scope()
|
||||
->bankId($bankId)
|
||||
->where('transaction_id', '!=', '')
|
||||
->where('expense_date', '>=', Carbon::now()->subYear()->format('Y-m-d'))
|
||||
->withTrashed()
|
||||
->get(['transaction_id'])
|
||||
->toArray();
|
||||
@ -92,12 +94,13 @@ class BankAccountService extends BaseService
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function loadBankAccounts($bankId, $username, $password, $includeTransactions = true)
|
||||
public function loadBankAccounts($bankAccount, $username, $password, $includeTransactions = true)
|
||||
{
|
||||
if (! $bankId || ! $username || ! $password) {
|
||||
if (! $bankAccount || ! $username || ! $password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$bankId = $bankAccount->bank_id;
|
||||
$expenses = $this->getExpenses();
|
||||
$vendorMap = $this->createVendorMap();
|
||||
$bankAccounts = BankSubaccount::scope()
|
||||
@ -112,7 +115,11 @@ class BankAccountService extends BaseService
|
||||
try {
|
||||
$finance = new Finance();
|
||||
$finance->banks[$bankId] = $bank->getOFXBank($finance);
|
||||
$finance->banks[$bankId]->logins[] = new Login($finance->banks[$bankId], $username, $password);
|
||||
|
||||
$login = new Login($finance->banks[$bankId], $username, $password);
|
||||
$login->appVersion = $bankAccount->app_version;
|
||||
$login->ofxVersion = $bankAccount->ofx_version;
|
||||
$finance->banks[$bankId]->logins[] = $login;
|
||||
|
||||
foreach ($finance->banks as $bank) {
|
||||
foreach ($bank->logins as $login) {
|
||||
|
@ -74,6 +74,10 @@ class UpdateDarkMode extends Migration
|
||||
$table->unsignedInteger('recurring_expense_id')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('bank_accounts', function ($table) {
|
||||
$table->mediumInteger('app_version')->default(DEFAULT_BANK_APP_VERSION);
|
||||
$table->mediumInteger('ofx_version')->default(DEFAULT_BANK_OFX_VERSION);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,5 +98,10 @@ class UpdateDarkMode extends Migration
|
||||
$table->dropColumn('credit_number_prefix');
|
||||
$table->dropColumn('credit_number_pattern');
|
||||
});
|
||||
|
||||
Schema::table('bank_accounts', function ($table) {
|
||||
$table->dropColumn('app_version');
|
||||
$table->dropColumn('ofx_version');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2299,6 +2299,8 @@ $LANG = array(
|
||||
'padding_help' => 'The number of zero\'s to pad the number.',
|
||||
'import_warning_invalid_date' => 'Warning: The date format appears to be invalid.',
|
||||
'product_notes' => 'Product Notes',
|
||||
'app_version' => 'App Version',
|
||||
'ofx_version' => 'OFX Version',
|
||||
|
||||
);
|
||||
|
||||
|
@ -30,9 +30,11 @@
|
||||
<div data-bind="visible: page() == 'login'">
|
||||
<div class="form-padding-right">
|
||||
@if ($bankAccount)
|
||||
{!! Former::populateField('public_id', $bankAccount->public_id) !!}
|
||||
{!! Former::populate($bankAccount) !!}
|
||||
{!! Former::hidden('public_id') !!}
|
||||
@else
|
||||
{!! Former::populateField('app_version', DEFAULT_BANK_APP_VERSION) !!}
|
||||
{!! Former::populateField('ofx_version', DEFAULT_BANK_OFX_VERSION) !!}
|
||||
{!! Former::select('bank_id')
|
||||
->data_bind('combobox: bank_id')
|
||||
->addOption('', '')
|
||||
@ -40,6 +42,8 @@
|
||||
->blockHelp(trans('texts.bank_accounts_help', ['link' => OFX_HOME_URL])) !!}
|
||||
@endif
|
||||
|
||||
<br/>
|
||||
|
||||
{!! Former::password('bank_username')
|
||||
->data_bind("value: bank_username, valueUpdate: 'afterkeydown'")
|
||||
->label(trans('texts.username')) !!}
|
||||
@ -48,6 +52,30 @@
|
||||
->label(trans('texts.password'))
|
||||
->data_bind("value: bank_password, valueUpdate: 'afterkeydown'")
|
||||
->blockHelp(trans(Request::secure() ? 'texts.bank_password_help' : 'texts.bank_password_warning')) !!}
|
||||
|
||||
<br/>
|
||||
|
||||
{!! Former::select('app_version')
|
||||
->addOption('Quicken 2005', 1400)
|
||||
->addOption('Quicken 2006', 1500)
|
||||
->addOption('Quicken 2007', 1600)
|
||||
->addOption('Quicken 2008', 1700)
|
||||
->addOption('Quicken 2009', 1800)
|
||||
->addOption('Quicken 2010', 1900)
|
||||
->addOption('Quicken 2011', 2000)
|
||||
->addOption('Quicken 2012', 2100)
|
||||
->addOption('Quicken 2013', 2200)
|
||||
->addOption('Quicken 2014', 2300)
|
||||
->addOption('Quicken 2015', 2400)
|
||||
->addOption('Quicken 2016', 2500)
|
||||
->addOption('Quicken 2017', 2600) !!}
|
||||
|
||||
{!! Former::select('ofx_version')
|
||||
->addOption('100', 100)
|
||||
->addOption('101', 101)
|
||||
->addOption('102', 102)
|
||||
->addOption('103', 103) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user