Skip to content

Commit

Permalink
fix(income/expense): ensure report can be saved
Browse files Browse the repository at this point in the history
This commit allows the income and expense reports to be saved in the
generic archive report page.
  • Loading branch information
Jonathan Niles committed Nov 4, 2016
1 parent 7def637 commit 0058b26
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
13 changes: 7 additions & 6 deletions client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1021,15 +1021,16 @@
"INCOME_EXPENSE" : "Incomes and Expenses Report",
"GENERATED" : "Generated Report",
"MONTHLY_BALANCE" : "Monthly Balance",
"OPENNING_BALANCE" : "Openning Balance",
"OPENNING_BALANCE" : "Opening Balance",
"PERIOD_START" : "Start",
"PERIOD_STOP" : "Stop",
"PRODUCED_BY" : "Produced by",
"PRODUCED_DATE" : "Production Date",
"PRODUCED_ON" : "Produced on",
"INCOME_REPORT" : "Incomes Report",
"EXPENSE_REPORT" : "Expenses Report",
"SINCE" : "Since"
"EXPENSE_REPORT" : "Expenses Report",
"SINCE" : "Since",
"INCOME_EXPENSE" : "Income Expense Report"
},
"SECTION_BILAN": {
"ADD_SECTION_BILAN" : "Add a bilan Section",
Expand Down Expand Up @@ -1182,7 +1183,7 @@
"PERIOD" : "Period",
"PHONE" : "Telephone",
"POSITION" : "Position",
"PO_BOX" : "Poste Office Box",
"PO_BOX" : "Post Office Box",
"PRICE" : "Price",
"PRICE_LIST" : "Price List",
"PROFIT" : "Profit",
Expand All @@ -1197,7 +1198,7 @@
"REF" : "Ref.",
"REFERENCE" : "Reference",
"REFERENCE_GROUP" : "Reference Group",
"REF_GROUP" : "Ref. Groupe",
"REF_GROUP" : "Ref. Group",
"REMAINING_BALANCE" : "Remaining Balance",
"REGISTERED_ON" : "Registered on",
"RESPONSIBLE" : "Responsible",
Expand Down Expand Up @@ -1320,7 +1321,7 @@
"ADD_ITEMS" : "Add item(s)",
"CASH_PAYMENT" : "Cash Payment",
"CREATE_SUCCESS" : "Successfully posted",
"CREATE_ERROR" : "An error occured when post",
"CREATE_ERROR" : "An error occurred when post",
"CREDITOR" : "Creditor (C)",
"DEBTOR" : "Debitor (D)",
"DEB_CRED" : "Debtor/Creditor",
Expand Down
6 changes: 4 additions & 2 deletions client/src/partials/reports/modals/income_expense.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ function IncomeExpenseConfigController($state, ModalInstance, Cashbox, Notify, L
})
.catch(Notify.errorHandler);

function generate() {
function generate(form) {
var url = 'reports/finance/income_expense';

if (form.$invalid) { return; }

var options = {
account_id: vm.cashbox.account_id,
dateFrom: vm.dateFrom,
label : vm.label,
dateTo: vm.dateTo,
lang: Languages.key,
reportType: vm.type,
reportType: vm.type
};

return SavedReports.requestPDF(url, report, options)
Expand Down
12 changes: 6 additions & 6 deletions client/src/partials/reports/modals/income_expense.modal.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="modal-header">
<ol class="headercrumb">
<li class="static">{{ ReportConfigCtrl.report.title_key | translate }}</li>
<li class="static">{{ ::ReportConfigCtrl.report.title_key | translate }}</li>
<li class="title">{{ "FORM.LABELS.CREATE" | translate }}</li>
</ol>
</div>

<form name="ConfigForm" bh-submit="ReportConfigCtrl.generate()" bh-form-defaults novalidate>
<form name="ConfigForm" bh-submit="ReportConfigCtrl.generate(ConfigForm)" bh-form-defaults novalidate>
<div class="modal-body">
<div class="form-group"
ng-class="{ 'has-error' : ConfigForm.$submitted && ConfigForm.label.$invalid }">
Expand Down Expand Up @@ -43,7 +43,7 @@
ng-model="ReportConfigCtrl.cashbox"
ng-options="cash as cash.hrlabel for cash in ReportConfigCtrl.cashboxes track by cash.id"
required>
<option value="" disabled>{{ 'FORM.SELECT.CASHBOX' | translate }}</option>
<option value="" disabled>{{ "FORM.SELECT.CASHBOX" | translate }}</option>
</select>
<div class="help-block" ng-messages="ConfigForm.cashbox.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
Expand All @@ -53,15 +53,15 @@
<div class="form-group"
ng-class="{ 'has-error' : ConfigForm.$submitted && ConfigForm.type.$invalid }">
<label class="control-label">
<i class="fa fa-briefcase"></i> {{ 'FORM.SELECT.REPORT_TYPE' | translate }}
<i class="fa fa-briefcase"></i> {{ "FORM.SELECT.REPORT_TYPE" | translate }}
</label>
<select
class="form-control"
name="type"
ng-model="ReportConfigCtrl.type"
ng-options="type as (type.label | translate) for type in ReportConfigCtrl.reportType track by type.id"
ng-options="type.id as (type.label | translate) for type in ReportConfigCtrl.reportType track by type.id"
required>
<option value="" disabled>{{ 'FORM.SELECT.REPORT_TYPE' | translate }}<option>
<option value="" disabled>{{ "FORM.SELECT.REPORT_TYPE" | translate }}<option>
</select>
<div class="help-block" ng-messages="ConfigForm.type.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="partials/templates/messages.tmpl.html"></div>
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/finance/reports/incomeExpense/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function document(req, res, next) {
session.dateTo = params.dateTo;
session.reportType = params.reportType;

_.defaults(params, { orientation : 'landscape' });
_.defaults(params, { orientation : 'landscape', user : req.session.user });

try {
report = new ReportManager(TEMPLATE, req.session, params);
Expand Down

0 comments on commit 0058b26

Please sign in to comment.