Working on partial due date

This commit is contained in:
Hillel Coren 2017-10-26 00:35:38 +03:00
parent ae962ecc70
commit 86e8c09701
7 changed files with 44 additions and 15 deletions

View File

@ -24,6 +24,10 @@ class AddDefaultRates extends Migration
$table->decimal('task_rate', 12, 4)->default(0);
});
Schema::table('invoices', function ($table) {
$table->date('partial_due_date')->nullable();
});
// Add 'Four Months' frequency option
if (DB::table('frequencies')->count() == 8) {
DB::table('frequencies')->where('id', '=', 7)->update(['name' => 'Four months']);
@ -53,5 +57,9 @@ class AddDefaultRates extends Migration
Schema::table('projects', function ($table) {
$table->dropColumn('task_rate');
});
Schema::table('invoices', function ($table) {
$table->dropColumn('partial_due_date');
});
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -616,7 +616,7 @@ body {
}
*/
div.discount-group span {
div.no-padding-or-border span {
padding: 0px;
border: none;
}
@ -1412,3 +1412,8 @@ div.panel-body div.panel-body {
vertical-align: top;
width: 140px;
}
.no-gutter > [class*='col-'] {
padding-right:0;
padding-left:0;
}

View File

@ -173,8 +173,25 @@
{!! Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->label($account->getLabel($invoice->getDueDateLabel()))
->placeholder($invoice->id || $invoice->isQuote() ? ' ' : $account->present()->dueDatePlaceholder())
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('due_date') !!}
{!! Former::text('partial')->data_bind("value: partial, valueUpdate: 'afterkeydown'")->onkeyup('onPartialChange()')
->addGroupClass('partial')!!}
<div class="form-group partial">
<label for="partial" class="control-label col-lg-4 col-sm-4">{{ trans('texts.partial') }}</label>
<div class="col-lg-8 col-sm-8 no-gutter">
<div data-bind="css: {'col-md-4': isPartialSet(), 'col-md-12': ! isPartialSet()}">
{!! Former::text('partial')->data_bind("value: partial, valueUpdate: 'afterkeydown'")
->onkeyup('onPartialChange()')
->raw() !!}
</div>
<div class="col-lg-8 no-gap">
{!! Former::text('partial_due_date')
->placeholder('due_date')
->style('display: none')
->data_bind("datePicker: partial_due_date, valueUpdate: 'afterkeydown', visible: isPartialSet")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))
->raw() !!}
</div>
</div>
</div>
</div>
@if ($entityType == ENTITY_INVOICE)
<div data-bind="visible: is_recurring" style="display: none">
@ -228,7 +245,7 @@
</span>
{!! Former::text('po_number')->label($account->getLabel('po_number', 'po_number_short'))->data_bind("value: po_number, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'")
->addGroupClass('discount-group')->type('number')->min('0')->step('any')->append(
->addGroupClass('no-padding-or-border')->type('number')->min('0')->step('any')->append(
Former::select('is_amount_discount')
->addOption(trans('texts.discount_percent'), '0')
->addOption(trans('texts.discount_amount'), '1')
@ -951,7 +968,7 @@
$('[rel=tooltip]').tooltip({'trigger':'manual'});
$('#invoice_date, #due_date, #start_date, #end_date, #last_sent_date').datepicker();
$('#invoice_date, #due_date, #start_date, #end_date, #last_sent_date, #partial_due_date').datepicker();
@if ($invoice->client && !$invoice->id)
$('input[name=client]').val({{ $invoice->client->public_id }});
@ -983,7 +1000,7 @@
});
}
$('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #start_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial, #custom_text_value1, #custom_text_value2').change(function() {
$('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #partial_due_date, #start_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial, #custom_text_value1, #custom_text_value2').change(function() {
$('#downloadPdfButton').attr('disabled', true);
setTimeout(function() {
refreshPDF(true);

View File

@ -27,8 +27,7 @@ function ViewModel(data) {
self.setDueDate = function() {
@if ($entityType == ENTITY_INVOICE)
var paymentTerms = parseInt(self.invoice().client().payment_terms());
if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date())
{
if (paymentTerms && paymentTerms != 0 && !self.invoice().due_date()) {
if (paymentTerms == -1) paymentTerms = 0;
var dueDate = $('#invoice_date').datepicker('getDate');
dueDate.setDate(dueDate.getDate() + paymentTerms);
@ -257,6 +256,7 @@ function InvoiceModel(data) {
self.partial = ko.observable(0);
self.has_tasks = ko.observable();
self.has_expenses = ko.observable();
self.partial_due_date = ko.observable('');
self.custom_value1 = ko.observable(0);
self.custom_value2 = ko.observable(0);
@ -620,6 +620,10 @@ function InvoiceModel(data) {
var isAmountDiscount = $('#is_amount_discount').val();
localStorage.setItem('last:is_amount_discount', isAmountDiscount);
}
self.isPartialSet = ko.computed(function() {
return self.partial() && self.partial() <= model.invoice().totals.rawTotal()
});
}
function ClientModel(data) {

View File

@ -86,11 +86,6 @@
text-decoration:underline;
}
.no-gutter > [class*='col-'] {
padding-right:0;
padding-left:0;
}
.list-group-item:before {
position: absolute;
top: 0;