示例#1
0
 private function ini()
 {
     if ($this->valuedate == null) {
         $this->valuedate = Record::writeDate(time());
     }
     if (!$this->ini) {
         $this->_precision = Yii::$app->params['precision'];
         $item = Item::findByPk($this->item_id, $this->valuedate);
         if (is_null($item)) {
             $this->iVatRate = 0;
         } else {
             $this->iVatRate = $item->vat;
         }
         //for vat resons...
         //if ($this->rate == 0) {
         $this->rate = Currates::GetRate($this->currency_id, $this->valuedate);
         //}
         if ($this->doc_rate == 0) {
             $doc = Docs::findOne($this->doc_id);
             $this->doc_rate = Currates::GetRate($doc->currency_id, $this->valuedate);
         }
         $this->ini != $this->ini;
     }
 }
示例#2
0
 public function refnumDocsLink()
 {
     $str = '';
     $array = explode(",", $this->refnum1);
     foreach ($array as $docid) {
         $doc = Docs::findOne($docid);
         if ($doc !== null) {
             $str .= Html::a(Html::encode(Yii::t('app', $doc->docType->name) . " #" . $doc->docnum), yii\helpers\BaseUrl::base() . "/docs/view/{$docid}");
         } else {
             $str .= $docid;
         }
         $str .= ",";
         //echo $docid;
     }
     return rtrim($str, ",");
 }
示例#3
0
 public function saveRef($id, $total)
 {
     $str = $this->refnum;
     //save new values
     $sum = 0;
     $tmp = explode(",", rtrim($str, ","));
     foreach ($tmp as $id) {
         //lets do this
         //if($id==$this->id){
         //    throw new \Exception(Yii::t('app','You cannot save doc as a refnum'));
         //}
         $doc = Docs::findOne((int) $id);
         if ($doc !== null) {
             $sum += $doc->total;
             //adam: need to multi currency!
             if ($sum <= $total) {
                 $doc->refstatus = Docs::STATUS_CLOSED;
             } else {
                 $doc->refstatus = Docs::STATUS_OPEN;
             }
             $doc->refnum = $id;
             $doc->save();
         }
     }
     //$this->refnum=$str;
 }