Exemplo n.º 1
0
        protected override void LoadData(DocumentGroup <ARInvoice> documentGroup, int?taxAgencyID, string taxPeriodID)
        {
            base.LoadData(documentGroup, taxAgencyID, taxPeriodID);

            SOInvoices = GafRepository.GetSOInvoices(documentGroup.DocumentType, documentGroup.DocumentsByRefNbr.Keys.ToArray())
                         .ToDictionary(soInvoice => soInvoice.RefNbr, soInvoice => soInvoice);
        }
 protected Dictionary <string, Dictionary <string, TaxTran> > LoadTaxTransForDocumentsGroupedByDocumentAndTax(string module, string docType, IEnumerable <string> refNbrs, int?taxAgencyID, string taxPeriodID)
 {
     return(GafRepository.GetReportedTaxTransForDocuments(module, docType, refNbrs.ToArray(), taxAgencyID, taxPeriodID)
            .GroupBy(taxTran => taxTran.RefNbr)
            .ToDictionary(group => group.Key,
                          group => group.ToDictionary(taxTran => taxTran.TaxID, taxTran => taxTran)));
 }
        protected Dictionary <int?, Vendor> GetContragentsForDocuments(IEnumerable <APRegister> documents)
        {
            var usedVendorIDs = documents.Select(apReg => apReg.VendorID)
                                .Distinct()
                                .ToArray();

            return(GafRepository.GetVendorsByIDs(usedVendorIDs)
                   .ToDictionary(vendor => vendor.BAccountID, vendor => vendor));
        }
        protected override void LoadData(DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID)
        {
            base.LoadData(documentIDGroup, branchID, taxPeriodID);

            var refNbrs = documentIDGroup.RefNbrs.ToArray();

            _taxAdjustmentsByRefNbr = GafRepository.GetTaxAdjustments(documentIDGroup.DocumentType, refNbrs)
                                      .ToDictionary(taxAdj => taxAdj.RefNbr, taxAdj => taxAdj);
        }
Exemplo n.º 5
0
        protected Dictionary <int?, Customer> GetContragentsForDocuments(IEnumerable <ARInvoice> documents)
        {
            var usedCustomerIDs = documents.Select(apReg => apReg.CustomerID)
                                  .Distinct()
                                  .ToArray();

            return(GafRepository.GetCustomersByIDs(usedCustomerIDs)
                   .ToDictionary(customer => customer.BAccountID, customer => customer));
        }
        protected override void LoadData(DocumentGroup <APRegister> documentGroup, int?taxAgencyID, string taxPeriodID)
        {
            Contragents = GetContragentsForDocuments(DocumentsByRefNbr.Values);

            _taxTransWithAdjdDocumentByRefNbrAndTaxID = GafRepository.GetReportedTaxTransWithAdjdDocumentForAPPayments(documentGroup.DocumentType,
                                                                                                                       documentGroup.DocumentsByRefNbr.Keys.ToArray(),
                                                                                                                       taxAgencyID,
                                                                                                                       taxPeriodID)
                                                        .GroupBy(row => ((TaxTran)row).RefNbr)
                                                        .ToDictionary(group => group.Key, group => group.ToList());
        }
        private void LoadValuableTaxApRegistersForDocuments(DocumentGroup <APInvoice> documentGroup, int?taxAgencyID)
        {
            _taxApRegistersByOrigRefNbrAndTax = new Dictionary <string, Dictionary <string, APRegister> >();

            var taxApRegistersWithTaxTransGroupsByOrigRefNbrAndTax = GafRepository.GetReportedTaxAPRegistersWithTaxTransForDocuments(documentGroup.DocumentType,
                                                                                                                                     documentGroup.DocumentsByRefNbr.Keys.ToArray(),
                                                                                                                                     taxAgencyID)
                                                                     .GroupBy(row => new { ((TaxTran)row).OrigRefNbr, ((TaxTran)row).TaxID });

            foreach (var taxApRegistersWithTaxTransGroup in taxApRegistersWithTaxTransGroupsByOrigRefNbrAndTax)
            {
                var taxApRegistersWithTaxTran = taxApRegistersWithTaxTransGroup.OrderBy(row =>
                {
                    var apRegister = (APRegister)row;

                    switch (apRegister.DocType)
                    {
                    case APDocType.Invoice:
                        return(0);

                    case APDocType.CreditAdj:
                        return(1);

                    case APDocType.DebitAdj:
                        return(2);

                    default:
                        throw new PXException(Messages.TaxDocumentTypeOfTaxTransactionCannotBeIdentified,
                                              apRegister.DocType, ((TaxTran)row).GetKeyImage());
                    }
                })
                                                .ThenBy(row => ((APRegister)row).RefNbr)
                                                .First();

                var taxTran       = (TaxTran)taxApRegistersWithTaxTran;
                var taxApRegister = (APRegister)taxApRegistersWithTaxTran;

                if (!_taxApRegistersByOrigRefNbrAndTax.ContainsKey(taxTran.OrigRefNbr))
                {
                    _taxApRegistersByOrigRefNbrAndTax[taxTran.OrigRefNbr] = new Dictionary <string, APRegister>();
                }

                _taxApRegistersByOrigRefNbrAndTax[taxTran.OrigRefNbr].Add(taxTran.TaxID, taxApRegister);
            }
        }
        protected override void LoadData(DocumentGroup <TDocument> documentGroup, int?taxAgencyID, string taxPeriodID)
        {
            var refNbrs = documentGroup.DocumentsByRefNbr.Keys.ToArray();

            TaxTransByRefNbrAndTaxID = LoadTaxTransForDocumentsGroupedByDocumentAndTax(documentGroup.Module, documentGroup.DocumentType, refNbrs, taxAgencyID, taxPeriodID);

            TranWithTranTaxByDocument = GetReportedTransWithTranTaxesForTaxCalcedOnItem(documentGroup.DocumentType, refNbrs, taxAgencyID, taxPeriodID)
                                        .GroupBy(row => ((TTran)row).RefNbr)
                                        .ToDictionary(group => group.Key, group => group.ToArray());

            var usedTaxIDs = TaxTransByRefNbrAndTaxID.Values.SelectMany(taxTransByTax => taxTransByTax.Values.Select(taxTran => taxTran.TaxID))
                             .Union(TranWithTranTaxByDocument.Values.SelectMany(rows => rows.Select(row => ((TTranTax)row).TaxID)))
                             .Distinct()
                             .ToArray();

            Taxes = GafRepository.GetTaxesByIDs(usedTaxIDs)
                    .ToDictionary(tax => tax.TaxID, tax => tax);
        }
Exemplo n.º 9
0
        protected override void LoadData(DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID)
        {
            base.LoadData(documentIDGroup, branchID, taxPeriodID);

            var refNbrs = documentIDGroup.RefNbrs.ToArray();

            _taxableGLTransWithCuryInfo = GafRepository.GetTaxableGLTransWithCuryInfoGroupedByDocumentAttrAndTaxCategory(branchID, refNbrs)
                                          .ToDictionary(row =>
            {
                var tran = (GLTran)row;
                return(new TaxableGLTranKey()
                {
                    BranchID = tran.BranchID,
                    RefNbr = tran.RefNbr,
                    BatchNbr = tran.BatchNbr,
                    TaxableCategoryID = tran.TaxCategoryID
                });
            }
                                                        );

            _taxCategoryDetsByTaxID = GafRepository.GetTaxCategoryDetsForTaxIDs(Taxes.Keys.ToArray())
                                      .GroupBy(taxCategoryDet => taxCategoryDet.TaxID, taxCategoryDet => taxCategoryDet)
                                      .ToDictionary(group => group.Key, group => group.ToArray());
        }
        protected override string GetSaleCountryID(ARInvoice extendedInvoice)
        {
            var address = GafRepository.GetARAddress(extendedInvoice.BillAddressID);

            return(address.CountryID);
        }
 protected override IEnumerable <PXResult <APTran, APTax> > GetReportedTransWithTranTaxesForTaxCalcedOnItem(string docType, string[] refNbrs, int?taxAgencyID, string taxPeriodID)
 {
     return(GafRepository.GetReportedAPTransWithAPTaxesForTaxCalcedOnItem(docType, refNbrs, taxAgencyID, taxPeriodID));
 }
        protected override string GetSaleCountryID(SOInvoice extendedInvoice)
        {
            var address = GafRepository.GetSOAddress(extendedInvoice.ShipAddressID);

            return(address.CountryID);
        }