Пример #1
0
 public function Execute()
 {
     $ret = 0;
     $cost = 0;
     foreach ($this->detaildata as $value) {
         $stock = \ZippyERP\ERP\Entity\Stock::load($value['stock_id']);
         $ret = $ret + $stock->price - $stock->partion;
         $cost = $cost + $stock->partion;
         $sc = new SubConto($this, 282, 0 - $value['quantity'] / 1000 * $stock->price);
         $sc->setStock($stock->stock_id);
         $sc->setQuantity(0 - $value['quantity']);
         $sc->save();
     }
     // списываем  наценку
     Entry::AddEntry("285", "282", $ret, $this->document_id, $this->document_date);
     $sc = new SubConto($this, 285, $ret);
     $sc->setExtCode($this->headerdata["store"]);
     $sc->save();
     // себестоимость реализации
     Entry::AddEntry("902", "282", $cost, $this->document_id, $this->document_date);
     //налоговые  обязательства
     if ($this->headerdata['totalnds'] > 0) {
         Entry::AddEntry("702", "643", $this->headerdata['totalnds'], $this->document_id, $this->document_date);
     }
     return true;
 }
Пример #2
0
 public function Execute()
 {
     $diffall = 0;
     foreach ($this->detaildata as $value) {
         $diffall = $diffall + $value['quantity'] / 1000 * ($value['newprice'] - $value['price']);
         $stock = Stock::load($value["stock_id"]);
         $newstock = Stock::getStock($stock->store_id, $stock->item_id, $value['newprice'], true);
         $sc = new SubConto($this, 282, 0 - $value['quantity'] / 1000 * $stock->price);
         $sc->setStock($stock->stock_id);
         $sc->setQuantity(0 - $value['quantity']);
         $sc->save();
         $sc = new SubConto($this, 282, $value['quantity'] / 1000 * $newstock->price);
         $sc->setStock($newstock->stock_id);
         $sc->setQuantity($value['quantity']);
         $sc->save();
     }
     Entry::AddEntry("282", "285", $diffall, $this->document_id, $cash->id, $customer_id);
     $sc = new SubConto($this, 285, 0 - $diffall);
     $sc->setExtCode($this->headerdata["store"]);
     $sc->save();
     return true;
 }
Пример #3
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $stock = Stock::load($id);
     $item = Item::load($stock->item_id);
     $this->editdetail->editprice->setText(H::fm($stock->price));
     $this->editdetail->qtystock->setText(Stock::getQuantity($id, $this->docform->document_date->getDate()) / 1000 . ' ' . $stock->measure_name);
     $this->updateAjax(array('editprice', 'qtystock'));
 }
Пример #4
0
 public function getItem($id)
 {
     return Stock::load($id);
 }
Пример #5
0
 public function OnItemType($sender)
 {
     $stock_id = $this->editdetail->edittovar->getKey();
     $stock = Stock::load($stock_id);
     $this->editdetail->qtystock->setText(Stock::getQuantity($stock_id, $this->docform->document_date->getDate(), $this->editdetail->edittype->getValue()) / 1000 . ' ' . $stock->measure_name);
 }
Пример #6
0
 public function OnChangeItem($sender)
 {
     $id = $sender->getKey();
     $stock = Stock::load($id);
     $item = Item::load($stock->item_id);
     $this->editdetail->editprice->setText(H::fm($stock->price));
     $this->updateAjax(array('editprice'));
 }
Пример #7
0
 public function OnChangeItem($sender)
 {
     $stock_id = $sender->getKey();
     $stock = Stock::load($stock_id);
     $store = Store::load($this->docform->storeto->getValue());
     if ($store->store_type == Store::STORE_TYPE_OPT) {
     } else {
         $item = Item::load($stock->item_id);
     }
     if ($store->store_type == Store::STORE_TYPE_RET) {
     }
 }
Пример #8
0
 public function OnChangeItem($sender)
 {
     $stock_id = $sender->getKey();
     $stock = Stock::load($stock_id);
     $this->editdetail->qtystock->setText(Stock::getQuantity($stock_id, $this->docform->document_date->getDate(), $this->editdetail->edittype->getValue()) / 1000 . ' ' . $stock->measure_name);
     $store = Store::load($this->docform->storeto->getValue());
     if ($store->store_type == Store::STORE_TYPE_OPT) {
         // $this->editdetail->editprice->setText(H::fm($stock->price));
     } else {
         $item = Item::load($stock->item_id);
         $this->editdetail->editprice->setText(H::fm($item->priceret));
     }
     if ($store->store_type == Store::STORE_TYPE_RET) {
         //если  уже   есть  товар  в  магазине  берем  цену  оттуда
         $stock = Stock::getFirst("store_id={$store->store_id} and item_id={$stock->item_id} and closed <> 1");
         if ($stock instanceof Stock) {
             $this->editdetail->editprice->setText(H::fm($stock->price));
         }
     }
 }