/** * Get the first Date From date of the next period based on Accumulation * @param from date * @return first date of next period */ public DateTime?GetDateFromNext(DateTime?from) { if (from == null) { return(from); } DateTime?retValue = from; if (BALANCEACCUMULATION_Daily.Equals(GetBALANCEACCUMULATION())) { return(null); } if (BALANCEACCUMULATION_CalendarMonth.Equals(GetBALANCEACCUMULATION())) { retValue = TimeUtil.AddMonths(from, 1); retValue = TimeUtil.Trunc(retValue, TimeUtil.TRUNC_MONTH); } else if (BALANCEACCUMULATION_CalendarWeek.Equals(GetBALANCEACCUMULATION())) { retValue = TimeUtil.AddDays(from, 7); retValue = TimeUtil.Trunc(retValue, TimeUtil.TRUNC_WEEK); } else if (BALANCEACCUMULATION_PeriodOfAViennaCalendar.Equals(GetBALANCEACCUMULATION()) && GetC_Calendar_ID() != 0) { } return(retValue); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord"></param> /// <returns>true</returns> protected override bool BeforeSave(bool newRecord) { try { // Calculate Complete Date (also used to verify) if (GetDateWorkStart() != null && GetDeliveryDays() != 0) { SetDateWorkComplete(TimeUtil.AddDays(GetDateWorkStart(), GetDeliveryDays())); } // Calculate Delivery Days else if (GetDateWorkStart() != null && GetDeliveryDays() == 0 && GetDateWorkComplete() != null) { SetDeliveryDays(TimeUtil.GetDaysBetween(GetDateWorkStart(), GetDateWorkComplete())); } // Calculate Start Date else if (GetDateWorkStart() == null && GetDeliveryDays() != 0 && GetDateWorkComplete() != null) { SetDateWorkStart(TimeUtil.AddDays(GetDateWorkComplete(), GetDeliveryDays() * -1)); } if (!IsActive()) { SetIsSelectedWinner(false); } } catch (Exception e) { // MessageBox.Show(e.ToString()); log.Severe(e.ToString()); } return(true); }
/// <summary> /// Is Period Open for Doc Base Type /// </summary> /// <param name="docBaseType">document base type</param> /// <returns>true if open</returns> public bool IsOpen(String docBaseType) { if (!IsActive()) { _log.Warning("Period not active: " + GetName()); return(false); } MAcctSchema mas = MClient.Get(GetCtx(), GetAD_Client_ID()).GetAcctSchema(); if (mas != null && mas.IsAutoPeriodControl()) { // if (as.getC_Period_ID() == getC_Period_ID()) // return true; DateTime today = DateTime.Now;// new DateTime(CommonFunctions.CurrentTimeMillis()); DateTime first = TimeUtil.AddDays(today, -mas.GetPeriod_OpenHistory()); DateTime last = TimeUtil.AddDays(today, mas.GetPeriod_OpenFuture()); //if (today.before(first)) if (today < first) { log.Warning("Today before first day - " + first); return(false); } //if (today.after(last)) if (today > last) { log.Warning("Today after last day - " + first); return(false); } // We are OK if (IsInPeriod(today)) { mas.SetC_Period_ID(GetC_Period_ID()); mas.Save(); } return(true); } // Standard Period Control if (docBaseType == null) { log.Warning(GetName() + " - No DocBaseType"); return(false); } MPeriodControl pc = GetPeriodControl(docBaseType); if (pc == null) { log.Warning(GetName() + " - Period Control not found for " + docBaseType); return(false); } log.Fine(GetName() + ": " + docBaseType); return(pc.IsOpen()); }
/** * Get Guarantee Date * @param getNew if true calculates/sets guarantee date * @return guarantee date or null if days = 0 */ public DateTime?GetGuaranteeDate(bool getNew) { if (getNew) { int days = GetMAttributeSet().GetGuaranteeDays(); if (days > 0) { DateTime ts = TimeUtil.AddDays(DateTime.Now, days); SetGuaranteeDate(ts); } } return(GetGuaranteeDate()); }
/// <summary> /// Does the dateAcct fall in the range /// </summary> /// <param name="dateAcct"></param> /// <returns>true if falls within range </returns> /// <date>07-march-2011</date> public Boolean IsAutoPeriodControlOpen(DateTime?dateAcct) { DateTime today = DateTime.Now.Date; DateTime first = TimeUtil.AddDays(today, -GetPeriod_OpenHistory()); DateTime last = TimeUtil.AddDays(today, GetPeriod_OpenFuture()); if (dateAcct < first) { log.Warning(dateAcct + " before first day - " + first); return(false); } if (dateAcct > last) { log.Warning(dateAcct + " after last day - " + first); return(false); } return(true); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord">newRecord new</param> /// <returns>true</returns> protected override bool BeforeSave(bool newRecord) { // Calculate Complete Date (also used to verify) if (GetDateWorkStart() != null && GetDeliveryDays() != 0) { SetDateWorkComplete(TimeUtil.AddDays(GetDateWorkStart(), GetDeliveryDays())); } // Calculate Delivery Days else if (GetDateWorkStart() != null && GetDeliveryDays() == 0 && GetDateWorkComplete() != null) { SetDeliveryDays(TimeUtil.GetDaysBetween(GetDateWorkStart(), GetDateWorkComplete())); } // Calculate Start Date else if (GetDateWorkStart() == null && GetDeliveryDays() != 0 && GetDateWorkComplete() != null) { SetDateWorkStart(TimeUtil.AddDays(GetDateWorkComplete(), GetDeliveryDays() * -1)); } return(true); }
/** * Parent Constructor * @param invoice invoice * @param paySchedule payment schedule */ public MInvoicePaySchedule(MInvoice invoice, MPaySchedule paySchedule) : base(invoice.GetCtx(), 0, invoice.Get_TrxName()) { _parent = invoice; SetClientOrg(invoice); SetC_Invoice_ID(invoice.GetC_Invoice_ID()); SetC_PaySchedule_ID(paySchedule.GetC_PaySchedule_ID()); // Amounts int scale = MCurrency.GetStdPrecision(GetCtx(), invoice.GetC_Currency_ID()); // distribute schedule based on GrandTotalAfterWithholding which is (GrandTotal – WithholdingAmount) Decimal due = (invoice.Get_ColumnIndex("GrandTotalAfterWithholding") > 0 && invoice.GetGrandTotalAfterWithholding() != 0 ? invoice.GetGrandTotalAfterWithholding() : invoice.GetGrandTotal()); if (due.CompareTo(Env.ZERO) == 0) { SetDueAmt(Env.ZERO); SetDiscountAmt(Env.ZERO); SetIsValid(false); } else { //due = due.multiply(paySchedule.getPercentage()).divide(HUNDRED, scale, Decimal.ROUND_HALF_UP); due = Decimal.Multiply(due, Decimal.Divide(paySchedule.GetPercentage(), Decimal.Round(HUNDRED, scale, MidpointRounding.AwayFromZero))); SetDueAmt(due); Decimal discount = Decimal.Multiply(due, Decimal.Divide(paySchedule.GetDiscount(), Decimal.Round(HUNDRED, scale, MidpointRounding.AwayFromZero))); SetDiscountAmt(discount); SetIsValid(true); } /** Adhoc Payment - Setting DueDate for an InvoicePaySchedule ** Dt: 18/01/2021 ** Modified By: Kumar **/ // Dates DateTime?dueDate = (invoice.Get_ColumnIndex("DueDate") >= 0 && invoice.GetDueDate() >= invoice.GetDateInvoiced()) ? invoice.GetDueDate() : TimeUtil.AddDays(invoice.GetDateInvoiced(), paySchedule.GetNetDays()); SetDueDate(dueDate); DateTime discountDate = TimeUtil.AddDays(invoice.GetDateInvoiced(), paySchedule.GetDiscountDays()); SetDiscountDate(discountDate); }
/** * Parent Constructor * @param invoice invoice * @param paySchedule payment schedule */ public MInvoicePaySchedule(MInvoice invoice, MPaySchedule paySchedule) : base(invoice.GetCtx(), 0, invoice.Get_TrxName()) { _parent = invoice; SetClientOrg(invoice); SetC_Invoice_ID(invoice.GetC_Invoice_ID()); SetC_PaySchedule_ID(paySchedule.GetC_PaySchedule_ID()); // Amounts int scale = MCurrency.GetStdPrecision(GetCtx(), invoice.GetC_Currency_ID()); Decimal due = invoice.GetGrandTotal(); if (due.CompareTo(Env.ZERO) == 0) { SetDueAmt(Env.ZERO); SetDiscountAmt(Env.ZERO); SetIsValid(false); } else { //due = due.multiply(paySchedule.getPercentage()).divide(HUNDRED, scale, Decimal.ROUND_HALF_UP); due = Decimal.Multiply(due, Decimal.Divide(paySchedule.GetPercentage(), Decimal.Round(HUNDRED, scale, MidpointRounding.AwayFromZero))); SetDueAmt(due); Decimal discount = Decimal.Multiply(due, Decimal.Divide(paySchedule.GetDiscount(), Decimal.Round(HUNDRED, scale, MidpointRounding.AwayFromZero))); SetDiscountAmt(discount); SetIsValid(true); } // Dates DateTime dueDate = TimeUtil.AddDays(invoice.GetDateInvoiced(), paySchedule.GetNetDays()); SetDueDate(dueDate); DateTime discountDate = TimeUtil.AddDays(invoice.GetDateInvoiced(), paySchedule.GetDiscountDays()); SetDiscountDate(discountDate); }
/** * Create Trial Asset * @param ctx context * @param user user * @param entityType entity type * @return asset or null if no product found */ public static MAsset GetTrial(Ctx ctx, MUser user, String entityType) { if (user == null) { _log.Warning("Cannot create Trial - No User"); return(null); } if (Utility.Util.IsEmpty(entityType)) { _log.Warning("Cannot create Trial - No Entity Type"); return(null); } MProduct product = MProduct.GetTrial(ctx, entityType); if (product == null) { _log.Warning("No Trial for Entity Type=" + entityType); return(null); } // DateTime now = Convert.ToDateTime(CommonFunctions.CurrentTimeMillis()); // MAsset asset = new MAsset(ctx, 0, null); asset.SetClientOrg(user); asset.SetAssetServiceDate(now); asset.SetIsOwned(false); asset.SetIsTrialPhase(true); // MBPartner partner = new MBPartner(ctx, user.GetC_BPartner_ID(), null); String documentNo = "Trial"; // Value String value = partner.GetValue() + "_" + product.GetValue(); if (value.Length > 40 - documentNo.Length) { value = value.Substring(0, 40 - documentNo.Length) + documentNo; } asset.SetValue(value); // Name MProduct.afterSave String name = "Trial " + partner.GetName() + " - " + product.GetName(); if (name.Length > 60) { name = name.Substring(0, 60); } asset.SetName(name); // Description String description = product.GetDescription(); asset.SetDescription(description); // User asset.SetAD_User_ID(user.GetAD_User_ID()); asset.SetC_BPartner_ID(user.GetC_BPartner_ID()); // Product asset.SetM_Product_ID(product.GetM_Product_ID()); asset.SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); asset.SetQty(new Decimal(product.GetSupportUnits())); // Guarantee & Version asset.SetGuaranteeDate(TimeUtil.AddDays(now, product.GetTrialPhaseDays())); asset.SetVersionNo(product.GetVersionNo()); // return(asset); }
// Create Asset From Invoice Mohit /** * Shipment Constructor * @param Invoice * @param shipLine shipment line * @param deliveryCount 0 or number of delivery */ public MAsset(MInvoice invoice, MInvoiceLine invoiceline, int deliveryCount) : this(invoiceline.GetCtx(), 0, invoiceline.Get_TrxName()) { SetClientOrg(invoiceline); SetValueNameDescription(invoice, invoiceline, deliveryCount); // Header //SetIsOwned(true); SetC_BPartner_ID(invoice.GetC_BPartner_ID()); SetC_BPartner_Location_ID(invoice.GetC_BPartner_Location_ID()); SetAD_User_ID(invoice.GetAD_User_ID()); //SetM_Locator_ID(invoice.GetM_Locator_ID()); SetIsInPosession(true); SetAssetServiceDate(invoice.GetDateAcct()); // Line MProduct product = invoiceline.GetProduct(); SetM_Product_ID(product.GetM_Product_ID()); SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); //////////////////////////////* //Changes for vafam // SetAssetServiceDate(shipment.GetMovementDate()); //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), invoice.Get_TrxName()); if (_assetGroup.IsOwned()) { SetIsOwned(true); //SetC_BPartner_ID(0); } if (_assetGroup.IsDepreciated()) { SetIsDepreciated(true); SetIsFullyDepreciated(false); } //////////////////////////////////// //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762 int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' ")); int countVAFAM = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VAFAM_' ")); if (countVA038 > 0) { Set_Value("VA038_AmortizationTemplate_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID"))); } if (countVAFAM > 0) { Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString()); Set_Value("VAFAM_DepreciationType_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID"))); } //////////////////////////////////// // Guarantee & Version SetGuaranteeDate(TimeUtil.AddDays(invoice.GetDateInvoiced(), product.GetGuaranteeDays())); SetVersionNo(product.GetVersionNo()); if (invoiceline.GetM_AttributeSetInstance_ID() != 0) // Instance { MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), invoiceline.GetM_AttributeSetInstance_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID()); SetLot(asi.GetLot()); SetSerNo(asi.GetSerNo()); } SetHelp(invoiceline.GetDescription()); // Qty int units = product.GetSupportUnits(); if (units == 0) { units = 1; } if (deliveryCount != 0) // one asset per UOM { SetQty(invoiceline.GetQtyEntered(), units); } else { SetQty((Decimal)units); } SetM_InOutLine_ID(invoiceline.GetM_InOutLine_ID()); Set_Value("C_InvoiceLine_ID", invoiceline.GetC_InvoiceLine_ID()); // Activate MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()); if (!ag.IsCreateAsActive()) { SetIsActive(false); } }
//Dictionary<MAttribute, KeyValuePair<MAttributeInstance, MAttributeValue[]>> attributesList = new Dictionary<MAttribute, KeyValuePair<MAttributeInstance, MAttributeValue[]>>(4); public AttributesObjects LoadInit(int _M_AttributeSetInstance_ID, int _M_Product_ID, bool _productWindow, int windowNo, Ctx ctx, int AD_Column_ID, int window_ID, bool IsSOTrx, string IsInternalUse) { AttributesObjects obj = new AttributesObjects(); MAttributeSet aset = null; MAttribute[] attributes = null; // Get Model MAttributeSetInstance _masi = MAttributeSetInstance.Get(ctx, _M_AttributeSetInstance_ID, _M_Product_ID); MProduct _prd = new MProduct(ctx, _M_Product_ID, null); if (_masi == null) { obj.IsReturnNull = true; obj.Error = "No Model for M_AttributeSetInstance_ID=" + _M_AttributeSetInstance_ID + ", M_Product_ID=" + _M_Product_ID; return(obj); } // Get Attribute Set aset = _masi.GetMAttributeSet(); // Product has no Attribute Set if (aset == null) { obj.IsReturnNull = true; obj.Error = "PAttributeNoAttributeSet"; return(obj); } obj.MAttributeSetID = aset.Get_ID(); // Product has no Instance Attributes if (!_productWindow && !aset.IsInstanceAttribute()) { obj.Error = "NPAttributeNoInstanceAttribute="; return(obj); } if (_productWindow) { attributes = aset.GetMAttributes(false); } else { attributes = aset.GetMAttributes(true); } //Row 0 obj.tableStucture = "<table style='width: 100%;'><tr>"; if (_productWindow) { for (int i = 0; i < attributes.Length; i++) { obj.tableStucture = AddAttributeLine(attributes[i], _M_AttributeSetInstance_ID, true, false, windowNo, obj, i); } } else { var newEditContent = VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "NewRecord")); if (_M_AttributeSetInstance_ID > 0) { newEditContent = VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "EditRecord")); } //column 1 obj.tableStucture += "<td style = 'visibility: hidden;'>"; obj.tableStucture += "<input type='checkbox' id='chkNewEdit_" + windowNo + "' ><label class='VIS_Pref_Label_Font'>" + newEditContent + "</label>"; obj.tableStucture += "</td>"; //column 2 obj.tableStucture += "<td>"; obj.tableStucture += "<button type='button' style='margin-bottom: 10px;' id='btnSelect_" + windowNo + "' role='button' aria-disabled='false'><img style='float: left;' src='~/Areas/VIS/Images/base/Delete24.PNG' /><span style='float: left;margin-left: 5px;margin-right: 5px;' >" + VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "SelectExisting")) + "</span></button>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Change 20-May-2015 Bharat var label = Msg.Translate(ctx, "AttrCode"); obj.tableStucture += "<tr>"; obj.tableStucture += "<td>"; obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' id=lot_" + windowNo + "' class='VIS_Pref_Label_Font'>" + label + "</label>"; obj.tableStucture += "</td>"; //column 2 obj.tableStucture += "<td>"; obj.tableStucture += "<input style='width: 100%;' id='txtAttrCode_" + windowNo + "' value='' class='VIS_Pref_pass' type='text'>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Row 1 obj.tableStucture += "<tr>"; // All Attributes for (int i = 0; i < attributes.Length; i++) { obj.tableStucture = AddAttributeLine(attributes[i], _M_AttributeSetInstance_ID, true, false, windowNo, obj, i); } } // Lot if (!_productWindow && aset.IsLot()) { //column 1 var label = Msg.Translate(ctx, "Lot"); obj.tableStucture += "<td>"; obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' id=lot_" + windowNo + "' class='VIS_Pref_Label_Font'>" + label + "</label>"; obj.tableStucture += "</td>"; //column 2 obj.tableStucture += "<td>"; obj.tableStucture += "<input style='width: 100%;' id='txtLotString_" + windowNo + "' value='" + _masi.GetLot() + "' class='VIS_Pref_pass' type='text'>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Row 1 if (!IsSOTrx || IsInternalUse == "N" || window_ID == 191 || window_ID == 140) { obj.tableStucture += "<tr>"; //column 1 label = Msg.Translate(ctx, "M_Lot_ID"); obj.tableStucture += "<td>"; obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' id=M_Lot_ID_" + windowNo + "' class='VIS_Pref_Label_Font'>" + label + "</label>"; obj.tableStucture += "</td>"; String sql = "SELECT M_Lot_ID, Name " + "FROM M_Lot l " + "WHERE EXISTS (SELECT M_Product_ID FROM M_Product p " + "WHERE p.M_AttributeSet_ID=" + _masi.GetM_AttributeSet_ID() + " AND p.M_Product_ID=l.M_Product_ID)"; KeyNamePair[] data = DB.GetKeyNamePairs(sql, true); //column 2 obj.tableStucture += "<td>"; obj.tableStucture += "<select style='width: 100%;margin-bottom: 10px;' id='cmbLot_" + windowNo + "'>"; obj.tableStucture += " <option selected value='" + 0 + "' > </option>"; for (int i = 1; i < data.Length; i++) { if (Convert.ToInt32(data[i].Key) == _masi.GetM_Lot_ID()) { obj.tableStucture += " <option selected value='" + data[i].Key + "' >" + data[i].Name + "</option>"; } else { obj.tableStucture += " <option value='" + data[i].Key + "' >" + data[i].Name + "</option>"; } } obj.tableStucture += "</select>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Row 2 obj.tableStucture += "<tr>"; // New Lot Button if (_masi.GetMAttributeSet().GetM_LotCtl_ID() != 0) { if (MRole.GetDefault(ctx).IsTableAccess(MLot.Table_ID, false) && MRole.GetDefault(ctx).IsTableAccess(MLotCtl.Table_ID, false)) { if (!_masi.IsExcludeLot(AD_Column_ID, IsSOTrx))//_windowNoParent { //column 1 obj.tableStucture += "<td></td>"; //column 2 obj.tableStucture += "<td>"; obj.tableStucture += "<button type='button' style='margin-bottom: 10px;' id='btnLot_" + windowNo + "' role='button' aria-disabled='false'><span >" + VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "New")) + "</span></button>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Row 3 obj.tableStucture += "<tr>"; } } } } //mZoom = new System.Windows.Forms.ToolStripMenuItem(Msg.GetMsg(Env.GetContext(), "Zoom"), Env.GetImageIcon("Zoom16.gif")); //mZoom.Click += new EventHandler(mZoom_Click); //ctxStrip.Items.Add(mZoom); } // SerNo if (!_productWindow && aset.IsSerNo()) { //column 1 var label = Msg.Translate(ctx, "SerNo"); obj.tableStucture += "<td>"; obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' id=SerNo_" + windowNo + "' class='VIS_Pref_Label_Font'>" + label + "</label>"; obj.tableStucture += "</td>"; //column 2 // txtSerNo.Text = _masi.GetSerNo(); obj.tableStucture += "<td>"; obj.tableStucture += "<input style='width: 100%;' id='txtSerNo_" + windowNo + "' value='" + _masi.GetSerNo() + "' class='VIS_Pref_pass' type='text'>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Row 1 obj.tableStucture += "<tr>"; // New SerNo Button if (_masi.GetMAttributeSet().GetM_SerNoCtl_ID() != 0) { if (MRole.GetDefault(ctx).IsTableAccess(MSerNoCtl.Table_ID, false)) { if (!_masi.IsExcludeSerNo(AD_Column_ID, IsSOTrx))//_windowNoParent { //column 1 obj.tableStucture += "<td></td>"; obj.tableStucture += "<td>"; obj.tableStucture += "<button type='button' style='margin-bottom: 10px;' id='btnSerNo_" + windowNo + "' role='button' aria-disabled='false'><span >" + VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "New")) + "</span></button>"; obj.tableStucture += "</td>"; } obj.tableStucture += "</tr>"; //Row 2 obj.tableStucture += "<tr>"; } } } // SerNo //// GuaranteeDate if (!_productWindow && aset.IsGuaranteeDate()) { var dtpicGuaranteeDate = TimeUtil.AddDays(DateTime.Now, _prd.GetGuaranteeDays()); if (_M_AttributeSetInstance_ID > 0) { dtpicGuaranteeDate = (DateTime)(_masi.GetGuaranteeDate()); } var label = Msg.Translate(ctx, "GuaranteeDate"); //Column 1 obj.tableStucture += "<td>"; obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' id='guaranteeDate_" + windowNo + "' class='VIS_Pref_Label_Font'>" + label + "</label>"; obj.tableStucture += "</td>"; //Column 2 obj.tableStucture += "<td>"; //obj.tableStucture += "<input style='width: 100%;' value='" + String.Format("{0:yyyy-MM-dd}", dtpicGuaranteeDate) + "' type='date' id='dtpicGuaranteeDate_" + windowNo + "' class='VIS_Pref_pass'/>"; obj.tableStucture += "<input style='width: 100%;' value='" + String.Format("{0:yyyy-MM-dd}", dtpicGuaranteeDate) + "' type='date' id='dtpicGuaranteeDate_" + windowNo + "' class='VIS_Pref_pass'/>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Row 2 obj.tableStucture += "<tr>"; } //string[] sep = new string[1]; //sep[0] = "<tr>"; //sep = obj.tableStucture.Split(sep, StringSplitOptions.RemoveEmptyEntries); //if (sep.Length <= 3) //{ // obj.Error = "PAttributeNoInfo"; // obj.IsReturnNull = true; // return null; //} // New/Edit Window if (!_productWindow) { //chkNewEdit.IsChecked = _M_AttributeSetInstance_ID == 0; } // Attrribute Set Instance Description //Column 1 var label1 = Msg.Translate(ctx, "Description"); obj.tableStucture += "<td>"; obj.tableStucture += "<label style='padding-bottom: 10px; padding-right: 5px;' id='description_" + windowNo + "' class='VIS_Pref_Label_Font'>" + label1 + "</label>"; obj.tableStucture += "</td>"; //Column 2 obj.tableStucture += "<td>"; obj.tableStucture += "<input style='width: 100%;' readonly id='txtDescription_" + windowNo + "' value='" + _masi.GetDescription() + "' class='VIS_Pref_pass vis-gc-vpanel-table-readOnly' type='text'>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; //Add Ok and Cancel button //Last row obj.tableStucture += "<tr>"; obj.tableStucture += "<td style='text-align:right' colspan='2'>"; obj.tableStucture += "<button style='margin-bottom:0px;margin-top:0px; float:right' type='button' class='VIS_Pref_btn-2' style='float: right;' id='btnCancel_" + windowNo + "' role='button' aria-disabled='false'>" + VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "Cancel")) + "</button>"; obj.tableStucture += "<button style='margin-bottom:0px;margin-top:0px; float:right; margin-right: 10px;' type='button' class='VIS_Pref_btn-2' style='float: right; margin-right: 10px;' id='btnOk_" + windowNo + "' role='button' aria-disabled='false'>" + VAdvantage.Utility.Util.CleanMnemonic(Msg.GetMsg(ctx, "OK")) + "</button>"; obj.tableStucture += "</td>"; obj.tableStucture += "</tr>"; obj.tableStucture += "</table>"; if (obj.ControlList != null) { if (obj.ControlList.Length > 1) { obj.ControlList = obj.ControlList.Substring(0, obj.ControlList.Length - 1); } ; } return(obj); }
/// <summary> /// Apply Payment Term without schedule to Order /// </summary> /// <param name="order">Order</param> private void ApplyAdvanceTermSchedule(MOrder order) { //for(int i=0;i<_schedule.Length;i++)) StringBuilder _sql = new StringBuilder(); Decimal remainder = order.GetGrandTotal(); MVA009OrderPaySchedule schedule = new MVA009OrderPaySchedule(GetCtx(), 0, Get_TrxName()); MPaymentTerm payterm = new MPaymentTerm(GetCtx(), order.GetC_PaymentTerm_ID(), Get_TrxName()); schedule.SetAD_Client_ID(order.GetAD_Client_ID()); schedule.SetAD_Org_ID(order.GetAD_Org_ID()); schedule.SetC_Order_ID(order.GetC_Order_ID()); schedule.SetC_PaymentTerm_ID(order.GetC_PaymentTerm_ID()); schedule.SetVA009_PaymentMethod_ID(order.GetVA009_PaymentMethod_ID()); //schedule.SetDueDate(GetDueDate(order)); // Get Next Business Day if Next Business Days check box is set to true DateTime?payDueDate = null; if (payterm.IsNextBusinessDay()) { payDueDate = payterm.GetNextBusinessDate(TimeUtil.AddDays(order.GetDateOrdered(), payterm.GetNetDays())); } else { payDueDate = TimeUtil.AddDays(order.GetDateOrdered(), payterm.GetNetDays()); } schedule.SetDueDate(payDueDate); schedule.SetDueAmt(order.GetGrandTotal()); if (payterm.IsNextBusinessDay()) { payDueDate = payterm.GetNextBusinessDate(TimeUtil.AddDays(order.GetDateOrdered(), payterm.GetDiscountDays())); } else { payDueDate = TimeUtil.AddDays(order.GetDateOrdered(), payterm.GetDiscountDays()); } schedule.SetDiscountDate(payDueDate); //schedule.SetDiscountDate(order.GetDateOrdered().Value.AddDays(Util.GetValueOfInt(payterm.GetDiscountDays()))); schedule.SetDiscountAmt((Util.GetValueOfDecimal((order.GetGrandTotal() * payterm.GetDiscount()) / 100))); if (payterm.IsNextBusinessDay()) { payDueDate = payterm.GetNextBusinessDate(TimeUtil.AddDays(order.GetDateOrdered(), payterm.GetDiscountDays2())); } else { payDueDate = TimeUtil.AddDays(order.GetDateOrdered(), payterm.GetDiscountDays2()); } schedule.SetDiscountDays2(payDueDate); //schedule.SetDiscountDays2(order.GetDateOrdered().Value.AddDays(Util.GetValueOfInt(payterm.GetDiscountDays2()))); schedule.SetDiscount2((Util.GetValueOfDecimal((order.GetGrandTotal() * payterm.GetDiscount2()) / 100))); schedule.SetVA009_PlannedDueDate(GetDueDate(order)); int BaseCurrency = GetCtx().GetContextAsInt("$C_Currency_ID"); if (BaseCurrency != order.GetC_Currency_ID()) { decimal multiplyRate = MConversionRate.GetRate(order.GetC_Currency_ID(), BaseCurrency, order.GetDateAcct(), order.GetC_ConversionType_ID(), order.GetAD_Client_ID(), order.GetAD_Org_ID()); schedule.SetVA009_OpenAmnt(order.GetGrandTotal() * multiplyRate); } else { schedule.SetVA009_OpenAmnt(order.GetGrandTotal()); } schedule.SetC_Currency_ID(order.GetC_Currency_ID()); schedule.SetVA009_BseCurrncy(BaseCurrency); schedule.SetVA009_OpnAmntInvce(order.GetGrandTotal()); schedule.SetC_BPartner_ID(order.GetC_BPartner_ID()); MOrder _Order = new MOrder(GetCtx(), order.GetC_Order_ID(), Get_TrxName()); //schedule.SetVA009_PaymentMethod_ID(_Order.GetVA009_PaymentMethod_ID()); //schedule.SetC_PaymentTerm_ID(_Order.GetC_PaymentTerm_ID()); int _graceDay = payterm.GetGraceDays(); DateTime?_followUpDay = GetDueDate(order); schedule.SetVA009_FollowupDate(_followUpDay.Value.AddDays(_graceDay)); _sql.Clear(); _sql.Append("SELECT VA009_PaymentMode, VA009_PaymentType, VA009_PaymentTrigger FROM VA009_PaymentMethod WHERE VA009_PaymentMethod_ID=" + order.GetVA009_PaymentMethod_ID() + " AND IsActive = 'Y' AND AD_Client_ID = " + order.GetAD_Client_ID()); DataSet ds = new DataSet(); ds = DB.ExecuteDataset(_sql.ToString()); if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { schedule.SetVA009_PaymentMode(Util.GetValueOfString(ds.Tables[0].Rows[0]["VA009_PaymentMode"])); schedule.SetVA009_PaymentType(Util.GetValueOfString(ds.Tables[0].Rows[0]["VA009_PaymentType"])); schedule.SetVA009_PaymentTrigger(Util.GetValueOfString(ds.Tables[0].Rows[0]["VA009_PaymentTrigger"])); schedule.SetVA009_ExecutionStatus("A"); } // updateInvoice if (!schedule.Save()) { ValueNamePair pp = VLogger.RetrieveError(); log.Info("Error found during creation of Order Schedule against Order ID = " + order.GetC_Order_ID() + " Error Name is " + pp.GetName()); } }
/** * Shipment Constructor * @param shipment shipment * @param shipLine shipment line * @param deliveryCount 0 or number of delivery */ public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount) : this(shipment.GetCtx(), 0, shipment.Get_TrxName()) { SetClientOrg(shipment); SetValueNameDescription(shipment, shipLine, deliveryCount); // Header // SetIsOwned(true); SetC_BPartner_ID(shipment.GetC_BPartner_ID()); SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID()); SetAD_User_ID(shipment.GetAD_User_ID()); SetM_Locator_ID(shipLine.GetM_Locator_ID()); SetIsInPosession(true); SetAssetServiceDate(shipment.GetDateAcct()); // Line MProduct product = shipLine.GetProduct(); SetM_Product_ID(product.GetM_Product_ID()); SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); //////////////////////////////* //Changes for vafam // SetAssetServiceDate(shipment.GetMovementDate()); //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName()); if (_assetGroup.IsOwned()) { SetIsOwned(true); //SetC_BPartner_ID(0); } if (_assetGroup.IsDepreciated()) { SetIsDepreciated(true); SetIsFullyDepreciated(false); } //Change by Sukhwinder for setting Asset type and amortization template on Asset window, MANTIS ID:1762 int countVA038 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA038_' ")); int countVAFAM = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VAFAM_' ")); if (countVA038 > 0) { Set_Value("VA038_AmortizationTemplate_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VA038_AmortizationTemplate_ID"))); } if (countVAFAM > 0) { Set_Value("VAFAM_AssetType", _assetGroup.Get_Value("VAFAM_AssetType").ToString()); Set_Value("VAFAM_DepreciationType_ID", Utility.Util.GetValueOfInt(_assetGroup.Get_Value("VAFAM_DepreciationType_ID"))); } //////////////////////////////////// // Guarantee & Version SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); SetVersionNo(product.GetVersionNo()); if (shipLine.GetM_AttributeSetInstance_ID() != 0) // Instance { MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID()); SetLot(asi.GetLot()); SetSerNo(asi.GetSerNo()); } SetHelp(shipLine.GetDescription()); // Qty int units = product.GetSupportUnits(); if (units == 0) { units = 1; } if (deliveryCount != 0) // one asset per UOM { SetQty(shipLine.GetMovementQty(), units); } else { SetQty((Decimal)units); } SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID()); // Activate MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()); if (!ag.IsCreateAsActive()) { SetIsActive(false); } //Check if the Software Industry module installed, update following fields on Asset window if (Env.IsModuleInstalled("VA077_")) { //Set default values SetIsInPosession(false); SetIsOwned(false); SetIsActive(true); SetIsDisposed(false); Set_Value("VA077_SerialNo", shipLine.Get_Value("VA077_SerialNo")); Set_Value("VA077_CNAutodesk", shipLine.Get_Value("VA077_CNAutodesk")); Set_Value("VA077_RegEmail", shipLine.Get_Value("VA077_RegEmail")); Set_Value("VA077_IsCustAsset", "Y"); Set_Value("VA077_OldSN", shipLine.Get_Value("VA077_OldSN")); Set_Value("VA077_UserRef_ID", shipLine.Get_Value("VA077_UserRef_ID")); Set_Value("VA077_ProductInfo", shipLine.Get_Value("VA077_ProductInfo")); Set_Value("VA077_ServiceContract_ID", shipLine.Get_Value("VA077_ServiceContract_ID")); Set_Value("AD_OrgTrx_ID", shipLine.Get_Value("AD_OrgTrx_ID")); if (Util.GetValueOfBool(product.Get_Value("VA077_LicenceTracked"))) { Set_Value("VA077_LicenceTracked", "Y"); } else { Set_Value("VA077_LicenceTracked", "N"); } } }
/** * Shipment Constructor * @param shipment shipment * @param shipLine shipment line * @param deliveryCount 0 or number of delivery */ public MAsset(MInOut shipment, MInOutLine shipLine, int deliveryCount) : this(shipment.GetCtx(), 0, shipment.Get_TrxName()) { SetClientOrg(shipment); SetValueNameDescription(shipment, shipLine, deliveryCount); // Header SetIsOwned(true); SetC_BPartner_ID(shipment.GetC_BPartner_ID()); SetC_BPartner_Location_ID(shipment.GetC_BPartner_Location_ID()); SetAD_User_ID(shipment.GetAD_User_ID()); SetM_Locator_ID(shipLine.GetM_Locator_ID()); SetIsInPosession(true); // Line MProduct product = shipLine.GetProduct(); SetM_Product_ID(product.GetM_Product_ID()); SetA_Asset_Group_ID(product.GetA_Asset_Group_ID()); //////////////////////////////* //Changes for vafam // SetAssetServiceDate(shipment.GetMovementDate()); //SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); MAssetGroup _assetGroup = new MAssetGroup(GetCtx(), GetA_Asset_Group_ID(), shipment.Get_TrxName()); if (_assetGroup.IsOwned()) { SetIsOwned(true); //SetC_BPartner_ID(0); } if (_assetGroup.IsDepreciated()) { SetIsDepreciated(true); SetIsFullyDepreciated(false); } //////////////////////////////////// // Guarantee & Version SetGuaranteeDate(TimeUtil.AddDays(shipment.GetMovementDate(), product.GetGuaranteeDays())); SetVersionNo(product.GetVersionNo()); if (shipLine.GetM_AttributeSetInstance_ID() != 0) // Instance { MAttributeSetInstance asi = new MAttributeSetInstance(GetCtx(), shipLine.GetM_AttributeSetInstance_ID(), Get_TrxName()); SetM_AttributeSetInstance_ID(asi.GetM_AttributeSetInstance_ID()); SetLot(asi.GetLot()); SetSerNo(asi.GetSerNo()); } SetHelp(shipLine.GetDescription()); // Qty int units = product.GetSupportUnits(); if (units == 0) { units = 1; } if (deliveryCount != 0) // one asset per UOM { SetQty(shipLine.GetMovementQty(), units); } else { SetQty((Decimal)units); } SetM_InOutLine_ID(shipLine.GetM_InOutLine_ID()); // Activate MAssetGroup ag = MAssetGroup.Get(GetCtx(), GetA_Asset_Group_ID()); if (!ag.IsCreateAsActive()) { SetIsActive(false); } }