Пример #1
0
        protected void _(Events.RowSelected <EPExpenseClaim> e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(e.Cache, e.Args);

            manGUIExpense.Cache.AllowSelect = TWNGUIValidation.ActivateTWGUI(Base);
            manGUIExpense.Cache.AllowDelete = manGUIExpense.Cache.AllowInsert = manGUIExpense.Cache.AllowUpdate = !e.Row.Status.Equals(EPExpenseClaimStatus.ReleasedStatus);
        }
Пример #2
0
        protected void _(Events.RowSelected <Tax> e, PXRowSelected InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(e.Cache, e.Args);

            PXUIFieldAttribute.SetVisible <TaxExt.usrGUIType>(e.Cache, null, TWNGUIValidation.ActivateTWGUI(Base));
            PXUIFieldAttribute.SetVisible <TaxExt.usrTWNGUI> (e.Cache, null, TWNGUIValidation.ActivateTWGUI(Base));
        }
Пример #3
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);
        }
Пример #4
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);
                    }
                }
            }
        }
Пример #5
0
        public void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            if (string.IsNullOrEmpty((string)e.NewValue) ||
                e.NewValue.ToString().Length.Equals(10) ||
                TWNGUIValidation.ActivateTWGUI(new PXGraph()).Equals(false))
            {
                return;
            }

            object obj     = null;
            string vATCode = null;

            switch (this.BqlTable.Name)
            {
            case nameof(APRegister):
                obj = sender.GetValueExt <APRegisterExt.usrVATInCode>(e.Row);
                break;

            case nameof(ARRegister):
                obj = sender.GetValueExt <ARRegisterExt.usrVATOutCode>(e.Row);
                break;

            case nameof(TWNGUITrans):
                obj = sender.GetValueExt <TWNGUITrans.gUIFormatcode>(e.Row);
                break;

            case nameof(TWNManualGUIAP):
                obj = sender.GetValueExt <TWNManualGUIAP.vATInCode>(e.Row);
                break;

            case nameof(TWNManualGUIAR):
                obj = sender.GetValueExt <TWNManualGUIAR.vatOutCode>(e.Row);
                break;

            case nameof(TWNManualGUIBank):
                obj = sender.GetValueExt <TWNManualGUIBank.vATInCode>(e.Row);
                break;

            case nameof(TWNManualGUIExpense):
                obj = sender.GetValueExt <TWNManualGUIExpense.vATInCode>(e.Row);
                break;
            }

            vATCode = obj is null ? string.Empty : obj.ToString();

            if (!vATCode.IsIn(TWGUIFormatCode.vATOutCode33, TWGUIFormatCode.vATOutCode34) ||
                vATCode.IsIn(TWGUIFormatCode.vATInCode21, TWGUIFormatCode.vATInCode23, TWGUIFormatCode.vATInCode25)
                )
            {
                throw new PXSetPropertyException(e.NewValue.ToString().Length > 10 ? TWMessages.GUINbrLength : TWMessages.GUINbrMini, PXErrorLevel.Error);
            }
        }
Пример #6
0
        protected void _(Events.RowSelected <APInvoice> e, PXRowSelected baseHandler)
        {
            baseHandler?.Invoke(e.Cache, e.Args);

            var row = e.Row as APInvoice;

            if (row != null)
            {
                ManualAPBill.Cache.AllowSelect = TWNGUIValidation.ActivateTWGUI(Base);
                ManualAPBill.Cache.AllowDelete = ManualAPBill.Cache.AllowInsert = ManualAPBill.Cache.AllowUpdate = row.Status.IsIn(APDocStatus.Hold, APDocStatus.Balanced);
            }

            //PXUIFieldAttribute.SetVisible<APRegisterExt.usrDeduction>(e.Cache, null, activateGUI);
            //PXUIFieldAttribute.SetVisible<APRegisterExt.usrGUIDate>(e.Cache, null, activateGUI);
            //PXUIFieldAttribute.SetVisible<APRegisterExt.usrGUINbr>(e.Cache, null, activateGUI);
            //PXUIFieldAttribute.SetVisible<APRegisterExt.usrOurTaxNbr>(e.Cache, null, activateGUI);
            //PXUIFieldAttribute.SetVisible<APRegisterExt.usrTaxNbr>(e.Cache, null, activateGUI);
            //PXUIFieldAttribute.SetVisible<APRegisterExt.usrVATInCode>(e.Cache, null, activateGUI);
        }
Пример #7
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);
        }
Пример #8
0
 public static bool IsActive() => TWNGUIValidation.ActivateTWGUI(new PXGraph());