Rework payment tables, enable payment editing

This commit is contained in:
Deon George
2021-07-23 17:25:26 +10:00
parent fa62a47680
commit d463239b17
19 changed files with 352 additions and 116 deletions

View File

@@ -8,19 +8,29 @@ use App\Traits\{NextKey,PushNew};
class PaymentItem extends Model
{
use NextKey,PushNew;
use PushNew;
const RECORD_ID = 'payment_item';
public $incrementing = FALSE;
protected $dateFormat = 'U';
const CREATED_AT = 'date_orig';
const UPDATED_AT = 'date_last';
protected $table = 'ab_payment_item';
/* RELATIONS */
public function payment() {
return $this->belongsTo(Payment::class);
}
/* ATTRIBUTES */
/**
* If our amount is negative, and invoice_id is null, then this is a reversal.
*
* @param $value
* @return float
*/
public function getAllocAmtAttribute($value): float
{
return (is_null($this->invoice_id) && $value < 0) ? -$value : $value;
}
}