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; }
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; }
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; }