public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $service = new CompanyService();
     $em = $serviceLocator->get('em');
     $service->setEm($em);
     return $service;
 }
Esempio n. 2
0
 public function removeBankRowAction()
 {
     if ($this->request->isPost() && $this->request->isXmlHttpRequest()) {
         $bank = $this->companyService->getBankById($this->request->getPost()->bankId);
         if ($bank) {
             $this->companyService->deleteBank($bank);
         }
     }
     return $this->response;
 }
Esempio n. 3
0
 private function getCompanyValues()
 {
     $results = array();
     foreach ($this->companyService->getCompanyByUser($this->user) as $company) {
         $results[$company->getId()] = $company->getName() . '-' . $company->getRegNo();
     }
     return $results;
 }
Esempio n. 4
0
 public function saveInvoiceWithParams(Document $invoice = null, User $user, array $data, $type)
 {
     if (!$invoice) {
         $company = $this->companyService->getCompanyByUser($user);
         if (!$company) {
             $this->companyService->setDefaultUserCompany($user);
             $company = $this->companyService->getCompanyByUser($user);
         }
         if ($type == Document::TYPE_INVOICE) {
             $invoice = new Invoice();
         } elseif ($type == Document::TYPE_PURCHASE_INVOICE) {
             $invoice = new Document\PurchaseInvoice();
         } elseif ($type == Document::TYPE_CREDIT_INVOICE) {
             $invoice = new Document\CreditInvoice();
         }
         $invoice->setCompany($company);
         $invoice->setUser($user);
         $invoice->setCreatedBy($user);
     }
     if (isset($data['customer']) && $data['customer'] > 0) {
         $customer = $this->customerService->getCustomerById($data['customer']);
         if ($customer) {
             $invoice->setCustomer($customer);
         }
     }
     if (isset($data['supplier']) && $data['supplier'] > 0) {
         $supplier = $this->supplierService->getSupplierById($data['supplier']);
         if ($supplier) {
             $invoice->setSupplier($supplier);
         }
     }
     if (isset($data['vat']) && $data['vat'] > 0) {
         $vat = $this->settingsService->getVatById($data['vat']);
         if ($vat) {
             $invoice->setVat($vat);
         }
     }
     if (isset($data['docDate'])) {
         $docDate = \DateTime::createFromFormat('d.m.Y', $data['docDate']);
         if (!$docDate) {
             $docDate = new \DateTime();
         }
         $deadLine = clone $docDate;
         $deadlineDays = isset($data['deadlineDays']) && $data['deadlineDays'] > 0 ? $data['deadlineDays'] : 0;
         $deadLine = $deadLine->add(new \DateInterval('P' . $deadlineDays . 'D'));
         $invoice->setDocumentDate($docDate);
         $invoice->setPaymentDate($deadLine);
     }
     if (isset($data['deadlineDays'])) {
         $invoice->setDeadlineDays($data['deadlineDays']);
     }
     if (isset($data['supplierDocNumber'])) {
         $invoice->setSupplierDocumentNumber($data['supplierDocNumber']);
     }
     if (isset($data['amount'])) {
         $invoice->setAmount($data['amount']);
     }
     if (isset($data['delayPercent'])) {
         $invoice->setDelayPercent($data['delayPercent']);
     }
     if (isset($data['taxAmount'])) {
         $invoice->setTaxAmount($data['taxAmount']);
     }
     if (isset($data['paymentType'])) {
         $invoice->setPaymentType($data['paymentType']);
     }
     if (isset($data['amountTax'])) {
         $invoice->setAmountTax($data['amountTax']);
     }
     if (isset($data['amountTax'])) {
         $invoice->setAmountTax($data['amountTax']);
     }
     if (isset($data['comment'])) {
         $invoice->setComment($data['comment']);
     }
     return $this->saveInvoiceRows($invoice, $data);
 }