Hi ,
it’s still not clear how to make these kind of test. I got another similar case.
It do not work properly but do not make errors.
Now it makes only update also if I insert a new record (???)
I also tryed to invert Update and Insert (as below) sections but it do not works the same.
$sql_check_payment = "SELECT paymentID FROM payments WHERE InvoiceID = [glo_invoiceNr] AND invoiceDate = '[glo_invoiceDate]' AND vendorID = [glo_vendorID]";
sc_select(check_payment, $sql_check_payment);
$check_payment = {check_payment};
echo "VAR ". {check_payment} . " $ ". $check_payment ;
if (false == {check_payment})
{
// Error while accessing database
}
elseif ({check_payment}->EOF)
{ echo “SON UPDATE”;
$sql_vendor_name = “SELECT CompanyName FROM suppliers WHERE SupplierID = [glo_vendorID]”;
sc_lookup(vendor_name, $sql_vendor_name);
$vendor_name = {vendor_name[0][0]};
$payment_text = {lang_payments_nr_invoice} . ’ ’ . [glo_invoiceNr] . ’ ’ . {lang_payments_date_invoice} . ’ ’ . [glo_invoiceDate_eu] . ’ ’ . $vendor_name;
$sql_update_payment = "UPDATE payments SET
payment_cbID = 1,
payment_timingID = 1,
payment_casusal_ID = 1,
payment_ledgerID = 2,
paymentDate = '[glo_invoiceDate]',
paydescr = '[glo_descri]',
amount_in = [glo_Invoice_Vat_incl],
currency = [glo_currencyID],
exchange_rate = [glo_exchange_rate],
note = '$payment_text',
cashin_type = 17,
service_typeID = [glo_service_typeID],
projectID = [glo_projectID],
invoiceID = [glo_invoiceNr],
invoiceDate = '[glo_invoiceDate]',
vendorID = [glo_vendorID],
amount_vat_escl = [glo_Invoice_Vat_escl],
amount_vat_incl = [glo_Invoice_Vat_incl],
amount_vat= [glo_tot_vat]
WHERE InvoiceID = [glo_invoiceNr] AND invoiceDate = '[glo_invoiceDate]' AND vendorID = [glo_vendorID] ";
sc_exec_sql($sql_update_payment);
// Attention payment_casusal_ID is 1 - cashin_type = 17 ??
[yes_no]=0;
}
else
{ echo “SON INSERT”;
$sql_vendor_name = “SELECT CompanyName FROM suppliers WHERE SupplierID = [glo_vendorID]”;
sc_lookup(vendor_name, $sql_vendor_name);
$vendor_name = {vendor_name[0][0]};
$payment_text = {lang_payments_nr_invoice} . ’ ’ . [glo_invoiceNr] . ’ ’ . {lang_payments_date_invoice} . ’ ’ . [glo_invoiceDate_eu] . ’ ’ . $vendor_name;
$sql_inser_payment = "INSERT INTO payments
( payment_cbID, payment_timingID, payment_casusal_ID, payment_ledgerID, paymentDate, paydescr, amount_in,
currency, exchange_rate, note, cashin_type, service_typeID, projectID, invoiceID, invoiceDate, vendorID,
amount_vat_escl, amount_vat_incl, amount_vat)
VALUES ( 1, 1, 1, 2, '[glo_invoiceDate]', '[glo_descri]' , [glo_Invoice_Vat_escl],
[glo_currencyID], [glo_exchange_rate], '$payment_text', 17, [glo_service_typeID], [glo_projectID], [glo_invoiceNr],
'[glo_invoiceDate]', [glo_vendorID], [glo_Invoice_Vat_escl], [glo_tot_vat], [glo_Invoice_Vat_incl] )";
sc_exec_sql($sql_inser_payment);
// Attention payment_casusal_ID is 1 - cashin_type = 17 ??
[yes_no]=0;
}