Ejemplo n.º 1
0
        /// <summary>
        /// canceling credit note.
        /// </summary>
        public bool CancelCreditNote(tbt_BillingBasic _doBillingBasic, doGetCreditNote _doGetCreditNote)
        {
            try
            {
                IBillingHandler billingHandler    = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                decimal         CNAmountExcVAT    = _doGetCreditNote.CreditAmountIncVAT - (_doGetCreditNote.CreditVATAmount ?? 0);
                decimal         CNAmountExcVATUsd = _doGetCreditNote.CreditAmountIncVATUsd - (_doGetCreditNote.CreditVATAmountUsd ?? 0);

                //Add by Pachara S. 15032017
                string CNAmountExcVATCurrencyType;
                if (_doGetCreditNote.CreditAmountIncVATCurrencyType == null)
                {
                    CNAmountExcVATCurrencyType = _doGetCreditNote.CreditVATAmountCurrencyType;
                }
                else
                {
                    CNAmountExcVATCurrencyType = _doGetCreditNote.CreditAmountIncVATCurrencyType;
                }

                decimal?decBalanceDeposit             = 0;
                decimal?decBalanceDepositUsd          = 0;
                string  decBalanceDepositCurrencyType = CurrencyUtil.C_CURRENCY_LOCAL;
                billingHandler.UpdateBalanceDepositOfBillingBasic(_doBillingBasic.ContractCode, _doBillingBasic.BillingOCC
                                                                  , CNAmountExcVAT, CNAmountExcVATUsd, "1", out decBalanceDeposit, out decBalanceDepositUsd, out decBalanceDepositCurrencyType); // add by Jirawat Jannet @2016-10-05 ยังไม่ถูก แก้ด้วย

                if (decBalanceDeposit < 0)                                                                                                                                                       // Incase of null is not happen
                {
                    return(false);
                }
                else
                {
                    bool blnSuccess = billingHandler.InsertDepositFeeCancelRefund(_doBillingBasic.ContractCode, _doBillingBasic.BillingOCC, _doGetCreditNote.CreditNoteNo, CNAmountExcVAT, CNAmountExcVATUsd, CNAmountExcVATCurrencyType);
                    return(blnSuccess);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }