Support editing credit balance

This commit is contained in:
Hillel Coren 2017-02-26 20:29:45 +02:00
parent a6eb37151e
commit 0a2f2593f8
2 changed files with 8 additions and 2 deletions

View File

@ -96,18 +96,19 @@ class CreditRepository extends BaseRepository
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;
if ($credit) { if ($credit) {
// do nothing $credit->balance = Utils::parseFloat($input['balance']);
} elseif ($publicId) { } elseif ($publicId) {
$credit = Credit::scope($publicId)->firstOrFail(); $credit = Credit::scope($publicId)->firstOrFail();
$credit->balance = Utils::parseFloat($input['balance']);
\Log::warning('Entity not set in credit repo save'); \Log::warning('Entity not set in credit repo save');
} else { } else {
$credit = Credit::createNew(); $credit = Credit::createNew();
$credit->balance = Utils::parseFloat($input['amount']);
$credit->client_id = Client::getPrivateId($input['client']); $credit->client_id = Client::getPrivateId($input['client']);
} }
$credit->credit_date = Utils::toSqlDate($input['credit_date']); $credit->credit_date = Utils::toSqlDate($input['credit_date']);
$credit->amount = Utils::parseFloat($input['amount']); $credit->amount = Utils::parseFloat($input['amount']);
$credit->balance = Utils::parseFloat($input['amount']);
$credit->private_notes = trim($input['private_notes']); $credit->private_notes = trim($input['private_notes']);
$credit->save(); $credit->save();

View File

@ -28,6 +28,11 @@
@endif @endif
{!! Former::text('amount') !!} {!! Former::text('amount') !!}
@if ($credit)
{!! Former::text('balance') !!}
@endif
{!! Former::text('credit_date') {!! Former::text('credit_date')
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT)) ->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))
->addGroupClass('credit_date') ->addGroupClass('credit_date')