vendredi 27 novembre 2015

How to display journal entries filtered by date and associated to baskets / topics in a table view?

Im building a system with laravel to manage an associations interests including a functionality for keeping track of finances. I want to display a complex table-layout an ended up in big trouble with loops and how to structure my code for building the table.

My 'plan':

  • Every account movement is saved as an entry in a journaling-table
  • Every entry is connected to an account and a 'basket' with shall represent its intern financial allocation
  • An Account within a business year has its journal-view, witch displays all movements concerning this account associated with all baskets used in this year. Also I would like to add new movements here.
class Journaling extends Model {
        protected $table = 'journaling';

    public function account()
    {
        return $this->belongsTo('App\Finance\Account');
    }
    public function basket()
    {
        return $this->belongsTo('App\Finance\Basket');
    }
}

 

class Account extends Model {
        public function journaling(){
                return $this->hasMany('App\Finance\Journaling', 'account_id');       
        }
     public function years(){
                return $this->belongsToMany('App\Finance\Year');
        }
}

 

class Year extends Model{
     public function accounts(){
                return $this->belongsToMany('App\Finance\Account', 'accounts_years', 'account_id', 'year_id');
        }
}



class Basket extends Model{
    public function journaling(){
                return $this->hasMany('App\Finance\Journaling', 'basket_id');        
        }

        public function parent()
    {
        return $this->belongsTo('App\Finance\Basket', 'parent_id');
    }

    public function children()
    {
        return $this->hasMany('App\Finance\Basket', 'parent_id');
    }
}

Here is a mockup for the final result with annotations:

Some mockup Can somebody give an advice how to get the data in this table structure?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire