Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/RCandidate'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vienna-PRU committed Oct 28, 2022
2 parents c4996ff + 03e8d92 commit 0ccb94a
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 7 deletions.
76 changes: 76 additions & 0 deletions ModelLibrary/Model/MCash.cs
Expand Up @@ -270,6 +270,82 @@ public static MCash Get(Ctx ctx, int C_CashBook_ID, DateTime? dateAcct, Trx trxN
return retValue;
}

/// <summary>
/// Get Cash Journal for CashBook and date
/// </summary>
/// <param name="ctx">Context</param>
/// <param name="C_CashBook_ID">CashBook</param>
/// <param name="AD_OrgTrx_ID">Organization Unit</param>
/// <param name="dateAcct">Date</param>
/// <param name="trxName">Transaction</param>
/// <returns></returns>
public static MCash Get(Ctx ctx, int C_CashBook_ID, int AD_OrgTrx_ID, DateTime? dateAcct, Trx trxName)
{
MCash retValue = null;
// Existing Journal
String sql = "SELECT * FROM C_Cash c "
+ "WHERE c.C_CashBook_ID=" + C_CashBook_ID // #1
+ " AND TRUNC(c.StatementDate,'DD')=@sdate" // #2
+ " AND c.Processed='N'";
DataTable dt = null;
SqlParameter[] param = null;
IDataReader idr = null;
try
{
param = new SqlParameter[1];
param[0] = new SqlParameter("@sdate", TimeUtil.GetDay(dateAcct));
idr = DB.ExecuteReader(sql, param, trxName);
dt = new DataTable();
dt.Load(idr);
foreach (DataRow dr in dt.Rows)
{
retValue = new MCash(ctx, dr, trxName);
}
}
catch (Exception e)
{
_log.Log(Level.SEVERE, sql, e);
}
finally {
if (idr != null)
{
idr.Close();
idr = null;
}
dt = null; }

if (retValue != null)
return retValue;

// Get CashBook
MCashBook cb = new MCashBook(ctx, C_CashBook_ID, trxName);
if (cb.Get_ID() == 0)
{
_log.Warning("Not found C_CashBook_ID=" + C_CashBook_ID);
return null;
}

// Create New Journal
retValue = new MCash(cb, dateAcct);
sql = @"SELECT SUM(completedbalance + runningbalance)AS BegningBalance FROM c_cashbook WHERE IsActive = 'Y' AND c_cashbook_id =" + cb.GetC_CashBook_ID();
decimal beginingBalance = Util.GetValueOfDecimal(DB.ExecuteScalar(sql, null, trxName));

int DocType_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT C_Doctype_ID FROM C_Doctype WHERE DocBaseType='CMC' AND AD_Client_ID='" + ctx.GetAD_Client_ID() + "' AND AD_Org_ID IN('0','" + ctx.GetAD_Org_ID() + "') ORDER BY AD_Org_ID DESC"));
if (DocType_ID != 0)
{
retValue.SetC_DocType_ID(DocType_ID);
}

// Set Organization Unit
if(AD_OrgTrx_ID > 0)
{
retValue.SetAD_OrgTrx_ID(AD_OrgTrx_ID);
}

retValue.SetBeginningBalance(beginingBalance);
retValue.Save(trxName);
return retValue;
}
/// <summary>
/// Get MCash Model against cash book id ,date acoount ,and shift date
/// </summary>
Expand Down
38 changes: 35 additions & 3 deletions ModelLibrary/Model/MInvoice.cs
Expand Up @@ -2857,14 +2857,24 @@ public String CompleteIt()
} // end vapos order
else // std pos order
{
cash = MCash.Get(GetCtx(), GetAD_Org_ID(),
GetDateInvoiced(), GetC_Currency_ID(), Get_TrxName());
// VIS0060: Get Cash Journal from the CashBook selected on Organization Unit Info.
cash = GetCasJournal(GetDateInvoiced(), GetAD_OrgTrx_ID());
if (cash == null)
{
cash = MCash.Get(GetCtx(), GetAD_Org_ID(),
GetDateInvoiced(), GetC_Currency_ID(), Get_TrxName());
}
}
}
else
{
cash = MCash.Get(GetCtx(), GetAD_Org_ID(),
// VIS0060: Get Cash Journal from the CashBook selected on Organization Unit Info.
cash = GetCasJournal(GetDateInvoiced(), GetAD_OrgTrx_ID());
if (cash == null)
{
cash = MCash.Get(GetCtx(), GetAD_Org_ID(),
GetDateInvoiced(), GetC_Currency_ID(), Get_TrxName());
}
}
if (isStdPosOrder)
{
Expand Down Expand Up @@ -4808,6 +4818,28 @@ public String CompleteIt()
return DocActionVariables.STATUS_COMPLETED;
}

/// <summary>
/// Get or Create Cash Journal from CashBook selected on Organization Unit Info
/// </summary>
/// <param name="dateAcct">Account Date</param>
/// <returns>Cash Journal</returns>
private MCash GetCasJournal(DateTime? dateAcct, int AD_OrgTrx_ID)
{
int cashbook_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT C_CashBook_ID FROM AD_OrgInfo WHERE AD_Org_ID=" + AD_OrgTrx_ID, null, Get_Trx()));

// get cashbook
if (cashbook_ID > 0)
{
// Get or Create Cash Journal
return MCash.Get(GetCtx(), cashbook_ID, AD_OrgTrx_ID, dateAcct, Get_Trx());
}
else
{
_log.Warning("No CashBook for Organization Unit " + AD_OrgTrx_ID);
return null;
}
}

/// <summary>
/// Update Values on Asset
/// VIS0060: 16-Feb-2022
Expand Down
2 changes: 1 addition & 1 deletion ModelLibrary/Properties/AssemblyInfo.cs
Expand Up @@ -35,5 +35,5 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]

[assembly: AssemblyFileVersion("1.11.5.0")]
[assembly: AssemblyFileVersion("1.11.7.0")]

20 changes: 18 additions & 2 deletions VIS/Areas/VIS/Controllers/CallOut/MRequestTypeController.cs
Expand Up @@ -33,7 +33,23 @@ public JsonResult GetDefaultR_Status_ID(string fields)
}
return Json(retJSON , JsonRequestBehavior.AllowGet);
}


/// <summary>
/// Get Resolution text on Resolution change
/// </summary>
/// <param name="fields">Resolution ID</param>
/// <returns>Result</returns>
public JsonResult GetResolutionText(string fields) //VIS_0336 calling method for fetching the comments of selected resolution in request window.
{
String retJSON = "";
if (Session["ctx"] != null)
{
VAdvantage.Utility.Ctx ctx = Session["ctx"] as Ctx;
MRequestTypeModel rt = new MRequestTypeModel();
retJSON = JsonConvert.SerializeObject(rt.GetResolutionText(Util.GetValueOfInt(fields)));
}
return Json(retJSON, JsonRequestBehavior.AllowGet);
}
}
}

}
14 changes: 13 additions & 1 deletion VIS/Areas/VIS/Models/Callouts/MRequestTypeModel.cs
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VAdvantage.DataBase;
using VAdvantage.Model;
using VAdvantage.Utility;

Expand All @@ -28,6 +29,17 @@ public int GetDefaultR_Status_ID(Ctx ctx,string fields)
int R_Status_ID = rt.GetDefaultR_Status_ID();
return R_Status_ID;
}


/// <summary>
/// Get Resolution text on Request
/// </summary>
/// <param name="Resolution_ID"></param>
/// <returns>Result</returns>
public string GetResolutionText(int Resolution_ID) //VIS_0336 this method is for fetching the comments(help) of selected resolution in request window.
{
return Util.GetValueOfString(DB.ExecuteScalar("SELECT HELP FROM R_Resolution WHERE R_Resolution_ID=" + Resolution_ID, null, null));
}


}
}
31 changes: 31 additions & 0 deletions VIS/Areas/VIS/Scripts/model/callouts.js
Expand Up @@ -14327,6 +14327,37 @@
return "";
};// type

/// <summary>
/// Request - Copy Resolution Data - <b>Callout</b>
/// </summary>
/// <param name="ctx">Context</param>
/// <param name="WindowNo">current Window No</param>
/// <param name="mTab">Model Tab</param>
/// <param name="mField">Model Field</param>
/// <param name="value">The new value</param>
/// <returns>Error message or ""</returns>
CalloutRequest.prototype.CopyResolution = function (ctx, windowNo, mTab, mField, value, oldValue) { // VIS_0336 callout for showing comments of selected Resolution in result field.
//
var colName = mField.getColumnName();
this.log.info(colName + "=" + value);
if (value == null || value.toString() == "") {
return "";
}

try {
var txt = VIS.dataContext.getJSONRecord("MRequestType/GetResolutionText", value.toString());
txt = VIS.Env.parseContext(ctx, windowNo, txt, false, true);
mTab.setValue("Result", txt);


}
catch (err) {
this.setCalloutActive(false);
this.log.log(Level.SEVERE, sql, err);
}
ctx = windowNo = mTab = mField = value = oldValue = null;
return "";
};

//CalloutRequest.prototype.BPartner = function (ctx, windowNo, mTab, mField, value, oldValue) {
// if (value == null || value.toString() == "" || this.isCalloutActive()) {
Expand Down

0 comments on commit 0ccb94a

Please sign in to comment.