Bug correction in global payback

Bug correction in global paybacks, should now work fine.
This commit is contained in:
Phyks 2013-11-04 21:12:22 +01:00
parent 523daa3f00
commit 7a3d414536
4 changed files with 47 additions and 26 deletions

1
TODO
View File

@ -1,4 +1,5 @@
* Notifications by e-mail for users * Notifications by e-mail for users
* Simplify matrix
Improvements : Improvements :
============== ==============

20
inc/UsersInGlobalPayback.class.php Normal file → Executable file
View File

@ -26,7 +26,15 @@
} }
public function get() { public function get() {
return $this->users_list; // Note : store amounts as int in database
$display = array();
foreach($this->users_list as $key1=>$temp) {
foreach($temp as $key2=>$amount) {
$display[$key1][$key2] = (float) ($amount / 100);
}
}
return $display;
} }
// Setters // Setters
@ -36,7 +44,15 @@
} }
public function set($users_in) { public function set($users_in) {
$this->users_list = $users_in; // Note : store amounts as int in database
$store = array();
foreach($users_in as $key1=>$temp) {
foreach($temp as $key2=>$amount) {
$store[$key1][$key2] = (int) ($amount * 100);
}
}
$this->users_list = $store;
} }
// Maps htmlspecialchars on the class before display // Maps htmlspecialchars on the class before display

4
index.php Normal file → Executable file
View File

@ -903,6 +903,7 @@
if($invoices !== false) { if($invoices !== false) {
foreach($invoices as $invoice) { foreach($invoices as $invoice) {
if($invoice->getAmountPerPerson($user1_id) !== false) {
$paybacks = new Payback(); $paybacks = new Payback();
$paybacks = $paybacks->load(array('invoice_id'=>$invoice->getId(), 'to_user'=>$user2_id, 'from_user'=>$user1_id)); $paybacks = $paybacks->load(array('invoice_id'=>$invoice->getId(), 'to_user'=>$user2_id, 'from_user'=>$user1_id));
@ -920,6 +921,7 @@
} }
} }
} }
}
// Confirm all paybacks when from is buyer // Confirm all paybacks when from is buyer
$invoices = new Invoice(); $invoices = new Invoice();
@ -927,6 +929,7 @@
if($invoices !== false) { if($invoices !== false) {
foreach($invoices as $invoice) { foreach($invoices as $invoice) {
if($invoice->getAmountPerPerson($user2_id) !== false) {
$paybacks = new Payback(); $paybacks = new Payback();
$paybacks = $paybacks->load(array('invoice_id'=>$invoice->getId(), 'to_user'=>$user1_id, 'from_user'=>$user2_id)); $paybacks = $paybacks->load(array('invoice_id'=>$invoice->getId(), 'to_user'=>$user1_id, 'from_user'=>$user2_id));
@ -947,6 +950,7 @@
} }
} }
} }
}
$global_payback->setUsersIn($users_in); $global_payback->setUsersIn($users_in);

0
install.php Normal file → Executable file
View File