Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support arbitrary depth of depends on #69

Merged

Conversation

meesiris
Copy link
Contributor

@meesiris meesiris commented Apr 7, 2021

Depends on with One to Many supported.

image

Create Plugin, Model and Controller

php artisan create:plugin Meesiris.Plan
php artisan create:model Meesiris.Plan Dependency
php artisan create:controller Meesiris.Plan Dependencies

create_dependencies_table.php

<?php namespace Meesiris\Plan\Updates;

use Schema;
use Winter\Storm\Database\Schema\Blueprint;
use Winter\Storm\Database\Updates\Migration;

class CreateDependenciesTable extends Migration
{
    public function up()
    {
        Schema::create('meesiris_plan_dependencies', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('cus_name');
            $table->integer('per_income_per_day')->nullable();
            $table->integer('per_income_per_month')->nullable();
            $table->integer('per_income_per_year')->nullable();
            $table->integer('per_income_total')->nullable();
            $table->integer('per_expense_per_day')->nullable();
            $table->integer('per_expense_per_month')->nullable();
            $table->integer('per_expense_per_year')->nullable();
            $table->integer('per_expense_total')->nullable();
            $table->integer('per_balance_total')->nullable();
            $table->integer('fam_income_per_day')->nullable();
            $table->integer('fam_income_per_month')->nullable();
            $table->integer('fam_income_per_year')->nullable();
            $table->integer('fam_income_total')->nullable();
            $table->integer('fam_expense_per_day')->nullable();
            $table->integer('fam_expense_per_month')->nullable();
            $table->integer('fam_expense_per_year')->nullable();
            $table->integer('fam_expense_total')->nullable();
            $table->integer('fam_balance_total')->nullable();
            $table->integer('all_balance_total')->nullable();
            $table->integer('all_income_total')->nullable();
            $table->integer('all_expense_total')->nullable();
            $table->integer('all_income_per_day')->nullable();
            $table->integer('all_income_per_week')->nullable();
            $table->integer('all_income_per_month')->nullable();
            $table->integer('all_income_per_year')->nullable();
            $table->integer('all_expense_per_day')->nullable();
            $table->integer('all_expense_per_week')->nullable();
            $table->integer('all_expense_per_month')->nullable();
            $table->integer('all_expense_per_year')->nullable();
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('meesiris_plan_dependencies');
    }
}

Model: Dependency.php

<?php namespace Meesiris\Plan\Models;

use Model;

/**
 * Dependency Model
 */
class Dependency extends Model
{
    use \Winter\Storm\Database\Traits\Validation;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'meesiris_plan_dependencies';

    /**
     * @var array Guarded fields
     */
    protected $guarded = ['*'];

    /**
     * @var array Fillable fields
     */
    protected $fillable = [];

    /**
     * @var array Validation rules for attributes
     */
    public $rules = [];

    /**
     * @var array Attributes to be cast to native types
     */
    protected $casts = [];

    /**
     * @var array Attributes to be cast to JSON
     */
    protected $jsonable = [];

    /**
     * @var array Attributes to be appended to the API representation of the model (ex. toArray())
     */
    protected $appends = [];

    /**
     * @var array Attributes to be removed from the API representation of the model (ex. toArray())
     */
    protected $hidden = [];

    /**
     * @var array Attributes to be cast to Argon (Carbon) instances
     */
    protected $dates = [
        'created_at',
        'updated_at'
    ];

    /**
     * @var array Relations
     */
    public $hasOne = [];
    public $hasMany = [];
    public $hasOneThrough = [];
    public $hasManyThrough = [];
    public $belongsTo = [];
    public $belongsToMany = [];
    public $morphTo = [];
    public $morphOne = [];
    public $morphMany = [];
    public $attachOne = [];
    public $attachMany = [];

    public function getPerIncomeTotalAttribute()
    {
        $result = ($this->per_income_per_day*365)
                +($this->per_income_per_week*52)
                +($this->per_income_per_month*12)
                +($this->per_income_per_year*1);
        return  $result;
    }

    public function getPerExpenseTotalAttribute()
    {
        $result = ($this->per_expense_per_day*365)
                +($this->per_expense_per_week*52)
                +($this->per_expense_per_month*12)
                +($this->per_expense_per_year*1);
        return  $result;
    }

    public function getPerBalanceTotalAttribute()
    {
        return  $this->per_income_total-$this->per_expense_total;
    }

    public function getFamIncomeTotalAttribute()
    {
        $result = ($this->fam_income_per_day*365)
                +($this->fam_income_per_week*52)
                +($this->fam_income_per_month*12)
                +($this->fam_income_per_year*1);
        return  $result;
    }

    public function getFamExpenseTotalAttribute()
    {
        $result = ($this->fam_expense_per_day*365)
                +($this->fam_expense_per_week*52)
                +($this->fam_expense_per_month*12)
                +($this->fam_expense_per_year*1);
        return  $result;
    }

    public function getFamBalanceTotalAttribute()
    {
        return  $this->fam_income_total-$this->fam_expense_total;
    }

    public function getAllBalanceTotalAttribute()
    {
        return   $this->per_balance_total+$this->fam_balance_total;
    }

    public function getAllIncomeTotalAttribute()
    {
        return   $this->per_income_total+$this->fam_income_total;
    }

    public function getAllExpenseTotalAttribute()
    {
        return   $this->per_expense_total+$this->fam_expense_total;
    }

    public function getAllIncomePerDayAttribute()
    {
        return   $this->all_income_total/365;
    }

    public function getAllIncomePerWeekAttribute()
    {
        return   $this->all_income_total/52;
    }

    public function getAllIncomePerMonthAttribute()
    {
        return   $this->all_income_total/12;
    }

    public function getAllIncomePerYearAttribute()
    {
        return   $this->all_income_total/1;
    }

    public function getAllExpensePerDayAttribute()
    {
        return   $this->all_expense_total/365;
    }

    public function getAllExpensePerWeekAttribute()
    {
        return   $this->all_expense_total/52;
    }

    public function getAllExpensePerMonthAttribute()
    {
        return   $this->all_expense_total/12;
    }

    public function getAllExpensePerYearAttribute()
    {
        return   $this->all_expense_total/1;
    }

}

columns.yaml

columns:
    cus_name:
        label: cus_name
        type: text
    all_balance_total:
        label: all_balance_total
        type: number

fields.yaml

# ===================================
#  Form Field Definitions
# ===================================

fields:
    cus_name:
        label: Customer Name
        type: text
        span: left
    per_income_per_day:
        label: Personal income per day
        type: number
        span: left
    per_income_per_month:
        label: Personal income per month
        type: number
        span: left
    per_income_per_year:
        label: Personal income per year
        type: number
        span: left
    per_income_total:
        label: Personal income total
        type: number
        span: left
        dependsOn:
            - per_income_per_day
            - per_income_per_month
            - per_income_per_year
        readOnly: true
    per_expense_per_day:
        label: Personal expense per day
        type: number
        span: left
    per_expense_per_month:
        label: Personal expense per month
        type: number
        span: left
    per_expense_per_year:
        label: Personal expense per year
        type: number
        span: left
    per_expense_total:
        label: Personal expense total
        type: number
        span: left
        dependsOn:
            - per_expense_per_day
            - per_expense_per_month
            - per_expense_per_year
        readOnly: true
    per_balance_total:
        label: Personal balance total
        type: number
        span: left
        dependsOn:
            - per_income_total
            - per_expense_total
        readOnly: true
    fam_income_per_day:
        label: Family income per day
        type: number
        span: left
    fam_income_per_month:
        label: Family income per month
        type: number
        span: left
    fam_income_per_year:
        label: Family income per year
        type: number
        span: left
    fam_income_total:
        label: Family income total
        type: number
        span: left
        dependsOn:
            - fam_income_per_day
            - fam_income_per_month
            - fam_income_per_year
        readOnly: true
    fam_expense_per_day:
        label: Family expense per day
        type: number
        span: left
    fam_expense_per_month:
        label: Family expense per month
        type: number
        span: left
    fam_expense_per_year:
        label: Family expense per year
        type: number
        span: left
    fam_expense_total:
        label: Family expense total
        type: number
        span: left
        dependsOn:
            - fam_expense_per_day
            - fam_expense_per_month
            - fam_expense_per_year
        readOnly: true
    fam_balance_total:
        label: Family balance total
        type: number
        span: left
        dependsOn:
            - fam_income_total
            - fam_expense_total
        readOnly: true
    all_income_total:
        label: All income total
        type: number
        span: left
        dependsOn:
            - per_income_total
            - fam_income_total
        readOnly: true
    all_expense_total:
        label: All expense total
        type: number
        span: left
        dependsOn:
            - per_expense_total
            - fam_expense_total
        readOnly: true
    all_balance_total:
        label: All balance total
        type: number
        span: left
        dependsOn:
            - per_balance_total
            - fam_balance_total
        readOnly: true
    all_income_per_day:
        label: All income per day
        type: number
        span: left
        dependsOn:
            - all_income_total
        readOnly: true
    all_income_per_week:
        label: All income per week
        type: number
        span: left
        dependsOn:
            - all_income_total
        readOnly: true
    all_income_per_month:
        label: All income per month
        type: number
        span: left
        dependsOn:
            - all_income_total
        readOnly: true
    all_income_per_year:
        label: All income per year
        type: number
        span: left
        dependsOn:
            - all_income_total
        readOnly: true
    all_expense_per_day:
        label: All expense per day
        type: number
        span: left
        dependsOn:
            - all_expense_total
        readOnly: true
    all_expense_per_week:
        label: All expense per week
        type: number
        span: left
        dependsOn:
            - all_expense_total
        readOnly: true
    all_expense_per_month:
        label: All expense per month
        type: number
        span: left
        dependsOn:
            - all_expense_total
        readOnly: true
    all_expense_per_year:
        label: All expense per year
        type: number
        span: left
        dependsOn:
            - all_expense_total
        readOnly: true

Refresh Plugin for create dependencies table.

php artisan plugin:refresh Meesiris.Plan

@LukeTowers LukeTowers added needs review Issues/PRs that require a review from a maintainer enhancement PRs that implement a new feature or substantial change labels Apr 7, 2021
@bennothommo
Copy link
Member

@meesiris thanks for the PR. We're prioritising finishing off 1.1.3 and releasing the website and marketplace. Once these are done, we'll be happy to consider implementing this.

We'll be in touch soon.

@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Jun 13, 2021
@bennothommo bennothommo removed the stale Issues/PRs that have had no activity and may be archived label Jun 13, 2021
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Aug 13, 2021
@bennothommo bennothommo removed the stale Issues/PRs that have had no activity and may be archived label Aug 13, 2021
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Oct 13, 2021
@LukeTowers LukeTowers removed the stale Issues/PRs that have had no activity and may be archived label Oct 13, 2021
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Dec 13, 2021
@LukeTowers LukeTowers removed the stale Issues/PRs that have had no activity and may be archived label Dec 13, 2021
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Feb 12, 2022
@LukeTowers LukeTowers removed the stale Issues/PRs that have had no activity and may be archived label Feb 12, 2022
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Apr 14, 2022
@github-actions github-actions bot closed this Apr 18, 2022
@LukeTowers LukeTowers reopened this Apr 18, 2022
@LukeTowers LukeTowers removed the stale Issues/PRs that have had no activity and may be archived label Apr 18, 2022
@LukeTowers
Copy link
Member

@meesiris was there an issue associated with this PR?

@meesiris
Copy link
Contributor Author

@LukeTowers
Copy link
Member

@meesiris looks like those issues were fixed by #34 in 712843d. What's the key issue with the original approach in #34 that makes it so that this PR is required? I think I have a grasp of what's going on here but if you could restate the problem as simply as possible that would be helpful and then I should be able to merge this.

@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in this pull request for the last 6 months.
If you intend to continue working on this pull request, please respond within 3 days.
If this pull request is critical for your business, please reach out to us at [email protected].

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Oct 20, 2022
@bennothommo bennothommo removed the stale Issues/PRs that have had no activity and may be archived label Oct 20, 2022
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in this pull request for the last 6 months.
If you intend to continue working on this pull request, please respond within 3 days.
If this pull request is critical for your business, please reach out to us at [email protected].

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Apr 21, 2023
@github-actions github-actions bot closed this Apr 24, 2023
@LukeTowers LukeTowers reopened this Apr 24, 2023
@LukeTowers LukeTowers removed the stale Issues/PRs that have had no activity and may be archived label Apr 24, 2023
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in this pull request for the last 6 months.
If you intend to continue working on this pull request, please respond within 3 days.
If this pull request is critical for your business, please reach out to us at [email protected].

@github-actions github-actions bot added the stale Issues/PRs that have had no activity and may be archived label Oct 24, 2023
@LukeTowers
Copy link
Member

@meesiris (or anyone) did you have a response for #69 (comment)? I'm not opposed to merging this but if no one currently cares then I won't bother at the moment and will just let the bot close it.

@sutat-meesiri-wt
Copy link

@LukeTowers This PR enhancement of #34

@github-actions github-actions bot closed this Oct 30, 2023
@LukeTowers LukeTowers removed the stale Issues/PRs that have had no activity and may be archived label Oct 30, 2023
@LukeTowers LukeTowers reopened this Oct 30, 2023
@LukeTowers
Copy link
Member

@meesiris you didn't respond to my comment.

@sutat-meesiri-wt
Copy link

@meesiris you didn't respond to my comment.

@LukeTowers This PR enhancement of #34. It will loop in deep more than #34.

@LukeTowers LukeTowers added Status: Completed and removed needs review Issues/PRs that require a review from a maintainer labels Feb 20, 2024
@LukeTowers LukeTowers added this to the 1.2.5 milestone Feb 20, 2024
@LukeTowers LukeTowers merged commit d2f284c into wintercms:develop Feb 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PRs that implement a new feature or substantial change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants