Esempio n. 1
0
        protected override void CalcTaxes(PXCache sender, object row, PXTaxCheck taxchk)
        {
            if (isManualVAT(sender))
            {
                CalcTotals(sender, row, true);
                return;
            }

            base.CalcTaxes(sender, row, taxchk);
        }
        protected List <object> SelectTaxes <TWhere, TLineNbr>(PXGraph graph, object[] currents, PXTaxCheck taxchk, params object[] parameters)
            where TWhere : IBqlWhere, new()
            where TLineNbr : IBqlOperand
        {
            Dictionary <string, PXResult <Tax, TaxRev> > tail = new Dictionary <string, PXResult <Tax, TaxRev> >();

            foreach (PXResult <Tax, TaxRev> record in PXSelectReadonly2 <Tax,
                                                                         LeftJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                               And <TaxRev.outdated, Equal <boolFalse>,
                                                                                                    And2 <Where <TaxRev.taxType, Equal <TaxType.purchase>, And <Tax.reverseTax, Equal <boolFalse>,
                                                                                                                                                                Or <TaxRev.taxType, Equal <TaxType.sales>, And <Where <Tax.reverseTax, Equal <boolTrue>,
                                                                                                                                                                                                                       Or <Tax.taxType, Equal <CSTaxType.use>, Or <Tax.taxType, Equal <CSTaxType.withholding> > > > > > > >,
                                                                                                          And <Current <POLandedCostDoc.docDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > >,
                                                                         TWhere>
                     .SelectMultiBound(graph, currents, parameters))
            {
                tail[((Tax)record).TaxID] = record;
            }
            List <object> ret = new List <object>();

            switch (taxchk)
            {
            case PXTaxCheck.Line:
                foreach (POLandedCostTax record in PXSelect <POLandedCostTax,
                                                             Where <POLandedCostTax.docType, Equal <Current <POLandedCostDoc.docType> >,
                                                                    And <POLandedCostTax.refNbr, Equal <Current <POLandedCostDoc.refNbr> >,
                                                                         And <POLandedCostTax.lineNbr, Equal <TLineNbr> > > > >
                         .SelectMultiBound(graph, currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx;
                        for (idx = ret.Count;
                             (idx > 0) &&
                             String.Compare(((Tax)(PXResult <POLandedCostTax, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                             idx--)
                        {
                            ;
                        }
                        ret.Insert(idx, new PXResult <POLandedCostTax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                return(ret);

            case PXTaxCheck.RecalcLine:
                foreach (POLandedCostTax record in PXSelect <POLandedCostTax,
                                                             Where <POLandedCostTax.docType, Equal <Current <POLandedCostDoc.docType> >,
                                                                    And <POLandedCostTax.refNbr, Equal <Current <POLandedCostDoc.refNbr> >,
                                                                         And <POLandedCostTax.lineNbr, Less <intMax> > > > >
                         .SelectMultiBound(graph, currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx;
                        for (idx = ret.Count;
                             (idx > 0) &&
                             ((POLandedCostTax)(PXResult <POLandedCostTax, Tax, TaxRev>)ret[idx - 1]).LineNbr == record.LineNbr &&
                             String.Compare(((Tax)(PXResult <POLandedCostTax, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                             idx--)
                        {
                            ;
                        }
                        ret.Insert(idx, new PXResult <POLandedCostTax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                return(ret);

            case PXTaxCheck.RecalcTotals:
                foreach (POLandedCostTaxTran record in PXSelect <POLandedCostTaxTran,
                                                                 Where <POLandedCostTaxTran.docType, Equal <Current <POLandedCostDoc.docType> >, And <POLandedCostTaxTran.refNbr, Equal <Current <POLandedCostDoc.refNbr> > > > >
                         .SelectMultiBound(graph, currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (record.TaxID != null && tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx;
                        for (idx = ret.Count;
                             (idx > 0) &&
                             String.Compare(((Tax)(PXResult <POLandedCostTaxTran, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                             idx--)
                        {
                            ;
                        }
                        ret.Insert(idx, new PXResult <POLandedCostTaxTran, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                return(ret);

            default:
                return(ret);
            }
        }
        protected override List <object> SelectTaxes <TWhere>(PXGraph graph, object row, PXTaxCheck taxchk, params object[] parameters)
        {
            var result = SelectTaxes <TWhere, Current <POLandedCostDetail.lineNbr> >(graph, new object[] { row, ((POLandedCostDocEntry)graph).Document.Current }, taxchk, parameters);

            return(result);
        }
Esempio n. 4
0
        protected override List <object> SelectTaxes <Where>(PXGraph graph, object row, PXTaxCheck taxchk, params object[] parameters)
        {
            List <object> ret = new List <object>();

            switch (taxchk)
            {
            case PXTaxCheck.Line:
                int?linenbr = int.MinValue;

                if (row != null && row.GetType() == typeof(PMProformaProgressLine))
                {
                    linenbr = (int?)graph.Caches[typeof(PMProformaProgressLine)].GetValue <PMProformaProgressLine.lineNbr>(row);
                }

                if (row != null && row.GetType() == typeof(PMProformaTransactLine))
                {
                    linenbr = (int?)graph.Caches[typeof(PMProformaTransactLine)].GetValue <PMProformaTransactLine.lineNbr>(row);
                }

                foreach (PMTax record in PXSelect <PMTax, Where <PMTax.refNbr, Equal <Current <PMProforma.refNbr> > > > .SelectMultiBound(graph, new object[] { row }))
                {
                    if (record.LineNbr == linenbr)
                    {
                        AppendTail <PMTax, Where>(graph, ret, record, row, parameters);
                    }
                }
                return(ret);

            case PXTaxCheck.RecalcLine:
                foreach (PMTax record in PXSelect <PMTax, Where <PMTax.refNbr, Equal <Current <PMProforma.refNbr> > > > .SelectMultiBound(graph, new object[] { row }))
                {
                    AppendTail <PMTax, Where>(graph, ret, record, row, parameters);
                }
                return(ret);

            case PXTaxCheck.RecalcTotals:
                foreach (PMTaxTran record in PXSelect <PMTaxTran,
                                                       Where <PMTaxTran.refNbr, Equal <Current <PMProforma.refNbr> > > > .SelectMultiBound(graph, new object[] { row }))
                {
                    AppendTail <PMTaxTran, Where>(graph, ret, record, row, parameters);
                }
                return(ret);

            default:
                return(ret);
            }
        }
Esempio n. 5
0
 protected override List <object> SelectTaxes <WhereType>(PXGraph graph, object row, PXTaxCheck taxchk, params object[] parameters)
 {
     return
         (IsRetainedTaxes(graph)
                                 ? base.SelectTaxes <WhereType>(graph, row, taxchk, parameters)
                                 : new List <object>());
 }
            protected override List <object> SelectTaxes <Where>(PXGraph graph, object row, PXTaxCheck taxchk, params object[] parameters)
            {
                Dictionary <string, PXResult <Tax, TaxRev> > tail = new Dictionary <string, PXResult <Tax, TaxRev> >();
                var currents = new[]
                {
                    row != null && row is Extensions.SalesTax.Detail ? Details.Cache.GetMain((Extensions.SalesTax.Detail)row):null,
                    ((AppointmentEntryBase)graph).AppointmentSelected.Current
                };

                foreach (PXResult <Tax, TaxRev> record in PXSelectReadonly2 <Tax,
                                                                             LeftJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                                   And <TaxRev.outdated, Equal <False>,
                                                                                                        And <TaxRev.taxType, Equal <TaxType.sales>,
                                                                                                             And <Tax.taxType, NotEqual <CSTaxType.withholding>,
                                                                                                                  And <Tax.taxType, NotEqual <CSTaxType.use>,
                                                                                                                       And <Tax.reverseTax, Equal <False>,
                                                                                                                            And <Current <FSAppointment.executionDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > > > > >,
                                                                             Where>
                         .SelectMultiBound(graph, currents, parameters))
                {
                    tail[((Tax)record).TaxID] = record;
                }
                List <object> ret = new List <object>();

                switch (taxchk)
                {
                case PXTaxCheck.Line:
                    foreach (FSAppointmentTax record in PXSelect <FSAppointmentTax,
                                                                  Where <FSAppointmentTax.entityID, Equal <Current <FSAppointment.appointmentID> >,
                                                                         And <FSAppointmentTax.lineNbr, Equal <Current <FSAppointmentDetUNION.apptLineNbr> > > > >
                             .SelectMultiBound(graph, currents))
                    {
                        PXResult <Tax, TaxRev> line;
                        if (tail.TryGetValue(record.TaxID, out line))
                        {
                            int idx;
                            for (idx = ret.Count;
                                 (idx > 0) &&
                                 String.Compare(((Tax)(PXResult <FSAppointmentTax, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                                 idx--)
                            {
                                ;
                            }
                            ret.Insert(idx, new PXResult <FSAppointmentTax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                        }
                    }
                    return(ret);

                case PXTaxCheck.RecalcLine:
                    foreach (FSAppointmentTax record in PXSelect <FSAppointmentTax,
                                                                  Where <FSAppointmentTax.entityID, Equal <Current <FSAppointment.appointmentID> >,
                                                                         And <FSAppointmentTax.lineNbr, Less <intMax> > > >
                             .SelectMultiBound(graph, currents))
                    {
                        PXResult <Tax, TaxRev> line;
                        if (tail.TryGetValue(record.TaxID, out line))
                        {
                            int idx;
                            for (idx = ret.Count;
                                 (idx > 0) &&
                                 ((FSAppointmentTax)(PXResult <FSAppointmentTax, Tax, TaxRev>)ret[idx - 1]).LineNbr == record.LineNbr &&
                                 String.Compare(((Tax)(PXResult <FSAppointmentTax, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                                 idx--)
                            {
                                ;
                            }
                            ret.Insert(idx, new PXResult <FSAppointmentTax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                        }
                    }
                    return(ret);

                case PXTaxCheck.RecalcTotals:
                    foreach (FSAppointmentTaxTran record in PXSelect <FSAppointmentTaxTran,
                                                                      Where <FSAppointmentTaxTran.entityID, Equal <Current <FSAppointment.appointmentID> > >,
                                                                      OrderBy <Asc <FSAppointmentTaxTran.entityID, Asc <FSAppointmentTaxTran.lineNbr, Asc <FSAppointmentTaxTran.taxID> > > > >
                             .SelectMultiBound(graph, currents))
                    {
                        PXResult <Tax, TaxRev> line;
                        if (record.TaxID != null && tail.TryGetValue(record.TaxID, out line))
                        {
                            int idx;
                            for (idx = ret.Count;
                                 (idx > 0) &&
                                 String.Compare(((Tax)(PXResult <FSAppointmentTaxTran, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                                 idx--)
                            {
                                ;
                            }
                            ret.Insert(idx, new PXResult <FSAppointmentTaxTran, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                        }
                    }
                    return(ret);

                default:
                    return(ret);
                }
            }
Esempio n. 7
0
        protected override List <object> SelectTaxes <Where>(PXGraph graph, object row, PXTaxCheck taxchk, params object[] parameters)
        {
            Dictionary <string, PXResult <Tax, TaxRev> > tail = new Dictionary <string, PXResult <Tax, TaxRev> >();

            object[] currents = new object[] { row };
            foreach (PXResult <Tax, TaxRev> record in PXSelectReadonly2 <Tax,
                                                                         LeftJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                               And <TaxRev.outdated, Equal <boolFalse>,
                                                                                                    And2 <Where <TaxRev.taxType, Equal <TaxType.purchase>, And <Tax.reverseTax, Equal <boolFalse>,
                                                                                                                                                                Or <TaxRev.taxType, Equal <TaxType.sales>, And <Tax.reverseTax, Equal <boolTrue>,
                                                                                                                                                                                                                Or <Tax.taxType, Equal <CSTaxType.use>,
                                                                                                                                                                                                                    Or <Tax.taxType, Equal <CSTaxType.withholding> > > > > > >,
                                                                                                          And <Current <EPExpenseClaimDetails.expenseDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > >,
                                                                         Where>
                     .SelectMultiBound(graph, currents, parameters))
            {
                Tax adjdTax = AdjustTaxLevel(graph, (Tax)record);
                tail[((Tax)record).TaxID] = new PXResult <Tax, TaxRev>(adjdTax, (TaxRev)record);
            }
            List <object> ret = new List <object>();

            switch (taxchk)
            {
            case PXTaxCheck.Line:
            case PXTaxCheck.RecalcLine:
                var cmdEPTax = new PXSelect <EPTax,
                                             Where <EPTax.claimDetailID, Equal <Current <EPExpenseClaimDetails.claimDetailID> > > >(graph);
                if (IsTaxTipAttribute())
                {
                    cmdEPTax.WhereAnd <Where <EPTax.isTipTax, Equal <True> > >();
                }
                else
                {
                    cmdEPTax.WhereAnd <Where <EPTax.isTipTax, Equal <False> > >();
                }
                foreach (EPTax record in cmdEPTax.Select(currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx;
                        for (idx = ret.Count;
                             (idx > 0) &&
                             String.Compare(((Tax)(PXResult <EPTax, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                             idx--)
                        {
                            ;
                        }
                        ret.Insert(idx, new PXResult <EPTax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                break;

            case PXTaxCheck.RecalcTotals:
                var cmdEPTaxTran = new PXSelect <EPTaxTran,
                                                 Where <EPTaxTran.claimDetailID, Equal <Current <EPExpenseClaimDetails.claimDetailID> > > >(graph);
                if (IsTaxTipAttribute())
                {
                    cmdEPTaxTran.WhereAnd <Where <EPTaxTran.isTipTax, Equal <True> > >();
                }
                else
                {
                    cmdEPTaxTran.WhereAnd <Where <EPTaxTran.isTipTax, Equal <False> > >();
                }
                foreach (EPTaxTran record in cmdEPTaxTran.Select(currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx;
                        for (idx = ret.Count;
                             (idx > 0) &&
                             String.Compare(((Tax)(PXResult <EPTaxTran, Tax, TaxRev>)ret[idx - 1]).TaxCalcLevel, ((Tax)line).TaxCalcLevel) > 0;
                             idx--)
                        {
                            ;
                        }
                        ret.Insert(idx, new PXResult <EPTaxTran, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                break;
            }
            return(ret);
        }
Esempio n. 8
0
        protected override List <object> SelectTaxes <Where>(PXGraph graph, object row, PXTaxCheck taxchk, params object[] parameters)
        {
            Dictionary <string, PXResult <Tax, TaxRev> > tail = new Dictionary <string, PXResult <Tax, TaxRev> >();

            object[] currents = new object[] { row, ((CATranEntry)graph).CAAdjRecords.Current };
            foreach (PXResult <Tax, TaxRev> record in PXSelectReadonly2 <Tax,
                                                                         LeftJoin <TaxRev, On <TaxRev.taxID, Equal <Tax.taxID>,
                                                                                               And <TaxRev.outdated, Equal <boolFalse>,
                                                                                                    And2 <
                                                                                                        Where <Current <CAAdj.drCr>, Equal <CADrCr.cACredit>, And <TaxRev.taxType, Equal <TaxType.purchase>, And <Tax.reverseTax, Equal <boolFalse>,
                                                                                                                                                                                                                  Or <Current <CAAdj.drCr>, Equal <CADrCr.cACredit>, And <TaxRev.taxType, Equal <TaxType.sales>, And2 <Where <Tax.reverseTax, Equal <boolTrue>,
                                                                                                                                                                                                                                                                                                                              Or <Tax.taxType, Equal <CSTaxType.use> > >,
                                                                                                                                                                                                                                                                                                                       Or <Current <CAAdj.drCr>, Equal <CADrCr.cADebit>, And <TaxRev.taxType, Equal <TaxType.sales>, And <Tax.reverseTax, Equal <boolFalse>,
                                                                                                                                                                                                                                                                                                                                                                                                                          And <Tax.taxType, NotEqual <CSTaxType.withholding>, And <Tax.taxType, NotEqual <CSTaxType.use> > > > > > > > > > > >,
                                                                                                        And <Current <CAAdj.tranDate>, Between <TaxRev.startDate, TaxRev.endDate> > > > > >,
                                                                         Where>
                     .SelectMultiBound(graph, currents, parameters))
            {
                Tax adjdTax = AdjustTaxLevel(graph, (Tax)record);
                tail[((Tax)record).TaxID] = new PXResult <Tax, TaxRev>(adjdTax, (TaxRev)record);
            }
            List <object> ret = new List <object>();

            switch (taxchk)
            {
            case PXTaxCheck.Line:
                foreach (CATax record in PXSelect <CATax,
                                                   Where <CATax.adjTranType, Equal <Current <CASplit.adjTranType> >,
                                                          And <CATax.adjRefNbr, Equal <Current <CASplit.adjRefNbr> >,
                                                               And <CATax.lineNbr, Equal <Current <CASplit.lineNbr> > > > > >
                         .SelectMultiBound(graph, currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx = CalculateIndex <CATax>(ret, line);
                        ret.Insert(idx, new PXResult <CATax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                return(ret);

            case PXTaxCheck.RecalcLine:
                foreach (CATax record in PXSelect <CATax,
                                                   Where <CATax.adjTranType, Equal <Current <CAAdj.adjTranType> >,
                                                          And <CATax.adjRefNbr, Equal <Current <CAAdj.adjRefNbr> > > > >
                         .SelectMultiBound(graph, currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx = CalculateIndex <CATax>(ret, line);
                        ret.Insert(idx, new PXResult <CATax, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                return(ret);

            case PXTaxCheck.RecalcTotals:
                foreach (CATaxTran record in PXSelect <CATaxTran,
                                                       Where <CATaxTran.module, Equal <BatchModule.moduleCA>,
                                                              And <CATaxTran.tranType, Equal <Current <CAAdj.adjTranType> >,
                                                                   And <CATaxTran.refNbr, Equal <Current <CAAdj.adjRefNbr> > > > > >
                         .SelectMultiBound(graph, currents))
                {
                    PXResult <Tax, TaxRev> line;
                    if (record.TaxID != null && tail.TryGetValue(record.TaxID, out line))
                    {
                        int idx = CalculateIndex <CATaxTran>(ret, line);
                        ret.Insert(idx, new PXResult <CATaxTran, Tax, TaxRev>(record, (Tax)line, (TaxRev)line));
                    }
                }
                return(ret);

            default:
                return(ret);
            }
        }