Ejemplo n.º 1
0
        public GetPaymentCodeResponse GetPaymentByPaymentCode(GetPaymentCodeRequest req)
        {
            var res = new GetPaymentCodeResponse();

            try
            {
                using (var container = new TransactionModelContainer())
                {
                    var payment = container.Payments
                                  .Include("PaymentItems")
                                  .FirstOrDefault(x => x.PaymentCode == req.PaymentCode);

                    res.SetPaymentResponse(payment);

                    res.Succeed();
                }
            }
            catch (Exception ex)
            {
                res.Fail(ex);
                CreateLog(ex);
            }

            return(res);
        }
Ejemplo n.º 2
0
        public static void SetPaymentResponse(this GetPaymentCodeResponse res, Payment payment)
        {
            res.PaymentId                 = payment.Id;
            res.PaymentCode               = payment.PaymentCode;
            res.CreateBy                  = payment.CreatedBy;
            res.CreateDate                = payment.CreatedDate;
            res.UpdateBy                  = payment.UpdatedBy;
            res.UpdateDate                = payment.UpdatedDate;
            res.CustomerIDMPartyID        = payment.CustomerIdmPartyId;
            res.CustomerCode              = null;
            res.CustomerName              = payment.CustomerName;
            res.CustomerAddress           = payment.CustomerAddress;
            res.CustomerAccountNumber     = payment.CustomerRefundAccountNo;
            res.CustomerAccountName       = payment.CustomerRefundAccountName;
            res.CustomerAccountBankId     = payment.CustomerRefundBankId;
            res.CustomerMobilePhoneNumber = payment.CustomerMobilePhoneNo;
            res.Remark                    = payment.Remark;
            res.Ref1                      = payment.Ref1;
            res.Ref2                      = payment.Ref2;
            res.Ref3                      = payment.Ref3;
            res.PaymentStatus             = payment.Status;
            res.RemainingAmount           = payment.RemainingAmount();
            res.GrandTotal                = payment.GrandTotal();
            res.TotalVatAmount            = payment.TotalVat();
            res.TotalWithholdingTaxAmount = payment.TotalWithholdingTax();
            res.TotalBeforeAdjustment     = payment.TotalNoDiscount();
            res.TotalAdjustment           = payment.TotalDiscount();

            var input  = payment.PaymentItems.ToArray();
            var result = new PaymentItemResponse[input.Count()];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new PaymentItemResponse
                {
                    //ServiceCode = input[i].ServiceCode.ToString(),
                    //ServiceName = input[i].ServiceName,
                    ItemDescription       = input[i].ItemDescription,
                    Quantity              = input[i].Qty,
                    UnitAmount            = input[i].UnitAmount,
                    VatPercent            = input[i].VatPercent,
                    WithholdingTaxPercent = input[i].WithholdingTexPercent,
                    WithholdingTaxAmount  = input[i].WithHoldingTaxAmount(),
                    IsRevenue             = input[i].ServiceIsRevenue,
                    IsLegalPerson         = input[i].IsLegalPerson,
                    VatAmount             = input[i].VATAmount(),
                    Remark        = input[i].Remark,
                    SubTotal      = input[i].SubTotal(),
                    PaymentItemId = input[i].Id,
                    GroupRef1     = input[i].GroupRef1,
                    GroupRef2     = input[i].GroupRef2,
                    GroupRef3     = input[i].GroupRef3,
                    NetTotal      = input[i].NetTotal()
                };
            }
        }