コード例 #1
0
 public function actionCreate($type = 0)
 {
     $model = new FormOutcome();
     if ($type == 1) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.payvat");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     if ($type == 2) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.natinspay");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     if ($type == 3) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.pretax");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     // Uncomment the following line if AJAX validation is needed
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return \yii\widgets\ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->transaction()) {
             \Yii::$app->getSession()->setFlash('success', Yii::t('app', 'transaction Success'));
         }
     }
     return $this->render('create', array('model' => $model));
 }
コード例 #2
0
ファイル: Accounts.php プロジェクト: chaimvaid/linet3
 public static function SrcTax($id)
 {
     $model = Accounts::findOne($id);
     if ($model === null) {
         return false;
     } else {
         $value = \app\helpers\Linet3Helper::getOverride("SrcTax", ["account" => $model]);
         if ($value !== null) {
             return $value;
         }
         return $model->src_tax;
     }
 }
コード例 #3
0
ファイル: _form.php プロジェクト: chaimvaid/linet3
$form = kartik\form\ActiveForm::begin(array('id' => 'outcome-form', 'enableAjaxValidation' => true));
?>



            <?php 
echo $form->errorSummary($model);
?>




            <?php 
if ((int) $model->account_id != 0) {
    echo $form->field($model, 'account_id')->hiddenInput();
    echo "<h2>" . Accounts::findOne($model->account_id)->name . "</h2>";
} else {
    echo $form->field($model, 'account_id')->widget(Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(Accounts::find()->where(['type' => 1])->all(), 'id', 'name')]);
    //supplieres
}
?>


            <?php 
echo $form->field($model, 'currency_id')->widget(Select2::className(), ['data' => \yii\helpers\ArrayHelper::map(Currates::GetRateList(), 'id', 'name')]);
?>

            <br />

            <?php 
echo $form->field($model, 'sum');
コード例 #4
0
ファイル: FormReportTaxrep.php プロジェクト: chaimvaid/linet3
 public function calcPay()
 {
     $this->step = 1;
     $this->dates();
     $this->income_sum = Acctype::findOne(3)->getTotal($this->from_date, $this->to_date);
     $this->tax_rate = \app\helpers\Linet3Helper::getSetting('company.tax.rate');
     //$tax
     $this->tax_sum = $this->income_sum * ($this->tax_rate / 100);
     $this->custtax_acc = \app\helpers\Linet3Helper::getSetting('company.acc.custtax');
     $this->custtax_sum = Accounts::findOne($this->custtax_acc)->getTotal($this->from_date, $this->to_date);
     //*-1
     $this->custtax_total = Accounts::findOne($this->custtax_acc)->getTotal(0, $this->to_date);
     if ($this->custtax_total > $this->tax_sum) {
         $this->custtax_total = $this->tax_sum;
     }
     $this->tax_total = $this->tax_sum + $this->custtax_total;
     return $this->tax_total;
 }
コード例 #5
0
ファイル: FormLinet2Import.php プロジェクト: chaimvaid/linet3
 public function import()
 {
     //add warehouse
     $array = $this->read();
     //companies
     $company = $this->parseLine($array['companies'][0]);
     $prefix = $company[1];
     //echo $prefix;
     $this->saveSetting('company.name', $company[0]);
     $this->saveSetting('company.vat.id', $company[3]);
     $this->saveSetting('company.address', $company[4]);
     $this->saveSetting('company.city', $company[5]);
     $this->saveSetting('company.zip', $company[6]);
     $this->saveSetting('company.phone', $company[7]);
     $this->saveSetting('company.fax', $company[8]);
     $this->saveSetting('company.website', $company[9]);
     $this->saveSetting('company.tax.rate', $company[10]);
     $this->saveSetting('company.tax.irs', $company[11]);
     //$this->saveSetting('account.100.srctax', $company[12]);
     $this->saveSetting('company.tax.vat', $company[13]);
     //exit;
     ///*
     if (isset($array['accounts'])) {
         $this->imprtAccounts($array['accounts'], $prefix);
     }
     if (isset($array['items'])) {
         $this->imprtItems($array['items'], $prefix);
     }
     if (isset($array['docs'])) {
         $this->imprtDocs($array['docs'], $prefix);
     }
     if (isset($array['cheques'])) {
         $this->imprtCheques($array['cheques'], $prefix);
     }
     if (isset($array['docdetails'])) {
         $this->imprtDocdetails($array['docdetails'], $prefix);
     }
     if (isset($array['transactions'])) {
         $this->imprtTransactions($array['transactions'], $prefix);
     }
     if (isset($array['bankbook'])) {
         $this->imprtBankbooks($array['bankbook'], $prefix);
     }
     if (isset($array['correlation'])) {
         $this->imprtCorrelations($array['correlation'], $prefix);
     }
     //*/
     //vat rate
     $acc = Accounts::findOne(100);
     $acc->src_tax = $company[12];
     $acc->save();
     $acc = Accounts::findOne(101);
     $acc->src_tax = $company[12];
     $acc->save();
     //add warehouse
     //add genral item
     //get transaction num
     $this->saveSetting('company.transaction', Transactions::getMax() + 1);
     //get docnums
     $types = Doctype::find()->All();
     foreach ($types as $type) {
         $type->last_docnum = Docs::getMax($type->id);
         $type->save();
     }
     //contacthist
     //contacts??
     //tranrep??
 }
コード例 #6
0
ファイル: Transactions.php プロジェクト: chaimvaid/linet3
 public function beforeSave($insert)
 {
     $this->num = $this->newNum();
     if ($this->reg_date == null) {
         $this->reg_date = date("Y-m-d H:i:s");
     }
     $cur = \app\helpers\Linet3Helper::getSetting('company.cur');
     $acc = Accounts::findOne($this->account_id);
     if ($acc === null) {
         $acccur = $this->currency_id;
     } else {
         $acccur = $acc->currency_id;
     }
     if ($this->currency_id == '') {
         $this->currency_id = $cur;
         $this->sum = $this->leadsum;
     }
     //leadsum
     if ($cur == $this->currency_id) {
         $this->leadsum = $this->sum;
     } else {
         $rate = Currates::GetRate($this->currency_id, $this->valuedate);
         $this->leadsum = $this->sum * $rate;
     }
     //set sum accourding to acc
     if (!isset($this->sum)) {
         //adam need to dubl chk
         if ($this->currency_id != $acccur) {
             $this->currency_id = $acccur;
             $rate = Currates::GetRate($acccur, $this->valuedate);
             if ($rate == 0) {
                 throw new \Exception(Yii::t('app', 'The rate for') . $this->currency_id . Yii::t('app', 'is invalid'));
             }
             $this->sum = $this->leadsum / $rate;
         }
     }
     //secsum
     $seccur = \app\helpers\Linet3Helper::getSetting('company.seccur');
     //$seccur = Yii::$app->user->settings['company.seccur'];
     if ($seccur != '') {
         if ($seccur == $this->currency_id) {
             $this->secsum = $this->sum;
         } else {
             $rate = Currates::GetRate($this->currency_id, $this->valuedate);
             if ($rate == 0) {
                 throw new \Exception(Yii::t('app', 'The sec rate for') . $seccur . $this->currency_id . Yii::t('app', 'is invalid'));
             }
             $this->secsum = $this->leadsum / $rate;
         }
     }
     return true;
 }
コード例 #7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 protected function findModel($id)
 {
     if (($model = Accounts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new \yii\web\HttpException(404, 'The requested page does not exist.');
     }
 }
コード例 #8
0
ファイル: Docs.php プロジェクト: chaimvaid/linet3
 public function accountVal($attribute, $params)
 {
     $doctype = Doctype::findOne(['id' => $this->doctype]);
     $type = null;
     if ($doctype == null) {
         $this->addError($attribute, Yii::t('app', 'Not a valid Doc Type'));
     } else {
         if ($attribute == 'account_id') {
             $type = $doctype->account_type;
         } else {
             $type = $doctype->oppt_account_type;
         }
     }
     $model = Accounts::findOne(['id' => $this->{$attribute}, 'type' => $type]);
     if ($model == null) {
         $this->addError($attribute, Yii::t('app', 'Not a valid account id'));
     }
 }
コード例 #9
0
ファイル: Docdetails.php プロジェクト: chaimvaid/linet3
 public function transaction($transaction, $action, $optacc)
 {
     $this->ini();
     if (is_null($this->item)) {
         throw new \Exception('The item ' . $this->item_id . ' does not exsits.');
     }
     $vatcat = $this->item->itemVatCat_id;
     $vatCatAcc = UserIncomeMap::findOne(array('user_id' => $transaction->owner_id, 'itemVatCat_id' => $vatcat));
     if ($vatCatAcc === null) {
         throw new \Exception('The item ' . $this->item_id . ' does not have a vat catagory.');
     }
     $sum = 0;
     if ($optacc == '') {
         $incomeacc = $vatCatAcc->account_id;
         $sum = $this->ihTotal * $action;
     } else {
         $incomeacc = $optacc;
         $multi = 1;
         $vat = $this->iTotalVat - $this->iTotal;
         if ($oppt = Accounts::findOne($incomeacc)) {
             //not null?
             $multi = 1 - $oppt->src_tax / 100;
         }
         $vat = round($vat * $multi, $this->_precision);
         //$multi=$this->iTotalVat*$multi;
         // Yii::info($this);
         //Yii::info($multi);
         $sum = ($this->ihTotal + $vat) * $action;
     }
     if ($sum) {
         return $transaction->addSingleLine($incomeacc, round($sum, $this->_precision));
     }
     return $transaction;
 }
コード例 #10
0
ファイル: FormReportVat.php プロジェクト: chaimvaid/linet3
 public function calcPay()
 {
     $this->step = 1;
     $this->dates();
     $incomes = Accounts::findAllByType(3);
     //incomes
     foreach ($incomes as $account) {
         //echo $transaction->date.','.$transaction->sum.'<br>';
         if ($account->src_tax == 0) {
             $this->income_sum_novat += $account->getTotal($this->from_date, $this->to_date);
         } else {
             $this->income_sum += $account->getTotal($this->from_date, $this->to_date);
         }
     }
     $this->selvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.sellvat');
     $selvat = Accounts::findOne($this->selvat_acc);
     $this->selvat_total = $selvat->getTotal($this->from_date, $this->to_date);
     $this->buyvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.buyvat');
     $buyvat = Accounts::findOne($this->buyvat_acc);
     $this->buyvat_total = $buyvat->getTotal($this->from_date, $this->to_date) * -1;
     //hAS TO INVERT
     $this->assetvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.assetvat');
     $assetvat = Accounts::findOne($this->assetvat_acc);
     $this->assetvat_total = $assetvat->getTotal($this->from_date, $this->to_date) * -1;
     //hAS TO INVERT
     $this->payvat_total = $this->selvat_total - ($this->buyvat_total + $this->assetvat_total);
     return $this->payvat_total;
 }