コード例 #1
0
ファイル: retailissue.php プロジェクト: Niqpue/zippyerp
 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
ファイル: serviceincome.php プロジェクト: Niqpue/zippyerp
 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
ファイル: bankstatement.php プロジェクト: Niqpue/zippyerp
 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']);
     }
 }
コード例 #4
0
ファイル: movebackitem.php プロジェクト: Niqpue/zippyerp
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $conn->StartTrans();
     $ret = 0;
     // торговая  наценка
     $amount = 0;
     foreach ($this->detaildata as $value) {
         //приниммаем на склад
         $stockto = Stock::getStock($this->headerdata['storeto'], $value['item_id'], $value['partion'], true);
         $sc = new SubConto($this, $value['type'], $value['quantity'] / 1000 * $stockto->price);
         $sc->setStock($stockto->stock_id);
         $sc->setQuantity($value['quantity']);
         $sc->save();
         $store = Store::load($this->headerdata['storefrom']);
         if ($store->store_type == Store::STORE_TYPE_RET) {
             //розница
             $stockfrom = Stock::getFirst("store_id={$this->headerdata['storefrom']} and item_id={$value['item_id']} and price={$value['price']} and partion={$value['partion']} and closed <> 1");
             if ($stockfrom == null) {
                 return false;
             }
             $sc = new SubConto($this, 282, 0 - $value['quantity'] / 1000 * $stockfrom->price);
             $sc->setStock($stockfrom->stock_id);
             $sc->setQuantity(0 - $value['quantity']);
             $sc->save();
             $ret += $value['quantity'] / 1000 * ($value['price'] - $value['partion']);
             $amount += $value['quantity'] / 1000 * $value['partion'];
         }
         if ($store->store_type == Store::STORE_TYPE_RET_SUM) {
             //розница суммовой учет
             //специальный  товар  для  cуммового  учета
             $item = \ZippyERP\ERP\Entity\Item::getSumItem();
             $stockfrom = Stock::getStock($this->headerdata['storefrom'], $item->item_id, 1, true);
             $sc = new SubConto($this, 282, 0 - $value['quantity'] * $value['price']);
             //цена  единицы  товара = 1 копейка.
             $sc->setStock($stockfrom->stock_id);
             $sc->setQuantity(0 - $value['quantity'] * $value['price']);
             //цена  единицы  товара - 1 копейка.
             $sc->save();
             $ret += $value['quantity'] / 1000 * ($value['price'] - $value['partion']);
             $amount += $value['quantity'] / 1000 * $value['partion'];
         }
     }
     if ($amount > 0) {
         // розница
         Entry::AddEntry(281, 282, $amount, $this->document_id, $this->document_date);
         Entry::AddEntry(285, 282, $ret, $this->document_id, $this->document_date);
         $sc = new SubConto($this, 285, $ret);
         $sc->setExtCode($store->store_id);
         $sc->save();
     }
     $conn->CompleteTrans();
     return true;
 }
コード例 #5
0
ファイル: revaluationretsum.php プロジェクト: Niqpue/zippyerp
 public function Execute()
 {
     $diff = $this->headerdata['summa'] - $this->headerdata['actual'];
     Entry::AddEntry("282", "285", $diff, $this->document_id, $cash->id, $customer_id);
     $sc = new SubConto($this, 282, $diff);
     $sc->setStock($this->headerdata["stock_id"]);
     $sc->setQuantity($diff);
     $sc->save();
     $sc = new SubConto($this, 285, 0 - $diff);
     $sc->setExtCode($this->headerdata["store_id"]);
     $sc->save();
     return true;
 }
コード例 #6
0
ファイル: goodsreceipt.php プロジェクト: Niqpue/zippyerp
 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;
 }
コード例 #7
0
ファイル: cashreceiptin.php プロジェクト: Niqpue/zippyerp
 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;
 }
コード例 #8
0
ファイル: revaluationret.php プロジェクト: Niqpue/zippyerp
 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;
 }