Skip to content

Commit

Permalink
#97: отображение сводки по аренде
Browse files Browse the repository at this point in the history
  • Loading branch information
sedovalx committed Jul 14, 2015
1 parent 045a330 commit 9a6cea4
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 37 deletions.
4 changes: 2 additions & 2 deletions sources/client/app/controllers/cashier-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export default ListController.extend({
this.set('date','');
this.transitionToRoute("cashier-list", {queryParams: null});
},
gotoHistory: function(){
gotoRentInfo: function(){
let selected = this.get("selectedRow");
let rentId = selected.get("rentId");
if (rentId != null)
this.transitionToRoute("rent.edit", rentId, { queryParams: { tab: "history" } })
this.transitionToRoute("rent.edit", rentId, { queryParams: { tab: "total" } })
}
},
selectionRentIsEmpty: function(){
Expand Down
9 changes: 8 additions & 1 deletion sources/client/app/controllers/rent/edit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import RentController from "client/controllers/base/rent-controller";
/* global moment */
// No import for moment, it's a global called `moment`

export default RentController.extend({
queryParams: ['tab'],
tab: "general",
isGeneral: function(){
return this.get('tab') !== 'history';
return this.get('tab') !== 'total';
}.property('tab'),
minutesHumanize: function(){
let minutes = this.get('rentTotal.minutes');
let a = moment.duration(minutes, 'minutes');
return Math.floor(a.asDays()) + ' дней ' + a.hours() + ' часов ' + a.minutes() + ' минут';
}.property('rentTotal.minutes'),
actions: {
showOperation: function(operation){
this.transitionToRoute('operations.edit', operation.operationId);
Expand Down
6 changes: 4 additions & 2 deletions sources/client/app/routes/rent/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ export default ProtectedRoute.extend(DirtyRouteMixin, {
model: function(params, transition){
return Ember.RSVP.all([
this.store.find("rent", transition.params.rent.rent_id),
Ember.$.getJSON('/api/reports/q-rent-history', { rent: transition.params.rent.rent_id })
Ember.$.getJSON('/api/reports/q-rent-history', { rent: transition.params.rent.rent_id }),
Ember.$.getJSON('/api/reports/q-rent-total', { rent: transition.params.rent.rent_id })
]);
},
setupController: function(controller, data){
// see https://babeljs.io/docs/learn-es2015/#destructuring
let [model, history] = data;
let [model, history, total] = data;
controller.set('model', model);
controller.set('history', defineAmountSign(history));
controller.set('rentTotal', total);
},
actions: {
invalidateModel: function(){
Expand Down
8 changes: 5 additions & 3 deletions sources/client/app/styles/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
@main-content-side-margin: 50px;

html, body, .application {
height: 100%;
width: 100%;
//height: 100%;
//width: 100%;
}

body > .ember-view {
Expand All @@ -18,14 +18,16 @@ body > .ember-view {

.application {

.app-header.affix {
.app-header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1;
}

.app-content {
margin-top: 60px;
margin-left: @main-content-side-margin;
margin-right: @main-content-side-margin;
min-width: 869px;
Expand Down
4 changes: 4 additions & 0 deletions sources/client/app/styles/editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

.commands-panel {
margin-top: 10px;

&.affix {
border: red 2px solid;
}
}

.ember-view.has-error {
Expand Down
2 changes: 1 addition & 1 deletion sources/client/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="application">
<div class="app-header" data-spy="affix" data-offset-top="1">
<div class="app-header">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
Expand Down
4 changes: 2 additions & 2 deletions sources/client/app/templates/cashier-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<button type="button" class="btn btn-primary" {{action "createChargeOperation"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-taxi"></i> Создать списание
</button>
<button type="button" class="btn btn-primary" {{action "gotoHistory"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-rub"></i> Просмотр истории по аренде
<button type="button" class="btn btn-primary" {{action "gotoRentInfo"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-rub"></i> Просмотр сводки по аренде
</button>
</div>
</div>
2 changes: 1 addition & 1 deletion sources/client/app/templates/components/save-cancel.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="command-panel" data-spy="affix" data-offset-bottom="1">
<div class="command-panel clearfix" data-spy="affix">
<div class="buttons btn-group pull-right" role="group">
<button type="button" class="btn btn-primary" {{action "save"}} {{bind-attr disabled=isSaveDisabled}}>
<i class="fa fa-floppy-o"></i> Сохранить
Expand Down
93 changes: 71 additions & 22 deletions sources/client/app/templates/rent/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a href="#general" aria-controls="general" role="tab" data-toggle="tab" {{action "changeTab" "general"}}>Основное</a>
</li>
<li role="presentation" {{bind-attr class="isGeneral::active"}}>
<a href="#history" aria-controls="history" role="tab" data-toggle="tab" {{action "changeTab" "history"}}>История</a>
<a href="#total" aria-controls="total" role="tab" data-toggle="tab" {{action "changeTab" "total"}}>Сводка</a>
</li>
</ul>
<div class="tab-content">
Expand All @@ -29,30 +29,79 @@
{{property-row title="Примечания" value=comment}}
</form>
</div>
<div role="tabpanel" id="history" {{bind-attr class=":tab-pane isGeneral::active"}}>
<div class="history-container container-fluid">
{{#each status in history}}
<div class="history-item status row">
<div class="col-md-1 status-icon">
<i class="fa fa-bell"></i>
</div>
<div class="col-md-4">{{format-date status.changeTime}}</div>
<div class="col-md-5">{{rent-status status.status}}</div>
</div>
<div class="operations-container">
{{#each op in status.operations}}
<div {{bind-attr class=":history-item :operation :row op.isPositive:positive:negative"}} {{action "showOperation" op}}>
<div class="col-md-1 operation-icon">
{{account-type-icon op.accountType}}
<div role="tabpanel" id="total" {{bind-attr class=":tab-pane isGeneral::active"}}>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="rentTotalHeading">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#rentTotalCollapse" aria-expanded="true" aria-controls="rentTotalCollapse">
Итого: {{rentTotal.total}}
</a>
</h4>
</div>
<div id="rentTotalCollapse" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="rentTotalHeading">
<div class="panel-body">
<div class="rent-total-container">
<form class="form-horizontal">
{{#property-row title="Продолжительность" labelCssWidth="col-sm-3" inputCssWidth="col-sm-9"}}
{{input value=minutesHumanize readonly="true"}}
{{/property-row}}
{{#property-row title="Аренда" labelCssWidth="col-sm-3" inputCssWidth="col-sm-9"}}
{{input value=rentTotal.rent readonly="true"}}
{{/property-row}}
{{#property-row title="Ремонт" labelCssWidth="col-sm-3" inputCssWidth="col-sm-9"}}
{{input value=rentTotal.repairs readonly="true"}}
{{/property-row}}
{{#property-row title="Штрафы" labelCssWidth="col-sm-3" inputCssWidth="col-sm-9"}}
{{input value=rentTotal.fines readonly="true"}}
{{/property-row}}
{{#property-row title="Залог" labelCssWidth="col-sm-3" inputCssWidth="col-sm-9"}}
{{input value=rentTotal.deposit readonly="true"}}
{{/property-row}}
</form>
</div>
<div class="col-md-4">{{format-date op.operationTime}}</div>
<div class="col-md-5">{{account-type op.accountType}}</div>
<div class="col-md-2">{{op.amount}} р.</div>
</div>
{{/each}}
</div>
{{/each}}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="rentHistoryHeading">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#rentHistoryCollapse" aria-expanded="false" aria-controls="rentHistoryCollapse">
История
</a>
</h4>
</div>
<div id="rentHistoryCollapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="rentHistoryHeading">
<div class="panel-body">
<div class="history-container container-fluid">
{{#each status in history}}
<div class="history-item status row">
<div class="col-md-1 status-icon">
<i class="fa fa-bell"></i>
</div>
<div class="col-md-4">{{format-date status.changeTime}}</div>
<div class="col-md-5">{{rent-status status.status}}</div>
</div>
<div class="operations-container">
{{#each op in status.operations}}
<div {{bind-attr class=":history-item :operation :row op.isPositive:positive:negative"}} {{action "showOperation" op}}>
<div class="col-md-1 operation-icon">
{{account-type-icon op.accountType}}
</div>
<div class="col-md-4">{{format-date op.operationTime}}</div>
<div class="col-md-5">{{account-type op.accountType}}</div>
<div class="col-md-2">{{op.amount}} р.</div>
</div>
{{/each}}
</div>
{{/each}}

</div>
</div>
</div>
</div>
</div>

</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion sources/server/app/query/RentTotalQuery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RentTotalQuery @Inject()(dbConfig: DatabaseConfig[JdbcProfile]) extends Sq
private implicit val writes = Json.writes[RentTotal]
private implicit val getResult = GetResult(r => RentTotal(r.<<, r.<<, r.<<, r.<<, r.<<, r.<<, r.<<))

case class RentTotal(rentId: Int, minutes: Int, payments: BigDecimal, repairs: BigDecimal, fines: BigDecimal, deposit: BigDecimal, total: BigDecimal)
case class RentTotal(rentId: Int, minutes: Int, rent: BigDecimal, repairs: BigDecimal, fines: BigDecimal, deposit: BigDecimal, total: BigDecimal)

override protected def doExecute(parameters: Map[String, Seq[String]]): Future[JsValue] = {
val filter = parseFilter(parameters)
Expand Down
4 changes: 2 additions & 2 deletions sources/server/conf/sql/q-rent-total.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
select
rent_id,
minutes,
payments,
rent_balance as "rent",
repairs,
fines,
deposit,
payments + repairs + fines + deposit as "total"
rent_balance + repairs + fines + deposit as "total"
from func_rent_balances('@controlTime')
where rent_id = @rentId

0 comments on commit 9a6cea4

Please sign in to comment.