✏️ 正在编辑: Split.php
路径:
/srv/systems_dir/koruspay/application/models/Split.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_Split extends Core_Model { public function getCompany() { return $this->findParentRow('Model_DbTable_Company'); } public function calculateTax() { return $this->getDbTable()->getSplitValues($this->getCompany(), md5($this->id)); } public function transactionTaxDebited() { $tax = Model_Container::getTransactions()->fetchRow([ 'split_id = ?' => $this->id, 'type = ?' => 'TARIFA', 'situation = ?' => 'CONCLUIDO', 'deleted = ?' => 0 ]); return $tax ? true : false; } public function display(string $id) { $dbTable = new Model_DbTable_Split(); $split = $dbTable->fetchRow(["MD5(id) = ?" => $id]); if ($split) { return $split; } return false; } public static function updateSplit(string $id, array $data) { $table = new Model_DbTable_Split(); return $table->update($data, ['MD5(id) = ?' => $id]); } public static function updateStatus(string $id, string $status, string $currentStatus) { $table = new Model_DbTable_Split(); return $table->update( ['situation' => $status], [ 'MD5(id) = ?' => $id, 'situation = ?' => $currentStatus, 'deleted = ?' => 0 ] ); } public function saveSplit(array $payments, int $companyId, string $origin) { $payments = array_filter($payments); if (empty($payments)) { return; } $dbtable = Model_Container::getSplit(); $idSplit = $dbtable->insert([ 'company_id' => $companyId ?: Yuppie_Auth::getIdentity()->company_id, 'situation' => 'PENDENTE', 'origin' => $origin ]); if (empty($idSplit)) { return false; } $tbItens = Model_Container::getSplitItens(); foreach ($payments as $payment) { $result = $tbItens->insert([ 'split_id' => $idSplit, 'doc_number' => $payment['doc_number'], 'name_holder' => $payment['name_holder'], 'bank_code' => $payment['bank_code'], 'account_type' => $payment['account_type'], 'branch_code' => $payment['branch_code'], 'account_number' => $payment['account_number'], 'type_pix' => strtoupper($payment['type_pix']) == "CPF" && strlen($payment['pix']) > 11 ? "CNPJ" : strtoupper($payment['type_pix']), 'pix' => $payment['pix'], 'amount' => $payment['amount'], 'description' => $payment['description'] ]); $count += $result ? 1 : 0; } if (count($payments) != $count) { self::updateSplit(md5($idSplit), ['deleted' => 1]); $tbItens->deleteSplit($idSplit); return false; } return $idSplit; } }
💾 保存文件
← 返回文件管理器