using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
using MercatorApi;
using MercatorController;
using System.Windows.Forms;
using MercatorExtensions;
using MercatorDatabase;
// <CompileWithRoslyn />
namespace MercatorUi.MovableControls.ButtonsCodes
{
public static class Script
{
public static void Exec(MercatorUi.MovableControls.MovableButton clickedButton)
{
Forms.Billing.BillingForm billingForm = (Forms.Billing.BillingForm)clickedButton.Form;
MercatorPayTerm.PayTermMollie payTermMollie = Globals.PayTerms.OfType<MercatorPayTerm.PayTermMollie>().FirstOrDefault();
if (payTermMollie == null)
{
Dialogs.Stop("Optie MOLLIE niet aanwezig!");
return;
}
string transactionId = xFunctions.xMollie(billingForm.BillingEngine.PIEDS, "id", 1);
if (transactionId == "")
{
Dialogs.Stop("De eerste betalingswijze is niet Mollie!");
return;
}
double d = Dialogs.AskDouble("Te retourneren bedrag?", 0, "### ##0.00");
if (d == double.MinValue)
return;
var r = payTermMollie.Refund(transactionId, d, billingForm.BillingEngine.Journal + "_" + billingForm.BillingEngine.Piece, out string error);
if (error != null)
Dialogs.Stop(error);
else
Dialogs.Stop("Status = " + r.status.ToString());
}
}
}