Skip to content

Commit

Permalink
Merge #3794
Browse files Browse the repository at this point in the history
3794: (cron job) add cron email component to main reports r=mbayopanda a=jeremielodi

closes #3792

Co-authored-by: jeremielodi <jeremielodi@gmail.com>
  • Loading branch information
bors[bot] and jeremielodi committed Aug 2, 2019
2 parents d115442 + 438b1ac commit 7ae875f
Show file tree
Hide file tree
Showing 16 changed files with 389 additions and 1,506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@ <h3 class="text-capitalize" translate>REPORT.CLIENTS.TITLE</h3>
</div>
</div>
</div>

<div class="col-md-6">
<bh-cron-email-report
report-id="17"
report-form="ConfigForm"
report-details="ReportConfigCtrl.reportDetails"
on-select-report="ReportConfigCtrl.onSelectCronReport(report)">
</bh-cron-email-report>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function AnnualClientsReportController($state, $sce, Notify, AppCache, SavedRepo
vm.reportDetails.fiscalId = fiscal.id;
};

vm.onSelectCronReport = report => {
vm.reportDetails = angular.copy(report);
};

vm.onSelectCurrency = currencyId => {
vm.reportDetails.currencyId = currencyId;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function CashFlowConfigController($sce, Notify, SavedReports, AppCache, reportDa
vm.previewResult = null;
};

vm.onSelectCronReport = report => {
vm.reportDetails = angular.copy(report);
};

vm.requestSaveAs = function requestSaveAs() {
const options = {
url : reportUrl,
Expand Down
9 changes: 9 additions & 0 deletions client/src/modules/reports/generate/cashflow/cashflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,14 @@ <h3 class="text-capitalize" translate>REPORT.CASHFLOW.TITLE</h3>
</div>
</div>
</div>

<div class="col-md-6">
<bh-cron-email-report
report-id="1"
report-form="ConfigForm"
report-details="ReportConfigCtrl.reportDetails"
on-select-report="ReportConfigCtrl.onSelectCronReport(report)">
</bh-cron-email-report>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ angular.module('bhima.controllers')
.controller('stock_valueController', StockValueConfigController);

StockValueConfigController.$inject = [
'$sce', 'NotifyService', 'BaseReportService', 'AppCache', 'reportData', '$state',
'$sce', 'NotifyService', 'BaseReportService',
'AppCache', 'reportData', '$state',
'LanguageService', 'moment',
];

function StockValueConfigController($sce, Notify, SavedReports, AppCache, reportData, $state, Languages, moment) {
function StockValueConfigController($sce, Notify, SavedReports,
AppCache, reportData, $state, Languages, moment) {
const vm = this;
const cache = new AppCache('configure_stock_value_report');
const reportUrl = 'reports/stock/value';
Expand All @@ -24,8 +26,12 @@ function StockValueConfigController($sce, Notify, SavedReports, AppCache, report

vm.onSelectDepot = function onSelectDepot(depot) {
vm.depot = depot;
formatData();
};

vm.onSelectCronReport = report => {
vm.reportDetails = angular.copy(report);
};

vm.clear = function clear(key) {
delete vm[key];
Expand All @@ -35,24 +41,20 @@ function StockValueConfigController($sce, Notify, SavedReports, AppCache, report
vm.previewGenerated = false;
vm.previewResult = null;
};

vm.onSelectCurrency = (currencyId) => {
vm.reportDetails.currency_id = currencyId;
vm.currency_id = currencyId;
formatData();
};

vm.preview = function preview(form) {
if (form.$invalid) { return 0; }

function formatData() {
const params = {
depot_uuid : vm.depot.uuid,
dateTo : vm.dateTo,
currency_id : vm.currency_id,
};

// update cached configuration
cache.reportDetails = angular.copy(params);

// format date for the server
params.dateTo = moment(params.dateTo).format('YYYY-MM-DD');

const options = {
Expand All @@ -61,6 +63,13 @@ function StockValueConfigController($sce, Notify, SavedReports, AppCache, report
};

vm.reportDetails = options;
return vm.reportDetails;
}

vm.preview = function preview(form) {
if (form.$invalid) { return 0; }

vm.reportDetails = formatData();

return SavedReports.requestPreview(reportUrl, reportData.id, angular.copy(vm.reportDetails))
.then((result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,14 @@ <h3 translate>REPORT.STOCK_VALUE.TITLE</h3>
</div>
</div>
</div>

<div class="col-md-6">
<bh-cron-email-report
report-id="25"
report-form="ConfigForm"
report-details="ReportConfigCtrl.reportDetails"
on-select-report="ReportConfigCtrl.onSelectCronReport(report)">
</bh-cron-email-report>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function UnbalancedInvoicePaymentsConfigController($sce, Notify, SavedReports, A
vm.reportDetails.debtorGroupUuid = debtorGroup.uuid;
};

vm.onSelectCronReport = report => {
vm.reportDetails = angular.copy(report);
};

vm.onClear = () => {
delete vm.reportDetails.debtorGroupName;
delete vm.reportDetails.debtorGroupUuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,15 @@ <h3 class="text-capitalize" translate>REPORT.UNPAID_INVOICE_PAYMENTS_REPORT.TITL
</div>
</div>
</div>

<div class="col-md-6">
<bh-cron-email-report
report-id="23"
report-form="ConfigForm"
report-details="ReportConfigCtrl.reportDetails"
on-select-report="ReportConfigCtrl.onSelectCronReport(report)">
</bh-cron-email-report>
</div>
</div>
</div>
</div>
Loading

0 comments on commit 7ae875f

Please sign in to comment.