/** * Set Value Name Description * @param Invoice * @param line line * @param deliveryCount */ public void SetValueNameDescription(MInvoice invoice, MInvoiceLine line, int deliveryCount) { MProduct product = line.GetProduct(); MBPartner partner = new MBPartner(GetCtx(), invoice.GetC_BPartner_ID(), null); SetValueNameDescription(invoice, deliveryCount, product, partner); }
/** * Apply Payment Term to Invoice * @param invoice invoice * @return true if payment schedule is valid */ public bool Apply(MInvoice invoice) { if (invoice == null || invoice.Get_ID() == 0) { log.Log(Level.SEVERE, "No valid invoice - " + invoice); return(false); } //Added By Vivek on 17/5/2016 fro Advance Payment GetSchedule(true); if (invoice.GetC_Order_ID() != 0) { return(ApplyNoSchedule(invoice)); } else { return(ApplySchedule(invoice)); } //End Vivek //if (!IsValid()) // return ApplyNoSchedule(invoice); //// //GetSchedule(true); //if (_schedule.Length <= 1) // return ApplyNoSchedule(invoice); //else // only if valid // return ApplySchedule(invoice); }
/** * Set Value, Name, Description * @param invoice * @param deliveryCount count * @param product product * @param partner partner */ public void SetValueNameDescription(MInvoice invoice, int deliveryCount, MProduct product, MBPartner partner) { String documentNo = "_" + invoice.GetDocumentNo(); if (deliveryCount > 1) { documentNo += "_" + deliveryCount; } // Value String value = partner.GetValue() + "_" + product.GetValue(); if (value.Length > 40 - documentNo.Length) { value = value.Substring(0, 40 - documentNo.Length) + documentNo; } // Change to set Value from Document Sequence // SetValue(value); // Change to set only name of product as value in Asset // Name MProduct.afterSave // String name = partner.GetName() + " - " + product.GetName(); String name = product.GetName(); if (name.Length > 60) { name = name.Substring(0, 60); } SetName(name); // Description String description = product.GetDescription(); SetDescription(description); }
/// <summary> /// Create Cash Journal Line /// </summary> /// <param name="invoice">Invoice</param> /// <param name="C_InvoicePaySchedule_ID">Invoice Payemt Schedule</param> /// <param name="amt">Amount</param> public void CreateCashLine(MInvoice invoice, int C_InvoicePaySchedule_ID, decimal amt) { SetC_Invoice_ID(invoice.GetC_Invoice_ID()); SetC_InvoicePaySchedule_ID(C_InvoicePaySchedule_ID); SetCashType(CASHTYPE_Invoice); SetC_BPartner_ID(invoice.GetC_BPartner_ID()); // JID_0687: System is not updating the Location on cash journal line in cases of POS order and payment method cash SetC_BPartner_Location_ID(invoice.GetC_BPartner_Location_ID()); SetC_Currency_ID(invoice.GetC_Currency_ID()); // Amount MDocType dt = MDocType.Get(GetCtx(), invoice.GetC_DocType_ID()); if (MDocBaseType.DOCBASETYPE_APINVOICE.Equals(dt.GetDocBaseType()) || MDocBaseType.DOCBASETYPE_ARCREDITMEMO.Equals(dt.GetDocBaseType())) { amt = Decimal.Negate(amt); SetVSS_PAYMENTTYPE("P"); } else { SetVSS_PAYMENTTYPE("R"); } SetAmount(amt); // SetDiscountAmt(Env.ZERO); SetWriteOffAmt(Env.ZERO); SetIsGenerated(true); _invoice = invoice; }
/************************************************************************** * Create Invoice Line from Order Line * @param order order * @param orderLine line * @param qtyInvoiced qty * @param qtyEntered qty */ private void CreateLine(MOrder order, MOrderLine orderLine, Decimal qtyInvoiced, Decimal qtyEntered) { if (_invoice == null) { _invoice = new MInvoice(order, 0, _DateInvoiced); if (!_invoice.Save()) { throw new Exception("Could not create Invoice (o)"); } } // MInvoiceLine line = new MInvoiceLine(_invoice); line.SetOrderLine(orderLine); line.SetQtyInvoiced(qtyInvoiced); log.Info("Qty Invoiced" + line.GetQtyInvoiced()); line.SetQtyEntered(qtyEntered); line.SetLine(_line + orderLine.GetLine()); if (!line.Save()) { throw new Exception("Could not create Invoice Line (o)"); } log.Fine(line.ToString()); }
} // MTaxDeclarationLine /// <summary> /// Parent Constructor /// </summary> /// <param name="parent">parent</param> /// <param name="invoice">invoice</param> /// <param name="iLine">invoice line</param> public MTaxDeclarationLine(MTaxDeclaration parent, MInvoice invoice, MInvoiceLine iLine) : this(parent.GetCtx(), 0, parent.Get_TrxName()) { // this(parent.getCtx(), 0, parent.get_TrxName()); SetClientOrg(invoice); SetC_TaxDeclaration_ID(parent.GetC_TaxDeclaration_ID()); SetIsManual(false); // SetC_Invoice_ID(invoice.GetC_Invoice_ID()); SetC_BPartner_ID(invoice.GetC_BPartner_ID()); SetC_Currency_ID(invoice.GetC_Currency_ID()); SetDateAcct(invoice.GetDateAcct()); // SetC_InvoiceLine_ID(iLine.GetC_InvoiceLine_ID()); SetC_Tax_ID(iLine.GetC_Tax_ID()); if (invoice.IsTaxIncluded()) { SetTaxBaseAmt(iLine.GetLineNetAmt()); SetTaxAmt(iLine.GetTaxAmt()); } else { SetTaxBaseAmt(iLine.GetLineNetAmt()); SetTaxAmt(iLine.GetTaxAmt()); } } // MTaxDeclarationLine
/** * Apply Payment Term with schedule to Invoice * @param invoice invoice * @return true if payment schedule is valid */ private bool ApplySchedule(MInvoice invoice) { DeleteInvoicePaySchedule(invoice.GetC_Invoice_ID(), invoice.Get_TrxName()); // Create Schedule MInvoicePaySchedule ips = null; Decimal remainder = invoice.GetGrandTotal(); for (int i = 0; i < _schedule.Length; i++) { ips = new MInvoicePaySchedule(invoice, _schedule[i]); ips.Save(invoice.Get_TrxName()); log.Fine(ips.ToString()); remainder = Decimal.Subtract(remainder, ips.GetDueAmt()); } // for all schedules // Remainder - update last if (remainder.CompareTo(Env.ZERO) != 0 && ips != null) { ips.SetDueAmt(Decimal.Add(ips.GetDueAmt(), remainder)); ips.Save(invoice.Get_TrxName()); log.Fine("Remainder=" + remainder + " - " + ips); } // updateInvoice if (invoice.GetC_PaymentTerm_ID() != GetC_PaymentTerm_ID()) { invoice.SetC_PaymentTerm_ID(GetC_PaymentTerm_ID()); } return(invoice.ValidatePaySchedule()); }
/// <summary> /// Complete Invoice /// </summary> /// <param name="invoice">invoice</param> private void CompleteInvoice(MInvoice invoice, MTimeExpense te) { if (invoice == null) { return; } invoice.SetDocAction(DocActionVariables.ACTION_PREPARE); invoice.ProcessIt(DocActionVariables.ACTION_COMPLETE); if (!invoice.Save()) { //Added By Siddheshwar if (!IncompleteInvoice.Contains(te.GetS_TimeExpense_ID())) { IncompleteInvoice.Add(te.GetS_TimeExpense_ID()); if (string.IsNullOrEmpty(bpNameInvoice)) { bpNameInvoice = te.GetDocumentNo(); } else { bpNameInvoice += te.GetDocumentNo() + ", "; } } new Exception(invoice + "Cannot save Invoice"); Rollback(); } else { Commit(); _noInvoices++; AddLog(invoice.Get_ID(), invoice.GetDateInvoiced(), invoice.GetGrandTotal(), invoice.GetDocumentNo()); } } // completeInvoice
public void CreateCashLine(MInvoice invoice, int C_InvoicePaySchedule_ID, decimal amt) { SetC_Invoice_ID(invoice.GetC_Invoice_ID()); SetC_InvoicePaySchedule_ID(C_InvoicePaySchedule_ID); SetCashType(CASHTYPE_Invoice); SetC_BPartner_ID(invoice.GetC_BPartner_ID()); SetC_Currency_ID(invoice.GetC_Currency_ID()); // Amount MDocType dt = MDocType.Get(GetCtx(), invoice.GetC_DocType_ID()); if (MDocBaseType.DOCBASETYPE_APINVOICE.Equals(dt.GetDocBaseType()) || MDocBaseType.DOCBASETYPE_ARCREDITMEMO.Equals(dt.GetDocBaseType())) { amt = Decimal.Negate(amt); SetVSS_PAYMENTTYPE("P"); } else { SetVSS_PAYMENTTYPE("R"); } SetAmount(amt); // SetDiscountAmt(Env.ZERO); SetWriteOffAmt(Env.ZERO); SetIsGenerated(true); _invoice = invoice; }
/** * Set Order - no discount * @param order order * @param trxName transaction */ public void SetOrder(MOrder order, Trx trxName) { SetCashType(CASHTYPE_Invoice); SetC_Currency_ID(order.GetC_Currency_ID()); // Amount Decimal amt = order.GetGrandTotal(); SetAmount(amt); SetDiscountAmt(Env.ZERO); SetWriteOffAmt(Env.ZERO); SetIsGenerated(true); // if (MOrder.DOCSTATUS_WaitingPayment.Equals(order.GetDocStatus())) { Save(trxName); order.SetC_CashLine_ID(GetC_CashLine_ID()); //order.ProcessIt(MOrder.ACTION_WaitComplete); order.ProcessIt(DocActionVariables.ACTION_WAITCOMPLETE); order.Save(trxName); // Set Invoice MInvoice[] invoices = order.GetInvoices(true); int length = invoices.Length; if (length > 0) // get last invoice { _invoice = invoices[length - 1]; SetC_Invoice_ID(_invoice.GetC_Invoice_ID()); } } }
/// <summary> /// Dunning Level Consequences /// </summary> /// <param name="level"></param> /// <param name="entry"></param> private void DunningLevelConsequences(MDunningLevel level, MDunningRunEntry entry) { // Update Business Partner based on Level if (level.IsSetCreditStop() || level.IsSetPaymentTerm()) { MBPartner thisBPartner = new MBPartner(GetCtx(), entry.GetC_BPartner_ID(), Get_TrxName()); if (level.IsSetCreditStop()) { thisBPartner.SetSOCreditStatus(X_C_BPartner.SOCREDITSTATUS_CreditStop); } if (level.IsSetPaymentTerm() && level.GetC_PaymentTerm_ID() != 0) { thisBPartner.SetC_PaymentTerm_ID(level.GetC_PaymentTerm_ID()); } thisBPartner.Save(); } // Update Invoices if not Statement (Statement is hardcoded -9999 see also MDunningLevel) if (!level.GetDaysAfterDue().Equals(new Decimal(-9999)) && level.GetInvoiceCollectionType() != null) { MDunningRunLine[] lines = entry.GetLines(); for (int i = 0; i < lines.Length; i++) { MDunningRunLine line = lines[i]; if (line.GetC_Invoice_ID() != 0 && line.IsActive()) { MInvoice invoice = new MInvoice(GetCtx(), line.GetC_Invoice_ID(), Get_TrxName()); invoice.SetInvoiceCollectionType(level.GetInvoiceCollectionType()); invoice.Save(); } } } }
} // invoiceDone /// <summary> /// New Invoice /// </summary> /// <param name="request">request</param> private void InvoiceNew(MRequest request) { _m_invoice = new MInvoice(GetCtx(), 0, Get_TrxName()); _m_invoice.SetC_DocTypeTarget_ID(MDocBaseType.DOCBASETYPE_ARINVOICE); MBPartner partner = new MBPartner(GetCtx(), request.GetC_BPartner_ID(), Get_TrxName()); _m_invoice.SetBPartner(partner); _m_invoice.SetM_PriceList_ID(partner.GetM_PriceList_ID()); int _CountVA009 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA009_' AND IsActive = 'Y'")); if (_CountVA009 > 0) { _m_invoice.SetVA009_PaymentMethod_ID(partner.GetVA009_PaymentMethod_ID()); } _m_invoice.Save(); request.SetC_Invoice_ID(_m_invoice.GetC_Invoice_ID()); request.Save(); if (string.IsNullOrEmpty(_msg)) { _msg = "Invoice-[ID:" + _m_invoice.Get_ID() + "] created"; } else { _msg += ",Invoice-[ID: " + _m_invoice.Get_ID() + "] created"; } //_m_linecount = 0; } // invoiceNew
/** * Get Invoice * @return invoice */ public MInvoice GetInvoice() { if (_invoice == null && GetC_Invoice_ID() != 0) { _invoice = MInvoice.Get(GetCtx(), GetC_Invoice_ID()); } return(_invoice); }
/** * @return Returns the parent. */ public MInvoice GetParent() { if (_parent == null) { _parent = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName()); } return(_parent); }
/** * Get Invoice * @return invoice */ public MInvoice GetInvoice() { if (_invoice == null && GetC_Invoice_ID() != 0) { _invoice = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName()); } return(_invoice); }
// Added by Bharat on 30 Jan 2018 to Get Inco Term public int GetIncoTerm(Ctx ctx, string fields) { string[] paramValue = fields.Split(','); bool isSOTrx = false; int incoTerm_ID = 0, referenceID = 0; string tableName = "", refColumn = "", qry = ""; isSOTrx = Util.GetValueOfBool(paramValue[0]); tableName = Util.GetValueOfString(paramValue[1]); refColumn = Util.GetValueOfString(paramValue[2]); referenceID = Util.GetValueOfInt(paramValue[3]); if (tableName == "C_Order") { if (referenceID > 0) { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } } else if (tableName == "C_Invoice") { if (isSOTrx && referenceID > 0) { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "C_Order_ID") { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "M_InOut_ID") { MInOut inOut = new MInOut(ctx, referenceID, null); incoTerm_ID = inOut.GetC_IncoTerm_ID(); } } else if (tableName == "M_InOut") { if (isSOTrx && referenceID > 0) { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "C_Order_ID") { MOrder ord = new MOrder(ctx, referenceID, null); incoTerm_ID = ord.GetC_IncoTerm_ID(); } else if (!isSOTrx && referenceID > 0 && refColumn == "C_Invoice_ID") { MInvoice inv = new MInvoice(ctx, referenceID, null); incoTerm_ID = inv.GetC_IncoTerm_ID(); } } return(incoTerm_ID); }
} // toString /// <summary> /// Execute Run. /// </summary> /// <returns>clear text info</returns> public String ExecuteRun() { DateTime?dateDoc = GetDateNextRun(); if (!CalculateRuns()) { throw new Exception("No Runs Left"); } // log MRecurringRun run = new MRecurringRun(GetCtx(), this); String msg = "@Created@ "; // Copy if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Order)) { MOrder from = new MOrder(GetCtx(), GetC_Order_ID(), Get_TrxName()); MOrder order = MOrder.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), false, false, Get_TrxName()); run.SetC_Order_ID(order.GetC_Order_ID()); msg += order.GetDocumentNo(); } else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Invoice)) { MInvoice from = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName()); MInvoice invoice = MInvoice.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), false, Get_TrxName(), false); run.SetC_Invoice_ID(invoice.GetC_Invoice_ID()); msg += invoice.GetDocumentNo(); } else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Project)) { MProject project = MProject.CopyFrom(GetCtx(), GetC_Project_ID(), dateDoc, Get_TrxName()); run.SetC_Project_ID(project.GetC_Project_ID()); msg += project.GetValue(); } else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournal)) { MJournalBatch journal = MJournalBatch.CopyFrom(GetCtx(), GetGL_JournalBatch_ID(), dateDoc, Get_TrxName()); run.SetGL_JournalBatch_ID(journal.GetGL_JournalBatch_ID()); msg += journal.GetDocumentNo(); } else { return("Invalid @RecurringType@ = " + GetRecurringType()); } run.Save(Get_TrxName()); // SetDateLastRun(run.GetUpdated()); SetRunsRemaining(GetRunsRemaining() - 1); SetDateNextRun(); Save(Get_TrxName()); return(msg); } // execureRun
/// <summary> /// Create Invoice. /// </summary> /// <returns>document no</returns> protected override String DoIt() { //log.info("M_InOut_ID=" + _M_InOut_ID // + ", M_PriceList_ID=" + _M_PriceList_ID // + ", InvoiceDocumentNo=" + _InvoiceDocumentNo); if (_M_InOut_ID == 0) { throw new ArgumentException("No Shipment"); } // MInOut ship = new MInOut(GetCtx(), _M_InOut_ID, null); if (ship.Get_ID() == 0) { throw new ArgumentException("Shipment not found"); } if (!MInOut.DOCSTATUS_Completed.Equals(ship.GetDocStatus())) { throw new ArgumentException("Shipment not completed"); } MInvoice invoice = new MInvoice(ship, null); if (ship.IsReturnTrx()) { invoice.SetC_DocTypeTarget_ID(ship.IsSOTrx() ? MDocBaseType.DOCBASETYPE_ARCREDITMEMO : MDocBaseType.DOCBASETYPE_APCREDITMEMO); } if (_M_PriceList_ID != 0) { invoice.SetM_PriceList_ID(_M_PriceList_ID); } if (_InvoiceDocumentNo != null && _InvoiceDocumentNo.Length > 0) { invoice.SetDocumentNo(_InvoiceDocumentNo); } if (!invoice.Save()) { throw new ArgumentException("Cannot save Invoice"); } MInOutLine[] shipLines = ship.GetLines(false); for (int i = 0; i < shipLines.Length; i++) { MInOutLine sLine = shipLines[i]; MInvoiceLine line = new MInvoiceLine(invoice); line.SetShipLine(sLine); line.SetQtyEntered(sLine.GetQtyEntered()); line.SetQtyInvoiced(sLine.GetMovementQty()); if (!line.Save()) { throw new ArgumentException("Cannot save Invoice Line"); } } return(invoice.GetDocumentNo()); }
/************************************************************************* * Apply Payment Term to Invoice - * @param C_Invoice_ID invoice * @return true if payment schedule is valid */ public bool Apply(int C_Invoice_ID) { MInvoice invoice = new MInvoice(GetCtx(), C_Invoice_ID, Get_TrxName()); if (invoice == null || invoice.Get_ID() == 0) { log.Log(Level.SEVERE, "apply - Not valid C_Invoice_ID=" + C_Invoice_ID); return(false); } return(Apply(invoice)); }
public LcDetails GetLcDetail(int Invoice_ID, Ctx ctx) { LcDetails lc = new LcDetails(); MInvoice inv = new MInvoice(ctx, Invoice_ID, null); if (inv.GetC_Order_ID() > 0) { MOrder order = new MOrder(ctx, inv.GetC_Order_ID(), null); try { lc.paymethod = order.GetVA009_PaymentMethod_ID(); if (Util.GetValueOfString(DB.ExecuteScalar("SELECT VA009_PaymentBaseType FROM VA009_PaymentMethod WHERE VA009_PaymentMethod_ID=" + order.GetVA009_PaymentMethod_ID(), null, null)) == "L") { lc.lcno = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT MIN(VA026_LCDetail_ID) FROM VA026_LCDetail WHERE IsActive = 'Y' AND DocStatus IN ('CO' , 'CL') AND c_order_id =" + order.GetC_Order_ID(), null, null)); // Check PO Detail tab of Letter of Credit if (lc.lcno == 0) { lc.lcno = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT MIN(lc.VA026_LCDetail_ID) FROM VA026_LCDetail lc INNER JOIN VA026_PODetail sod ON sod.VA026_LCDetail_ID = lc.VA026_LCDetail_ID WHERE sod.IsActive = 'Y' AND lc.IsActive = 'Y' AND lc.DocStatus IN ('CO' , 'CL') AND sod.C_Order_ID =" + order.GetC_Order_ID(), null, null)); if (lc.lcno != 0) { if (Util.GetValueOfString(DB.ExecuteScalar("SELECT VA026_IsLoanRequired FROM VA026_LCDetail WHERE VA026_LCDetail_ID=" + lc.lcno, null, null)) == "Y") { lc.trloan_id = Util.GetValueOfInt(DB.ExecuteScalar("SELECT VA026_TRLoanApplication_ID FROM VA026_TRLoanApplication WHERE IsActive='Y' AND DOCSTATUS='CO' AND VA026_LCDetail_ID= " + lc.lcno, null, null)); } } } else { if (Util.GetValueOfString(DB.ExecuteScalar("SELECT VA026_IsLoanRequired FROM VA026_LCDetail WHERE VA026_LCDetail_ID=" + lc.lcno, null, null)) == "Y") { lc.trloan_id = Util.GetValueOfInt(DB.ExecuteScalar("SELECT VA026_TRLoanApplication_ID FROM VA026_TRLoanApplication WHERE IsActive='Y' AND DOCSTATUS='CO' AND VA026_LCDetail_ID= " + lc.lcno, null, null)); } } } else { lc.lcno = 0; lc.trloan_id = 0; } } catch (Exception e) { } } return(lc); }
private DateTime?GetDueDate(MInvoice invoice) { MPaymentTerm payterm = new MPaymentTerm(GetCtx(), invoice.GetC_PaymentTerm_ID(), Get_TrxName()); String _sql = "Select PAYMENTTERMDUEDATE (C_PaymentTerm_ID, DATEINVOICED) as DueDate from C_invoice where C_invoice_ID=" + invoice.GetC_Invoice_ID(); DateTime? _dueDate = Util.GetValueOfDateTime(DB.ExecuteScalar(_sql.ToString(), null, Get_TrxName())); if (_dueDate == Util.GetValueOfDateTime("1/1/0001 12:00:00 AM")) { _dueDate = DateTime.Now; } return(_dueDate); }
/// <summary> /// Get Invoice /// </summary> /// <returns>Returns the invoice.</returns> public MInvoice GetInvoice() { if (GetC_Invoice_ID() == 0) { _invoice = null; } else if (_invoice == null) { _invoice = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName()); } return(_invoice); }
/************************************************************************** * Create Invoice Line from Order Line * @param order order * @param orderLine line * @param qtyInvoiced qty * @param qtyEntered qty */ private void CreateLine(MOrder order, MOrderLine orderLine, Decimal qtyInvoiced, Decimal qtyEntered) { if (_invoice == null) { _invoice = new MInvoice(order, 0, _DateInvoiced); //-----------------Column Added by Anuj------------------ int _CountVA009 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA009_' AND IsActive = 'Y'")); if (_CountVA009 > 0) { int _PaymentMethod_ID = order.GetVA009_PaymentMethod_ID(); if (_PaymentMethod_ID > 0) { _invoice.SetVA009_PaymentMethod_ID(_PaymentMethod_ID); } } //-----------------Column Added by Anuj------------------ int _CountVA026 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='VA026_' AND IsActive = 'Y'")); if (_CountVA026 > 0) { _invoice.SetVA026_LCDetail_ID(order.GetVA026_LCDetail_ID()); } // Added by Bharat on 29 Jan 2018 to set Inco Term from Order if (_invoice.Get_ColumnIndex("C_IncoTerm_ID") > 0) { _invoice.SetC_IncoTerm_ID(order.GetC_IncoTerm_ID()); } if (!_invoice.Save()) { throw new Exception("Could not create Invoice (o)"); } } // MInvoiceLine line = new MInvoiceLine(_invoice); line.SetOrderLine(orderLine); line.SetQtyInvoiced(qtyInvoiced); // if drop ship line true line.SetIsDropShip(orderLine.IsDropShip()); log.Info("Qty Invoiced" + line.GetQtyInvoiced()); line.SetQtyEntered(qtyEntered); line.SetLine(_line + orderLine.GetLine()); if (!line.Save()) { throw new Exception("Could not create Invoice Line (o)"); } log.Fine(line.ToString()); }
/// <summary> /// GetInvoice /// </summary> /// <param name="ctx"></param> /// <param name="fields"></param> /// <returns></returns> public Dictionary<string, string> GetInvoice(Ctx ctx,string fields) { string[] paramValue = fields.Split(','); int C_Invoice_ID; //Assign parameter value C_Invoice_ID = Util.GetValueOfInt(paramValue[0].ToString()); //End Assign parameter value MInvoice inv = new MInvoice(ctx, C_Invoice_ID, null); Dictionary<string, string> result = new Dictionary<string, string>(); result["IsSOTrx"] = inv.IsSOTrx().ToString(); return result; }
/** * Apply Payment Term without schedule to Invoice * @param invoice invoice * @return false as no payment schedule */ private bool ApplyNoSchedule(MInvoice invoice) { DeleteInvoicePaySchedule(invoice.GetC_Invoice_ID(), invoice.Get_TrxName()); // updateInvoice if (invoice.GetC_PaymentTerm_ID() != GetC_PaymentTerm_ID()) { invoice.SetC_PaymentTerm_ID(GetC_PaymentTerm_ID()); } if (invoice.IsPayScheduleValid()) { invoice.SetIsPayScheduleValid(false); } return(false); }
/// <summary> /// Perrform Process. /// </summary> /// <returns>Message (clear text)</returns> protected override String DoIt() { //log.info ("C_InvoicePaySchedule_ID=" + getRecord_ID()); MInvoicePaySchedule[] schedule = MInvoicePaySchedule.GetInvoicePaySchedule(GetCtx(), 0, GetRecord_ID(), null); if (schedule.Length == 0) { throw new ArgumentException("InvoicePayScheduleValidate - No Schedule"); } // Get Invoice MInvoice invoice = new MInvoice(GetCtx(), schedule[0].GetC_Invoice_ID(), null); if (invoice.Get_ID() == 0) { throw new ArgumentException("InvoicePayScheduleValidate - No Invoice"); } // Decimal total = Env.ZERO; for (int i = 0; i < schedule.Length; i++) { Decimal due = schedule[i].GetDueAmt(); if (due != 0) { total = Decimal.Add(total, due); } } bool valid = invoice.GetGrandTotal().CompareTo(total) == 0; invoice.SetIsPayScheduleValid(valid); invoice.Save(); // Schedule for (int i = 0; i < schedule.Length; i++) { if (schedule[i].IsValid() != valid) { schedule[i].SetIsValid(valid); schedule[i].Save(); } } String msg = "@OK@"; if (!valid) { msg = "@GrandTotal@ = " + invoice.GetGrandTotal() + " <> @Total@ = " + total + " - @Difference@ = " + Decimal.Subtract(invoice.GetGrandTotal(), total); } return(Msg.ParseTranslation(GetCtx(), msg)); }
} // MTaxDeclarationLine /// <summary> /// Parent Constructor /// </summary> /// <param name="parent">parent</param> /// <param name="invoice">invoice</param> /// <param name="tLine">tax line</param> public MTaxDeclarationLine(MTaxDeclaration parent, MInvoice invoice, MInvoiceTax tLine) : this(parent.GetCtx(), 0, parent.Get_TrxName()) { //this(parent.getCtx(), 0, parent.get_TrxName()); SetClientOrg(invoice); SetC_TaxDeclaration_ID(parent.GetC_TaxDeclaration_ID()); SetIsManual(false); // SetC_Invoice_ID(invoice.GetC_Invoice_ID()); SetC_BPartner_ID(invoice.GetC_BPartner_ID()); SetC_Currency_ID(invoice.GetC_Currency_ID()); SetDateAcct(invoice.GetDateAcct()); // SetC_Tax_ID(tLine.GetC_Tax_ID()); SetTaxBaseAmt(tLine.GetTaxBaseAmt()); SetTaxAmt(tLine.GetTaxAmt()); } // MTaxDeclarationLine
} // doIt /// <summary> /// Complete Invoice /// </summary> private void CompleteInvoice() { if (_invoice == null) { return; } _invoice.SetDocAction(_DocAction); _invoice.ProcessIt(_DocAction); _invoice.Save(); AddLog(0, _invoice.GetDateInvoiced(), _invoice.GetGrandTotal(), _invoice.GetDocumentNo()); _count++; _invoice = null; } // completeInvoice
/** * Complete Invoice */ private void CompleteInvoice() { if (_invoice != null) { if (!_invoice.ProcessIt(_docAction)) { log.Warning("completeInvoice - failed: " + _invoice); } _invoice.Save(); // AddLog(_invoice.GetC_Invoice_ID(), Convert.ToDateTime(_invoice.GetDateInvoiced()), null, _invoice.GetDocumentNo()); _created++; } _invoice = null; _ship = null; _line = 0; }
/// <summary> /// Load Specific Document Details /// </summary> /// <returns>error message or null</returns> public override String LoadDocumentDetails() { MInvoice invoice = (MInvoice)GetPO(); SetDateDoc(invoice.GetDateInvoiced()); SetIsTaxIncluded(invoice.IsTaxIncluded()); // Amounts SetAmount(Doc.AMTTYPE_Gross, invoice.GetGrandTotal()); SetAmount(Doc.AMTTYPE_Net, invoice.GetTotalLines()); SetAmount(Doc.AMTTYPE_Charge, invoice.GetChargeAmt()); // Contained Objects _taxes = LoadTaxes(); _lines = LoadLines(invoice); log.Fine("Lines=" + _lines.Length + ", Taxes=" + _taxes.Length); return(null); }