public static void CheckReportSettingsEditable(PXGraph graph, int?vendorID) { if (ReportTaxProcess.PrepearedTaxPeriodForVendorExists(graph, vendorID)) { throw new PXException(Messages.TheTaxReportSettingsCannotBeModified); } }
private void SetDocDateByPeriods(PXCache cache, TaxAdjustment document) { if (document.TaxPeriod == null) { return; } var taxPeriod = ReportTaxProcess.FindTaxPeriodByKey(this, document.VendorID, document.TaxPeriod); if (taxPeriod == null) { return; } DateTime?docDate; if (vendor.Current.TaxReportFinPeriod == true) { var finPeriod = FinPeriodIDAttribute.FindMaxFinPeriodWithEndDataBelongToInterval(this, taxPeriod.StartDate, taxPeriod.EndDate); docDate = finPeriod != null ? finPeriod.FinDate : Accessinfo.BusinessDate; } else { docDate = taxPeriod.EndDateUI; } cache.SetValueExt <TaxAdjustment.docDate>(document, docDate); }
protected void baseVATPeriodFilterRowSelected(PXCache sender, PXRowSelectedEventArgs e) { VATPeriodFilter filter = e.Row as VATPeriodFilter; if (filter?.OrganizationID == null) { return; } Organization organization = OrganizationMaint.FindOrganizationByID(this, filter.OrganizationID); if (organization.FileTaxesByBranches == true && filter.BranchID == null || filter.VendorID == null || filter.TaxPeriodID == null) { return; } TaxPeriod taxPeriod = Period.Select(); int?maxRevision = ReportTaxProcess.CurrentRevisionId(sender.Graph, filter.OrganizationID, filter.BranchID, filter.VendorID, filter.TaxPeriodID); filter.StartDate = taxPeriod?.StartDateUI; filter.EndDate = taxPeriod?.EndDate != null ? (DateTime?)(((DateTime)taxPeriod.EndDate).AddDays(-1)) : null; PXUIFieldAttribute.SetEnabled <VATPeriodFilter.revisionId>(sender, null, maxRevision > 1); PXUIFieldAttribute.SetEnabled <VATPeriodFilter.taxPeriodID>(sender, null, true); }
public static void CheckReportSettingsEditableAndSetWarningTo <TVendorIDField>(PXGraph graph, PXCache cache, object row, int?vendorID) where TVendorIDField : IBqlField { if (ReportTaxProcess.PrepearedTaxPeriodForVendorExists(graph, vendorID)) { var bAccIDfieldState = (PXFieldState)cache.GetStateExt <TVendorIDField>(row); cache.RaiseExceptionHandling <TVendorIDField>(row, bAccIDfieldState.Value, new PXSetPropertyException(Messages.TheTaxReportSettingsCannotBeModified, PXErrorLevel.Warning)); } }
protected void ApplySign(GAFRecordBase gafRecord, string taxTranModule, string docType) { var sign = ReportTaxProcess.GetMultByTranType(taxTranModule, docType); if (sign < 0) { gafRecord.Amount *= sign; gafRecord.GSTAmount *= sign; gafRecord.ForeignCurrencyAmount *= sign; gafRecord.ForeignCurrencyAmountGST *= sign; } }
protected void ApplySign(IEnumerable <GAFRecordBase> gafRecords, string taxTranModule, string docType) { var sign = ReportTaxProcess.GetMultByTranType(taxTranModule, docType); if (sign < 0) { foreach (var gafRecord in gafRecords) { gafRecord.Amount *= sign; gafRecord.GSTAmount *= sign; gafRecord.ForeignCurrencyAmount *= sign; gafRecord.ForeignCurrencyAmountGST *= sign; } } }
private void ValidateDocDate(PXCache cache, TaxAdjustment doc) { if (doc.DocDate == null || doc.TaxPeriod == null) { return; } var taxPeriod = ReportTaxProcess.FindTaxPeriodByKey(this, doc.VendorID, doc.TaxPeriod); if (taxPeriod == null) { return; } string errorMessage = null; if (vendor.Current.TaxReportFinPeriod == true) { var finPeriod = FinPeriodIDAttribute.GetFinPeriodByID(this, doc.FinPeriodID); if (finPeriod.FinDate >= taxPeriod.EndDate) { errorMessage = Messages.SelectedDateBelongsToTheTaxPeriodThatIsGreaterThanTheSpecifiedOne; } } else if (doc.DocDate >= taxPeriod.EndDate) { errorMessage = Messages.SelectedDateBelongsToTheTaxPeriodThatIsGreaterThanTheSpecifiedOne; } var ex = errorMessage != null ? new PXSetPropertyException(errorMessage, PXErrorLevel.Warning) : null; cache.RaiseExceptionHandling <TaxAdjustment.docDate>(doc, doc.DocDate, ex); }
public static void ProcessPendingVATProc(List <TaxTran> list) { JournalEntry je = PXGraph.CreateInstance <JournalEntry>(); PXCache dummycache = je.Caches[typeof(TaxTran)]; dummycache = je.Caches[typeof(VATTaxTran)]; je.Views.Caches.Add(typeof(VATTaxTran)); DocumentList <Batch> created = new DocumentList <Batch>(je); foreach (TaxTran taxtran in list) { PXProcessing <TaxTran> .SetCurrentItem(taxtran); if (string.IsNullOrEmpty(taxtran.TaxInvoiceNbr) == true || taxtran.TaxInvoiceDate == null) { //PXProcessing<TaxTran>.SetWarning(Messages.CannotProcessW); PXProcessing <TaxTran> .SetError(Messages.CannotProcessW); } else { using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <VATTaxTran, CurrencyInfo, Tax> res in PXSelectJoin <VATTaxTran, InnerJoin <CurrencyInfo, On <CurrencyInfo.curyInfoID, Equal <VATTaxTran.curyInfoID> >, InnerJoin <Tax, On <Tax.taxID, Equal <VATTaxTran.taxID> > > >, Where <VATTaxTran.module, Equal <Current <TaxTran.module> >, And <VATTaxTran.tranType, Equal <Current <TaxTran.tranType> >, And <VATTaxTran.refNbr, Equal <Current <TaxTran.refNbr> >, And <VATTaxTran.taxID, Equal <Current <TaxTran.taxID> > > > > > > .SelectSingleBound(je, new object[] { taxtran })) { VATTaxTran n = (VATTaxTran)res; CurrencyInfo info = (CurrencyInfo)res; Tax x = (Tax)res; string strFinPeriodID = FinPeriodSelectorAttribute.PeriodFromDate(taxtran.TaxInvoiceDate); SegregateBatch(je, info.CuryID, taxtran.TaxInvoiceDate, strFinPeriodID, created); n.TaxInvoiceNbr = taxtran.TaxInvoiceNbr; n.TaxInvoiceDate = taxtran.TaxInvoiceDate; je.Caches[typeof(VATTaxTran)].Update(n); CurrencyInfo new_info = PXCache <CurrencyInfo> .CreateCopy(info); new_info.CuryInfoID = null; new_info.ModuleCode = "GL"; new_info.BaseCalc = false; new_info = je.currencyinfo.Insert(new_info) ?? new_info; //reverse original transaction { GLTran tran = new GLTran(); tran.AccountID = n.AccountID; tran.SubID = n.SubID; tran.CuryDebitAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? n.CuryTaxAmt : 0m; tran.DebitAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? n.TaxAmt : 0m; tran.CuryCreditAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? 0m : n.CuryTaxAmt; tran.CreditAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? 0m : n.TaxAmt; tran.TranType = n.TranType; tran.TranClass = "N"; tran.RefNbr = n.RefNbr; tran.TranDesc = n.TaxInvoiceNbr; tran.TranPeriodID = strFinPeriodID; tran.FinPeriodID = strFinPeriodID; tran.TranDate = n.TaxInvoiceDate; tran.CuryInfoID = new_info.CuryInfoID; tran.Released = true; je.GLTranModuleBatNbr.Insert(tran); VATTaxTran newtran = PXCache <VATTaxTran> .CreateCopy(n); newtran.Module = "GL"; newtran.TranType = (n.TaxType == TaxType.PendingSales) ? TaxAdjustmentType.ReverseOutputVAT : TaxAdjustmentType.ReverseInputVAT; newtran.RefNbr = newtran.TaxInvoiceNbr; newtran.TranDate = newtran.TaxInvoiceDate; newtran.CuryTaxableAmt = -ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.CuryTaxableAmt; newtran.TaxableAmt = -ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.TaxableAmt; newtran.CuryTaxAmt = -ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.CuryTaxAmt; newtran.TaxAmt = -ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.TaxAmt; je.Caches[typeof(VATTaxTran)].Insert(newtran); } //reclassify to VAT account { GLTran tran = new GLTran(); tran.AccountID = (n.TaxType == TaxType.PendingSales) ? x.SalesTaxAcctID : x.PurchTaxAcctID; tran.SubID = (n.TaxType == TaxType.PendingSales) ? x.SalesTaxSubID : x.PurchTaxSubID; tran.CuryDebitAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? 0m : n.CuryTaxAmt; tran.DebitAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? 0m : n.TaxAmt; tran.CuryCreditAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? n.CuryTaxAmt : 0m; tran.CreditAmt = (n.TaxType == TaxType.PendingSales && ReportTaxProcess.GetMult(n) == 1m) ? n.TaxAmt : 0m; tran.TranType = n.TranType; tran.TranClass = "N"; tran.RefNbr = n.RefNbr; tran.TranDesc = n.TaxInvoiceNbr; tran.TranPeriodID = strFinPeriodID; tran.FinPeriodID = strFinPeriodID; tran.TranDate = n.TaxInvoiceDate; tran.CuryInfoID = new_info.CuryInfoID; tran.Released = true; je.GLTranModuleBatNbr.Insert(tran); VATTaxTran newtran = PXCache <VATTaxTran> .CreateCopy(n); newtran.Module = "GL"; newtran.TranType = (n.TaxType == TaxType.PendingSales) ? TaxAdjustmentType.OutputVAT : TaxAdjustmentType.InputVAT; newtran.TaxType = (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase; newtran.AccountID = (n.TaxType == TaxType.PendingSales) ? x.SalesTaxAcctID : x.PurchTaxAcctID; newtran.SubID = (n.TaxType == TaxType.PendingSales) ? x.SalesTaxSubID : x.PurchTaxSubID; newtran.RefNbr = newtran.TaxInvoiceNbr; newtran.TranDate = newtran.TaxInvoiceDate; newtran.CuryTaxableAmt = ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.CuryTaxableAmt; newtran.TaxableAmt = ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.TaxableAmt; newtran.CuryTaxAmt = ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.CuryTaxAmt; newtran.TaxAmt = ReportTaxProcess.GetMult(n.Module, n.TranType, (n.TaxType == TaxType.PendingSales) ? TaxType.Sales : TaxType.Purchase, (short)1) * newtran.TaxAmt; je.Caches[typeof(VATTaxTran)].Insert(newtran); } } je.Save.Press(); ts.Complete(); } PXProcessing <TaxTran> .SetProcessed(); } } }
protected virtual void baseTaxPeriodFilterRowUpdated(PXCache sender, PXRowUpdatedEventArgs e) { VATPeriodFilter filter = (VATPeriodFilter)e.Row; if (filter == null) { return; } if (!sender.ObjectsEqual <VATPeriodFilter.organizationID, VATPeriodFilter.branchID>(e.Row, e.OldRow)) { List <PXView> views = this.Views.Select(view => view.Value).ToList(); foreach (var view in views) { view.Clear(); } } if (!sender.ObjectsEqual <VATPeriodFilter.organizationID>(e.Row, e.OldRow) || !sender.ObjectsEqual <VATPeriodFilter.branchID>(e.Row, e.OldRow) || !sender.ObjectsEqual <VATPeriodFilter.vendorID>(e.Row, e.OldRow)) { if (filter.OrganizationID != null && filter.VendorID != null) { PX.Objects.TX.TaxPeriod taxper = TaxYearMaint.FindPreparedPeriod(this, filter.OrganizationID, filter.VendorID); if (taxper != null) { filter.TaxPeriodID = taxper.TaxPeriodID; } else { taxper = TaxYearMaint.FindLastClosedPeriod(this, filter.OrganizationID, filter.VendorID); filter.TaxPeriodID = taxper != null ? taxper.TaxPeriodID : null; } } else { filter.TaxPeriodID = null; } } Organization organization = OrganizationMaint.FindOrganizationByID(this, filter.OrganizationID); if (!sender.ObjectsEqual <VATPeriodFilter.organizationID>(e.Row, e.OldRow) || !sender.ObjectsEqual <VATPeriodFilter.branchID>(e.Row, e.OldRow) || !sender.ObjectsEqual <VATPeriodFilter.vendorID>(e.Row, e.OldRow) || !sender.ObjectsEqual <VATPeriodFilter.taxPeriodID>(e.Row, e.OldRow) || filter.RevisionId == null) { if (filter.OrganizationID != null && (filter.BranchID != null && organization.FileTaxesByBranches == true || organization.FileTaxesByBranches != true) && filter.VendorID != null && filter.TaxPeriodID != null) { filter.RevisionId = ReportTaxProcess.CurrentRevisionId(this, filter.OrganizationID, filter.BranchID, filter.VendorID, filter.TaxPeriodID); } else { filter.RevisionId = null; } } }