コード例 #1
0
ファイル: PaymentsWnd.cs プロジェクト: marioricci/erp-luma
		private void ShowCreditPaymentWindow()
		{
			if (mboIsCreditAllowed)
			{
				CreditPaymentWnd credit = new CreditPaymentWnd();
                credit.TerminalDetails = mclsTerminalDetails;
				credit.SalesTransactionDetails = mclsSalesTransactionDetails;
                credit.CustomerDetails = mclsCustomerDetails;
                credit.AllowedCredit = mdecAllowedCredit;

                decimal decBalance = Convert.ToDecimal(lblBalance.Text);
                decimal decAdditionalCreditCharge = 0;
                if (mclsCustomerDetails.CreditDetails.CreditType == CreditType.Group && mclsTerminalDetails.GroupChargeType.ChargeTypeID != 0)
                {
                    if (mclsTerminalDetails.GroupChargeType.InPercent)
                        decAdditionalCreditCharge = decBalance * (mclsTerminalDetails.GroupChargeType.ChargeAmount / 100);
                    else
                        decAdditionalCreditCharge = decBalance + mclsTerminalDetails.GroupChargeType.ChargeAmount;

                    if ((decBalance + decAdditionalCreditCharge) > mdecAllowedCredit)
                    {
                        if (mclsTerminalDetails.GroupChargeType.InPercent)
                            decAdditionalCreditCharge = mdecAllowedCredit * (mclsTerminalDetails.GroupChargeType.ChargeAmount / 100);
                        else
                            decAdditionalCreditCharge = mdecAllowedCredit + mclsTerminalDetails.GroupChargeType.ChargeAmount;
                    }
                }
                else if (mclsCustomerDetails.CreditDetails.CreditType == CreditType.Individual && mclsTerminalDetails.PersonalChargeType.ChargeTypeID != 0)
                {
                    if (mclsTerminalDetails.PersonalChargeType.InPercent)
                        decAdditionalCreditCharge = decBalance * (mclsTerminalDetails.PersonalChargeType.ChargeAmount / 100);
                    else
                        decAdditionalCreditCharge = decBalance + mclsTerminalDetails.PersonalChargeType.ChargeAmount;

                    if ((decBalance + decAdditionalCreditCharge) > mdecAllowedCredit)
                    {
                        if (mclsTerminalDetails.PersonalChargeType.InPercent)
                            decAdditionalCreditCharge = mdecAllowedCredit * (mclsTerminalDetails.PersonalChargeType.ChargeAmount / 100);
                        else
                            decAdditionalCreditCharge = mdecAllowedCredit + mclsTerminalDetails.PersonalChargeType.ChargeAmount;
                    }
                }

                credit.BalanceAmount = decBalance + Convert.ToDecimal(decAdditionalCreditCharge.ToString("#,##0.#0"));
                credit.IsRefund = mboIsRefund;
				credit.ShowDialog(this);
				DialogResult result = credit.Result;
				Data.CreditPaymentDetails creditDetails = credit.Details;
				credit.Close();
				credit.Dispose();

				if (result == DialogResult.OK)
				{
                    if (mclsCustomerDetails.CreditDetails.CreditType == CreditType.Group && mclsTerminalDetails.GroupChargeType.ChargeTypeID != 0)
                    {
                        // update transaction with additional charge
                        if (mclsTerminalDetails.GroupChargeType.InPercent)
                            decAdditionalCreditCharge = creditDetails.Amount * (mclsTerminalDetails.GroupChargeType.ChargeAmount / 100);
                        else
                            decAdditionalCreditCharge = creditDetails.Amount + mclsTerminalDetails.GroupChargeType.ChargeAmount;

                        lblCharge.Text = Convert.ToDecimal(Convert.ToDecimal(lblCharge.Text) + decAdditionalCreditCharge).ToString("#,##0.#0");
                        mclsSalesTransactionDetails.CreditChargeAmount = decAdditionalCreditCharge;
                        
                        //Aug 30, 2014 delete need to move this from here to mainwnd
                        Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions();
                        clsSalesTransactions.UpdateCreditChargeAmount(mclsSalesTransactionDetails.TransactionID, mclsSalesTransactionDetails.CreditChargeAmount);
                        clsSalesTransactions.CommitAndDispose();
                    }

                    mdecAllowedCredit -= creditDetails.Amount;
					lblAmountPaid.Text = Convert.ToDecimal(Convert.ToDecimal(lblAmountPaid.Text) + creditDetails.Amount).ToString("#,##0.#0");
					marrCreditPaymentDetails.Add(creditDetails);

                    // Add 
					ComputePayments();
					lblCredit.Tag = Convert.ToDecimal(Convert.ToDecimal(lblCredit.Tag) + creditDetails.Amount - Convert.ToDecimal(lblChange.Text)).ToString("#,##0.#0");

					if (mPaymentType == PaymentTypes.NotYetAssigned)
						mPaymentType = PaymentTypes.Credit;
					else
						mPaymentType = PaymentTypes.Combination;
				}
			}
		}
コード例 #2
0
ファイル: PaymentsWnd.cs プロジェクト: marioricci/erp-luma
		private void ShowCreditPaymentWindow()
		{
			if (mboIsCreditAllowed)
			{
				CreditPaymentWnd credit = new CreditPaymentWnd();
                credit.SalesTransactionDetails = mclsSalesTransactionDetails;
                credit.CustomerDetails = mclsCustomerDetails;
				credit.AllowedCredit = mdecAllowedCredit;
				credit.BalanceAmount = Convert.ToDecimal(lblBalance.Text);
				
				credit.ShowDialog(this);
				DialogResult result = credit.Result;
				Data.CreditPaymentDetails creditDetails = credit.Details;
				credit.Close();
				credit.Dispose();

				if (result == DialogResult.OK)
				{
					lblAmountPaid.Text = Convert.ToDecimal(Convert.ToDecimal(lblAmountPaid.Text) + creditDetails.Amount).ToString("#,##0.#0");
					marrCreditPaymentDetails.Add(creditDetails);

                    // Add 
					ComputePayments();
					lblCredit.Tag = Convert.ToDecimal(Convert.ToDecimal(lblCredit.Tag) + creditDetails.Amount - Convert.ToDecimal(lblChange.Text)).ToString("#,##0.#0");

					if (mPaymentType == PaymentTypes.NotYetAssigned)
						mPaymentType = PaymentTypes.Credit;
					else
						mPaymentType = PaymentTypes.Combination;
				}
				
			}
		}