Exemplo n.º 1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int rowLine = gridTaxs.GetSelectedRows()[0];

            if (cmbTaxType.SelectedIndex == 0)
            {
                TaxCode tax = taxas[rowLine];
                if (tax.flagPrincipal)
                {
                    MessageBox.Show("Esta taxa não pode ser eliminada..!");
                }
                else
                {
                    _taxController.deleteFoId(tax.Id);
                    updateGrid();
                }
            }
            else
            {
                TaxReasonExemption ISE = motivos[rowLine];

                if (ISE.flagPrincipal)
                {
                    MessageBox.Show("Esta taxa não pode ser eliminada..!");
                }
                else
                {
                    _taxISEController.deleteFoId(ISE.Id);
                    updateGrid();
                }
            }
        }
Exemplo n.º 2
0
        private void gridTaxs_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            int rowLine = e.RowHandle;

            decimal taxa = 0;

            if (e.Column.Name == "ClTaxaNor")
            {
                taxa = decimal.Parse(e.Value.ToString());
            }

            if (e.Value.ToString() == string.Empty)
            {
                updateGrid();
            }
            else
            {
                if (cmbTaxType.SelectedIndex == 0)
                {
                    TaxCode tax = taxas[rowLine];
                    if (tax.flagPrincipal)
                    {
                        MessageBox.Show("Esta taxa não pode ser Alterada..!");
                        updateGrid();
                    }
                    else
                    {
                        if (taxa > 0)
                        {
                            //_taxController.update(tax);
                            _tiposTaxa.update(_tiposTaxa.getOne(1));
                        }
                        else
                        {
                            MessageBox.Show("O valor da taxa não pode ser 0..!");
                        }
                    }
                }
                else
                {
                    TaxReasonExemption ISE = motivos[rowLine];
                    if (ISE.flagPrincipal)
                    {
                        if (e.Column.Name == "CLCodigoISE")
                        {
                            MessageBox.Show("Não pode alterar o codigo das Isentas principais.!");
                        }
                        else
                        {
                            // _taxISEController.update(ISE);
                            _tiposTaxa.update(_tiposTaxa.getOne(2));
                        }
                    }
                    else
                    {
                        _tiposTaxa.update(_tiposTaxa.getOne(2));
                    }
                }
            }
        }
 public int update(TaxReasonExemption taxReasonExemption)
 {
     return(_taxRepository.update(taxReasonExemption));
 }
 public int delete(TaxReasonExemption taxReasonExemption)
 {
     return(_taxRepository.remove(taxReasonExemption));
 }
 public int insert(TaxReasonExemption taxReasonExemption)
 {
     return(_taxRepository.insert(taxReasonExemption));
 }
Exemplo n.º 6
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            if (txtCode.Text != string.Empty && txtDescricao.Text != string.Empty)
            {
                if (cmbTaxType.SelectedIndex == 0)
                {
                    if (decimal.Parse(txtTax.Text) >= 1)
                    {
                        TaxCodeController _taxController = new TaxCodeController();
                        TaxCode           taxcode        = new TaxCode()
                        {
                            Code          = txtCode.Text.Trim(),
                            Taxa          = decimal.Parse(txtTax.Text),
                            Descricao     = txtDescricao.Text.Trim(),
                            flagPrincipal = false,
                        };

                        bool taxaExiste = false;
                        foreach (var item in _taxController.ListALL())
                        {
                            taxaExiste = item.Taxa == taxcode.Taxa;
                            if (taxaExiste)
                            {
                                break;
                            }
                        }

                        if (taxaExiste)
                        {
                            MessageBox.Show("Já Exixte a percentagem de taxa de (" + taxcode.Taxa + "%) !\nDigite uma nova taxa para cadastrar..!");
                        }
                        else
                        {
                            _taxController.insert(taxcode);
                            _tiposTaxa = new TaxTypeController();
                            updateGrid();
                        }
                    }
                    else
                    {
                        MessageBox.Show("A taxa não pode ser zero...");
                    }
                }
                else
                {
                    TaxReasonExemptionController _taxController = new TaxReasonExemptionController();
                    TaxReasonExemption           taxReason      = new TaxReasonExemption()
                    {
                        Id            = txtCode.Text.Trim(),
                        MencaoFatura  = txtDescricao.Text.Trim(),
                        flagPrincipal = false,
                    };

                    bool codigoExiste = false;

                    foreach (var item in _taxController.ListALL())
                    {
                        codigoExiste = item.Id.Equals(taxReason.Id);
                        if (codigoExiste)
                        {
                            break;
                        }
                    }

                    if (codigoExiste)
                    {
                        MessageBox.Show("Já Exixte este código de isenta..!");
                    }
                    else
                    {
                        _taxController.insert(taxReason);
                        _tiposTaxa = new TaxTypeController();
                        updateGrid();
                    }
                }
            }
            else
            {
                MessageBox.Show("Há campos vazio..!");
            }
        }
Exemplo n.º 7
0
        public AuditFileSourceDocumentsWorkingDocuments getWorkDocuments()
        {
            var groupListProductInvoice = _productSalesController.ListALL().
                                          Where(c => c.DataCadastro.Date >= dataInicio.Date && c.DataCadastro.Date <= dataFinal.Date && c.Fatura.TipoDocumento.WorkDocuments).ToList().
                                          GroupBy(c => c.FaturaId).ToList();

            AuditFileSourceDocumentsWorkingDocumentsWorkDocument[] listProformas = new AuditFileSourceDocumentsWorkingDocumentsWorkDocument[groupListProductInvoice.Count()];

            decimal totalCredit = 0;
            int     i           = 0;
            int     j;

            foreach (var item in groupListProductInvoice)
            {
                Invoice iv = item.ToList()[0].Fatura;

                if (iv.InvoiceStatusId != 3 /*Doc. Anulado*/ && iv.InvoiceStatusId != 5 /*Doc. faturado*/)
                {
                    totalCredit += iv.TotalIncidencia;
                }

                AuditFileSourceDocumentsWorkingDocumentsWorkDocumentLine[] linesInvoice = new AuditFileSourceDocumentsWorkingDocumentsWorkDocumentLine[iv.ProductsSales.Count()];

                j = 0;
                foreach (var lineProduct in iv.ProductsSales)
                {
                    string             imposto     = lineProduct.Product.CodigoTaxa.Code;
                    string             impostoType = lineProduct.Product.CodigoTaxaId == 3 ? "NS" : "IVA";
                    TaxReasonExemption taxReason   = null;
                    taxReason = lineProduct.Product.MotivoISEId != null ? new TaxReasonExemptionController().getOne(lineProduct.Product.MotivoISEId) : null;


                    linesInvoice[j] = new AuditFileSourceDocumentsWorkingDocumentsWorkDocumentLine()
                    {
                        CreditAmount       = lineProduct.TotalIncidencia.ToString("F3").Replace(",", "."),
                        Description        = "bom",
                        LineNumber         = (j + 1).ToString(),
                        ProductCode        = lineProduct.ProductId.ToString(),
                        Quantity           = lineProduct.Quantidade.ToString("F3").Replace(",", "."),
                        UnitPrice          = lineProduct.Preco.ToString("F3").Replace(",", "."),
                        ProductDescription = lineProduct.Descricao_Produto,
                        UnitOfMeasure      = lineProduct.Unidade,
                        TaxPointDate       = Convert.ToDateTime(iv.InvoiceDate),
                        Tax = new AuditFileSourceDocumentsWorkingDocumentsWorkDocumentLineTax()
                        {
                            TaxCountryRegion = "AO",
                            TaxType          = impostoType,
                            TaxPercentage    = lineProduct.Taxa.ToString("F3").Replace(",", "."),
                            TaxCode          = imposto,
                        },
                        TaxExemptionReason = taxReason != null ? taxReason.MencaoFatura : null,
                        TaxExemptionCode   = taxReason != null ? taxReason.Id : null,
                        SettlementAmount   = lineProduct.ValorDesconto.ToString("F3").Replace(",", "."), // lineProduct.ValorDesconto.ToString("F").Replace(",", "."),
                    };

                    j++;
                }

                listProformas[i] = new AuditFileSourceDocumentsWorkingDocumentsWorkDocument()
                {
                    CustomerID     = iv.Cliente.Nif.Contains("9999999") || iv.Cliente.Nif == string.Empty ? finalCustomer.Id.ToString() : iv.ClienteId.ToString(),
                    DocumentStatus = new AuditFileSourceDocumentsWorkingDocumentsWorkDocumentDocumentStatus()
                    {
                        WorkStatus     = iv.InvoiceStatus.Estado,
                        WorkStatusDate = iv.DataCadastro.ToString("yyyy-MM-ddTHH:mm:ss"),
                        Reason         = iv.RazaoNota,
                        SourceID       = iv.UserId.ToString(),
                        SourceBilling  = "P",
                    },
                    //TransactionID
                    Hash            = iv.Hash,
                    WorkDate        = Convert.ToDateTime(iv.InvoiceDate),
                    DocumentNumber  = iv.InvoiceNo,
                    WorkType        = iv.TipoDocumento.Tipo,
                    SourceID        = iv.UserId.ToString(),
                    HashControl     = "0",
                    SystemEntryDate = Convert.ToDateTime(iv.DataCadastro.ToString(fDateT)),
                    Period          = iv.DataCadastro.Month.ToString(),
                    DocumentTotals  = new AuditFileSourceDocumentsWorkingDocumentsWorkDocumentDocumentTotals()
                    {
                        TaxPayable = iv.TotalImposto.ToString("F3").Replace(",", "."),
                        NetTotal   = iv.TotalIncidencia.ToString("F3").Replace(",", "."),
                        GrossTotal = iv.TotalGeral.ToString("F3").Replace(",", "."),
                    },
                    Line = linesInvoice,
                };

                i++;
            }


            return(new AuditFileSourceDocumentsWorkingDocuments()
            {
                TotalCredit = totalCredit.ToString("F3").Replace(",", "."),
                TotalDebit = "0.00",
                NumberOfEntries = listProformas.Count().ToString(),
                WorkDocument = listProformas.Count() > 0 ? listProformas : null,
            });
        }
Exemplo n.º 8
0
        public AuditFileSourceDocumentsSalesInvoices getSalesInvoices()
        {
            var groupListProductInvoice = _productSalesController.ListALL().
                                          Where(c => c.DataCadastro.Date >= dataInicio.Date && c.DataCadastro.Date <= dataFinal.Date && c.Fatura.TipoDocumento.SalesInvoices).ToList().
                                          GroupBy(c => c.FaturaId).ToList();

            //AuditFileSourceDocumentsMovementOfGoods[] auditmovmentsOfGood = new AuditFileSourceDocumentsMovementOfGoods[];
            AuditFileSourceDocumentsSalesInvoicesInvoice[] listSalesInvoices = new AuditFileSourceDocumentsSalesInvoicesInvoice[groupListProductInvoice.Count()];

            decimal totalDebit  = 0;
            decimal totalCredit = 0;
            int     i           = 0;

            foreach (var item in groupListProductInvoice)
            {
                Invoice iv = item.ToList()[0].Fatura;
                bool    notaCreditoOuDebito = iv.TipoDocumento.Id == "10" || iv.TipoDocumento.Id == "9";

                if (iv.InvoiceStatusId != 3 /*Doc. Anulado*/ && iv.InvoiceStatusId != 5 /*Doc. faturado*/)
                {
                    if (notaCreditoOuDebito)
                    {
                        totalDebit += iv.TotalIncidencia;
                    }
                    else
                    {
                        totalCredit += iv.TotalIncidencia;
                    }
                }

                AuditFileSourceDocumentsSalesInvoicesInvoiceLine[] linesInvoice = new AuditFileSourceDocumentsSalesInvoicesInvoiceLine[iv.ProductsSales.Count()];

                int j = 0;
                foreach (var lineProduct in iv.ProductsSales)
                {
                    string             imposto     = lineProduct.Product.CodigoTaxa.Code;
                    string             impostoType = lineProduct.Product.CodigoTaxaId == 3 ? "NS" : "IVA";
                    TaxReasonExemption taxReason   = null;

                    taxReason = lineProduct.Product.MotivoISEId != null ? new TaxReasonExemptionController().getOne(lineProduct.Product.MotivoISEId) : null;
                    bool showCreditField = true;
                    AuditFileSourceDocumentsSalesInvoicesInvoiceLineReferences references = null;

                    if (notaCreditoOuDebito)
                    {
                        showCreditField = false;
                        references      = new AuditFileSourceDocumentsSalesInvoicesInvoiceLineReferences()
                        {
                            Reference = iv.Referencia,
                            Reason    = iv.RazaoNota == string.Empty ? null : iv.RazaoNota,
                        };
                    }

                    linesInvoice[j] = new AuditFileSourceDocumentsSalesInvoicesInvoiceLine()
                    {
                        CreditAmountSpecified = showCreditField,
                        DebitAmountSpecified  = !showCreditField,

                        CreditAmount       = lineProduct.TotalIncidencia.ToString("F3").Replace(",", "."),
                        DebitAmount        = lineProduct.TotalIncidencia.ToString("F3").Replace(",", "."),
                        Description        = "bom",
                        LineNumber         = (j + 1).ToString(),
                        ProductCode        = lineProduct.ProductId.ToString(),
                        Quantity           = lineProduct.Quantidade.ToString("F3").Replace(",", "."),
                        UnitPrice          = lineProduct.Preco.ToString("F3").Replace(",", "."),
                        ProductDescription = lineProduct.Descricao_Produto,
                        UnitOfMeasure      = lineProduct.Unidade,
                        Tax = new AuditFileSourceDocumentsSalesInvoicesInvoiceLineTax()
                        {
                            TaxCountryRegion = "AO",
                            TaxType          = impostoType,
                            TaxPercentage    = lineProduct.Taxa.ToString("F3").Replace(",", "."),
                            TaxCode          = imposto,
                        },
                        References         = references,
                        TaxExemptionReason = taxReason != null ? taxReason.MencaoFatura : null,
                        TaxExemptionCode   = taxReason != null ? taxReason.Id : null,
                        TaxPointDate       = Convert.ToDateTime(iv.InvoiceDate),
                        SettlementAmount   = /*lineProduct.ValorDesconto.ToString().Replace(",", ".") */ lineProduct.ValorDesconto.ToString("F3").Replace(",", "."),
                    };

                    j++;
                }

                listSalesInvoices[i] = new AuditFileSourceDocumentsSalesInvoicesInvoice()
                {
                    CustomerID     = iv.Cliente.Nif.Contains("9999999") || iv.Cliente.Nif == string.Empty ? finalCustomer.Id.ToString() : iv.ClienteId.ToString(),
                    DocumentStatus = new AuditFileSourceDocumentsSalesInvoicesInvoiceDocumentStatus()
                    {
                        InvoiceStatus     = iv.InvoiceStatus.Estado,
                        InvoiceStatusDate = iv.DataCadastro.ToString("yyyy-MM-ddTHH:mm:ss"),
                        SourceID          = iv.UserId.ToString(),
                        SourceBilling     = "P",
                    },
                    Hash            = iv.Hash,
                    InvoiceDate     = iv.InvoiceDate,
                    InvoiceNo       = iv.InvoiceNo,
                    InvoiceType     = iv.TipoDocumento.Tipo,
                    SourceID        = iv.UserId.ToString(),
                    HashControl     = systemInfo.SoftwareValidationNumber == "0" ? "0" : "1",
                    SystemEntryDate = iv.DataCadastro.ToString(fDateT),
                    Period          = iv.DataCadastro.Month.ToString(),
                    DocumentTotals  = new AuditFileSourceDocumentsSalesInvoicesInvoiceDocumentTotals()
                    {
                        TaxPayable = iv.TotalImposto.ToString("F3").Replace(",", "."),
                        NetTotal   = iv.TotalIncidencia.ToString("F3").Replace(",", "."),
                        GrossTotal = iv.TotalGeral.ToString("F3").Replace(",", "."),
                        Payment    = new AuditFileSourceDocumentsSalesInvoicesInvoiceDocumentTotalsPayment()
                        {
                            PaymentMechanism = iv.FormaPagamento.Id,
                            PaymentAmount    = /*iv.TotalGeral.ToString("F").Replace(",", "."), */ iv.ValorPago.ToString("F3").Replace(",", "."),
                            PaymentDate      = Convert.ToDateTime(iv.InvoiceDate),
                        },
                    },
                    Line           = linesInvoice,
                    SpecialRegimes = new AuditFileSourceDocumentsSalesInvoicesInvoiceSpecialRegimes()
                    {
                        CashVATSchemeIndicator       = "0",
                        SelfBillingIndicator         = "0",
                        ThirdPartiesBillingIndicator = "0"
                    },

                    /* WithholdingTax = new AuditFileSourceDocumentsSalesInvoicesInvoiceWithholdingTax()
                     * {
                     *   WithholdingTaxType = "IRT",
                     *   WithholdingTaxDescription = "Aplicação da Retenção",
                     *   WithholdingTaxAmount = "0",
                     * },
                     */
                };
                i++;
            }

            return(new AuditFileSourceDocumentsSalesInvoices()
            {
                Invoice = listSalesInvoices.Count() > 0 ? listSalesInvoices : null,
                TotalCredit = totalCredit.ToString("F3").Replace(",", "."),
                TotalDebit = totalDebit.ToString("F3").Replace(",", "."),
                NumberOfEntries = listSalesInvoices.Count().ToString(),
            });
        }