Esempio n. 1
0
 public function testImportRealData()
 {
     $fname = realpath(__DIR__ . '/templates.kml');
     $raw = file_get_contents($fname);
     $kml = new VISMAkml();
     $kml->import($raw);
     // Build representation in file
     $AA = new Template();
     $AA->setId('AA');
     $AA->setName('Inbetald AA-avgift');
     $AA->setText('Medl.fakt. {F-nr} ({M-nr}) ({OCR}) åäö');
     $AA->addTransaction('3000', '-450');
     $AA->addTransaction('4110', '{SAC-AA}');
     $AA->addTransaction('2421', '-{SAC-AA}');
     $AA->addTransaction('4120', '{Sodra-AA}');
     $AA->addTransaction('2422', '-{Sodra-AA}');
     $AA->addTransaction('{Betkanal}', '{Summa}');
     $AA1 = new Template();
     $AA1->setId('AA1');
     $AA1->setName('Inbetald AA-avgift');
     $AA1->setText('Medl.fakt. {F-nr} ({M-nr}) ({OCR})');
     $AA1->addTransaction('3000', '-450');
     $AA1->addTransaction('4110', '{SAC-AA}');
     $AA1->addTransaction('2421', '-{SAC-AA}');
     $AA1->addTransaction('4120', '{Sodra-AA}');
     $AA1->addTransaction('2422', '-{Sodra-AA}');
     $AA1->addTransaction('{Betkanal}', '{Summa}');
     $expected = array('AA' => $AA, 'AA1' => $AA1);
     // Assert equality
     $this->assertEquals($expected, $kml->getTemplates());
 }
Esempio n. 2
0
 /**
  * @expectedException ledgr\accounting\Exception\UnexpectedValueException
  */
 public function testMissingAmountKey()
 {
     $t = new Template();
     $t->addTransaction('3000', '-{value}');
     $t->buildVerification($this->getChart());
 }
Esempio n. 3
0
 /**
  * Import templates from VISMA kml format
  *
  * @param  string $kml Must be ISO-8859-1 charset
  * @return void
  */
 public function import($kml)
 {
     $kml = iconv("ISO-8859-1", "UTF-8", $kml);
     $data = @parse_ini_string($kml, true, INI_SCANNER_RAW);
     foreach ($data as $values) {
         $id = isset($values['id']) ? $values['id'] : '';
         $name = isset($values['namn']) ? $values['namn'] : '';
         $text = isset($values['text']) ? $values['text'] : '';
         $template = new Template();
         $template->setId($id);
         $template->setName($name);
         $template->setText($text);
         $index = 0;
         while (true) {
             // Break when there are no more transactions
             if (!isset($values["Rad{$index}_konto"]) || !isset($values["Rad{$index}_belopp"])) {
                 break;
             }
             // Add this transaction
             $template->addTransaction($values["Rad{$index}_konto"], $values["Rad{$index}_belopp"]);
             $index++;
         }
         $this->addTemplate($template);
     }
 }