/**
  * @return bool|TblPerson
  */
 public function getServiceManagementPerson()
 {
     if (null === $this->serviceManagement_Person) {
         return false;
     } else {
         return Management::servicePerson()->entityPersonById($this->serviceManagement_Person);
     }
 }
Exemple #2
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
  *
  * @return Stage
  */
 public function frontendInvoiceAddressSelect($Id)
 {
     $Stage = new Stage();
     $Stage->setTitle('Rechnung');
     $Stage->setDescription('Rechnungsadresse Auswählen');
     $Stage->addButton(new Primary('Zurück', '/Billing/Bookkeeping/Invoice/IsNotConfirmed/Edit', new ChevronLeft(), array('Id' => $Id)));
     $tblInvoice = Invoice::useService()->entityInvoiceById($Id);
     $tblAddressAll = Management::servicePerson()->entityAddressAllByPerson(Banking::useService()->entityDebtorByDebtorNumber($tblInvoice->getDebtorNumber())->getServiceManagementPerson());
     $layoutGroup = self::layoutAddress($tblAddressAll, $tblInvoice->getServiceManagementAddress(), $tblInvoice);
     $Stage->setContent(new Layout(array(new LayoutGroup(array(new LayoutRow(array(new LayoutColumn(array(new Panel('Rechnungsnummer', $tblInvoice->getNumber(), Panel::PANEL_TYPE_SUCCESS)), 3), new LayoutColumn(array(new Panel('Empfänger', $tblInvoice->getDebtorFullName(), Panel::PANEL_TYPE_SUCCESS)), 3))))))) . $layoutGroup);
     return $Stage;
 }
 /**
  * @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;
 }
Exemple #5
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;
     }
 }
 /**
  * @return Stage
  */
 public function frontendBankingPerson()
 {
     $Stage = new Stage();
     $Stage->setTitle('Debitorensuche');
     $Stage->addButton(new Primary('Zurück', '/Billing/Accounting/Banking', new ChevronLeft()));
     //        $tblPerson = Management::servicePerson()->entityPersonAll(); // todo
     $tblPerson = false;
     // todo
     if (!empty($tblPerson)) {
         foreach ($tblPerson as $Person) {
             $PersonType = Management::servicePerson()->entityPersonById($Person->getId())->getTblPersonType();
             $Person->Option = (new Primary('Debitor erstellen', '/Billing/Accounting/Banking/Person/Select', new Edit(), array('Id' => $Person->getId())))->__toString();
             $Person->PersonType = $PersonType->getName();
         }
     }
     $Stage->setContent(new Layout(array(new LayoutGroup(array(new LayoutRow(array(new LayoutColumn(array(new TableData($tblPerson, null, array('FirstName' => 'Vorname', 'MiddleName' => 'Zweitname', 'LastName' => 'Nachname', 'PersonType' => 'Persontyp', 'Option' => 'Debitor hinzufügen')))))))))));
     return $Stage;
 }