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(); $employee_id = $this->headerdata["employee"]; $expensetype = $this->headerdata['expensetype']; if ($expensetype == 201 || $expensetype == 22 || $expensetype == 281) { foreach ($this->detaildata as $value) { //поиск записи о товаре на складе $stock = \ZippyERP\ERP\Entity\Stock::getStock($this->headerdata['store'], $value['item_id'], $value['price'], true); $sc = new SubConto($this, $expensetype, $value['quantity'] / 1000 * $stock->price); $sc->setStock($stock->stock_id); $sc->setQuantity($value['quantity']); $sc->save(); } Entry::AddEntry($expensetype, "372", $this->headerdata['total'] - $this->headerdata['totalnds'], $this->document_id, $this->document_date); //налоговый кредит if ($this->headerdata['totalnds'] > 0) { Entry::AddEntry("644", "372", $this->headerdata['totalnds'], $this->document_id, $this->document_date); } } else { Entry::AddEntry($expensetype, "372", $this->headerdata["expenseamount"], $this->document_id, $this->document_date); $sc = new SubConto($this, 372, 0 - $this->headerdata["expenseamount"]); $sc->setEmployee($employee_id); $sc->save(); } $conn->CompleteTrans(); return true; }
public function Execute() { $accarr = unserialize(base64_decode($this->headerdata['entry'])); foreach ($accarr as $entry) { Entry::AddEntry($entry->acc_d, $entry->acc_c, $entry->amount, $this->document_id, $this->document_date); } //ТМЦ $itemarr = unserialize(base64_decode($this->headerdata['item'])); if (is_array($itemarr)) { foreach ($itemarr as $item) { $stock = Stock::getStock($item->store_id, $item->item_id, $item->price, true); $acc = explode('_', $item->op); $sc = new SubConto($this, $acc[0], $acc[1] == 'd' ? $item->qty / 1000 * $stock->price : 0 - $item->qty / 1000 * $stock->price); $sc->setStock($stock->stock_id); $sc->setQuantity($acc[1] == 'd' ? $item->qty : 0 - $item->qty); $sc->save(); } } //сотрудники (лицевые счета) $emparr = unserialize(base64_decode($this->headerdata['emp'])); if (count($emparr) > 0) { foreach ($emparr as $emp) { $val = $emp->val; $acc = explode('_', $emp->op); $sc = new SubConto($this, $acc[0], $acc[1] == 'd' ? $val : 0 - $val); $sc->setEmployee($emp->employee_id); $sc->save(); } } //контрагенты (взаиморасчеты) $carr = unserialize(base64_decode($this->headerdata['c'])); if (count($carr) > 0) { foreach ($carr as $c) { $val = $c->val; $acc = explode('_', $c->op); $sc = new SubConto($this, $acc[0], $acc[1] == 'd' ? $val : 0 - $val); $sc->setCustomer($c->customer_id); $sc->save(); } } //денежные счета $farr = unserialize(base64_decode($this->headerdata['f'])); if (count($farr) > 0) { foreach ($farr as $f) { $val = $f->val; $acc = explode('_', $f->op); $sc = new SubConto($this, $acc[0], $acc[1] == 'd' ? $val : 0 - $val); $sc->setMoneyfund($f->id); $sc->save(); } } }
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; }