Calculate (General ledger like) using laravel eloquent

Calculate (General ledger like) using laravel eloquent

By : user2954905
Date : November 22 2020, 10:33 AM
hope this fix your issue SQL magic inspired by this answer
It doesn't look very pretty but works. Alternatively you may consider creating a db view with the balance select to keep your code a bit cleaner.
code :
Finance::select('id', 'amount', 'type', 'date',
                DB::raw('@balance := @balance + IF(type = "credit", amount, -amount) AS balance'))
         ->from(DB::raw('finances, (SELECT @balance := 0) AS balanceStart'))
$allFinances = // query from above
$perPage = 10;
$pagination = App::make('paginator');
$count = $allFinances->count();
$page = $pagination->getCurrentPage($count);
$finances = $this->slice(($page - 1) * $perPage, $perPage)->all();
$items = $pagination->make($items, $count, $perPage);

// pass $items to the view

Share : facebook icon twitter icon
Laravel Eloquent Calculate

Laravel Eloquent Calculate

By : Sonny Kotler
Date : March 29 2020, 07:55 AM
This might help you I have a Model and want to insert something into the database. , Simply use the increments method:
code :
PurchasesModel::where('id', '=', 1)
              ->increment('updates_until', 'INTERVAL ' . $updates_included_time . ' SECOND');
How Can Calculate Credits,Debits & Balance in the general ledger?

How Can Calculate Credits,Debits & Balance in the general ledger?

By : Eyal Askenazi
Date : March 29 2020, 07:55 AM
I wish this helpful for you Balance Not showing proper value
code :
 select s.*,
        s.debit - s.credit as Balance,
        @RunningBalance:= @RunningBalance + s.debit - s.credit RunningBalance
select min(trx_id) trx_id,t.staff_id,
    sum(case when trx_type = 'debit' then trx_amount else 0 end) as Debit,
    sum(case when trx_type = 'credit' then trx_amount else 0 end) as Credit
from  trans t
group by staff_id 
order by trx_id
) s,
(Select @RunningBalance:=0) rb
order by s.trx_id
| trx_id | staff_id | Debit | Credit | Balance | RunningBalance |
|      1 |        7 |     0 |    100 |    -100 |           -100 |
|      2 |        5 |   200 |      0 |     200 |            100 |
|      3 |        4 |   460 |    300 |     160 |            260 |
|      5 |        2 |     0 |    450 |    -450 |           -190 |
|      7 |        3 |     0 |    350 |    -350 |           -540 |
SQLSTATE[HY000]: General error: 1364 (Laravel create new row with eloquent)

SQLSTATE[HY000]: General error: 1364 (Laravel create new row with eloquent)

By : javalover
Date : March 29 2020, 07:55 AM
around this issue Don't do create, create will attempt to create the row, but you haven't associated it with any form yet.
code :
 $formcoord=new Formcoord($data->all());
Php general ledger query

Php general ledger query

By : Vishal Karathiya
Date : March 29 2020, 07:55 AM
Does that help I am new in PHP I want to know how to create general ledger. , Maybe you want to count the total, you can do it like this:
code :
$total = mysql_query("SELECT count(money) as total FROM invoice");//your query string
$res = mysql_fetch_array($total);
$count = $res['total']; //statistics
General Entry Ledger for MS Access

General Entry Ledger for MS Access

By : user1436797
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Because ms-access didn't support Windows function
You can write a subquery in select clause to calculate balance column.
code :
 select t.*,(
          SELECT SUM(IIF(Debit IS NOT NULL,Debit,0))+
                 SUM(IIF(Credit IS NOT NULL,-Credit,0))
          FROM SomeTable  t1 
          WHERE t1.DATE <= t.DATE
         ) as balance
from SomeTable t
Related Posts Related Posts :
  • How to add Smarty templating engine to CodeIgniters 3 framework?
  • Am I maxing out possible data insert
  • Redirect to homepage without changing address bar URL
  • What is the best user-Id Value for a MySql "users" table
  • PHP $_COOKIE is only available in one directory
  • php regular expressions documantation
  • cannot import too large sql file to mysql
  • not getting appilcation/json in content-type in header
  • Only the first data display from my database but other shows but not on a table
  • Is it possible to have a print button link as the content of the mail
  • how to extract full mail address in imap php
  • Alternative to output buffering to put eval'd code into a variable
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org