So erstellen Sie ein Hauptbuch / T-Konto mit PHP MySQL

Ich versuche, ein Finanzbuchhaltungssystem mit doppelter Erfassung einzurichten. Ich habe die Datenbank dafür entworfen. Bitte überprüfen Sie diesen Link, um das Diagramm meiner Datenbank zu sehen.http://i39.tinypic.com/juhbv6.png

Ich habe viel versucht, um die MySQL-Abfrage zu entwickeln, um das Hauptbuch zu produzieren, aber ich habe keine wo in der Nähe. Ich habe es nur geschafft, ein Hauptbuch für ein Konto zu erstellen, für das ich ein unbegrenztes Konto erstellen muss.

Die Abfrage, die ich versucht habe, ist folgende:

<code> $this->db->select('*');
    $this->db->from('credit_side');
    $this->db->join('debit_side', ' debit_side.transaction_id_dr = credit_side.transaction_id_cr ');
    $this->db->join('transaction_info', 'transaction_info.transaction_id = credit_side.transaction_id_cr ');
    $this->db->join('accounts', 'accounts.code = credit_side.account_code ');
    $this->db->where('debit_side.account_code', '1001'); 
    $this->db->order_by('voucher_date','ASC');
</code>

Nachdem ich die mysql-Abfrage nicht geschrieben habe, die das Hauptbuch für alle Konten erstellen kann, habe ich die Logik zum Erstellen des Hauptbuchs / T-Kontos aufgeschrieben.

Könnten Sie mir jetzt bitte bei der MySQL-Abfrage helfen?

Bitte überprüfen Sie die Datenbank, bevor Sie die folgenden Schritte ausführen. Danke im Voraus :)

Bekommen dasaccounts.name AS AccountHead,accounts.code von Konten.

Gehe zum Tischdebit_side undget debit_side.account_code, obdebit_side.account_code=accounts.code dann gehcredit_side.account_code AS AccountName1 (aber wenn ich in PHP zurückkomme, möchte ich den Namen anstelle des Codes selbst erhalten) undcredit_side.amount AS Amount1,SUM(credit_side.amount) AS TotalAmount1 voncredit_side woherdebit_side.transaction_id_dr=credit_side.transaction_id_cr undtransaction_info.voucher_date liegt zwischen date1 und date2 WOtransaction_info.transaction_id=debit_side.transaction_id_dr

Nach Abschluss des zweiten Schritts gehen Sie zu der Tabellecredit_side undget credit_side.account_code,
obcredit_side.account_code=accounts.code dann gehdebit_side.account_code AS AccountName2 (aber wenn ich in PHP zurückkomme, möchte ich den Namen anstelle des Codes selbst erhalten) unddebit_side.amount AS Amount2,SUM(debit_side.amount) AS TotalAmount2 vondebit_side wohercredit_side.transaction_id_cr=debit_side.transaction_id_dr undtransaction_info.voucher_date liegt zwischen date1 und date2 WOtransaction_info.transaction_id=credit_side.transaction_id_cr

In der Ansichtsdatei möchte ich Folgendes haben:

<code>   <table width="200" border="0">
     <tr><td colspan="5">Account Head <?echo $AccountHead ; ?> </td> </tr>


    <tr>
           <td>Dr.</td>
           <td>amount.</td>
            <td>&nbsp;</td>
           <td>Cr</td>
          <td>Amount</td>

    </tr>
     <tr>
       <td><?echo $AccountName1 ; ?></td>
       <td><?echo $Ammount1 ; ?></td>
      <td></td>
 <td><?echo $AccountName2 ; ?></td>
     <td><?echo $Ammount2 ; ?></td>

     </tr>

     <tr>
     <td>Total</td>
     <td><?echo $TotalAmount1 ; ?></td>
     <td>&nbsp;</td>
 <td>Total  </td>
 <td><?echo $TotalAmount2 ; ?></td>

     </tr>
     </table>
</code>

Hauptbuchprobe

Antworten auf die Frage(1)

Ihre Antwort auf die Frage