Ejemplo n.º 1
0
        public void OnReleaseComplete(ICADocument doc, OnReleaseCompleteDelegate baseMethod)
        {
            CAAdj cAAdj = doc as CAAdj;

            if (TWNGUIValidation.ActivateTWGUI(Base) == true &&
                cAAdj != null &&
                cAAdj.Released == true &&
                cAAdj.AdjTranType == CATranType.CAAdjustment)
            {
                TWNReleaseProcess rp = PXGraph.CreateInstance <TWNReleaseProcess>();

                PXSelectBase <TWNManualGUIBank> ViewManGUIBank = new SelectFrom <TWNManualGUIBank> .Where <TWNManualGUIBank.adjRefNbr.IsEqual <@P.AsString> > .View(Base);

                foreach (TWNManualGUIBank manualGUIBank in ViewManGUIBank.Cache.Cached)
                {
                    if (PXCache <Tax> .GetExtension <TaxExt>(Tax.PK.Find(Base, manualGUIBank.TaxID)).UsrTWNGUI.Equals(false))
                    {
                        continue;
                    }

                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        rp.CreateGUITrans(new STWNGUITran()
                        {
                            VATCode      = manualGUIBank.VATInCode,
                            GUINbr       = manualGUIBank.GUINbr,
                            GUIStatus    = TWNGUIStatus.Used,
                            BranchID     = Base.CATranCashTrans_Ordered.Current.BranchID,
                            GUIDirection = TWNGUIDirection.Receipt,
                            GUIDate      = manualGUIBank.GUIDate,
                            GUITitle     = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank,
                                                                                typeof(APRegister.vendorID).Name, manualGUIBank.VendorID,
                                                                                typeof(Vendor.acctName).Name),
                            TaxZoneID     = manualGUIBank.TaxZoneID,
                            TaxCategoryID = manualGUIBank.TaxCategoryID,
                            TaxID         = manualGUIBank.TaxID,
                            TaxNbr        = manualGUIBank.TaxNbr,
                            OurTaxNbr     = manualGUIBank.OurTaxNbr,
                            NetAmount     = manualGUIBank.NetAmt,
                            TaxAmount     = manualGUIBank.TaxAmt,
                            AcctCD        = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank,
                                                                                 typeof(APRegister.vendorID).Name, manualGUIBank.VendorID,
                                                                                 typeof(Vendor.acctCD).Name),
                            AcctName = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank,
                                                                            typeof(APRegister.vendorID).Name, manualGUIBank.VendorID,
                                                                            typeof(Vendor.acctName).Name),
                            DeductionCode = manualGUIBank.Deduction,
                            Remark        = manualGUIBank.Remark,
                            OrderNbr      = manualGUIBank.AdjRefNbr
                        });

                        ts.Complete(Base);
                    }
                }
            }

            baseMethod(doc);
        }
Ejemplo n.º 2
0
        public void ReleaseDocProc(EPExpenseClaim claim, ReleaseDocProcDelegate baseMethod)
        {
            baseMethod(claim);

            if (TWNGUIValidation.ActivateTWGUI(Base) == true &&
                claim != null &&
                claim.Released == true)
            {
                ExpenseClaimEntry graph = PXGraph.CreateInstance <ExpenseClaimEntry>();
                TWNReleaseProcess rp    = PXGraph.CreateInstance <TWNReleaseProcess>();

                Vendor vendor = new Vendor();

                foreach (TWNManualGUIExpense manualGUIExp in SelectFrom <TWNManualGUIExpense> .Where <TWNManualGUIExpense.refNbr.IsEqual <@P.AsString> > .View.Select(Base, claim.RefNbr))
                {
                    if (PXCache <Tax> .GetExtension <TaxExt>(Tax.PK.Find(Base, manualGUIExp.TaxID)).UsrTWNGUI == false)
                    {
                        continue;
                    }

                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        if (manualGUIExp.VendorID != null)
                        {
                            vendor = SelectFrom <Vendor> .Where <Vendor.bAccountID.IsEqual <@P.AsInt> > .View.SelectSingleBound(Base, null, manualGUIExp.VendorID);
                        }

                        rp.CreateGUITrans(new STWNGUITran()
                        {
                            VATCode       = manualGUIExp.VATInCode,
                            GUINbr        = manualGUIExp.GUINbr,
                            GUIStatus     = TWNGUIStatus.Used,
                            BranchID      = graph.ExpenseClaimDetailsCurrent.Current.BranchID,
                            GUIDirection  = TWNGUIDirection.Receipt,
                            GUIDate       = manualGUIExp.GUIDate,
                            GUITitle      = vendor.AcctName,
                            TaxZoneID     = manualGUIExp.TaxZoneID,
                            TaxCategoryID = manualGUIExp.TaxCategoryID,
                            TaxID         = manualGUIExp.TaxID,
                            TaxNbr        = manualGUIExp.TaxNbr,
                            OurTaxNbr     = manualGUIExp.OurTaxNbr,
                            NetAmount     = manualGUIExp.NetAmt,
                            TaxAmount     = manualGUIExp.TaxAmt,
                            AcctCD        = vendor.AcctCD,
                            AcctName      = vendor.AcctName,
                            DeductionCode = manualGUIExp.Deduction,
                            Remark        = manualGUIExp.Remark,
                            OrderNbr      = manualGUIExp.RefNbr
                        });

                        ts.Complete(Base);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void _(Events.RowDeleted <ARInvoice> e)
        {
            ARRegisterExt aRRegisterExt = PXCache <ARRegister> .GetExtension <ARRegisterExt>(e.Row);

            string taxID = string.Empty;

            /// When deleted, ARTax does not keep the current record, but can fetches the record from the cache.
            foreach (ARTax aRTax in Base.Tax_Rows.Cache.Deleted)
            {
                taxID = aRTax.TaxID;

                goto CreateGUI;
            }

CreateGUI:
            if (activateGUI && string.IsNullOrEmpty(taxID))
            {
                throw new PXException(TWMessages.NoInvTaxDtls);
            }

            if (string.IsNullOrEmpty(aRRegisterExt.UsrGUINbr) || !activateGUI || string.IsNullOrEmpty(TX.Tax.PK.Find(Base, taxID).GetExtension <TX.TaxExt>().UsrGUIType))
            {
                return;
            }

            // Acuminator disable once PX1043 SavingChangesInEventHandlers [Justification]
            rp.CreateGUITrans(new STWNGUITran()
            {
                VATCode       = aRRegisterExt.UsrVATOutCode,
                GUINbr        = aRRegisterExt.UsrGUINbr,
                GUIStatus     = TWNGUIStatus.Voided,
                GUIDirection  = TWNGUIDirection.Issue,
                GUIDate       = aRRegisterExt.UsrGUIDate,
                TaxZoneID     = e.Row.TaxZoneID,
                TaxCategoryID = Base.taxzone.Current.DfltTaxCategoryID,
                TaxID         = taxID,
                TaxNbr        = aRRegisterExt.UsrTaxNbr,
                OurTaxNbr     = aRRegisterExt.UsrOurTaxNbr,
                NetAmount     = 0,
                TaxAmount     = 0,
                AcctCD        = Base.customer.Current.AcctCD,
                AcctName      = Base.customer.Current.AcctName,
                DeductionCode = string.Empty,
                Remark        = string.Format(TWMessages.DeleteInfo, Base.Accessinfo.UserName),
                OrderNbr      = e.Row.RefNbr
            });
        }
Ejemplo n.º 4
0
        public void Persist(PersistDelegate baseMethod)
        {
            baseMethod();

            APRegister    doc    = Base.APDocument.Current;
            APRegisterExt docExt = PXCache <APRegister> .GetExtension <APRegisterExt>(doc);

            // Check for document and released flag
            if (TWNGUIValidation.ActivateTWGUI(Base) == true &&
                doc != null &&
                doc.Released == true &&
                doc.DocType.IsIn(APDocType.Invoice, APDocType.DebitAdj))
            {
                //if (Base.APTaxTran_TranType_RefNbr.Current == null)
                //{
                //    throw new PXException(TWMessages.NoInvTaxDtls);
                //}

                foreach (TWNManualGUIAPBill row in SelectFrom <TWNManualGUIAPBill> .Where <TWNManualGUIAPBill.docType.IsEqual <@P.AsString>
                                                                                           .And <TWNManualGUIAPBill.refNbr.IsEqual <@P.AsString> > > .View.Select(Base, doc.DocType, doc.RefNbr))
                {
                    // Avoid standard logic calling this method twice and inserting duplicate records into TWNGUITrans.
                    if (CountExistedRec(Base, row.GUINbr, row.VATInCode, doc.RefNbr) >= 1)
                    {
                        return;
                    }

                    if (Tax.PK.Find(Base, row.TaxID).GetExtension <TaxExt>().UsrTWNGUI != true)
                    {
                        continue;
                    }

                    Vendor vendor = Vendor.PK.Find(Base, row.VendorID);

                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        TWNReleaseProcess rp = PXGraph.CreateInstance <TWNReleaseProcess>();

                        TWNGUITrans tWNGUITrans = rp.InitAndCheckOnAP(row.GUINbr, row.VATInCode);

                        rp.CreateGUITrans(new STWNGUITran()
                        {
                            VATCode       = row.VATInCode,
                            GUINbr        = row.GUINbr,
                            GUIStatus     = TWNGUIStatus.Used,
                            BranchID      = Base.APTran_TranType_RefNbr.Current.BranchID,
                            GUIDirection  = TWNGUIDirection.Receipt,
                            GUIDate       = row.GUIDate,
                            GUITitle      = vendor?.AcctName,
                            TaxZoneID     = row.TaxZoneID,
                            TaxCategoryID = row.TaxCategoryID,
                            TaxID         = row.TaxID,
                            TaxNbr        = row.TaxNbr,
                            OurTaxNbr     = row.OurTaxNbr,
                            NetAmount     = row.NetAmt,
                            TaxAmount     = row.TaxAmt,
                            AcctCD        = vendor?.AcctCD,
                            AcctName      = vendor?.AcctName,
                            DeductionCode = row.Deduction,
                            Remark        = row.Remark,
                            BatchNbr      = doc.BatchNbr,
                            OrderNbr      = doc.RefNbr
                        });

                        if (tWNGUITrans != null)
                        {
                            if (tWNGUITrans.NetAmtRemain < row.NetAmt)
                            {
                                throw new PXException(TWMessages.RemainAmt);
                            }

                            ViewGUITrans.SetValueExt <TWNGUITrans.netAmtRemain>(tWNGUITrans, (tWNGUITrans.NetAmtRemain -= row.NetAmt));
                            ViewGUITrans.SetValueExt <TWNGUITrans.taxAmtRemain>(tWNGUITrans, (tWNGUITrans.TaxAmtRemain -= row.TaxAmt));

                            tWNGUITrans = ViewGUITrans.Update(tWNGUITrans);
                        }

                        // Manually Saving as base code will not call base graph persis.
                        ViewGUITrans.Cache.Persist(PXDBOperation.Insert);
                        ViewGUITrans.Cache.Persist(PXDBOperation.Update);

                        ts.Complete(Base);
                    }
                }
            }

            // Triggering after save events.
            ViewGUITrans.Cache.Persisted(false);
        }