Пример #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;
 }
Пример #2
0
 public function Execute()
 {
     $total = $this->headerdata['total'];
     $customer_id = $this->headerdata["customer"];
     if ($this->headerdata['cash'] == true) {
         $cash = MoneyFund::getCash();
         Entry::AddEntry("63", "30", $total, $this->document_id, $this->document_date);
         $sc = new SubConto($this, 63, $total);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
         $sc = new SubConto($this, 30, $total);
         $sc->setMoneyfund($cash->id);
         // $sc->save();
     }
     if ($this->headerdata['totalnds'] > 0) {
         $total = $total - $this->headerdata['totalnds'];
         Entry::AddEntry("644", "63", $this->headerdata['totalnds'], $this->document_id, 0, $customer_id);
         $sc = new SubConto($this, 63, 0 - $this->headerdata['totalnds']);
         $sc->setCustomer($customer_id);
         $sc->save();
         $sc = new SubConto($this, 644, $this->headerdata['totalnds']);
         $sc->setExtCode(TAX_NDS);
         //$sc->save();
     }
     Entry::AddEntry("91", "63", $total, $this->document_id, $this->document_date);
     $sc = new SubConto($this, 63, 0 - $value);
     $sc->setCustomer($customer_id);
     $sc->save();
     return true;
 }
Пример #3
0
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $total = $this->headerdata['total'];
     $customer_id = $this->headerdata["customer"];
     // \ZippyERP\ERP\Entity\Customer::AddActivity($customer_id, 0 - $total, $this->document_id);
     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();
     }
     if ($this->headerdata['totalnds'] > 0) {
         Entry::AddEntry("703", "643", $this->headerdata['totalnds'], $this->document_id, $this->document_date);
     }
     Entry::AddEntry("36", "703", $total, $this->document_id, $this->document_date);
     $sc = new SubConto($this, 36, $total);
     $sc->setCustomer($this->headerdata["customer"]);
     $sc->save();
     $conn->CompleteTrans();
     return true;
 }
Пример #4
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;
 }
Пример #5
0
 public function Execute()
 {
     foreach ($this->detaildata as $value) {
         if ($value['noentry'] === 'true') {
             //не выполнять проводки
             continue;
         }
         if ($value['optype'] == self::OUT) {
             Entry::AddEntry('63', "31", $value['amount'], $this->document_id, $this->document_date);
             $sc = new SubConto($this, 63, $value['amount']);
             $sc->setCustomer($value['customer']);
             $sc->save();
             $sc = new SubConto($this, 31, 0 - $value['amount']);
             $sc->setMoneyfund($this->headerdata['bankaccount']);
             $sc->save();
         }
         if ($value['optype'] == self::IN) {
             Entry::AddEntry('31', "36", $value['amount'], $this->document_id, $this->document_date);
             $sc = new SubConto($this, 36, 0 - $value['amount']);
             $sc->setCustomer($value['customer']);
             $sc->save();
             $sc = new SubConto($this, 31, $value['amount']);
             $sc->setMoneyfund($this->headerdata['bankaccount']);
             $sc->save();
         }
         if ($value['optype'] == self::TAX) {
             //Entry::AddEntry('643', "644", $value['amount'], $this->document_id, $this->document_date);
             Entry::AddEntry('643', "31", $value['amount'], $this->document_id, $this->document_date);
             $sc = new SubConto($this, 643, $value['amount']);
             $sc->setCustomer($value['customer']);
             $sc->save();
             $sc = new SubConto($this, 31, 0 - $value['amount']);
             $sc->setMoneyfund($this->headerdata['bankaccount']);
             $sc->setExtCode($value['tax']);
             // код налога
             $sc->save();
         }
         if ($value['optype'] == self::CASHIN) {
             $cash = MoneyFund::getCash();
             Entry::AddEntry('30', "31", $value['amount'], $this->document_id, $this->document_date);
             $sc = new SubConto($this, 31, 0 - $value['amount']);
             $sc->setMoneyfund($this->headerdata['bankaccount']);
             $sc->save();
         }
         if ($value['optype'] == self::CASHOUT) {
             $cash = MoneyFund::getCash();
             Entry::AddEntry('31', "30", $value['amount'], $this->document_id, $this->document_date);
             $sc = new SubConto($this, 31, $value['amount']);
             $sc->setMoneyfund($this->headerdata['bankaccount']);
             $sc->save();
         }
         // $this->AddConnectedDoc($value['doc']);
     }
 }
Пример #6
0
 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();
         }
     }
 }
Пример #7
0
 public function Execute()
 {
     $types = array();
     //аналитика
     foreach ($this->detaildata as $item) {
         $stock = \ZippyERP\ERP\Entity\Stock::getStock($this->headerdata['store'], $item['item_id'], $item['price'], true);
         $sc = new SubConto($this, $item['type'], $item['amount'] - $item['nds']);
         $sc->setStock($stock->stock_id);
         $sc->setQuantity($item['quantity']);
         $sc->save();
         //группируем по синтетическим счетам
         if ($types[$item['type']] > 0) {
             $types[$item['type']] = $types[$item['type']] + $item['amount'] - $item['nds'];
         } else {
             $types[$item['type']] = $item['amount'] - $item['nds'];
         }
     }
     foreach ($types as $acc => $value) {
         Entry::AddEntry($acc, "63", $value, $this->document_id, $this->document_date);
         $sc = new SubConto($this, 63, 0 - $value);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
     }
     $total = $this->headerdata['total'];
     if ($this->headerdata['cash'] == true) {
         $cash = MoneyFund::getCash();
         Entry::AddEntry("63", "30", $total, $this->document_id, $this->document_date);
         $sc = new SubConto($this, 63, $total);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
         $sc = new SubConto($this, 30, 0 - $total);
         $sc->setMoneyfund($cash->id);
         // $sc->save();
     }
     //налоговый кредит
     if ($this->headerdata['totalnds'] > 0) {
         Entry::AddEntry("644", "63", $this->headerdata['totalnds'], $this->document_id, $this->document_date);
         $sc = new SubConto($this, 63, 0 - $this->headerdata['totalnds']);
         $sc->setCustomer($this->headerdata["customer"]);
         $sc->save();
         $sc = new SubConto($this, 644, $this->headerdata['totalnds']);
         $sc->setExtCode(TAX_NDS);
         //$sc->save();
     }
     return true;
 }
Пример #8
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;
 }