Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Added taxes list
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericoregateiro committed Oct 13, 2017
1 parent 5b093b4 commit 9749bfe
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/SolRIA.SaftAnalyser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void Init()
new SaftPage{ Name = "Cabeçalho", View = PagesIds.SAFT_HEADER },
new SaftPage{ Name = "Clientes", View = PagesIds.SAFT_CUSTOMERS },
new SaftPage{ Name = "Produtos", View = PagesIds.SAFT_PRODUCTS },
new SaftPage{ Name = "Impostos", View = PagesIds.SAFT_TAXES },
new SaftPage{ Name = "Doc. Faturação", View = PagesIds.SAFT_INVOICES },
new SaftPage{ Name = "Erros", View = PagesIds.SAFT_ERRORS },
});
Expand Down
3 changes: 2 additions & 1 deletion src/SolRIA.SaftAnalyser/PagesIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public class PagesIds
public const string SAFT_HEADER = "SaftHeader";
public const string SAFT_CUSTOMERS = "SaftCustomers";
public const string SAFT_PRODUCTS = "SaftProducts";
public const string SAFT_INVOICES = "SaftInvoices";
public const string SAFT_TAXES = "SaftTaxes";
public const string SAFT_INVOICES = "SaftInvoices";
public const string SAFT_ERRORS = "SaftErrors";
}
}
8 changes: 8 additions & 0 deletions src/SolRIA.SaftAnalyser/SolRIA.SaftAnalyser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
</ApplicationDefinition>
<Compile Include="PageBase.cs" />
<Compile Include="PagesIds.cs" />
<Compile Include="ViewModels\SaftTaxesViewModel.cs" />
<Compile Include="ViewModels\SaftProductsViewModel.cs" />
<Compile Include="ViewModels\SaftCustomersViewModel.cs" />
<Compile Include="ViewModels\SaftErrorsViewModel.cs" />
Expand All @@ -135,6 +136,9 @@
<Compile Include="Views\Home.xaml.cs">
<DependentUpon>Home.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SaftTaxes.xaml.cs">
<DependentUpon>SaftTaxes.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SaftProducts.xaml.cs">
<DependentUpon>SaftProducts.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -173,6 +177,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SaftTaxes.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SaftProducts.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
115 changes: 115 additions & 0 deletions src/SolRIA.SaftAnalyser/ViewModels/SaftTaxesViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using OfficeOpenXml;
using OfficeOpenXml.Table;
using Prism.Commands;
using Prism.Mvvm;
using SolRia.Erp.MobileApp.Models.SaftV4;
using SolRIA.SaftAnalyser.Interfaces;
using System;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace SolRIA.SaftAnalyser.ViewModels
{
public class SaftTaxesViewModel : BindableBase
{
INavigationService navService;
IMessageService messageService;
public SaftTaxesViewModel(INavigationService navService, IMessageService messageService)
{
this.navService = navService;
this.messageService = messageService;

DoPrintCommand = new DelegateCommand(OnPrint);

navService.LoadCompleted += NavService_LoadCompleted;
}

private void NavService_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
if (OpenedFileInstance.Instance.SaftFile.MasterFiles != null)
taxesBack = OpenedFileInstance.Instance.SaftFile.MasterFiles.TaxTable;

TaxTable = taxesBack;
messageService.CloseDialog();
}

TaxTableEntry[] taxesBack;

TaxTableEntry[] taxTable;
public TaxTableEntry[] TaxTable
{
get => taxTable;
set => SetProperty(ref taxTable, value);
}

TaxTableEntry tax;
public TaxTableEntry Tax
{
get => tax;
set => SetProperty(ref tax, value);
}

string filter;
public string Filter
{
get { return filter; }
set
{
filter = value;

if (taxesBack != null)
{
if (string.IsNullOrEmpty(filter))
TaxTable = taxesBack;
else
{
TaxTable =
(from c in taxesBack
where !string.IsNullOrEmpty(c.Description) && c.Description.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.TaxCode) && c.TaxCode.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.TaxCountryRegion) && c.TaxCountryRegion.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
c.TaxType.ToString().IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0
select c).ToArray();
}
}
}
}

public DelegateCommand DoPrintCommand { get; private set; }
private void OnPrint()
{
if (TaxTable != null && TaxTable.Length > 0)
{
DataTable dt = new DataTable();
dt.Columns.Add("País ou região imposto", typeof(string));
dt.Columns.Add("Código", typeof(string));
dt.Columns.Add("Descrição", typeof(string));
dt.Columns.Add("Data fim", typeof(DateTime));
dt.Columns.Add("Valor", typeof(string));
dt.Columns.Add("Tipo", typeof(string));

foreach (var p in TaxTable)
{
dt.Rows.Add(p.TaxCountryRegion, p.TaxCode, p.Description, p.TaxExpirationDate, p.Item, p.ItemElementName);
}

ExcelPackage pck = new ExcelPackage();
var wsEnum = pck.Workbook.Worksheets.Add("SolRIA | SAFT");
//Load the collection starting from cell A1...
wsEnum.Cells["A1"].LoadFromDataTable(dt, true, TableStyles.Medium9);
wsEnum.Cells[wsEnum.Dimension.Address].AutoFitColumns();

//...and save
var fi = new FileInfo(Path.GetTempPath() + Path.GetRandomFileName() + ".xlsx");
if (fi.Exists)
fi.Delete();

pck.SaveAs(fi);

Process.Start(fi.FullName);
}
}
}
}
64 changes: 39 additions & 25 deletions src/SolRIA.SaftAnalyser/Views/SaftInvoices.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,30 @@

<DatePicker SelectedDate="{Binding FiltroDataInicio}" Style="{StaticResource MaterialDesignFloatingHintDatePicker}"/>
<DatePicker SelectedDate="{Binding FiltroDataFim}" Style="{StaticResource MaterialDesignFloatingHintDatePicker}"/>
<TextBox Margin="3" HorizontalAlignment="Stretch" Style="{StaticResource MaterialDesignTextBox}"

<Border Margin="3" Background="White" MaxHeight="30" HorizontalAlignment="Stretch" CornerRadius="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Style="{DynamicResource MaterialDesignToolButton}"
Command="{Binding SearchCommand}" x:Name="SearchButton"
Height="24" Width="24">
<materialDesign:PackIcon Kind="Magnify" Opacity=".56" />
</Button>
<TextBox Grid.Column="1" Margin="5 0 0 0" Text="{Binding FilterInvoices, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Filtro por: No ou Cliente"
Text="{Binding FilterInvoices, UpdateSourceTrigger=PropertyChanged}"/>
materialDesign:TextFieldAssist.DecorationVisibility="Hidden" BorderThickness="0"
MinWidth="200" VerticalAlignment="Center">
<TextBox.InputBindings>
<KeyBinding Command="{Binding SearchCommand}" Key="Enter"/>
</TextBox.InputBindings>
</TextBox>
</Grid>
</Border>
</DockPanel>

<!--<DataGrid x:Name="dataGridInvoices" DockPanel.Dock="Bottom" TabIndex="1"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
VirtualizingPanel.IsVirtualizing="True" EnableRowVirtualization="True"
ItemsSource="{Binding Source={StaticResource invoices}}"
SelectedItem="{Binding CurrentInvoice}" SelectionChanged="dataGridInvoices_SelectionChanged" Height="169">
<DataGrid.RowValidationRules>
<v:InvoiceValidationRule ValidationStep="ConvertedProposedValue" ValidatesOnTargetUpdated="True"/>
</DataGrid.RowValidationRules>
</DataGrid>-->
<sf:SfDataGrid x:Name="dataGridInvoices" DockPanel.Dock="Bottom" AllowEditing="False" AllowGrouping="True" GridValidationMode="InView"
EnableDataVirtualization="True" HorizontalAlignment="Stretch" GroupCaptionTextFormat=" {Key} "
ShowGroupDropArea="True" AutoExpandGroups="True" IsGroupDropAreaExpanded="False" AutoGenerateColumns="False"
Expand Down Expand Up @@ -201,20 +210,25 @@

<Label Content="Linhas" DockPanel.Dock="Left" Margin="3" />

<TextBox
DockPanel.Dock="Right" Margin="3" TabIndex="2"
materialDesign:HintAssist.Hint="Filtro por: Descrição produto ou Código produto ou Descrição" HorizontalAlignment="Stretch"
Text="{Binding FilterLines, UpdateSourceTrigger=PropertyChanged}"/>
<Border Margin="3" Background="White" MaxHeight="30" HorizontalAlignment="Stretch" CornerRadius="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Style="{DynamicResource MaterialDesignToolButton}"
Height="24" Width="24">
<materialDesign:PackIcon Kind="Magnify" Opacity=".56" />
</Button>
<TextBox Grid.Column="1" Margin="5 0 0 0" Text="{Binding FilterLines, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Filtro por: Descrição produto ou Código produto ou Descrição"
materialDesign:TextFieldAssist.DecorationVisibility="Hidden" BorderThickness="0"
MinWidth="200" VerticalAlignment="Center">
</TextBox>
</Grid>
</Border>
</DockPanel>

<!--<DataGrid x:Name="dataGridInvoiceLines" Grid.Row="1" VirtualizingPanel.IsVirtualizing="True"
ItemsSource="{Binding CurrentInvoiceLines, IsAsync=True}"
SelectedItem="{Binding CurrentInvoiceLine}" SelectionChanged="dataGridInvoiceLines_SelectionChanged">
<DataGrid.RowValidationRules>
<v:InvoiceLineValidationRule ValidationStep="ConvertedProposedValue" ValidatesOnTargetUpdated="True"/>
</DataGrid.RowValidationRules>
</DataGrid>-->
<sf:SfDataGrid x:Name="dataGridInvoiceLines" Grid.Row="1" AllowEditing="False" AllowGrouping="True" GridValidationMode="InView"
EnableDataVirtualization="True" HorizontalAlignment="Stretch" GroupCaptionTextFormat=" {Key} "
ShowGroupDropArea="True" AutoExpandGroups="True" IsGroupDropAreaExpanded="False"
Expand All @@ -241,7 +255,7 @@
<sf:GridTextColumn HeaderText="Descrição" MappingName="Description" />
</sf:SfDataGrid.Columns>
</sf:SfDataGrid>

</Grid>
</Grid>
</local:PageBase>
63 changes: 63 additions & 0 deletions src/SolRIA.SaftAnalyser/Views/SaftTaxes.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<local:PageBase
x:Class="SolRIA.SaftAnalyser.Views.SaftTaxes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SolRIA.SaftAnalyser"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:sf="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d" >

<DockPanel>

<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Border Margin="3" Background="White" MaxHeight="30" Width="500" CornerRadius="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Style="{DynamicResource MaterialDesignToolButton}"
Height="24" Width="24">
<materialDesign:PackIcon Kind="Magnify" Opacity=".56" />
</Button>
<TextBox Grid.Column="1" Margin="5 0 0 0" Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Filtro por: País ou região imposto ou Código ou Descrição ou Tipo"
materialDesign:TextFieldAssist.DecorationVisibility="Hidden" BorderThickness="0"
MinWidth="200" VerticalAlignment="Center">
</TextBox>
</Grid>
</Border>

<Button Width="100" Height="25" Margin="5" Padding="3" VerticalAlignment="Center" ToolTip="Exportar para Excel"
Command="{Binding DoPrintCommand}"
CommandParameter="{Binding ElementName=dataGridTaxEntries}">
<StackPanel Orientation="Horizontal">
<Path Style="{StaticResource DataExcelStyle}" Width="20" Height="20"/>
<TextBlock Text="Impostos" Padding="5,0,0,0"/>
</StackPanel>
</Button>
</StackPanel>

<sf:SfDataGrid x:Name="dataGridTaxes" Grid.Row="1" AllowEditing="False" AllowGrouping="True" GridValidationMode="InView"
EnableDataVirtualization="True" HorizontalAlignment="Stretch" GroupCaptionTextFormat=" {Key} "
ShowGroupDropArea="True" AutoExpandGroups="True" IsGroupDropAreaExpanded="False"
ShowRowHeader="True" AutoGenerateColumns="False"
ItemsSource="{Binding TaxTable}"
SelectedItem="{Binding Tax}">
<sf:SfDataGrid.GroupColumnDescriptions>
<sf:GroupColumnDescription ColumnName="TaxType" />
</sf:SfDataGrid.GroupColumnDescriptions>
<sf:SfDataGrid.Columns>
<sf:GridTextColumn HeaderText="País ou região imposto" MappingName="TaxCountryRegion" />
<sf:GridTextColumn HeaderText="Código" MappingName="TaxCode" />
<sf:GridTextColumn HeaderText="Descrição" MappingName="Description" />
<sf:GridTextColumn HeaderText="Data fim" MappingName="TaxExpirationDate" />
<sf:GridTextColumn HeaderText="Valor" MappingName="Item" />
<sf:GridTextColumn HeaderText="Tipo" MappingName="ItemElementName" />
</sf:SfDataGrid.Columns>
</sf:SfDataGrid>

</DockPanel>
</local:PageBase>
16 changes: 16 additions & 0 deletions src/SolRIA.SaftAnalyser/Views/SaftTaxes.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Syncfusion.SfSkinManager;

namespace SolRIA.SaftAnalyser.Views
{
/// <summary>
/// Interaction logic for SaftTaxes.xaml
/// </summary>
public partial class SaftTaxes : PageBase
{
public SaftTaxes()
{
InitializeComponent();
SfSkinManager.SetVisualStyle(dataGridTaxes, VisualStyles.Blend);
}
}
}

0 comments on commit 9749bfe

Please sign in to comment.