Cambiado el nombre del informe mensual a libro de ventas mensual, ademas se agrego una utilidad para strings que por ahora solo contiene el toUpperCase aunque se ira llenando a medida que se necesite.
This commit is contained in:
@@ -24,8 +24,9 @@
|
||||
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.informes.InformeMensual;
|
||||
import danielcortes.xyz.views.InformeMensualDialog;
|
||||
import danielcortes.xyz.informes.InformeLibroDeVentas;
|
||||
import danielcortes.xyz.utils.StringUtils;
|
||||
import danielcortes.xyz.views.MonthSelectDialog;
|
||||
import danielcortes.xyz.views.InformesView;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -45,33 +46,32 @@ public class InformesController {
|
||||
}
|
||||
|
||||
private void setupViewEvents() {
|
||||
this.view.getInformeMensualButton().addActionListener(e -> generarInformeMensualListener());
|
||||
this.view.getInformeLibroDeVentasButton().addActionListener(e -> generarInformeLibroDeVentasListener());
|
||||
}
|
||||
|
||||
private void generarInformeMensualListener() {
|
||||
private void generarInformeLibroDeVentasListener() {
|
||||
LocalDate month = askForMonth();
|
||||
if (month == null) {
|
||||
return;
|
||||
if (month != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM YYYY");
|
||||
|
||||
String formatedName = month.format(formatter);
|
||||
String capitalized = StringUtils.toUpperCase(formatedName);
|
||||
|
||||
File saveFile = askForFile("Libro " + capitalized);
|
||||
|
||||
if (saveFile != null) {
|
||||
InformeLibroDeVentas informeLibroDeVentas = new InformeLibroDeVentas(month, saveFile);
|
||||
File generatedFile = informeLibroDeVentas.generarInforme();
|
||||
|
||||
this.showConfirmation(generatedFile);
|
||||
}
|
||||
}
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM YYYY");
|
||||
String formatedName = month.format(formatter);
|
||||
String capitalized = formatedName.substring(0, 1).toUpperCase() + formatedName.substring(1);
|
||||
File saveFile = askForFile("Informe " + capitalized);
|
||||
if (saveFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
InformeMensual informeMensual = new InformeMensual(month, saveFile);
|
||||
File generatedFile = informeMensual.generarInforme();
|
||||
|
||||
this.showConfirmation(generatedFile);
|
||||
}
|
||||
|
||||
private LocalDate askForMonth() {
|
||||
InformeMensualDialog informeMensualDialog = new InformeMensualDialog(this.view.getContentPanel());
|
||||
if (informeMensualDialog.isAcepted()) {
|
||||
return informeMensualDialog.getMonth();
|
||||
MonthSelectDialog monthSelectDialog = new MonthSelectDialog(this.view.getContentPanel());
|
||||
if (monthSelectDialog.isAcepted()) {
|
||||
return monthSelectDialog.getMonth();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
|
||||
public class InformeMensual {
|
||||
public class InformeLibroDeVentas {
|
||||
private final String[] titles = {
|
||||
"", "",
|
||||
"BOLETA MANUAL", "", "",
|
||||
@@ -74,7 +74,7 @@ public class InformeMensual {
|
||||
private CreationHelper createHelper;
|
||||
private HashMap<String, CellStyle> styles;
|
||||
|
||||
public InformeMensual(LocalDate date, File saveFile) {
|
||||
public InformeLibroDeVentas(LocalDate date, File saveFile) {
|
||||
new SQLiteCajaDAO().createCajasForMonth(date);
|
||||
|
||||
this.informe = new ArrayList<>(new SQLiteInformeMensualContentDAO().getInformeMensual(date));
|
||||
31
src/danielcortes/xyz/utils/StringUtils.java
Normal file
31
src/danielcortes/xyz/utils/StringUtils.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018-2019 Daniel Cortes
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package danielcortes.xyz.utils;
|
||||
|
||||
public class StringUtils {
|
||||
public static String toUpperCase(String string){
|
||||
return string.substring(0, 1).toUpperCase() + string.substring(1);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="danielcortes.xyz.views.InformesView">
|
||||
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="338" height="356"/>
|
||||
@@ -8,7 +8,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="ae41b" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="ae41b" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -21,14 +21,9 @@
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Informe Mensual"/>
|
||||
<text value="Libro de Ventas Mensual"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="3849b">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="7ae6d" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
@@ -61,6 +56,11 @@
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="215a5">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -39,7 +39,7 @@ public class InformesView {
|
||||
return contentPanel;
|
||||
}
|
||||
|
||||
public JButton getInformeMensualButton() {
|
||||
public JButton getInformeLibroDeVentasButton() {
|
||||
return informeMensualButton;
|
||||
}
|
||||
|
||||
@@ -59,26 +59,26 @@ public class InformesView {
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
contentPanel = new JPanel();
|
||||
contentPanel.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Informes"));
|
||||
informeMensualButton = new JButton();
|
||||
informeMensualButton.setText("Informe Mensual");
|
||||
informeMensualButton.setText("Libro de Ventas Mensual");
|
||||
panel1.add(informeMensualButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
panel1.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
final JPanel panel2 = new JPanel();
|
||||
panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPanel.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
final Spacer spacer2 = new Spacer();
|
||||
panel2.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
panel2.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
final JPanel panel3 = new JPanel();
|
||||
panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
contentPanel.add(panel3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
final Spacer spacer2 = new Spacer();
|
||||
panel3.add(spacer2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
final Spacer spacer3 = new Spacer();
|
||||
panel3.add(spacer3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||
contentPanel.add(spacer3, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="danielcortes.xyz.views.InformeMensualDialog">
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="danielcortes.xyz.views.MonthSelectDialog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
@@ -38,7 +38,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class InformeMensualDialog extends JDialog {
|
||||
public class MonthSelectDialog extends JDialog {
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JButton buttonCancel;
|
||||
@@ -49,7 +49,7 @@ public class InformeMensualDialog extends JDialog {
|
||||
|
||||
private boolean acepted;
|
||||
|
||||
public InformeMensualDialog(JComponent parent) {
|
||||
public MonthSelectDialog(JComponent parent) {
|
||||
$$$setupUI$$$();
|
||||
setContentPane(contentPane);
|
||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
Reference in New Issue
Block a user