Skip to content

Commit

Permalink
Bypassing LoansProcessorService in Angular in place of Laravel helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jongravois committed May 19, 2015
1 parent d797eac commit 7e0424e
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 23 deletions.
7 changes: 3 additions & 4 deletions app/Acme/Transformers/LoanTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function transform($arr)
'reconciliation' => (integer)$arr['reconciliation'],
'account_classification' => (integer)$arr['account_classification'],

'crops' => processCrops($arr['id']),
'cats' => getExpenseCategories($arr['id']),
'expenses' => $arr['cropexpenses'],
'expensez' => processExpenses($arr['id']),
Expand Down Expand Up @@ -189,11 +190,10 @@ public function transform($arr)
'entity_type_id' => $arr['applicant']['entitytype']['id'],
'entity_type' => $arr['applicant']['entitytype']['entitytype'],
'quests' => $arr['quests'][0],

'partners' => processPartners($arr['id']),

'ventures' => $arr['ventures'],
'corporations' => $arr['corporations'],
'xcols' => $arr['xcollaterals'],
'attachments' => processAttachments($arr['id']),
'conditions' => [
'asa' => (boolean)$arr['conditions_asa'],
Expand All @@ -217,8 +217,7 @@ public function transform($arr)
'othercollateral' => $arr['othercollateral'],
'priorlien' => $arr['priorliens'],
'systemics' => $arr['systemics'],
'last_activity' => $arr['updated_at'],
'xcols' => $arr['xcollaterals']
'last_activity' => $arr['updated_at']
];
}

Expand Down
21 changes: 21 additions & 0 deletions app/Acme/financials.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,24 @@ function getTotalClaims($loanID)
{
return Loancrop::where('loan_id', $loanID)->sum('claims');
}

function processCrops($loanID)
{
return [
'corn' => [
'crop_id' => 1,
'crop' => 'corn',
'name' => 'Corn',
'is_active' => true,
'acres' => 999999
],
'soybeans' => [],
'beansFAC' => [],
'sorghum' => [],
'wheat' => [],
'cotton' => [],
'rice' => [],
'peanuts' => [],
'sugarcane' => []
];
}
157 changes: 157 additions & 0 deletions app/config/packages/barryvdh/laravel-debugbar/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php

use Illuminate\Support\Facades\Config;

return array(

/*
|--------------------------------------------------------------------------
| Debugbar Settings
|--------------------------------------------------------------------------
|
| Debugbar is enabled by default, when debug is set to true in app.php.
|
*/

'enabled' => Config::get('app.debug'),

/*
|--------------------------------------------------------------------------
| Storage settings
|--------------------------------------------------------------------------
|
| DebugBar stores data for session/ajax requests.
| You can disable this, so the debugbar stores data in headers/session,
| but this can cause problems with large data collectors.
| By default, file storage (in the storage folder) is used. Redis and PDO
| can also be used. For PDO, run the package migrations first.
|
*/
'storage' => array(
'enabled' => true,
'driver' => 'file', // redis, file, pdo
'path' => storage_path() . '/debugbar', // For file driver
'connection' => null, // Leave null for default connection (Redis/PDO)
),

/*
|--------------------------------------------------------------------------
| Vendors
|--------------------------------------------------------------------------
|
| Vendor files are included by default, but can be set to false.
| This can also be set to 'js' or 'css', to only include javascript or css vendor files.
| Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
| and for js: jquery and and highlight.js
| So if you want syntax highlighting, set it to true.
| jQuery is set to not conflict with existing jQuery scripts.
|
*/

'include_vendors' => true,

/*
|--------------------------------------------------------------------------
| Capture Ajax Requests
|--------------------------------------------------------------------------
|
| The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
| you can use this option to disable sending the data through the headers.
|
*/

'capture_ajax' => true,

/*
|--------------------------------------------------------------------------
| Capture Console Commands
|--------------------------------------------------------------------------
|
| The Debugbar can listen to Artisan commands. You can view them with the browse button in the Debugbar.
|
*/

'capture_console' => false,

/*
|--------------------------------------------------------------------------
| DataCollectors
|--------------------------------------------------------------------------
|
| Enable/disable DataCollectors
|
*/

'collectors' => array(
'phpinfo' => true, // Php version
'messages' => true, // Messages
'time' => true, // Time Datalogger
'memory' => true, // Memory usage
'exceptions' => true, // Exception displayer
'log' => true, // Logs from Monolog (merged in messages if enabled)
'db' => true, // Show database (PDO) queries and bindings
'views' => true, // Views with their data
'route' => true, // Current route information
'laravel' => false, // Laravel version and environment
'events' => false, // All events fired
'default_request' => false, // Regular or special Symfony request logger
'symfony_request' => true, // Only one can be enabled..
'mail' => true, // Catch mail messages
'logs' => false, // Add the latest log messages
'files' => false, // Show the included files
'config' => false, // Display config settings
'auth' => false, // Display Laravel authentication status
'session' => false, // Display session data in a separate tab
),

/*
|--------------------------------------------------------------------------
| Extra options
|--------------------------------------------------------------------------
|
| Configure some DataCollectors
|
*/

'options' => array(
'auth' => array(
'show_name' => false, // Also show the users name/email in the debugbar
),
'db' => array(
'with_params' => true, // Render SQL with the parameters substituted
'timeline' => false, // Add the queries to the timeline
'backtrace' => false, // EXPERIMENTAL: Use a backtrace to find the origin of the query in your files.
'explain' => array( // EXPERIMENTAL: Show EXPLAIN output on queries
'enabled' => false,
'types' => array('SELECT'), // array('SELECT', 'INSERT', 'UPDATE', 'DELETE'); for MySQL 5.6.3+
),
'hints' => true, // Show hints for common mistakes
),
'mail' => array(
'full_log' => false
),
'views' => array(
'data' => false, //Note: Can slow down the application, because the data can be quite large..
),
'route' => array(
'label' => true // show complete route on bar
),
'logs' => array(
'file' => null
),
),

/*
|--------------------------------------------------------------------------
| Inject Debugbar in Response
|--------------------------------------------------------------------------
|
| Usually, the debugbar is added just before <body>, by listening to the
| Response after the App is done. If you disable this, you have to add them
| in your template yourself. See http://phpdebugbar.com/docs/rendering.html
|
*/

'inject' => true,

);
2 changes: 1 addition & 1 deletion app/controllers/LoansController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function index()

public function show($id)
{
$loan = Loan::with('appfins', 'applicant.entitytype', 'applicant.state', 'committee.user', 'corporations', 'comments.responses', 'comments.status', 'distributor', 'exceptions', 'cropexpenses.loancrop.crop', 'farmer.state', 'farms.county', 'financials', 'loanconditions', 'loancrop.crop', 'loanstatus', 'loantype.reqdocs', 'location', 'inspols.crop', 'othercollateral', 'partners', 'priorliens', 'quests', 'regions', 'suppins.counties', 'suppins.crops', 'systemics', 'user', 'ventures', 'xcollaterals')->where('applicant_id', '!=', 'null')->where('id', $id)->get();
$loan = Loan::with('appfins', 'applicant.entitytype', 'applicant.state', 'committee.user', 'corporations', 'comments.responses', 'comments.status', 'distributor', 'exceptions', 'cropexpenses.loancrop.crop', 'farmer.state', 'farms.county', 'loanconditions', 'loancrop.crop', 'loanstatus', 'loantype.reqdocs', 'location', 'inspols.crop', 'othercollateral', 'priorliens', 'quests', 'regions', 'suppins.counties', 'suppins.crops', 'systemics', 'user', 'ventures', 'xcollaterals')->where('id', $id)->get();
//return $loans; //REMOVE THIS

if ($loan->isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion app/models/Crosscollateral.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class Crosscollateral extends \Eloquent {
/* RELATIONSHIPS */
public function loans()
{
return $this->hasMany('Loan', 'id', 'collateral_id');
return $this->belongsTo('Loan');
}
}
2 changes: 1 addition & 1 deletion app/models/Loan.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function ventures()

public function xcollaterals()
{
return $this->hasMany('Crosscollateral');
return $this->hasMany('Crosscollateral', 'loan_id');
}


Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"barryvdh/laravel-cors": "0.2.x",
"itsgoingd/clockwork": "dev-master",
"guzzlehttp/guzzle": "~5.2",
"bdelespierre/underscore": "0.1.0",
"barryvdh/laravel-debugbar": "~1.8"
"bdelespierre/underscore": "0.1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4"
Expand Down
13 changes: 1 addition & 12 deletions public/angular/loans/services/loans.processor.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
loancrops: processLoanCrops(loan),
need_vote: getPendingVotes(loan),
priorlien: processPriorLien(loan.priorlien),
supplements: processSupInsurance(loan.suppins),
total_ins_value: getTotalInsValue(loan),
xcols: getCrossCollateralLoans(loan)
supplements: processSupInsurance(loan.suppins)
})
.then(function (updatedData) {
angular.extend(loan, updatedData);
Expand Down Expand Up @@ -120,9 +118,6 @@
});
});
}
function getCrossCollateralLoans(loan) {
return _.uniq(_.pluck(loan.xcols, 'collateral_id'));
}
function getPendingComments(loan) {
return $http.get(API_URL + '/loans/' + loan.id + '/commentstatus')
.then(function (response) {
Expand Down Expand Up @@ -200,12 +195,6 @@
return (ins);

}
function getTotalInsValue(loan) {
return $http.get(API_URL + '/insurance/' + loan.id + '/value')
.then(function (response) {
return response.data;
});
}
function makeCrop(id, list) {
var crop_id = Number(id);
var crop = _.filter(list, function(item){
Expand Down
15 changes: 13 additions & 2 deletions public/angular/main.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
FeederFactory.init();
$scope.feeder = FeederFactory.getObject();

LoansProcessor.getLoansWithExtraData()
/*LoansProcessor.getLoansWithExtraData()
.then(function (allLoans) {
$scope.loans = allLoans;
console.log('Loans from Main', allLoans);
Expand All @@ -50,7 +50,18 @@
//TODO: Determine initial sort order
$scope.sortedLoanList = orderByFilter($scope.loanList, '+id');
});
toastr.success('Loaded all loans', 'Success!');
toastr.success('Loaded all loans', 'Success!');*/

LoansFactory.getLoans()
.then(function(allLoans){
$scope.loan = allLoans;
console.log('Loans from Main', allLoans);
$scope.loanList = _.filter(allLoans, function(i) {
return (i.status_id === '1' || i.status_id === 1) && i.crop_year == $scope.globals.crop_year;
});
//TODO: Determine initial sort order
$scope.sortedLoanList = orderByFilter($scope.loanList, '+id');
});

FarmersFactory.getFarmers()
.then(function(rsp){
Expand Down

0 comments on commit 7e0424e

Please sign in to comment.