✏️ 正在编辑: Abstract.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/library/Core/Banco/Remessa/Abstract.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php use Core_Banco_Enum_BancoEnum as Banco; use Core_Banco_Service_Remessa as Service; use Core_Banco_Enum_ModalidadeEnum as Modalidade; abstract class Core_Banco_Remessa_Abstract extends Core_Banco_Remessa { /** @var Zend_Db_Table_Row_Abstract|null */ protected $empresa; /** @var Zend_Db_Table_Row */ protected $conta; /** @var string */ protected $bancoId; /** @var int|null */ protected $codigoRemessa; /** @var array */ protected $pagamentos = array(); /** @var string|null */ protected $dataPagamento = null; /** @var string|null */ public $tipoTransferencia = 'DOC'; /** @var Service */ private $service; /** @var float */ protected $valorTotal; /** @var int */ protected $lotes; /** @var int */ protected $registros; /** @var int */ protected $registrosTransacao; /** @var array */ protected $arquivo; /** * @param array|null $lancamentos * @param Zend_Db_Table_Row $conta * @param string|null $tipoTransferencia * @param string|null $dataPagamento * @param int|null $codigoRemessa * @throws Zend_Date_Exception * @throws Zend_Db_Table_Row_Exception */ public function __construct( ?array $lancamentos, Zend_Db_Table_Row $conta, ?string $tipoTransferencia, ?string $dataPagamento = null, ?int $codigoRemessa = 1 ) { $this->service = new Service(); $this->empresa = $conta->findParentRow('Model_DbTable_Empresa'); $this->conta = $conta; $this->bancoId = $conta->banco_id; $this->codigoRemessa = $codigoRemessa; $this->tipoTransferencia = $tipoTransferencia; $this->pagamentos = (new Model_ProtocoloPagamento()) ->listarProtocolosParaQuitar(['protocolo_pagamento_id' => $lancamentos]); $this->dataPagamento = empty($dataPagamento) ? Zend_Date::now()->get('ddMMyyyy') : (new Zend_Date($dataPagamento))->get('ddMMyyyy') ; $this->setFileNameResolve(); } /** * @return Zend_Db_Table_Row_Abstract|null */ public function getEmpresa() { return $this->empresa; } /** * @return Zend_Db_Table_Row_Abstract|null */ public function getConta() { return $this->conta; } /** * @param array $pagamento * @return string */ public function getValorPagamento(array $pagamento): string { return $this->service->getValorPagamento($pagamento); } /** * @return string */ public function gerar(): string { $this->service->validarPagamentos($this->pagamentos); $this->setNumero( $this->service->saveRemessa($this->empresa->id, $this->bancoId) ); $this->gerarLinhas(); return implode("\r\n", $this->arquivo) . "\r\n"; } abstract public function gerarLinhas(); /** * @param array $pagamento * @return int|null */ public function getCodigoRemessa(array $pagamento): ?int { return !empty($pagamento['codigo_remessa']) ? $pagamento['codigo_remessa'] : $this->codigoRemessa ; } /** * @param array $pagamento */ public function incrementValorTotal(array $pagamento): void { $this->valorTotal += $this->getValorPagamento($pagamento); } /** * @return int */ public function incrementLote(): int { if (!$this->lotes) { $this->lotes = 1; } return $this->lotes++; } /** * @return int */ public function incrementRegistro(): int { if (!$this->registros) { $this->registros = 1; } return $this->registros++; } /** * @return int */ public function incrementRegistroTransacao(): int { return $this->registrosTransacao += 1; } /** * @return int */ public function getQuantidadeTransacoes(): int { return $this->registrosTransacao ? $this->registrosTransacao : 0; } public function setFileNameResolve(): void { $data = Zend_Date::now(); $extensao = "rem"; switch ((int) $this->bancoId) { case Banco::BMG: $extensao = $this->getExtensaoBmg($data); parent::setFileName($this->getFileNameBmg($data)); break; case Banco::SANTANDER: parent::setFileName('santander'); break; case Banco::BRADESCO: parent::setFileName('remessa'); $extensao = "txt"; break; default: parent::setFileName('remessa'); break; } $this->setExtensao($extensao); } /** * @param Zend_Date $data * @return string */ public function getFileNameBmg(Zend_Date $data): string { return 'REM' . $this->conta->conta . $data->get('ddMMyy'); } /** * @param Zend_Date $data */ public function getExtensaoBmg(Zend_Date $data): string { return $this->service->getExtensaoBmg($data); } /** * @param string $cpfCnpj * @return int */ public function getTipoInscricao(string $cpfCnpj): int { return $this->service->getTipoInscricao($cpfCnpj); } /** * @return string|null */ public function getTipoTransferencia(): ?string { return $this->tipoTransferencia; } /** * @return int */ public function getCodigoModalidade(): int { $modalidade = Modalidade::MODALIDADES[$this->getTipoTransferencia()]; return $modalidade ? $modalidade : Modalidade::MODALIDADES['DOC']; } /** * @param string $tipoConta * @return int */ public function getCodigoTipoConta(string $tipoConta): int { return $this->service->getCodigoTipoConta($tipoConta); } /** * @return string */ public function getValorTotal(): string { return Service::formatFloat($this->valorTotal); } /** * @param string $conta * @return string */ public function getContaPagamento(string $conta): string { return explode("-", $conta)[0]; } /** * @param string $conta * @return string */ public function getDigitoContaPagamento(string $conta): string { return explode("-", $conta)[1] ?? ''; } }
💾 保存文件
← 返回文件管理器