コード例 #1
0
ファイル: ArticleCsv.php プロジェクト: carriercomm/Billing-5
 /**
  * add some more values (container id)
  *
  * @return array
  */
 protected function _addData($recordData)
 {
     $result = array();
     $aC = Billing_Controller_ArticleGroup::getInstance();
     $aGroup = $aC->getByName('Urkunden');
     $pC = Billing_Controller_PriceGroup::getInstance();
     $pGDiver = $pC->getByName('Taucher');
     $pGMember = $pC->getByName('Mitglied');
     $pGMTI = $pC->getByName('MTI');
     $pGMTA = $pC->getByName('MTA');
     $mwst = floor(($recordData['VK1'] / $recordData['VK1EXKL'] - 1) * 100);
     if ($mwst > 8) {
         $mwst = 19;
     } elseif ($mwst < 7) {
         $mwst = 0;
     }
     $vatId = Billing_Controller_Vat::getInstance()->getByName($mwst);
     $articleUnit = Billing_Controller_ArticleUnit::getInstance()->getByName('Stück');
     if ($mwst == 19) {
         $recordData['VK1EXKL'] = $recordData['VK1'] / 1.19;
         $recordData['VK2EXKL'] = $recordData['VK2'] / 1.19;
         $recordData['VK3EXKL'] = $recordData['VK3'] / 1.19;
     }
     $priceGroups['DIVER'] = array('id' => $pGDiver->getId(), 'netto' => $recordData['VK1EXKL'], 'brutto' => $recordData['VK1']);
     $priceGroups['MEMBER'] = array('id' => $pGMember->getId(), 'netto' => $recordData['VK2EXKL'], 'brutto' => $recordData['VK2']);
     $priceGroups['MTI'] = array('id' => $pGMTI->getId(), 'netto' => $recordData['VK3EXKL'], 'brutto' => $recordData['VK3']);
     $priceGroups['MTA'] = array('id' => $pGMTA->getId(), 'netto' => $recordData['VK3EXKL'], 'brutto' => $recordData['VK3']);
     $result['article_group_id'] = $aGroup->getId();
     $result['prices'] = $priceGroups;
     $result['vat_id'] = $vatId;
     $result['article_unit_id'] = $articleUnit->getId();
     return $result;
 }
コード例 #2
0
ファイル: ArticleUnit.php プロジェクト: carriercomm/Billing-5
 /**
  * the singleton pattern
  *
  * @return SoEventManager_Controller_SoEvent
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #3
0
 /**
  * add some more values (container id)
  *
  * @return array
  */
 protected function _addData($recordData)
 {
     $result = array();
     $priceGroupId = 1;
     $articleGroupId = null;
     if ($recordData['article_ext_nr']) {
         $isbn = $recordData['article_ext_nr'];
         if (strpos($isbn, 'WS')) {
             $articleGroupId = 5;
         } elseif (strpos($isbn, 'WK')) {
             $articleGroupId = 4;
         } elseif (strpos($isbn, 'OG')) {
             $articleGroupId = 3;
         } elseif (strpos($isbn, 'FB')) {
             $articleGroupId = 2;
         } elseif (strpos($isbn, 'EB')) {
             $articleGroupId = 1;
         }
     }
     if (!$articleGroupId) {
         $articleGroupId = 1;
     }
     $result['article_group_id'] = $articleGroupId;
     $pC = Billing_Controller_PriceGroup::getInstance();
     $pGEmpf = $pC->getByName('Empfohlen');
     $pGMitgl = $pC->getByName('Mitglied');
     $pGEntn = $pC->getByName('Entnahme');
     $vatId = Billing_Controller_Vat::getInstance()->getByName(7);
     $articleUnit = Billing_Controller_ArticleUnit::getInstance()->getByName('Stück');
     $recordData['mitgl_preis'] = str_replace(',', '.', $recordData['mitgl_preis']);
     $recordData['entn_preis'] = str_replace(',', '.', $recordData['entn_preis']);
     $recordData['empf_preis'] = str_replace(',', '.', $recordData['empf_preis']);
     if (!is_numeric($recordData['mitgl_preis'])) {
         $recordData['mitgl_preis'] = 0;
     } else {
         $recordData['mitgl_preis'] = abs((double) $recordData['mitgl_preis']);
     }
     if (!is_numeric($recordData['entn_preis'])) {
         $recordData['entn_preis'] = 0;
     } else {
         $recordData['entn_preis'] = abs((double) $recordData['entn_preis']);
     }
     if (!is_numeric($recordData['empf_preis'])) {
         $recordData['empf_preis'] = 0;
     } else {
         $recordData['empf_preis'] = abs((double) $recordData['empf_preis']);
     }
     $priceGroups['MITGL'] = array('id' => $pGMitgl->getId(), 'netto' => $recordData['mitgl_preis'], 'brutto' => $recordData['mitgl_preis'] * 1.07);
     $priceGroups['ENTN'] = array('id' => $pGEntn->getId(), 'netto' => $recordData['entn_preis'], 'brutto' => $recordData['entn_preis'] * 1.07);
     $priceGroups['EMPF'] = array('id' => $pGEmpf->getId(), 'netto' => $recordData['empf_preis'], 'brutto' => $recordData['empf_preis'] * 1.07);
     $result['prices'] = $priceGroups;
     $result['vat_id'] = $vatId;
     $result['article_unit_id'] = $articleUnit->getId();
     return $result;
 }
コード例 #4
0
ファイル: Json.php プロジェクト: carriercomm/Billing-5
 public function saveArticleUnit($recordData)
 {
     return $this->_save($recordData, Billing_Controller_ArticleUnit::getInstance(), 'ArticleUnit');
 }
コード例 #5
0
ファイル: Order.php プロジェクト: carriercomm/Billing-5
 /**
  * 
  * add positions to order
  * @param unknown_type $orderId
  * @param unknown_type $positions
  * @param unknown_type $debitor
  */
 public function addOrderPositions($orderId, $positions, $debitor)
 {
     $orderPositionController = Billing_Controller_OrderPosition::getInstance();
     $articleController = Billing_Controller_Article::getInstance();
     // create order positions
     $posCount = 0;
     foreach ($positions as $position) {
         ++$posCount;
         $articleId = $position['article_id'];
         if ($articleId) {
             $article = $articleController->get($articleId);
             $orderPos = $orderPositionController->getPositionFromArticle($article, $debitor, $position);
         } else {
             $order = $this->get($orderId);
             $order->flatten();
             $orderPos = new Billing_Model_OrderPosition(null, true);
             $orderPos->__set('price_group_id', $order->__get('price_group_id'));
             $unitId = Billing_Controller_ArticleUnit::getInstance()->get(1);
             $vatId = Billing_Controller_Vat::getInstance()->get(1);
             $vat2Id = Billing_Controller_Vat::getInstance()->getByName(0);
             $orderPos->__set('amount', $position['amount']);
             $orderPos->__set('unit_id', $unitId);
             $orderPos->__set('vat_id', $vatId);
             $orderPos->__set('price2_vat_id', $vat2Id);
             $orderPos->__set('name', $position['name']);
             if (array_key_exists('additionalData', $position)) {
                 $orderPos->setAdditionalData($position['additionalData']);
             }
         }
         $orderPos->__set('position_nr', $posCount);
         $orderPos->__set('price_brutto', $position['price_brutto']);
         $orderPos->__set('price_netto', $position['price_netto']);
         $orderPos->__set('total_brutto', $position['total_brutto']);
         $orderPos->__set('total_netto', $position['total_netto']);
         //$orderPos->__set('price2_brutto', ($position['price2_brutto']?$position['price2_brutto'],0));
         $orderPos->__set('price2_brutto', $position['price2_brutto'] ? $position['price2_brutto'] : 0);
         $orderPos->__set('price2_brutto', $position['price2_netto'] ? $position['price2_netto'] : 0);
         $orderPos->__set('price2_brutto', $position['total2_brutto'] ? $position['total2_brutto'] : 0);
         $orderPos->__set('price2_brutto', $position['total2_netto'] ? $position['total2_netto'] : 0);
         $orderPos->__set('price2_brutto', $position['total1_brutto'] ? $position['total1_brutto'] : 0);
         $orderPos->__set('price2_brutto', $position['total1_netto'] ? $position['total1_netto'] : 0);
         $orderPos->__set('order_id', $orderId);
         $orderPositionController->create($orderPos);
     }
 }