Example #1
0
 public function Execute()
 {
     $mf = MoneyFund::getCash();
     $optype = $this->headerdata['optype'];
     if ($optype == self::TYPEOP_CUSTOMER) {
         $ret = Entry::AddEntry(63, 30, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 63, $this->headerdata['amount']);
         $sc->setCustomer($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_CASH) {
         $ret = Entry::AddEntry(372, 30, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 372, $this->headerdata['amount']);
         $sc->setEmployee($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_BANK) {
         $ret = Entry::AddEntry(31, 30, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 31, $this->headerdata['amount']);
         $sc->setMoneyfund($this->headerdata['opdetail']);
         $sc->save();
     }
     //касса
     $sc = new SubConto($this, 30, 0 - $this->headerdata['amount']);
     $sc->setMoneyfund($this->headerdata['opdetail']);
     $sc->save();
     return true;
 }
Example #2
0
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $types = array();
     //аналитика
     foreach ($this->detaildata as $item) {
         $stock = \ZippyERP\ERP\Entity\Stock::getStock($this->headerdata['store'], $item['item_id'], $item['partion'], true);
         $sc = new SubConto($this, $item['type'], 0 - $item['partion'] * ($item['quantity'] / 1000));
         $sc->setStock($stock->stock_id);
         $sc->setQuantity(0 - $item['quantity']);
         $sc->save();
         //группируем по синтетическим счетам
         if ($types[$item['type']] > 0) {
             $types[$item['type']]['amount'] = $types[$item['type']] + $item['price'] * ($item['quantity'] / 1000);
             $types[$item['type']]['pamount'] = $types[$item['type']] + $item['partion'] * ($item['quantity'] / 1000);
             $types[$item['type']]['namount'] = $types[$item['type']] + $item['nds'];
         } else {
             $types[$item['type']]['amount'] = $item['pricends'] * ($item['quantity'] / 1000);
             $types[$item['type']]['pamount'] = $item['partion'] * ($item['quantity'] / 1000);
             $types[$item['type']]['namount'] = $item['nds'];
         }
     }
     foreach ($types as $acc => $value) {
         if ($acc == 281) {
             Entry::AddEntry("902", "281", $value['pamount'], $this->document_id, $this->document_date);
             Entry::AddEntry("36", "702", $value['amount'], $this->document_id, $this->document_date);
             if ($this->headerdata['isnds'] > 0) {
                 Entry::AddEntry("702", "643", $value['namount'], $this->document_id, $this->document_date);
             }
         }
         if ($acc == 26) {
             Entry::AddEntry("902", "26", $value['pamount'], $this->document_id, $this->document_date);
             Entry::AddEntry("36", "701", $value['amount'], $this->document_id, $this->document_date);
             if ($this->headerdata['isnds'] > 0) {
                 Entry::AddEntry("701", "643", $value['namount'], $this->document_id, $this->document_date);
             }
         }
         $sc = new SubConto($this, 36, $value['amount']);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
     }
     if ($this->headerdata['cash'] == true) {
         $cash = MoneyFund::getCash();
         \ZippyERP\ERP\Entity\Entry::AddEntry("30", "36", $total, $this->document_id, $cash->id, $customer_id);
         $sc = new SubConto($this, 36, 0 - $total);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
         $sc = new SubConto($this, 30, $total);
         $sc->setMoneyfund($cash->id);
         // $sc->save();
     }
     $conn->CompleteTrans();
     return true;
 }
Example #3
0
 public function generateReport()
 {
     $myfirm = \ZippyERP\System\System::getOptions("firmdetail");
     $myaccount = \ZippyERP\ERP\Entity\MoneyFund::load($this->headerdata['bankaccount']);
     $mybank = \ZippyERP\ERP\Entity\Bank::load($myaccount->bank);
     $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata['customer']);
     $cbank = \ZippyERP\ERP\Entity\Bank::load($customer->bank);
     $header = array('date' => date('d.m.Y', $this->document_date), 'myname' => $myfirm['name'], 'mycode' => $myfirm['code'], 'mybankaccount' => $myaccount->bankaccount, 'mybank' => $mybank->bank_name, 'mybankcode' => $mybank->mfo, 'cname' => $customer->customer_name, 'ccode' => $customer->code, 'cbankaccount' => $customer->bankaccount, 'cbank' => $cbank->bank_name, 'cbankcode' => $cbank->mfo, "document_number" => $this->document_number, "document_date" => date('Y.m.d', $this->document_date), "notes" => $this->headerdata['notes'], "amount" => H::fm($this->amount), "amountstr" => \ZippyERP\ERP\Util::ucfirst(\ZippyERP\ERP\Util::money2str($this->amount / 100)));
     $report = new \ZippyERP\ERP\Report('transferorder.tpl');
     $html = $report->generate($header, array());
     return $html;
 }
Example #4
0
 public function generateReport()
 {
     $types = $this->getTypes();
     $i = 1;
     $detail = array();
     $total = 0;
     foreach ($this->detaildata as $value) {
         $detail[] = array("type" => $types[$value['optype']], "cust" => $value['customername'], "amount" => H::fm($value['amount']), "comment" => $value['comment']);
     }
     $header = array('date' => date('d.m.Y', $this->document_date), 'bankaccount' => \ZippyERP\ERP\Entity\MoneyFund::load($this->headerdata['bankaccount'])->title, "document_number" => $this->document_number);
     $report = new \ZippyERP\ERP\Report('bankstatement.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Example #5
0
 public function opdetailOnAutocomplete($sender)
 {
     $text = $sender->getValue();
     $optype = $this->docform->optype->getValue();
     if ($optype == CROUT::TYPEOP_CUSTOMER) {
         return Customer::findArray('customer_name', "customer_name like '%{$text}%' and ( cust_type=" . Customer::TYPE_SELLER . " or cust_type= " . Customer::TYPE_BUYER_SELLER . " )");
     }
     if ($optype == CROUT::TYPEOP_BANK) {
         return MoneyFund::findArray('title', "title like '%{$text}%' ");
     }
     if ($optype == CROUT::TYPEOP_CASH) {
         return Employee::findArray('fullname', "fullname like '%{$text}%' ");
     }
 }
Example #6
0
 public function __construct($docid = 0, $basedocid = 0)
 {
     parent::__construct();
     $this->add(new Form('docform'));
     $this->docform->add(new TextInput('document_number'));
     $this->docform->add(new Date('document_date', time()));
     $this->docform->add(new DropDownChoice('bankaccount', \ZippyERP\ERP\Entity\MoneyFund::findArray('title', "ftype=1")));
     $this->docform->add(new CheckBox('tax'));
     $this->docform->add(new AutocompleteTextInput('customer'))->setAutocompleteHandler($this, "OnAutoContragent");
     $this->docform->add(new TextInput('amount'));
     $this->docform->add(new TextInput('nds'));
     $this->docform->add(new AutocompleteTextInput('basedoc'))->setAutocompleteHandler($this, 'OnAutocomplete');
     $this->docform->add(new TextArea('notes'));
     $this->docform->add(new Button('backtolist'))->setClickHandler($this, 'backtolistOnClick');
     $this->docform->add(new SubmitButton('savedoc'))->setClickHandler($this, 'savedocOnClick');
     $this->docform->add(new SubmitButton('execdoc'))->setClickHandler($this, 'savedocOnClick');
     if ($docid > 0) {
         //загружаем   содержимок  документа настраницу
         $this->_doc = Document::load($docid);
         if ($this->_doc == null) {
             App::RedirectError('Докумен не найден');
         }
         $this->docform->amount->setText($this->_doc->amount / 100);
         $this->docform->document_number->setText($this->_doc->document_number);
         $this->docform->document_date->setDate($this->_doc->document_date);
         $this->docform->nds->setText($this->_doc->headerdata['nds'] / 100);
         $this->docform->notes->setText($this->_doc->headerdata['notes']);
         $this->docform->bankaccount->setValue($this->_doc->headerdata['bankaccount']);
         $this->docform->tax->setValue($this->_doc->headerdata['tax']);
         $this->docform->basedoc->setKey($this->_doc->headerdata['basedoc']);
         $this->docform->basedoc->setText($this->_doc->headerdata['basedocname']);
         $this->docform->customer->setKey($this->_doc->headerdata['customer']);
         $this->docform->customer->setText($this->_doc->headerdata['customername']);
     } else {
         $this->_doc = Document::create('TransferOrder');
         $this->docform->document_number->setText($this->_doc->nextNumber());
         if ($basedocid > 0) {
             //создание на  основании
             $basedoc = Document::load($basedocid);
             if ($basedoc instanceof Document) {
                 $this->_basedocid = $basedocid;
             }
         }
     }
 }
Example #7
0
 public function Execute()
 {
     $cash = MoneyFund::getCash();
     $ret = "";
     $optype = $this->headerdata['optype'];
     if ($optype == self::TYPEOP_CUSTOMER) {
         $ret = Entry::AddEntry(30, 36, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 36, 0 - $this->headerdata['amount']);
         $sc->setCustomer($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_CASH) {
         $ret = Entry::AddEntry(30, 372, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 372, 0 - $this->headerdata['amount']);
         $sc->setEmployee($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_BANK) {
         $ret = Entry::AddEntry(30, 31, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 31, 0 - $this->headerdata['amount']);
         $sc->setMoneyfund($this->headerdata['opdetail']);
         $sc->save();
     }
     if ($optype == self::TYPEOP_RET) {
         $store_id = $this->headerdata['opdetail'];
         // магазин
         $ret = Entry::AddEntry(30, 702, $this->headerdata['amount'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 702, 0 - $this->headerdata['amount']);
         $sc->setExtCode($this->headerdata['opdetail']);
         $sc->save();
         $store = \ZippyERP\ERP\Entity\Store::load($store_id);
         if ($store->store_type == \ZippyERP\ERP\Entity\Store::STORE_TYPE_RET_SUM) {
             $nds = \ZippyERP\ERP\Helper::nds(true);
             Entry::AddEntry(702, 643, $nds * $this->headerdata['amount'], $this->document_id, $this->document_date);
         }
     }
     //касса
     $sc = new SubConto($this, 30, $this->headerdata['amount']);
     $sc->setMoneyfund($cash->id);
     $sc->save();
     if (strlen($ret) > 0) {
         throw new \Exception($ret);
     }
     return true;
 }
Example #8
0
 public function generateReport()
 {
     $i = 1;
     $detail = array();
     $total = 0;
     foreach ($this->detaildata as $value) {
         $detail[] = array("no" => $i++, "tovar_name" => $value['itemname'], "measure" => $value['measure_name'], "quantity" => $value['quantity'] / 1000, "price" => H::fm($value['price']), "amount" => H::fm($value['quantity'] / 1000 * $value['price']));
         $total += $value['quantity'] / 1000 * $value['price'];
     }
     $firm = \ZippyERP\System\System::getOptions("firmdetail");
     $f = \ZippyERP\ERP\Entity\MoneyFund::findOne('ftype = 1');
     $bank = \ZippyERP\ERP\Entity\Bank::load($f->bank);
     //  $customer = \ZippyERP\ERP\Entity\Customer::load($this->headerdata["customer"]);
     $header = array('date' => date('d.m.Y', $this->document_date), "firmname" => $firm['name'], "firmcode" => $firm['code'], "account" => $f->bankaccount, "bank" => $bank->bank_name, "mfo" => $bank->mfo, "address" => $firm['city'] . ', ' . $firm['street'], "customername" => $this->headerdata["customername"], "document_number" => $this->document_number, "base" => $this->base, "paydate" => date('d.m.Y', $this->headerdata["payment_date"]), "total" => H::fm($total), "totalnds" => H::fm($total + $this->headerdata["totalnds"]), "summa" => Util::ucfirst(Util::money2str($total + $this->headerdata["nds"] / 100, '.', '')));
     $report = new \ZippyERP\ERP\Report('invoice.tpl');
     $html = $report->generate($header, $detail);
     return $html;
 }
Example #9
0
 public function __construct($docid = 0)
 {
     parent::__construct();
     $this->add(new Form('docform'));
     $this->docform->add(new Date('document_date', time()));
     $this->docform->add(new TextInput('document_number'));
     $this->docform->add(new DropDownChoice('bankaccount', \ZippyERP\ERP\Entity\MoneyFund::findArray('title', "ftype=1")));
     $this->docform->add(new SubmitLink('addrow'))->setClickHandler($this, 'addrowOnClick');
     $this->docform->add(new SubmitButton('savedoc'))->setClickHandler($this, 'savedocOnClick');
     $this->docform->add(new SubmitButton('execdoc'))->setClickHandler($this, 'savedocOnClick');
     $this->docform->add(new Button('backtolist'))->setClickHandler($this, 'backtolistOnClick');
     $this->add(new Form('editdetail'))->setVisible(false);
     $this->editdetail->add(new DropDownChoice('editoptype', BS::getTypes()))->setChangeHandler($this, 'typeOnClick');
     $this->editdetail->add(new AutocompleteTextInput('editcustomer'))->setAutocompleteHandler($this, "OnAutoContragent");
     $this->editdetail->add(new DropDownChoice('editpayment'))->setOptionList(\ZippyERP\ERP\Consts::getTaxesList());
     $this->editdetail->editpayment->setVisible(false);
     $docinput = $this->editdetail->add(new AutocompleteTextInput('editdoc'));
     $docinput->setAutocompleteHandler($this, 'OnDocAutocomplete');
     $docinput->setAjaxChangeHandler($this, 'OnDocChange');
     $this->editdetail->add(new TextInput('editamount'))->setText("1");
     $this->editdetail->add(new TextInput('editnds'))->setText("0");
     $this->editdetail->add(new TextInput('editcomment'));
     $this->editdetail->add(new CheckBox('editnoentry'));
     $this->editdetail->add(new Button('cancelrow'))->setClickHandler($this, 'cancelrowOnClick');
     $this->editdetail->add(new SubmitButton('submitrow'))->setClickHandler($this, 'saverowOnClick');
     if ($docid > 0) {
         //загружаем   содержимок  документа на страницу
         $this->_doc = Document::load($docid);
         $this->docform->document_number->setText($this->_doc->document_number);
         $this->docform->bankaccount->setValue($this->_doc->headerdata['bankaccount']);
         $this->docform->document_date->setText(date('Y-m-d', $this->_doc->document_date));
         foreach ($this->_doc->detaildata as $item) {
             $entry = new Entry($item);
             $this->_list[$entry->entry_id] = $entry;
         }
         $this->docform->document_date->setText(date('Y-m-d', $this->_doc->document_date));
     } else {
         $this->_doc = Document::create('BankStatement');
     }
     $this->docform->add(new DataView('detail', new \Zippy\Html\DataList\ArrayDataSource(new \Zippy\Binding\PropertyBinding($this, '_list')), $this, 'detailOnRow'));
     $this->docform->detail->Reload();
 }
Example #10
0
 public function saveDetailOnClick($sender)
 {
     if ($this->detail->name->getText() == '') {
         $this->setError("Введите имя");
         return;
     }
     $detail = array();
     $detail['name'] = $this->detail->name->getText();
     $detail['edrpou'] = $this->detail->edrpou->getText();
     $detail['koatuu'] = $this->detail->koatuu->getText();
     $detail['kopfg'] = $this->detail->kopfg->getText();
     $detail['kodu'] = $this->detail->kodu->getText();
     $detail['kved'] = $this->detail->kved->getText();
     $detail['gni'] = $this->detail->gni->getText();
     $detail['inn'] = $this->detail->inn->getText();
     $detail['city'] = $this->detail->city->getText();
     $detail['street'] = $this->detail->street->getText();
     $detail['manager'] = $this->detail->manager->getText();
     $detail['accounter'] = $this->detail->accounter->getText();
     $detail['phone'] = $this->detail->phone->getText();
     $detail['email'] = $this->detail->email->getText();
     $f = \ZippyERP\ERP\Entity\MoneyFund::findOne('ftype = 1');
     if ($f != null) {
         // обноваляем  основной   счет
         $f->bank = $this->detail->bank->getValue();
         $f->bankaccount = $this->detail->bankaccount->getText();
         $f->save();
     }
     \ZippyERP\System\System::setOptions("firmdetail", $detail);
 }
Example #11
0
 public function addfbtnOnClick($sender)
 {
     $id = $this->docform->e_flist->getValue();
     if (isset($this->_farr[$id])) {
         $this->setError('Дублирование строки');
         return;
     }
     $f = MoneyFund::load($id);
     $f->val = 100 * $this->docform->e_famount->getText();
     $f->op = $this->docform->e_foper->getValue();
     $this->_farr[$id] = $f;
     $this->docform->ftable->Reload();
     $this->docform->e_famount->setText('');
 }