/**
  * @return bool|TblDebtor
  */
 public function getServiceBillingBilling()
 {
     if (null === $this->serviceBilling_Banking) {
         return false;
     } else {
         return Banking::useService()->entityDebtorById($this->serviceBilling_Banking);
     }
 }
 /**
  * @return bool|TblDebtor
  */
 public function getTblDebtor()
 {
     if (null === $this->tblDebtor) {
         return false;
     } else {
         return Banking::useService()->entityDebtorById($this->tblDebtor);
     }
 }
 public static function registerApplication()
 {
     /**
      * Register Module
      */
     Account::registerModule();
     Banking::registerModule();
     Basket::registerModule();
     Main::getDisplay()->addApplicationNavigation(new Link(new Link\Route(__NAMESPACE__), new Link\Name('Buchhaltung')));
     Main::getDisplay()->addModuleNavigation(new Link(new Link\Route(__NAMESPACE__ . '/Account'), new Link\Name('FIBU-Konten')));
     Main::getDisplay()->addModuleNavigation(new Link(new Link\Route(__NAMESPACE__ . '/Banking'), new Link\Name('Debitoren')));
     Main::getDisplay()->addModuleNavigation(new Link(new Link\Route(__NAMESPACE__ . '/Basket'), new Link\Name('Warenkorb')));
 }
Exemple #4
0
 /**
  * @param TblBasket $tblBasket
  * @param           $Date
  *
  * @return bool
  */
 public function actionCreateInvoiceListFromBasket(TblBasket $tblBasket, $Date)
 {
     $Manager = $this->Connection->getEntityManager();
     $tblTempInvoiceList = $this->entityTempInvoiceAllByBasket($tblBasket);
     /**@var TblTempInvoice $tblTempInvoice */
     foreach ($tblTempInvoiceList as $tblTempInvoice) {
         $tblDebtor = $tblTempInvoice->getServiceBillingDebtor();
         $tblPersonDebtor = Management::servicePerson()->entityPersonById($tblDebtor->getServiceManagementPerson());
         $tblPerson = $tblTempInvoice->getServiceManagementPerson();
         $Entity = new TblInvoice();
         $Entity->setIsPaid(false);
         $Entity->setIsVoid(false);
         $Entity->setNumber("40000000");
         $Entity->setBasketName($tblBasket->getName());
         $Entity->setServiceBillingBankingPaymentType($tblDebtor->getPaymentType());
         $leadTimeByDebtor = Banking::useService()->entityLeadTimeByDebtor($tblDebtor);
         $invoiceDate = (new \DateTime($Date))->sub(new \DateInterval('P' . $leadTimeByDebtor . 'D'));
         $now = new \DateTime();
         if ($invoiceDate->format('y.m.d') >= $now->format('y.m.d')) {
             $Entity->setInvoiceDate($invoiceDate);
             $Entity->setPaymentDate(new \DateTime($Date));
             $Entity->setIsPaymentDateModified(false);
         } else {
             $Entity->setInvoiceDate(new \DateTime('now'));
             $Entity->setPaymentDate($now->add(new \DateInterval('P' . $leadTimeByDebtor . 'D')));
             $Entity->setIsPaymentDateModified(true);
         }
         $Entity->setDiscount(0);
         $Entity->setDebtorFirstName($tblPersonDebtor->getFirstName());
         $Entity->setDebtorLastName($tblPersonDebtor->getLastName());
         $Entity->setDebtorSalutation($tblPersonDebtor->getTblPersonSalutation()->getName());
         $Entity->setDebtorNumber($tblDebtor->getDebtorNumber());
         $Entity->setServiceManagementPerson($tblPerson);
         if ($address = Management::servicePerson()->entityAddressAllByPerson($tblPersonDebtor)) {
             // TODO address type invoice
             $Entity->setServiceManagementAddress($address[0]);
         }
         $Manager->saveEntity($Entity);
         $Entity->setNumber((int) $Entity->getNumber() + $Entity->getId());
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
         $tblTempInvoiceCommodityList = $this->entityTempInvoiceCommodityAllByTempInvoice($tblTempInvoice);
         foreach ($tblTempInvoiceCommodityList as $tblTempInvoiceCommodity) {
             $tblCommodity = $tblTempInvoiceCommodity->getServiceBillingCommodity();
             $tblBasketItemAllByBasketAndCommodity = Basket::useService()->entityBasketItemAllByBasketAndCommodity($tblBasket, $tblCommodity);
             /**@var TblBasketItem $tblBasketItem */
             foreach ($tblBasketItemAllByBasketAndCommodity as $tblBasketItem) {
                 $tblItem = $tblBasketItem->getServiceBillingCommodityItem()->getTblItem();
                 if (!$tblItem->getServiceManagementCourse() && !$tblItem->getServiceManagementStudentChildRank()) {
                     $this->actionCreateInvoiceItem($tblCommodity, $tblItem, $tblBasket, $tblBasketItem, $Entity);
                 } else {
                     if ($tblItem->getServiceManagementCourse() && !$tblItem->getServiceManagementStudentChildRank()) {
                         if (($tblStudent = Management::serviceStudent()->entityStudentByPerson($tblPerson)) && $tblItem->getServiceManagementCourse()->getId() == $tblStudent->getServiceManagementCourse()->getId()) {
                             $this->actionCreateInvoiceItem($tblCommodity, $tblItem, $tblBasket, $tblBasketItem, $Entity);
                         }
                     } else {
                         if (!$tblItem->getServiceManagementCourse() && $tblItem->getServiceManagementStudentChildRank()) {
                             if (($tblStudent = Management::serviceStudent()->entityStudentByPerson($tblPerson)) && $tblItem->getServiceManagementStudentChildRank()->getId() == $tblStudent->getTblChildRank()->getId()) {
                                 $this->actionCreateInvoiceItem($tblCommodity, $tblItem, $tblBasket, $tblBasketItem, $Entity);
                             }
                         } else {
                             if ($tblItem->getServiceManagementCourse() && $tblItem->getServiceManagementStudentChildRank()) {
                                 if (($tblStudent = Management::serviceStudent()->entityStudentByPerson($tblPerson)) && $tblItem->getServiceManagementCourse()->getId() == $tblStudent->getServiceManagementCourse()->getId() && $tblItem->getServiceManagementStudentChildRank()->getId() == $tblStudent->getTblChildRank()->getId()) {
                                     $this->actionCreateInvoiceItem($tblCommodity, $tblItem, $tblBasket, $tblBasketItem, $Entity);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
 /**
  * @param $Id
  * @param $PaymentTypeId
  *
  * @return Stage
  */
 public function frontendInvoicePaymentTypeChange($Id, $PaymentTypeId)
 {
     $Stage = new Stage();
     $Stage->setTitle('Rechnung');
     $Stage->setDescription('Zahlungsart Ändern');
     $tblInvoice = Invoice::useService()->entityInvoiceById($Id);
     $tblPaymentType = Banking::useService()->entityPaymentTypeById($PaymentTypeId);
     $Stage->setContent(Invoice::useService()->executeChangeInvoicePaymentType($tblInvoice, $tblPaymentType));
     return $Stage;
 }
Exemple #6
0
 public function actionEditDebtor(TblDebtor $tblDebtor, $Description, $PaymentType, $Owner, $IBAN, $BIC, $CashSign, $BankName, $LeadTimeFirst, $LeadTimeFollow)
 {
     $Manager = $this->Connection->getEntityManager();
     /** @var TblDebtor $Entity */
     $Entity = $Manager->getEntityById('TblDebtor', $tblDebtor->getId());
     $Protocol = clone $Entity;
     if (null !== $Entity) {
         $Entity->setDescription($Description);
         $Entity->setPaymentType(Banking::useService()->entityPaymentTypeById($PaymentType));
         $Entity->setOwner($Owner);
         $Entity->setIBAN($IBAN);
         $Entity->setBIC($BIC);
         $Entity->setCashSign($CashSign);
         $Entity->setBankName($BankName);
         $Entity->setLeadTimeFirst($LeadTimeFirst);
         $Entity->setLeadTimeFollow($LeadTimeFollow);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createUpdateEntry($this->Connection->getDatabase(), $Protocol, $Entity);
         return true;
     }
     return false;
 }
 /**
  * @param IFormInterface $Stage
  * @param                $Debtor
  * @param                $Id
  *
  * @return IFormInterface|string
  */
 public function executeAddDebtor(IFormInterface &$Stage = null, $Debtor, $Id)
 {
     /**
      * Skip to Frontend
      */
     if (null === $Debtor) {
         return $Stage;
     }
     $Error = false;
     if (isset($Debtor['DebtorNumber']) && empty($Debtor['DebtorNumber'])) {
         $Stage->setError('Debtor[DebtorNumber]', 'Bitte geben sie die Debitorennummer an');
         $Error = true;
     }
     if (isset($Debtor['DebtorNumber']) && Banking::useService()->entityDebtorByDebtorNumber($Debtor['DebtorNumber'])) {
         $Stage->setError('Debtor[DebtorNumber]', 'Die Debitorennummer exisitiert bereits. Bitte geben Sie eine andere Debitorennummer an');
         $Error = true;
     }
     if (isset($Debtor['LeadTimeFirst']) && empty($Debtor['LeadTimeFirst'])) {
         $Stage->setError('Debtor[LeadTimeFirst]', 'Bitte geben sie den Ersteinzug an.');
         $Error = true;
     }
     if (isset($Debtor['LeadTimeFirst']) && !is_numeric($Debtor['LeadTimeFirst'])) {
         $Stage->setError('Debtor[LeadTimeFirst]', 'Bitte geben sie eine Zahl an.');
         $Error = true;
     }
     if (isset($Debtor['LeadTimeFollow']) && empty($Debtor['LeadTimeFollow'])) {
         $Stage->setError('Debtor[LeadTimeFollow]', 'Bitte geben sie den Folgeeinzug an.');
         $Error = true;
     }
     if (isset($Debtor['LeadTimeFollow']) && !is_numeric($Debtor['LeadTimeFollow'])) {
         $Stage->setError('Debtor[LeadTimeFollow]', 'Bitte geben sie eine Zahl an.');
         $Error = true;
     }
     if (isset($Debtor['Reference']) && Banking::useService()->entityReferenceByReference($Debtor['Reference'])) {
         $Stage->setError('Debtor[Reference]', 'Die Mandatsreferenz exisitiert bereits. Bitte geben Sie eine andere an');
         $Error = true;
     }
     if (!$Error) {
         (new Data($this->Binding))->actionAddDebtor($Debtor['DebtorNumber'], $Debtor['LeadTimeFirst'], $Debtor['LeadTimeFollow'], $Debtor['BankName'], $Debtor['Owner'], $Debtor['CashSign'], $Debtor['IBAN'], $Debtor['BIC'], $Debtor['Description'], $Debtor['PaymentType'], Management::servicePerson()->entityPersonById($Id));
         //todo
         if (!empty($Debtor['Reference'])) {
             (new Data($this->Binding))->actionAddReference($Debtor['Reference'], $Debtor['DebtorNumber'], $Debtor['ReferenceDate'], Commodity::useService()->entityCommodityById($Debtor['Commodity']));
         }
         return new Success('Der Debitor ist erfasst worden') . new Redirect('/Billing/Accounting/Banking', 2);
     }
     return $Stage;
 }
 /**
  * @return TblPaymentType $tblPaymentType
  */
 public function getPaymentType()
 {
     if (null === $this->tblPaymentType) {
         return false;
     } else {
         return Banking::useService()->entityPaymentTypeById($this->tblPaymentType);
     }
 }
Exemple #9
0
 /**
  * @param TblPerson $tblPerson
  *
  * @return TblDebtor[]|bool
  */
 public function checkDebtorExistsByPerson(TblPerson $tblPerson)
 {
     $tblDebtorAllList = array();
     $debtorPersonAll = Banking::useService()->entityDebtorAllByPerson($tblPerson);
     if (!empty($debtorPersonAll)) {
         foreach ($debtorPersonAll as $debtor) {
             array_push($tblDebtorAllList, $debtor);
         }
     }
     $tblPersonRelationshipList = Management::servicePerson()->entityPersonRelationshipAllByPerson($tblPerson);
     if (!empty($tblPersonRelationshipList)) {
         foreach ($tblPersonRelationshipList as $tblPersonRelationship) {
             if ($tblPerson->getId() === $tblPersonRelationship->getTblPersonA()) {
                 $tblDebtorList = Banking::useService()->entityDebtorAllByPerson($tblPersonRelationship->getTblPersonB());
             } else {
                 $tblDebtorList = Banking::useService()->entityDebtorAllByPerson($tblPersonRelationship->getTblPersonA());
             }
             if (!empty($tblDebtorList)) {
                 foreach ($tblDebtorList as $tblDebtor) {
                     array_push($tblDebtorAllList, $tblDebtor);
                 }
             }
         }
     }
     if (empty($tblDebtorAllList)) {
         return false;
     } else {
         return $tblDebtorAllList;
     }
 }
 /**
  * @param $Debtor
  * @param $Id
  *
  * @return Stage
  */
 public function frontendBankingPersonSelect($Debtor, $Id)
 {
     $Stage = new Stage();
     $Stage->setTitle('Debitoreninformationen');
     $Stage->addButton(new Primary('Zurück', '/Billing/Accounting/Banking/Person', new ChevronLeft()));
     //        $PersonName = Management::servicePerson()->entityPersonById( $Id )->getFullName();  //todo
     $PersonName = false;
     //        $PersonType = Management::servicePerson()->entityPersonById( $Id )->getTblPersonType();
     $PersonType = false;
     $tblPaymentType = Banking::useService()->entityPaymentTypeAll();
     $tblCommodity = Commodity::useService()->entityCommodityAll();
     //        $tblPerson = Management::servicePerson()->entityPersonById( $Id );
     $tblPerson = false;
     //todo
     //        $tblStudent = Management::serviceStudent()->entityStudentByPerson( $tblPerson );
     $tblStudent = false;
     //todo
     if ($tblStudent) {
         if ($tblStudent->getStudentNumber() === 0) {
             $tblStudent->setStudentNumber('Nicht vergeben');
         }
     }
     $Global = $this->getGlobal();
     $Global->POST['Debtor']['Owner'] = $PersonName;
     if (!isset($Global->POST['Debtor']['PaymentType'])) {
         $Global->POST['Debtor']['PaymentType'] = Banking::useService()->entityPaymentTypeByName('SEPA-Lastschrift')->getId();
     }
     if (Banking::useService()->entityDebtorByServiceManagementPerson($Id) == true) {
         $tblDebtor = Banking::useService()->entityDebtorByServiceManagementPerson($Id);
     }
     $Global->savePost();
     $Stage->setContent(new Layout(array(new LayoutGroup(array(empty($tblStudent) ? new LayoutRow(array(new LayoutColumn(array(new Panel(new Person() . ' Debitor', $PersonName, Panel::PANEL_TYPE_SUCCESS)), 6), new LayoutColumn(array(new Panel(new Group() . '. Personengruppe', $PersonType, Panel::PANEL_TYPE_SUCCESS)), 6))) : null, !empty($tblStudent) ? new LayoutRow(array(new LayoutColumn(array(new Panel(new Person() . ' Debitor', $PersonName, Panel::PANEL_TYPE_WARNING)), 4), new LayoutColumn(array(new Panel(new Group() . '. Schülernummer', $tblStudent, Panel::PANEL_TYPE_PRIMARY)), 4), new LayoutColumn(array(new Panel(new Group() . '. Personengruppe', $PersonType, Panel::PANEL_TYPE_WARNING)), 4))) : null)), new LayoutGroup(array(new LayoutRow(array(new LayoutColumn(array(Banking::useService()->executeAddDebtor(new Form(array(new FormGroup(array(new FormRow(array(new FormColumn(new TextField('Debtor[DebtorNumber]', 'Debitornummer', 'Debitornummer', new BarCode()), 12), new FormColumn(new SelectBox('Debtor[PaymentType]', 'Bezahlmethode', array(TblPaymentType::ATTR_NAME => $tblPaymentType), new Money()), 4), new FormColumn(new TextField('Debtor[LeadTimeFirst]', 'Vorlaufzeit in Tagen', 'Ersteinzug', new Time()), 4), new FormColumn(new TextField('Debtor[LeadTimeFollow]', 'Vorlaufzeit in Tagen', 'Folgeeinzug', new Time()), 4), new FormColumn(new TextField('Debtor[Description]', 'Beschreibung', 'Beschreibung', new Conversation()), 12)))), new \SPHERE\Common\Frontend\Form\Repository\Title('Debitor')), new FormGroup(array(new FormRow(array(new FormColumn(new TextField('Debtor[Owner]', 'Vorname Nachname', 'Inhaber', new Person()), 6), new FormColumn(new TextField('Debtor[BankName]', 'Name der Bank', 'Name der Bank', new Building()), 6), new FormColumn(new TextField('Debtor[IBAN]', 'XXXX XXXX XXXX XXXX XXXX XX', 'IBAN', new BarCode()), 4), new FormColumn(new TextField('Debtor[BIC]', 'XXXX XX XX XXX', 'BIC', new BarCode()), 4), new FormColumn(new TextField('Debtor[CashSign]', 'Kassenzeichen', 'Kassenzeichen', new Nameplate()), 4)))), new \SPHERE\Common\Frontend\Form\Repository\Title('Bankdaten')), new FormGroup(array(new FormRow(array(new FormColumn(new TextField('Debtor[Reference]', 'Referenz', 'Mandatsreferenz', new BarCode()), 4), new FormColumn(new DatePicker('Debtor[ReferenceDate]', 'Datum', 'Erstellungsdatum', new Time()), 4), new FormColumn(new SelectBox('Debtor[Commodity]', 'Leistung', array('Name' => $tblCommodity), new Time()), 4)))), new \SPHERE\Common\Frontend\Form\Repository\Title('Mandatsreferenz'))), new \SPHERE\Common\Frontend\Form\Repository\Button\Primary('Hinzufügen')), $Debtor, $Id))))))), !empty($tblDebtor) ? new LayoutGroup(array(new LayoutRow(array(new LayoutColumn(array(new Form(array(new FormGroup(array(new FormRow(array(new FormColumn(array(new TableData($tblDebtor, null, array('DebtorNumber' => 'Debitorennummer', 'BankName' => 'Name der Bank', 'IBAN' => 'IBAN', 'BIC' => 'BIC', 'Owner' => 'Inhaber'))))))))))), 12)))), new Title('Vorhandene Debitorennummer(n)')) : null)));
     return $Stage;
 }
 /**
  * @param TblInvoice $tblInvoice
  * @param            $Data
  *
  * @return string
  */
 public function executeConfirmInvoice(TblInvoice $tblInvoice, $Data)
 {
     if (Balance::useService()->actionCreateBalance(Banking::useService()->entityDebtorByDebtorNumber($tblInvoice->getDebtorNumber()), $tblInvoice, null)) {
         return new Success('Die Rechnung wurde erfolgreich bestätigt und freigegeben') . new Redirect('/Billing/Bookkeeping/Invoice/IsNotConfirmed', 0);
     } else {
         return new Warning('Die Rechnung wurde konnte nicht bestätigt und freigegeben werden') . new Redirect('/Billing/Bookkeeping/Invoice/IsNotConfirmed/Edit', 2, array('Id' => $tblInvoice->getId()));
     }
 }
 /**
  * @return bool|TblPaymentType
  */
 public function getServiceBillingBankingPaymentType()
 {
     if (null === $this->serviceBilling_Banking_Payment_Type) {
         return false;
     } else {
         return Banking::useService()->entityPaymentTypeById($this->serviceBilling_Banking_Payment_Type);
     }
 }