aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Assignment.php8
-rw-r--r--classes/Constants.php2
-rw-r--r--classes/Discount.php8
-rw-r--r--classes/Offer.php21
-rw-r--r--classes/Payment.php2
5 files changed, 30 insertions, 11 deletions
diff --git a/classes/Assignment.php b/classes/Assignment.php
index 27efb4a..2ceef94 100644
--- a/classes/Assignment.php
+++ b/classes/Assignment.php
@@ -24,8 +24,8 @@
/**
* An interface to the assignment table in the database
*/
-class Assignment extends Model {
- use Calculatable;
+class Assignment extends Model implements Calculatable {
+ use StandardCalculatable;
public
$table = 'assignment',
@@ -50,11 +50,11 @@ class Assignment extends Model {
return $pd->text($this->description);
}
- protected function calculateSubtotal() {
+ public function calculateSubtotal() {
return $this->hours * $this->price_per_hour;
}
- protected function calculateVAT() {
+ public function calculateVAT() {
return $this->calculateSubtotal() * $this->VAT_percentage / 100;
}
}
diff --git a/classes/Constants.php b/classes/Constants.php
index 3ffadd7..fb2435d 100644
--- a/classes/Constants.php
+++ b/classes/Constants.php
@@ -80,5 +80,5 @@ class Constants {
const password_cost = 10;
/** @const version Version of BusinessAdmin. Don't change this yourself! */
- const version = '0.4.2';
+ const version = '0.5';
}
diff --git a/classes/Discount.php b/classes/Discount.php
index 7216615..4084d43 100644
--- a/classes/Discount.php
+++ b/classes/Discount.php
@@ -24,8 +24,8 @@
/**
* An interface to the discount table in the database
*/
-class Discount extends Model {
- use Calculatable;
+class Discount extends Model implements Calculatable {
+ use StandardCalculatable;
public
$table = 'discount',
@@ -50,11 +50,11 @@ class Discount extends Model {
return $pd->text($this->description);
}
- protected function calculateSubtotal() {
+ public function calculateSubtotal() {
return - $this->value;
}
- protected function calculateVAT() {
+ public function calculateVAT() {
return $this->calculateSubtotal() * $this->VAT_percentage / 100;
}
}
diff --git a/classes/Offer.php b/classes/Offer.php
index 815f626..8fa9ba7 100644
--- a/classes/Offer.php
+++ b/classes/Offer.php
@@ -27,7 +27,7 @@
class Offer extends Model{
public
$table = 'offer',
- $fillable_columns = ['contactId', 'start_date', 'end_date', 'invoice_date', 'accepted', 'invoice_fileId'];
+ $fillable_columns = ['contactId', 'start_date', 'end_date', 'invoice_date', 'accepted', 'invoice_fileId', 'payment_key'];
protected function accessor($key, $value) {
switch ($key) {
@@ -57,6 +57,25 @@ class Offer extends Model{
}
/**
+ * A random max-63-char string that can be used as payment_key
+ *
+ * @return string The random string
+ */
+ public static function getRandomPaymentKey() {
+ return preg_replace('/[^\w]+/', '',
+ base64_encode(openssl_random_pseudo_bytes(45)));
+ }
+
+ /**
+ * Get whether the offer is eligible for online payment or not
+ *
+ * @return bool True iff it is eligible
+ */
+ public function getPaymentEligibility() {
+ return $this->payment_key != '';
+ }
+
+ /**
* Get the contact that this offer is linked to
*
* @return contact The contact
diff --git a/classes/Payment.php b/classes/Payment.php
index e60539f..5bc08dc 100644
--- a/classes/Payment.php
+++ b/classes/Payment.php
@@ -27,7 +27,7 @@
class Payment extends Model {
public
$table = 'payment',
- $fillable_columns = ['offerId', 'date'];
+ $fillable_columns = ['offerId', 'date', 'braintree_id'];
/**
* Get the offer that this payment is linked to