final class CustVendCreditInvoicing_Ok_Extension
{
public void clicked()
{
Common callerTable1;
CustInvoiceTable _custInvoiceTableOld, custInvoiceNew;
CustInvoiceLine _custInvoiceLineOld, _custLineNew;
FormRun formRun;
callerTable1 = element.args().record();
formRun = element.args().caller();
FormStringControl _cntrStr = this.formRun().design().controlName(/CustVendCorrectedInvoiceId/);
{
custInvoiceNew = callerTable1;
}
ttsbegin;
select _custInvoiceTableOld where _custInvoiceTableOld.InvoiceId == invoiceid;
custInvoiceNew.ReleaseDate = _custInvoiceTableOld.ReleaseDate;
custInvoiceNew.InclTax = _custInvoiceTableOld.InclTax;
custInvoiceNew.WorkerSalesTaker = _custInvoiceTableOld.WorkerSalesTaker;
custInvoiceNew.CustomerRef = _custInvoiceTableOld.CustomerRef;
custInvoiceNew.ContactPersonId = _custInvoiceTableOld.ContactPersonId;
custInvoiceNew.Payment = _custInvoiceTableOld.Payment;
custInvoiceNew.PaymMode = _custInvoiceTableOld.PaymMode;
custInvoiceNew.CustBankAccountId = _custInvoiceTableOld.CustBankAccountId;
custInvoiceNew.PaymentSched = _custInvoiceTableOld.PaymentSched;
custInvoiceNew.CashDiscCode = _custInvoiceTableOld.CashDiscCode;
custInvoiceNew.DirectDebitMandate = _custInvoiceTableOld.DirectDebitMandate;
custInvoiceNew.DefaultDimension = _custInvoiceTableOld.DefaultDimension;
custInvoiceNew.update();
{
_custLineNew.initValue();
_custLineNew.ParentRecId = custInvoiceNew.RecId;
_custLineNew.Description =_custInvoiceLineOld.Description;
_custLineNew.LedgerDimension = _custInvoiceLineOld.LedgerDimension;
_custLineNew.TaxGroup = _custInvoiceLineOld.TaxGroup;
_custLineNew.TaxItemGroup = _custInvoiceLineOld.TaxItemGroup;
_custLineNew.TaxWithholdGroup = _custInvoiceLineOld.TaxWithholdGroup;
_custLineNew.TaxWithholdItemGroupHeading_TH =_custInvoiceLineOld.TaxWithholdItemGroupHeading_TH;
_custLineNew.Quantity = - _custInvoiceLineOld.Quantity;//negataive value
_custLineNew.UnitPrice = _custInvoiceLineOld.UnitPrice;
_custLineNew.AmountCur = - _custInvoiceLineOld.AmountCur;//negative value
_custLineNew.DefaultDimension = _custInvoiceLineOld.DefaultDimension;
_custLineNew.insert();
}
ttscommit;
if(formrun)
{
formrun.doResearch(); // Force all parent form data sets to refresh
}