public function testbalance() { $actual = $this->ProductCredit->balance(1, 203776, 2003031); //debug($actual);exit; $expected = money::fromFloat(800.0); $this->assertEquals($actual, $expected); $actual = $this->ProductCredit->balance(1, 1, 1); $expected = money::fromFloat(-935.0); $this->assertEquals($actual, $expected); $actual = $this->ProductCredit->balance(1, 2, 2); $expected = money::fromFloat(0.0); $this->assertEquals($actual, $expected); $actual = $this->ProductCredit->balance(2, 563, 767); $expected = money::fromFloat(200.0); $this->assertEquals($actual, $expected); $actual = $this->ProductCredit->balance(3, 28127, 94063); $expected = money::fromFloat(100.0); $this->assertEquals($actual, $expected); $actual = $this->ProductCredit->balance(4, 32398, 262336); $expected = money::fromFloat(100.0); $this->assertEquals($actual, $expected); $actual = $this->ProductCredit->balance(5, 1066, 7555); $expected = money::fromFloat(125.0); $this->assertEquals($actual, $expected); }
public function testCalculatePartyTotal() { $total = $this->Order->calculatePartyTotal(1); $this->assertEqual($total, money::fromFloat(30)); $total = $this->Order->calculatePartyTotal(300); $this->assertEqual($total, money::fromFloat(0)); }
<?php require 'money.php'; require 'currency.php'; $kwota = money::EUR(666); var_dump($kwota); list($zaliczka1, $zaliczka2, $reszta) = $kwota->allocate([43, 6, 51]); $zaliczkaPlusVat = $zaliczka1->add(money::GBP(200)); $zaliczkaOstateczna = $zaliczkaPlusVat->substract(money::PLN(50)); var_dump((string) $zaliczka1, (string) $zaliczkaPlusVat, (string) $zaliczkaOstateczna); $kwotaPLN = money::PLN(0)->add($zaliczkaOstateczna); var_dump((string) $kwotaPLN); $kwotaPLN2 = $zaliczkaOstateczna->convertTo('PLN'); var_dump((string) $kwotaPLN2); $vat = $kwotaPLN->multiply(0.23); var_dump((string) $vat); $vat = $kwotaPLN->multiply(0.77); var_dump((string) $vat); var_dump($kwotaPLN->equals($kwotaPLN2)); var_dump($zaliczkaOstateczna->isSameAmount($kwotaPLN)); var_dump((string) $kwota); var_dump((string) $kwota->add(money::CLP(500))); var_dump((string) $kwota->add(money::CLP(500))->convertTo('CLP')); $string = file_get_contents('http://rozumiem.blox.pl/2008/10/Kursy-walut-8211-wartosc-pieniadza.html'); money::parseMoneyFromString($string);
public function testIsSameAmountStrict() { $a = money::USD(123); $a->setRestrictionToSameCurrency(true); $this->assertEquals(true, $a->isSameAmount(money::EUR(123))); }
public function convertTo($currencyName) { $converted = new money(0, new currency($currencyName)); return $converted->add($this); }
<?php /****************** * 查询OR转账文件 * by hg ******************/ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; $array = array(); $array['purpose'] = isset($_REQUEST['purpose']) ? intval($_REQUEST['purpose']) : ''; $array['from'] = isset($_REQUEST['from']) ? intval($_REQUEST['from']) : ''; $array['account'] = isset($_REQUEST['account']) ? $_REQUEST['account'] : ''; $array['money'] = isset($_REQUEST['money']) ? $_REQUEST['money'] : ''; $array['sign'] = isset($_REQUEST['sign']) ? $_REQUEST['sign'] : ''; if (empty($array)) { return false; } $obj_money = new money(); $return_msg = $obj_money->check_sign($array); //效验数据 if ($return_msg !== true) { echo json_encode($obj_money->return_msg()); die; } $obj_money->dispose(); echo json_encode($obj_money->return_msg());
echo json_encode(array('error' => true, 'message' => 'Failed to update money. Please try again')); } }); $app->get('/money', 'authenticate', function () { global $user_id; $response = array(); $db = new money(); $result = $db->getMoney(); echo json_encode($result); }); $app->get('/money/:id', 'authenticate', function ($idMoney) use($app) { global $user_id; $response = array(); $start = $app->request()->params('start'); $end = $app->request()->params('end'); $db = new money(); $result = $db->getHistoryMoney($idMoney, $start, $end); if ($result != NULL) { echo json_encode(array('id' => $idMoney, 'name' => $db->getNameById($idMoney)['name'], 'prices' => $result)); } else { echo json_encode(array('error' => true, 'message' => 'Failed to get money. Please try again')); } }); $app->get('/messages', 'authenticate', function () { global $user_id; $response = array(); $db = new messages(); $result = $db->getMessages(); echo json_encode(array('error' => false, 'message' => $result)); }); $app->put('/messages', 'authenticate', function () use($app) {
public function testAnonymousPartyList() { $list = $this->Order->anonymousPartyListing(1566525); $result = array((int) 0 => array('id' => '2973695', 'buyer' => 'test', 'facebookid' => '', 'date' => '2015-12-31 21:57:56', 'point_total' => '39.00', 'amount' => money::fromFloat(39))); $this->assertEquals($list, $result); }