mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support entering payment for draft invoice
This commit is contained in:
parent
eebe61b4d0
commit
00ae1d4a1c
@ -164,8 +164,10 @@ class PaymentController extends BaseController
|
||||
*/
|
||||
public function store(CreatePaymentRequest $request)
|
||||
{
|
||||
$input = $request->input();
|
||||
// check payment has been marked sent
|
||||
$request->invoice->markSentIfUnsent();
|
||||
|
||||
$input = $request->input();
|
||||
$input['invoice_id'] = Invoice::getPrivateId($input['invoice']);
|
||||
$input['client_id'] = Client::getPrivateId($input['client']);
|
||||
$payment = $this->paymentRepo->save($input);
|
||||
|
@ -22,9 +22,8 @@ class CreatePaymentRequest extends PaymentRequest
|
||||
public function rules()
|
||||
{
|
||||
$input = $this->input();
|
||||
$invoice = Invoice::scope($input['invoice'])
|
||||
$this->invoice = $invoice = Invoice::scope($input['invoice'])
|
||||
->invoices()
|
||||
->whereIsPublic(true)
|
||||
->firstOrFail();
|
||||
|
||||
$rules = [
|
||||
|
@ -585,7 +585,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
|
||||
public function canBePaid()
|
||||
{
|
||||
return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice() && $this->is_public;
|
||||
return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice();
|
||||
}
|
||||
|
||||
public static function calcStatusLabel($status, $class, $entityType, $quoteInvoiceId)
|
||||
|
@ -133,7 +133,7 @@ class InvoiceDatatable extends EntityDatatable
|
||||
return URL::to("payments/create/{$model->client_public_id}/{$model->public_id}");
|
||||
},
|
||||
function ($model) use ($entityType) {
|
||||
return $model->is_public && $entityType == ENTITY_INVOICE && $model->balance > 0 && Auth::user()->can('create', ENTITY_PAYMENT);
|
||||
return $entityType == ENTITY_INVOICE && $model->balance > 0 && Auth::user()->can('create', ENTITY_PAYMENT);
|
||||
}
|
||||
],
|
||||
[
|
||||
|
@ -593,6 +593,7 @@ class BasePaymentDriver
|
||||
{
|
||||
$invitation = $this->invitation;
|
||||
$invoice = $this->invoice();
|
||||
$invoice->markSentIfUnsent();
|
||||
|
||||
$payment = Payment::createNew($invitation);
|
||||
$payment->invitation_id = $invitation->id;
|
||||
|
@ -316,8 +316,7 @@ class InvoiceRepository extends BaseRepository
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
// set default to true for backwards compatability
|
||||
if ( ! isset($data['is_public']) || filter_var($data['is_public'], FILTER_VALIDATE_BOOLEAN)) {
|
||||
if (isset($data['is_public']) && filter_var($data['is_public'], FILTER_VALIDATE_BOOLEAN)) {
|
||||
$invoice->is_public = true;
|
||||
if ( ! $invoice->isSent()) {
|
||||
$invoice->invoice_status_id = INVOICE_STATUS_SENT;
|
||||
@ -773,9 +772,7 @@ class InvoiceRepository extends BaseRepository
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $invoice->isSent()) {
|
||||
$this->markSent($invoice);
|
||||
}
|
||||
$invoice->markSentIfUnsent();
|
||||
|
||||
$data = [
|
||||
'client_id' => $invoice->client_id,
|
||||
|
@ -364,6 +364,11 @@ class ImportService
|
||||
private function saveData($source, $entityType, $row, $data_index)
|
||||
{
|
||||
$data = $this->processedRows[$data_index];
|
||||
|
||||
if ($entityType == ENTITY_INVOICE) {
|
||||
$data['is_public'] = true;
|
||||
}
|
||||
|
||||
$entity = $this->{"{$entityType}Repo"}->save($data);
|
||||
|
||||
// update the entity maps
|
||||
|
@ -58,6 +58,8 @@ class PaymentService extends BaseService
|
||||
return false;
|
||||
}
|
||||
|
||||
$invoice->markSentIfUnsent();
|
||||
|
||||
if ($credits = $client->credits->sum('balance')) {
|
||||
$balance = $invoice->balance;
|
||||
$amount = min($credits, $balance);
|
||||
|
@ -30,7 +30,9 @@ class SupportNewPricing extends Migration
|
||||
// https://github.com/invoiceninja/invoiceninja/pull/955
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
$table->integer('task_id')->after('invitation_id')->nullable();
|
||||
$table->unsignedInteger('client_id')->nullable()->change();
|
||||
if (Schema::hasColumn('activities', 'client_id')) {
|
||||
$table->unsignedInteger('client_id')->nullable()->change();
|
||||
}
|
||||
});
|
||||
|
||||
// This may fail if the table was created as MyISAM
|
||||
|
Loading…
x
Reference in New Issue
Block a user