NAV OnlineInvoices
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
namespace Nuvolar.Module.Controllers
|
||||
{
|
||||
partial class NAV_Online_VC
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.aNAV_queryInvoiceStatus = new DevExpress.ExpressApp.Actions.SimpleAction(this.components);
|
||||
this.aNAV_manageInvoice = new DevExpress.ExpressApp.Actions.SimpleAction(this.components);
|
||||
this.aNAV_queryTaxpayer = new DevExpress.ExpressApp.Actions.SimpleAction(this.components);
|
||||
this.aNAV_queryInvoiceData = new DevExpress.ExpressApp.Actions.SimpleAction(this.components);
|
||||
//
|
||||
// aNAV_queryInvoiceStatus
|
||||
//
|
||||
this.aNAV_queryInvoiceStatus.Caption = "aNAV_queryInvoiceStatus";
|
||||
this.aNAV_queryInvoiceStatus.ConfirmationMessage = null;
|
||||
this.aNAV_queryInvoiceStatus.Id = "aNAV_queryInvoiceStatus";
|
||||
this.aNAV_queryInvoiceStatus.SelectionDependencyType = DevExpress.ExpressApp.Actions.SelectionDependencyType.RequireSingleObject;
|
||||
this.aNAV_queryInvoiceStatus.TargetObjectType = typeof(Nuvolar.Module.InvoiceHeader);
|
||||
this.aNAV_queryInvoiceStatus.ToolTip = null;
|
||||
this.aNAV_queryInvoiceStatus.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aNAV_queryInvoiceStatus_Execute);
|
||||
//
|
||||
// aNAV_manageInvoice
|
||||
//
|
||||
this.aNAV_manageInvoice.Caption = "aNAV_manageInvoice";
|
||||
this.aNAV_manageInvoice.ConfirmationMessage = null;
|
||||
this.aNAV_manageInvoice.Id = "aNAV_manageInvoice";
|
||||
this.aNAV_manageInvoice.SelectionDependencyType = DevExpress.ExpressApp.Actions.SelectionDependencyType.RequireSingleObject;
|
||||
this.aNAV_manageInvoice.TargetObjectType = typeof(Nuvolar.Module.InvoiceHeader);
|
||||
this.aNAV_manageInvoice.ToolTip = null;
|
||||
this.aNAV_manageInvoice.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aNAV_manageInvoice_Execute);
|
||||
//
|
||||
// aNAV_queryTaxpayer
|
||||
//
|
||||
this.aNAV_queryTaxpayer.Caption = "aNAV_queryTaxpayer";
|
||||
this.aNAV_queryTaxpayer.ConfirmationMessage = null;
|
||||
this.aNAV_queryTaxpayer.Id = "aNAV_queryTaxpayer";
|
||||
this.aNAV_queryTaxpayer.SelectionDependencyType = DevExpress.ExpressApp.Actions.SelectionDependencyType.RequireSingleObject;
|
||||
this.aNAV_queryTaxpayer.TargetObjectType = typeof(Nuvolar.Module.Customers);
|
||||
this.aNAV_queryTaxpayer.ToolTip = null;
|
||||
this.aNAV_queryTaxpayer.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aNAV_queryTaxpayer_Execute);
|
||||
//
|
||||
// aNAV_queryInvoiceData
|
||||
//
|
||||
this.aNAV_queryInvoiceData.Caption = "aNAV_queryInvoiceData";
|
||||
this.aNAV_queryInvoiceData.ConfirmationMessage = null;
|
||||
this.aNAV_queryInvoiceData.Id = "aNAV_queryInvoiceData";
|
||||
this.aNAV_queryInvoiceData.SelectionDependencyType = DevExpress.ExpressApp.Actions.SelectionDependencyType.RequireSingleObject;
|
||||
this.aNAV_queryInvoiceData.TargetObjectType = typeof(Nuvolar.Module.InvoiceHeader);
|
||||
this.aNAV_queryInvoiceData.ToolTip = null;
|
||||
this.aNAV_queryInvoiceData.Execute += new DevExpress.ExpressApp.Actions.SimpleActionExecuteEventHandler(this.aNAV_queryInvoiceData_Execute);
|
||||
//
|
||||
// NAV_Online_VC
|
||||
//
|
||||
this.Actions.Add(this.aNAV_queryInvoiceStatus);
|
||||
this.Actions.Add(this.aNAV_manageInvoice);
|
||||
this.Actions.Add(this.aNAV_queryTaxpayer);
|
||||
this.Actions.Add(this.aNAV_queryInvoiceData);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DevExpress.ExpressApp.Actions.SimpleAction aNAV_queryInvoiceStatus;
|
||||
private DevExpress.ExpressApp.Actions.SimpleAction aNAV_manageInvoice;
|
||||
private DevExpress.ExpressApp.Actions.SimpleAction aNAV_queryTaxpayer;
|
||||
private DevExpress.ExpressApp.Actions.SimpleAction aNAV_queryInvoiceData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
using DevExpress.Data.Filtering;
|
||||
using DevExpress.ExpressApp;
|
||||
using DevExpress.ExpressApp.Actions;
|
||||
using DevExpress.ExpressApp.Xpo;
|
||||
using Newtonsoft.Json;
|
||||
using Nuvolar.Module.StaticClass;
|
||||
|
||||
namespace Nuvolar.Module.Controllers
|
||||
{
|
||||
public partial class NAV_Online_VC : ViewController
|
||||
{
|
||||
public NAV_Online_VC()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Target required Views (via the TargetXXX properties) and create their Actions.
|
||||
}
|
||||
protected override void OnActivated()
|
||||
{
|
||||
base.OnActivated();
|
||||
// Perform various tasks depending on the target View.
|
||||
}
|
||||
protected override void OnViewControlsCreated()
|
||||
{
|
||||
base.OnViewControlsCreated();
|
||||
// Access and customize the target View control.
|
||||
}
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
// Unsubscribe from previously subscribed events and release other references and resources.
|
||||
base.OnDeactivated();
|
||||
}
|
||||
/// <summary>
|
||||
/// Adószám ellenőrzése a kiválasztott ügyfelek alapján
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void aNAV_queryTaxpayer_Execute(object sender, SimpleActionExecuteEventArgs e)
|
||||
{
|
||||
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
|
||||
Customers _Customers = View.SelectedObjects[0] as Customers;
|
||||
CustomersFrom _CustomersFrom = _ocur.FindObject<CustomersFrom>(CriteriaOperator.Parse("IsDefault=True"));
|
||||
var _postData = new
|
||||
{
|
||||
customersfrom = _CustomersFrom.Oid.ToString(),
|
||||
taxPayer = _Customers.VATNumber.Substring(0, 8),
|
||||
softwareId = "123456789123456789",
|
||||
softwareName = "3C ERP System",
|
||||
softwareOperation = "ONLINE_SERVICE",
|
||||
softwareMainVersion = "17.2.3",
|
||||
softwareDevName = "3C Távközlési Kft.",
|
||||
softwareDevContact = "http:\\3ctelecom.hu",
|
||||
softwareDevCountryCode = "HU",
|
||||
softwareDevTaxNumber = "10644209-2-43"
|
||||
};
|
||||
|
||||
RestAPI.ExecuteRootePOST("onlineinvoice/querytaxpayer", true, JsonConvert.SerializeObject(_postData));
|
||||
var _StatusCode = RestAPI.StatusCode;
|
||||
var _StatusDescription = RestAPI.StatusMessage;
|
||||
|
||||
if (_StatusCode == 200)
|
||||
{
|
||||
|
||||
|
||||
dynamic _ResultJSON = JsonConvert.DeserializeObject(_StatusDescription);
|
||||
|
||||
if (_ResultJSON.status.ToString() == "OK")
|
||||
{
|
||||
if (_ResultJSON.taxpayerValidity["0"].ToString() == "false")
|
||||
{
|
||||
_ocur.Session.ExecuteNonQuery(string.Format("UPDATE Customers set NAV_valid = 0,NAV_queryDate=NOW() WHERE Oid = '{0}'",
|
||||
_Customers.Oid.ToString()));
|
||||
}
|
||||
if (_ResultJSON.taxpayerValidity["0"].ToString() == "true")
|
||||
{
|
||||
_ocur.Session.ExecuteNonQuery(string.Format("UPDATE Customers set NAV_valid = 1,NAV_queryDate=NOW() WHERE Oid = '{0}'",
|
||||
_Customers.Oid.ToString()));
|
||||
}
|
||||
Application.ShowViewStrategy.ShowMessage("Adószám ellenőrzés megtörtént !", InformationType.Success, 2000, InformationPosition.Bottom);
|
||||
}
|
||||
if (_ResultJSON.status.ToString() == "ERROR")
|
||||
{
|
||||
string _ERROR = "Adószám ellenőrzés nem történt meg !";
|
||||
_ERROR += " [" + _ResultJSON.xml.result.message.ToString() + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string _ERROR = "Adószám ellenőrzés nem történt meg !";
|
||||
_ERROR += " [" + _StatusDescription.ToString() + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
private void aNAV_manageInvoice_Execute(object sender, SimpleActionExecuteEventArgs e)
|
||||
{
|
||||
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
|
||||
InvoiceHeader _InvoiceHeader = View.SelectedObjects[0] as InvoiceHeader;
|
||||
string _operation = "CREATE";
|
||||
|
||||
if (_InvoiceHeader.IsStorno)
|
||||
{
|
||||
_operation = "STORNO";
|
||||
}
|
||||
var _postData = new
|
||||
{
|
||||
documentnumber = _InvoiceHeader.DocumentNumber,
|
||||
customersfrom = _InvoiceHeader.CustomersFrom.Oid.ToString(),
|
||||
operation = _operation,
|
||||
technicalAnnulment = false,
|
||||
softwareId = "123456789123456789",
|
||||
softwareName = "3C ERP System",
|
||||
softwareOperation = "ONLINE_SERVICE",
|
||||
softwareMainVersion = "17.2.3",
|
||||
softwareDevName = "3C Távközlési Kft.",
|
||||
softwareDevContact = "http:\\3ctelecom.hu",
|
||||
softwareDevCountryCode = "HU",
|
||||
softwareDevTaxNumber = "10644209-2-43"
|
||||
|
||||
};
|
||||
|
||||
RestAPI.ExecuteRootePOST("onlineinvoice/manageinvoice", true, JsonConvert.SerializeObject(_postData));
|
||||
var _StatusCode = RestAPI.StatusCode;
|
||||
var _StatusDescription = RestAPI.StatusMessage;
|
||||
|
||||
if (_StatusCode == 200)
|
||||
{
|
||||
dynamic _ResultJSON = JsonConvert.DeserializeObject(_StatusDescription);
|
||||
|
||||
if (_ResultJSON.status.ToString() == "OK")
|
||||
{
|
||||
_ocur.Session.ExecuteNonQuery(string.Format("UPDATE InvoiceHeader set NAV_transactionID='{0}' WHERE Oid = '{1}'", _ResultJSON.transactionId["0"].ToString(), _InvoiceHeader.Oid.ToString()));
|
||||
|
||||
Application.ShowViewStrategy.ShowMessage("A számla beküldése megtörtént !", InformationType.Success, 2000, InformationPosition.Bottom);
|
||||
}
|
||||
if (_ResultJSON.status.ToString() == "ERROR")
|
||||
{
|
||||
string _ERROR = "A számla beküldése nem történt meg !";
|
||||
_ERROR += " [" + _ResultJSON.xml.result.message.ToString() + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string _ERROR = "A számla beküldése nem történt meg !";
|
||||
_ERROR += " [" + _StatusDescription + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
|
||||
(View as ListView).CollectionSource.Reload();
|
||||
}
|
||||
|
||||
private void aNAV_queryInvoiceStatus_Execute(object sender, SimpleActionExecuteEventArgs e)
|
||||
{
|
||||
XPObjectSpace _ocur = View.ObjectSpace as XPObjectSpace;
|
||||
InvoiceHeader _InvoiceHeader = View.SelectedObjects[0] as InvoiceHeader;
|
||||
|
||||
var _postData = new
|
||||
{
|
||||
documentnumber = _InvoiceHeader.DocumentNumber,
|
||||
customersfrom = _InvoiceHeader.CustomersFrom.Oid.ToString(),
|
||||
transactionId = _InvoiceHeader.NAV_transactionId,
|
||||
softwareId = "123456789123456789",
|
||||
softwareName = "3C ERP System",
|
||||
softwareOperation = "ONLINE_SERVICE",
|
||||
softwareMainVersion = "17.2.3",
|
||||
softwareDevName = "3C Távközlési Kft.",
|
||||
softwareDevContact = "http:\\3ctelecom.hu",
|
||||
softwareDevCountryCode = "HU",
|
||||
softwareDevTaxNumber = "10644209-2-43"
|
||||
|
||||
};
|
||||
|
||||
RestAPI.ExecuteRootePOST("onlineinvoice/queryinvoicestatus", true, JsonConvert.SerializeObject(_postData));
|
||||
var _StatusCode = RestAPI.StatusCode;
|
||||
var _StatusDescription = RestAPI.StatusMessage;
|
||||
|
||||
if (_StatusCode == 200)
|
||||
{
|
||||
dynamic _ResultJSON = JsonConvert.DeserializeObject(_StatusDescription);
|
||||
|
||||
if (_ResultJSON.status.ToString() == "OK")
|
||||
{
|
||||
_ocur.Session.ExecuteNonQuery(string.Format("UPDATE InvoiceHeader set NAV_InvoiceStatus='{0}',NAV_queryDate=NOW() WHERE Oid = '{1}'",
|
||||
_ResultJSON.processingResults.processingResult.invoiceStatus.ToString(), _InvoiceHeader.Oid.ToString()));
|
||||
Application.ShowViewStrategy.ShowMessage("A számla státusz lekérdezése megtörtént !", InformationType.Success, 2000, InformationPosition.Bottom);
|
||||
}
|
||||
if (_ResultJSON.status.ToString() == "ERROR")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string _ERROR = "A számla státusz ellenőrzés nem történt meg !";
|
||||
_ERROR += " [" + _StatusDescription + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
private void aNAV_queryInvoiceData_Execute(object sender, SimpleActionExecuteEventArgs e)
|
||||
{
|
||||
InvoiceHeader _InvoiceHeader = View.SelectedObjects[0] as InvoiceHeader;
|
||||
|
||||
var _postData = new
|
||||
{
|
||||
invoiceNumber = _InvoiceHeader.DocumentNumber,
|
||||
customersfrom = _InvoiceHeader.CustomersFrom.Oid.ToString(),
|
||||
softwareId = "123456789123456789",
|
||||
softwareName = "3C ERP System",
|
||||
softwareOperation = "ONLINE_SERVICE",
|
||||
softwareMainVersion = "17.2.3",
|
||||
softwareDevName = "3C Távközlési Kft.",
|
||||
softwareDevContact = "http:\\3ctelecom.hu",
|
||||
softwareDevCountryCode = "HU",
|
||||
softwareDevTaxNumber = "10644209-2-43"
|
||||
|
||||
};
|
||||
|
||||
RestAPI.ExecuteRootePOST("onlineinvoice/queryinvoicedata", true, JsonConvert.SerializeObject(_postData));
|
||||
var _StatusCode = RestAPI.StatusCode;
|
||||
var _StatusDescription = RestAPI.StatusMessage;
|
||||
if (_StatusCode == 200)
|
||||
{
|
||||
dynamic _ResultJSON = JsonConvert.DeserializeObject(_StatusDescription);
|
||||
|
||||
if (_ResultJSON.status.ToString() == "OK")
|
||||
{
|
||||
if (_ResultJSON.queryResults.availablePage.ToString() == "0")
|
||||
{
|
||||
string _ERROR = "A számla adat ellenőrzés megtörtént ! Nincs elérhető adat!";
|
||||
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Warning, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
if (_ResultJSON.queryResults.availablePage.ToString() != "0")
|
||||
{
|
||||
string _ERROR = "A számla adat ellenőrzés megtörtént !";
|
||||
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Success, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
}
|
||||
if (_ResultJSON.status.ToString() == "ERROR")
|
||||
{
|
||||
string _ERROR = "A számla adat ellenőrzés nem történt meg !";
|
||||
_ERROR += " [" + _ResultJSON.technicalValidationMessages.message.ToString() + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string _ERROR = "A számla státusz ellenőrzés nem történt meg !";
|
||||
_ERROR += " [" + _StatusDescription + "]";
|
||||
Application.ShowViewStrategy.ShowMessage(_ERROR, InformationType.Error, 5000, InformationPosition.Bottom);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user