-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Reports Semplification Proposal #24
Comments
Update scopeClosingBalance to mimic your calculations in Account::sectionBalances() /**
* Account::scopeClosingBalance()
*
* @since 0.0.1
* @access public
* @author Arsonus Digital
*/
public function scopeClosingBalance(Builder $builder, $startAt, $endAt = null)
{
return $builder->selectRaw("SUM(opening.amount) + SUM(current.amount) + SUM(movement.amount) as amount")
->openingBalance(ReportingPeriod::year($endAt))
->currentBalance(ReportingPeriod::periodStart($endAt), $startAt)
->selectSub(static::currentBalance($startAt, $endAt)->selectRaw("SUM(current.amount) as amount"), "movement");
} |
Hi arsonus, Thanks a lot for your suggestion. I've been thinking about shifting the responsibility for aggregation of values for the reports from php (loops) to the underlying db (raw sql) I just happen to have a weakness in the latter. I'll definitely be looking into your code above to see if I can incorporate it into the next release. The performance gains should be impressive! Thanks again, |
My pleasure ekmungai, i went further during these holidays and was able to get many of the aggregations to work by using Common Table Expressions (CTE). I will share a Gist with you once i get back to it, all the changes basically happened in the Account class so it wouldn't be difficult incorporating. Happy New Year man, |
Hi arsonus, Great to hear. I'll be looking forward to seeing the gist. Happy 2021! Cheers |
Great job man.
I do really like what you have done, i was thinking, wouldn't it's usage benefit from using the full power of Laravel Eloquent?
I see you are doing loops through all accounts for calculations, Please review below and let me know your thoughts, haven't tried it, just an idea that came in mind to easily query reports with any combinations.
By making use of scopes, one can then for example query Gross Profit:
The text was updated successfully, but these errors were encountered: