Exemplo n.º 1
0
     // Skip Empty
     if ($cr == 0 && $dr == 0) {
         continue;
     }
     $id = intval($_POST["{$i}_id"]);
     $ale = new AccountLedgerEntry($id);
     $ale['auth_user_id'] = $_SESSION['uid'];
     $ale['account_id'] = $_POST["{$i}_account_id"];
     $ale['account_journal_id'] = $aje['id'];
     // $ale->note = $req->getPost($i . '_note');
     $ale['amount'] = $dr > $cr ? abs($dr) * -1 : abs($cr);
     // Bind to an object
     $ale['link_id'] = $_POST["{$i}_link_id"];
     $ale['link_to'] = $_POST["{$i}_link_to"];
     // Save Ledger Entry
     $ale->save();
     // $_SESSION['account-transaction-list'][] = $ale;
     // Save Ledger Entry to Wizard
     // $awj->addLedgerEntry($ale);
     if ($id) {
         Session::flash('info', 'Account Ledger Entry #' . $id . ' updated');
     } else {
         Session::flash('info', 'Account Ledger Entry #' . $ale['id'] . ' created');
     }
 }
 // Memorise the Transaction
 if (1 == $_POST['memorise']) {
     // $awj->save();
     Session::flash('info', 'Account Wizard Memorised');
 }
 // File!
Exemplo n.º 2
0
        $je['note'] = $_POST['note'];
        // $req->getPost('note');
        $je['kind'] = 'N';
        // $req->getPost('kind');
        $je->save();
        // Debit Side
        $dr = new AccountLedgerEntry();
        $dr['auth_user_id'] = $_SESSION['uid'];
        $dr['account_journal_id'] = $je['id'];
        // Credit Side
        $cr = new AccountLedgerEntry();
        $cr['auth_user_id'] = $_SESSION['uid'];
        $cr['account_journal_id'] = $je['id'];
        if (!empty($_POST['cr'])) {
            // Credit to the Upload Target Account
            $cr['account_id'] = $_ENV['upload_account_id'];
            $cr['amount'] = abs(preg_replace('/[^\\d\\.]+/', null, $_POST['cr']));
            $dr['account_id'] = $_POST['offset_account_id'];
            $dr['amount'] = abs(preg_replace('/[^\\d\\.]+/', null, $_POST['cr'])) * -1;
        } elseif (!empty($_POST['dr'])) {
            // Debit to the Upload Target Account
            $cr['account_id'] = $_POST['offset_account_id'];
            $cr['amount'] = abs(preg_replace('/[^\\d\\.]+/', null, $_POST['dr']));
            $dr['account_id'] = $_ENV['upload_account_id'];
            $dr['amount'] = abs(preg_replace('/[^\\d\\.]+/', null, $_POST['dr'])) * -1;
        }
        $dr->save();
        $cr->save();
        die(json_encode(array('status' => 'success', 'result' => array('journal_entry_id' => $je['id']), 'detail' => 'Journal Entry saved')));
        break;
}