Beispiel #1
0
 /**
  *  Create from Pay Selection
  *	@param ps payment selection
  *	@param PaymentRule payment rule
  */
 public MPaySelectionCheck(MPaySelection ps, String PaymentRule)
     : this(ps.GetCtx(), 0, ps.Get_TrxName())
 {
     SetClientOrg(ps);
     SetC_PaySelection_ID(ps.GetC_PaySelection_ID());
     SetPaymentRule(PaymentRule);
 }
        /// <summary>
        /// Get Payment Batch for PaySelection
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="C_PaySelection_ID">id</param>
        /// <param name="trxName">transaction</param>
        /// <returns>payment batch</returns>
        public static MPaymentBatch GetForPaySelection(Ctx ctx, int C_PaySelection_ID, Trx trxName)
        {
            MPaySelection ps       = new MPaySelection(ctx, C_PaySelection_ID, trxName);
            MPaymentBatch retValue = new MPaymentBatch(ps);

            return(retValue);
        }
Beispiel #3
0
 /**
  *  Get Parent
  *	@return parent
  */
 public MPaySelection GetParent()
 {
     if (_parent == null)
     {
         _parent = new MPaySelection(GetCtx(), GetC_PaySelection_ID(), Get_TrxName());
     }
     return(_parent);
 }
Beispiel #4
0
        /**
         *  Create Check for Payment
         *	@param ctx context
         *	@param C_Payment_ID id
         *	@param trxName transaction
         *	@return pay selection check for payment or null
         */
        public static MPaySelectionCheck CreateForPayment(Ctx ctx, int C_Payment_ID, Trx trxName)
        {
            if (C_Payment_ID == 0)
            {
                return(null);
            }
            MPayment payment = new MPayment(ctx, C_Payment_ID, null);
            //	Map Payment Rule <- Tender Type
            String PaymentRule = PAYMENTRULE_Check;

            if (payment.GetTenderType().Equals(X_C_Payment.TENDERTYPE_CreditCard))
            {
                PaymentRule = PAYMENTRULE_CreditCard;
            }
            else if (payment.GetTenderType().Equals(X_C_Payment.TENDERTYPE_DirectDebit))
            {
                PaymentRule = PAYMENTRULE_DirectDebit;
            }
            else if (payment.GetTenderType().Equals(X_C_Payment.TENDERTYPE_DirectDeposit))
            {
                PaymentRule = PAYMENTRULE_DirectDeposit;
            }
            //	else if (payment.GetTenderType().Equals(MPayment.TENDERTYPE_Check))
            //		PaymentRule = MPaySelectionCheck.PAYMENTRULE_Check;

            //	Create new PaySelection
            MPaySelection ps = new MPaySelection(ctx, 0, trxName);

            ps.SetC_BankAccount_ID(payment.GetC_BankAccount_ID());
            ps.SetName(Msg.Translate(ctx, "C_Payment_ID") + ": " + payment.GetDocumentNo());
            ps.SetDescription(payment.GetDescription());
            ps.SetPayDate(payment.GetDateTrx());
            ps.SetTotalAmt(payment.GetPayAmt());
            ps.SetIsApproved(true);
            ps.Save();

            //	Create new PaySelection Line
            MPaySelectionLine psl = null;

            if (payment.GetC_Invoice_ID() != 0)
            {
                psl = new MPaySelectionLine(ps, 10, PaymentRule);
                psl.SetC_Invoice_ID(payment.GetC_Invoice_ID());
                psl.SetIsSOTrx(payment.IsReceipt());
                psl.SetOpenAmt(Decimal.Add(payment.GetPayAmt(), payment.GetDiscountAmt()));
                psl.SetPayAmt(payment.GetPayAmt());
                psl.SetDiscountAmt(payment.GetDiscountAmt());
                psl.SetDifferenceAmt(Env.ZERO);
                psl.Save();
            }

            //	Create new PaySelection Check
            MPaySelectionCheck psc = new MPaySelectionCheck(ps, PaymentRule);

            psc.SetC_BPartner_ID(payment.GetC_BPartner_ID());
            psc.SetC_Payment_ID(payment.GetC_Payment_ID());
            psc.SetIsReceipt(payment.IsReceipt());
            psc.SetPayAmt(payment.GetPayAmt());
            psc.SetDiscountAmt(payment.GetDiscountAmt());
            psc.SetQty(1);
            psc.SetDocumentNo(payment.GetDocumentNo());
            psc.SetProcessed(true);
            psc.Save();

            //	Update optional Line
            if (psl != null)
            {
                psl.SetC_PaySelectionCheck_ID(psc.GetC_PaySelectionCheck_ID());
                psl.SetProcessed(true);
                psl.Save();
            }

            //	Indicate Done
            ps.SetProcessed(true);
            ps.Save();
            return(psc);
        }
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="ps">Pay Selection</param>
 public MPaymentBatch(MPaySelection ps)
     : this(ps.GetCtx(), 0, ps.Get_TrxName())
 {
     SetClientOrg(ps);
     SetName(ps.GetName());
 }