public CalculatePaymentResponse CalculatePayment(CalculatePaymentRequest req)
        {
            var res = new CalculatePaymentResponse();
            try
            {
                using (var container = new TransactionModelContainer())
                {
                    var payment = new Payment("SystemService", -1,
                        req.CustomerName, "CARPASS", req.PaymentItems.CreatePaymentItems());

                    res.CustomerName = payment.CustomerName;
                    res.GrandTotal = payment.GrandTotal();
                    res.RemainingAmount = payment.RemainingAmount();
                    res.TotalVatAmount = payment.TotalVat();
                    res.TotalWithholdingTaxAmount = payment.TotalWithholdingTax();
                    res.TotalBeforeAdjustment = payment.TotalNoDiscount();
                    res.TotalAdjustment = payment.TotalDiscount();
                    res.PaymentItems = payment.PaymentItems.CreateCalculatePaymentItems();

                    res.Succeed();
                }
            }
            catch (Exception ex)
            {
                res.Fail(ex);
                CreateLog(ex);
            }
            return res;
        }
        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()
                };
            }
        }
 public static void SetPaymentResponse(this CreatePaymentResponse 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();
     res.PaymentItems = payment.PaymentItems.CreatePaymentResponseItem();
 }
        public static ReportHeader CreateViewPayment(Payment input, TransactionModelContainer container)
        {
            return new ReportHeader
            {
                No = string.Format("GAL-{0}-{1}", DateTime.Now.ToString("yyyy-MM"), input.Id),
                date = DateTime.Now.ToString(ConfigurationManager.Format.Date_Format),
                PaymentId = input.Id.ToString("0000000000"),
                PaymentCode = input.PaymentCode,
                PaymentStatus = input.Status,

                CustomerIdmId = input.CustomerIdmPartyId.ToString("0000000000"),
                CustomerName = input.CustomerName,
                CustomerAddress = input.CustomerAddress,
                CustomerMobilePhoneNo = input.CustomerMobilePhoneNo,
                CustomerAccountNo = input.CustomerRefundAccountNo,
                CustomerAccountName = input.CustomerRefundAccountName,

                Ref1 = input.Ref1,
                Ref2 = input.Ref2,
                Ref3 = input.Ref3,
                Remark = input.Remark,

                GrandTotal_SubTotal = input.TotalUnitAmount().ToString(ConfigurationManager.Format.Decimal_Format),
                GrandTotal_WH_Amount = input.TotalWithholdingTax().ToString(ConfigurationManager.Format.Decimal_Format),
                GrandTotal_VAT_Amount = input.TotalVat().ToString(ConfigurationManager.Format.Decimal_Format),
                GrandTotal_Net_Total = input.GrandTotal().ToString(ConfigurationManager.Format.Decimal_Format),

                Summary_Total = input.TotalNoDiscount().ToString(ConfigurationManager.Format.Decimal_Format),
                Summary_Adjustment = input.TotalDiscount().ToString(ConfigurationManager.Format.Decimal_Format),

                RemainingAmount = input.RemainingAmount().ToString(ConfigurationManager.Format.Decimal_Format),
            };
        }
Beispiel #5
0
        public void RefreshWhenDomainModelChanged(Payment payment)
        {
            string NumberFormat = ConfigurationManager.Format.Decimal_Format;

            PaymentId = payment.Id.ToString("0000000000");
            PaymentCode = payment.PaymentCode;
            PaymentStatus = payment.Status;

            CustomerIdmId = payment.CustomerIdmPartyId.ToString("0000000000");
            CustomerName = payment.CustomerName;
            CustomerAddress = payment.CustomerAddress;
            CustomerMobilePhoneNo = payment.CustomerMobilePhoneNo;
            CustomerAccountNo = payment.CustomerRefundAccountNo;
            CustomerAccountName = payment.CustomerRefundAccountName;

            Ref1 = payment.Ref1;
            Ref2 = payment.Ref2;
            Ref3 = payment.Ref3;
            Remark = payment.Remark;

            GrandTotal_SubTotal = payment.TotalUnitAmount().ToString(NumberFormat);
            GrandTotal_WH_Amount = payment.TotalWithholdingTax().ToString(NumberFormat);
            GrandTotal_VAT_Amount = payment.TotalVat().ToString(NumberFormat);
            GrandTotal_Net_Total = payment.GrandTotal().ToString(NumberFormat);

            Summary_Total = payment.TotalNoDiscount().ToString(NumberFormat);
            Summary_Adjustment = payment.TotalDiscount().ToString(NumberFormat);

            Installment_Total = payment.InstallmentAmount().ToString(NumberFormat);
            RemainingAmount = payment.RemainingAmount().ToString(NumberFormat);

            // PaymentItems
            Items = payment.PaymentItems.CreateViewPaymentItems();
            // Installments
            InstallmentItems = payment.Installments.CreateInstallment();
        }