コード例 #1
0
 /**
 * @brief retrieve amount of previous periode
 * @param $p_to frmo the start of the exercise until $p_to
 * @return $array with vat, price,other_amount
 * @note
 * @see
  @code
  array
  'price' => string '446.1900' (length=8)
  'vat' => string '21.7600' (length=7)
  'priv' => string '0.0000' (length=6)
  'tva_nd_recup' => string '0.0000' (length=6)
  'tva' =>
  array
  0 =>
  array
  'sum_vat' => string '13.7200' (length=7)
  'tva_id' => string '1' (length=1)
  1 =>
  array
  'sum_vat' => string '8.0400' (length=6)
  'tva_id' => string '3' (length=1)
  2 =>
  array
  'sum_vat' => string '0.0000' (length=6)
  'tva_id' => string '4' (length=1)
 
  @endcode
 */
 function previous_amount($p_to)
 {
     /* get the first periode of exercise */
     $periode = new Periode($this->db, $p_to);
     $exercise = $periode->get_exercice();
     list($min, $max) = $periode->get_limit($exercise);
     // transform min into date
     $min_date = $min->first_day();
     // transform $p_to  into date
     $periode_max = new Periode($this->db, $p_to);
     $max_date = $periode_max->first_day();
     bcscale(2);
     // min periode
     if ($this->type == 'ACH') {
         /*  get all amount exclude vat */
         $sql = "select coalesce(sum(qp_price),0) as price" . " ,coalesce(sum(qp_vat),0) as vat " . ',coalesce(sum(qp_dep_priv),0) as priv' . ',coalesce(sum(qp_vat_sided),0) as reversed' . ',coalesce(sum(qp_nd_tva_recup),0)+coalesce(sum(qp_nd_tva),0) as tva_nd' . ',coalesce(sum(qp_vat_sided),0) as tva_np' . '  from quant_purchase join jrnx using(j_id) ' . " where j_date >= to_date(\$1,'DD.MM.YYYY') and j_date < to_date(\$2,'DD.MM.YYYY') " . ' and j_jrn_def = $3';
         $array = $this->db->get_array($sql, array($min_date, $max_date, $this->id));
         $ret = $array[0];
         /* retrieve all vat code */
         $array = $this->db->get_array("select coalesce(sum(qp_vat),0) as sum_vat,tva_id\n                                        from quant_purchase as p right join tva_rate on (qp_vat_code=tva_id)  join jrnx using(j_id)\n                                        where tva_rate !=0 and  j_date >= to_date(\$1,'DD.MM.YYYY') and j_date < to_date(\$2,'DD.MM.YYYY') \n                                        and j_jrn_def = \$3\n                                        group by tva_id", array($min_date, $max_date, $this->id));
         $ret['tva'] = $array;
     }
     if ($this->type == 'VEN') {
         /*  get all amount exclude vat */
         $sql = "select coalesce(sum(qs_price),0) as price" . " ,coalesce(sum(qs_vat),0) as vat " . ',0 as priv' . ',0 as tva_nd' . ',coalesce(sum(qs_vat_sided),0) as tva_np' . '  from quant_sold join jrnx using(j_id) ' . " where j_date >= to_date(\$1,'DD.MM.YYYY') and j_date < to_date(\$2,'DD.MM.YYYY') " . ' and j_jrn_def = $3';
         $array = $this->db->get_array($sql, array($min_date, $max_date, $this->id));
         $ret = $array[0];
         /* retrieve all vat code */
         $array = $this->db->get_array("select coalesce(sum(qs_vat),0) as sum_vat,tva_id\n                                        from quant_sold as p right join tva_rate on (qs_vat_code=tva_id)  join jrnx using(j_id)\n                                        where tva_rate !=0 and\n                                        j_date >= to_date(\$1,'DD.MM.YYYY') and j_date < to_date(\$2,'DD.MM.YYYY') \n                                        and j_jrn_def = \$3\n                                        group by tva_id", array($min_date, $max_date, $this->id));
         $ret['tva'] = $array;
     }
     if ($this->type == "FIN") {
         /* find the quick code of this ledger */
         $ledger = new Acc_Ledger_Fin($this->db, $this->id);
         $qcode = $ledger->get_bank();
         $bank_card = new Fiche($this->db, $qcode);
         /*add the amount from Opening Writing                  */
         $cond = sprintf(" j_jrn_def <> %d  and j_date >= to_date('%s','DD.MM.YYYY') and j_date < to_date('%s','DD.MM.YYYY') ", $this->id, $min_date, $max_date);
         $saldo = $bank_card->get_bk_balance($cond);
         $ret['amount'] = bcsub($saldo['debit'], $saldo['credit']);
     }
     return $ret;
 }
コード例 #2
0
            if ($row['jr_id'] == $_POST['op'][$x]) {
                $iradio->selected = true;
                break;
            }
        }
    }
    $r .= td(HtmlInput::hidden('jrid[' . $i . ']', $row['jr_id']) . $iradio->input(), ' style="text-align:center" ');
    if ($i % 2 == 0) {
        echo tr($r, ' class="odd" ');
    } else {
        echo tr($r, ' class="even" ');
    }
}
echo '</table>';
$bk_card = new Fiche($cn);
$bk_card->id = $Ledger->get_bank();
$filter_year = "  j_tech_per in (select p_id from parm_periode where  p_exercice='" . $g_user->get_exercice() . "')";
/*  get saldo for not reconcilied operations  */
$saldo_not_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) ='' or jr_pj_number is null)");
/*  get saldo for reconcilied operation  */
$saldo_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (select jr_grpt_id from jrn where trim(jr_pj_number) != '' and jr_pj_number is not null)");
/* solde compte */
$saldo = $bk_card->get_solde_detail($filter_year);
echo '<table>';
echo '<tr>';
echo td("Solde compte  ");
echo td(nbm(bcsub($saldo['debit'], $saldo['credit'])), ' style="text-align:right"');
echo '</tr>';
echo '<tr>';
echo td("Solde non rapproché ");
echo td(nbm(bcsub($saldo_not_reconcilied['debit'], $saldo_not_reconcilied['credit'])), ' style="text-align:right"');
コード例 #3
0
 /**
  * @covers Acc_Ledger_Fin::get_bank
  * @todo   Implement testGet_bank().
  */
 public function testGet_bank()
 {
     $this->assertEquals(27, $this->object->get_bank());
 }