Search in sources :

Example 1 with ProfitLossTextReport

use of jgnash.report.ProfitLossTextReport in project jgnash by ccavanaugh.

the class ProfitLossTXT method run.

public void run() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final CurrencyNode baseCommodity = engine.getDefaultCurrency();
    final LocalDate[] dates = getDates();
    if (dates != null) {
        final String fileName = getFileName();
        ProfitLossTextReport report = new ProfitLossTextReport(fileName, dates[0], dates[1], baseCommodity, AccountBalanceDisplayManager::convertToSelectedBalanceMode);
        report.run();
    }
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) ProfitLossTextReport(jgnash.report.ProfitLossTextReport) LocalDate(java.time.LocalDate) Engine(jgnash.engine.Engine) AccountBalanceDisplayManager(jgnash.ui.register.AccountBalanceDisplayManager)

Example 2 with ProfitLossTextReport

use of jgnash.report.ProfitLossTextReport in project jgnash by ccavanaugh.

the class ReportActions method exportProfitLossReport.

public static void exportProfitLossReport() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final CurrencyNode baseCommodity = engine.getDefaultCurrency();
    final FXMLUtils.Pair<DateRangeDialogController> pair = FXMLUtils.load(DateRangeDialogController.class.getResource("DateRangeDialog.fxml"), ResourceUtils.getString("Title.ReportOptions"));
    pair.getStage().setResizable(false);
    pair.getStage().showAndWait();
    final Optional<LocalDate[]> optional = pair.getController().getDates();
    optional.ifPresent(localDates -> {
        final Preferences preferences = Preferences.userNodeForPackage(ReportActions.class);
        final String lastDir = preferences.get(LAST_DIR, null);
        final FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(ResourceUtils.getString("Title.SaveFile"));
        if (lastDir != null) {
            fileChooser.setInitialDirectory(new File(lastDir));
        }
        fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("TXT", "*.txt"));
        final File file = fileChooser.showSaveDialog(MainView.getPrimaryStage());
        if (file != null) {
            preferences.put(LAST_DIR, file.getParent());
            final ProfitLossTextReport report = new ProfitLossTextReport(file.getAbsolutePath(), localDates[0], localDates[1], baseCommodity, AccountBalanceDisplayManager::convertToSelectedBalanceMode);
            report.run();
        }
    });
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) FXMLUtils(jgnash.uifx.util.FXMLUtils) ProfitLossTextReport(jgnash.report.ProfitLossTextReport) FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File) Engine(jgnash.engine.Engine) DateRangeDialogController(jgnash.uifx.control.DateRangeDialogController) AccountBalanceDisplayManager(jgnash.uifx.views.AccountBalanceDisplayManager)

Aggregations

CurrencyNode (jgnash.engine.CurrencyNode)2 Engine (jgnash.engine.Engine)2 ProfitLossTextReport (jgnash.report.ProfitLossTextReport)2 File (java.io.File)1 LocalDate (java.time.LocalDate)1 Preferences (java.util.prefs.Preferences)1 FileChooser (javafx.stage.FileChooser)1 AccountBalanceDisplayManager (jgnash.ui.register.AccountBalanceDisplayManager)1 DateRangeDialogController (jgnash.uifx.control.DateRangeDialogController)1 FXMLUtils (jgnash.uifx.util.FXMLUtils)1 AccountBalanceDisplayManager (jgnash.uifx.views.AccountBalanceDisplayManager)1