diff --git a/src/operations/category.service.ts b/src/operations/category.service.ts new file mode 100644 index 0000000..675ff2d --- /dev/null +++ b/src/operations/category.service.ts @@ -0,0 +1,22 @@ +// vim: set tw=80 ts=2 sw=2 sts=2: + +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Rx'; + +import { Restangular } from "ngx-restangular"; + +import { Category } from './category'; + +@Injectable() +export class CategoryService { + constructor( + private restangular: Restangular + ) {} + + query(id: number, minDate: Date = null, maxDate: Date = null): Observable { + return this.restangular.one('account', id).getList('category', { + begin: minDate, + end: maxDate + }); + } +} diff --git a/src/operations/category.ts b/src/operations/category.ts new file mode 100644 index 0000000..fc7f2a6 --- /dev/null +++ b/src/operations/category.ts @@ -0,0 +1,7 @@ +// vim: set tw=80 ts=2 sw=2 sts=2 : + +export class Category { + category: string; + expenses: number; + revenues: number; +} diff --git a/src/operations/index.ts b/src/operations/index.ts index c6eaa2a..ff56ea5 100644 --- a/src/operations/index.ts +++ b/src/operations/index.ts @@ -35,6 +35,7 @@ var categoryChartModule = require('./category-chart.component'); import accountModule from '@accountant/accounts'; import { BalanceChartComponent } from './balanceChart.component'; +import { CategoryService } from './category.service'; var OperationFactory = require('./operation.factory'); var OperationController = require('./operation.controller'); @@ -52,6 +53,8 @@ export default angular.module('accountant.operations', [ .controller('OperationController', OperationController) + .factory('categoryService', downgradeInjectable(CategoryService)) + .directive('balanceChart', downgradeComponent({ component: BalanceChartComponent }) as angular.IDirectiveFactory) diff --git a/src/operations/operation.module.ts b/src/operations/operation.module.ts index 76edc19..a646106 100644 --- a/src/operations/operation.module.ts +++ b/src/operations/operation.module.ts @@ -9,6 +9,7 @@ import { NgLoggerModule, Level } from '@nsalaun/ng-logger'; import { RestangularModule } from 'ngx-restangular'; import { BalanceChartComponent } from './balanceChart.component'; +import { CategoryService } from './category.service' @NgModule({ imports: [ @@ -18,6 +19,9 @@ import { BalanceChartComponent } from './balanceChart.component'; NgLoggerModule, RestangularModule, ], + providers: [ + CategoryService, + ], declarations: [ BalanceChartComponent, ],