Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
update accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetancollaud committed Sep 27, 2015
1 parent 08d6881 commit a034702
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
18 changes: 18 additions & 0 deletions sql/data_update/accounting-upate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DELETE FROM r_group_role WHERE group_id=(
SELECT group_id FROM t_group WHERE technicalname = 'comite'
) AND role_id=(
SELECT role_id FROM t_role WHERE technicalname = 'ROLE_ACCOUNTING_MANAGE'
)

INSERT INTO t_group (technicalname,name)VALUES('accounting','Accounting');

INSERT INTO r_group_role (group_id, role_id) (SELECT
(SELECT group_id FROM t_group WHERE technicalname = 'accounting'),
(SELECT role_id FROM t_role WHERE technicalname = 'ROLE_ACCOUNTING_MANAGE')
);

INSERT INTO r_group_user (group_id, user_id) (SELECT
(SELECT group_id FROM t_group WHERE technicalname = 'accounting'),
(SELECT user_id FROM t_user WHERE email = 'todo')
);

Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public class HistoryEntry implements Comparable<HistoryEntry> {
private final Date date;
@CsvField(headerName = "amount")
private final double amount;
@CsvField(headerName = "user")
private final HistoryEntryUser user;
@CsvField(headerName = "detail")
private final String detail;
@CsvField(headerName = "comment")
private final String comment;
@CsvField(headerName = "user")
private final HistoryEntryUser user;

public HistoryEntry(PaymentEO payment) {
type = payment.getTotal()>0 ? HistoryEntryType.PAYMENT : HistoryEntryType.REFUND;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.collaud.fablab.manager.export.*;
import java.lang.reflect.Field;
import lombok.extern.slf4j.Slf4j;
import net.collaud.fablab.manager.data.type.HistoryEntryType;
import net.collaud.fablab.manager.data.virtual.HistoryEntry;

/**
Expand All @@ -29,7 +30,7 @@ protected String getFieldValue(HistoryEntry obj, Field f) {
String parsed = super.getFieldValue(obj, f);
if(f.getAnnotation(CsvField.class).headerName().equals(FIELD_TO_OVERRIDE)){
Double v = obj.getAmount();
if(v<0){
if(obj.getType()==HistoryEntryType.USAGE || obj.getType()==HistoryEntryType.SUBSCRIPTION){
return FIELD_SEPARATOR+Double.toString(-v);
}else{
return parsed+FIELD_SEPARATOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ <h1 translate="accounting.title"></h1>
'bg-warning':h.type==='USAGE',
'bg-success':(h.type==='PAYMENT'||h.type=='REFUND'),
'bg-info':h.type==='SUBSCRIPTION'
}">
}"
ng-init="leftColumn = (h.type === 'PAYMENT' || h.type==='REFUND')">
<td>{{h.date|formatTimestamp:'DD.MM.YYYY'}}</td>
<td><span ng-if="h.type === 'PAYMENT'">{{h.amount|currency}}</span></td>
<td><span ng-if="h.type !== 'PAYMENT'">{{-h.amount|currency}}</span></td>
<td><span ng-if="leftColumn">{{h.amount|currency}}</span></td>
<td><span ng-if="!leftColumn">{{-h.amount|currency}}</span></td>
<td>{{h.user|prettyUser}}</td>
<td>{{h.detail}}</td>
<td>{{h.comment}}</td>
Expand Down
10 changes: 7 additions & 3 deletions src/main/webapp/components/payment/by-user-ctrl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
(function () {
'use strict';

angular.module('Fablab').controller('PaymentByUserController', function ($scope, $log, $filter,
angular.module('Fablab').controller('PaymentByUserController', function ($scope, $rootScope, $log, $filter,
$location, $routeParams, UserService) {
$scope.selected = {user: undefined};

$scope.minDate = moment().subtract(App.CONFIG.ACCOUNTING_EDIT_HISTORY_LIMIT, 'days').format('YYYY-MM-DD');
if ($rootScope.hasRole('ACCOUNTING_MANAGE')) {
$scope.minDate = moment().subtract(1, 'year').format('YYYY-MM-DD');
} else {
$scope.minDate = moment().subtract(App.CONFIG.ACCOUNTING_EDIT_HISTORY_LIMIT, 'days').format('YYYY-MM-DD');
}

$scope.loadUser = function (userId) {
UserService.get(userId, function (data) {
Expand Down Expand Up @@ -36,7 +40,7 @@
$scope.loadUser($routeParams.id);
}
};

$scope.updateUser();

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="form-group">
<label class="col-sm-4 control-label" translate="payment.startDate"></label>
<div class="col-sm-8">
<input class="form-control" type="date" required ng-model="addSubscription.date" />
<input class="form-control" type="date" min="{{minDate}}" required ng-model="addSubscription.date" />
</div>
</div>
<div class="form-group">
Expand Down
15 changes: 15 additions & 0 deletions src/main/webapp/i18n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,20 @@ angular.module('Fablab').config(function ($translateProvider) {
rfid: 'RFID',
groups: 'Groupes'
},
accounting:{
title:'Comptabilité',
today:'Aujourd\'hui',
yesterday:'Hier',
thisMonth:'Ce mois',
lastMonth:'Le mois dernier',
thisYear:'Cette année',
lastYear:'L\'année dernière',
summary:'Résumé',
sell:'Ventes',
moneyIn:'Caisse',
delta:'Différence',
debit:'Débit',
credit:'Crédit'
}
});
});

0 comments on commit a034702

Please sign in to comment.