كيف يمكن منع حفظ فاتورة مبيعات إذا كانت ستؤدي إلى تخطي العميل لحد الائتمان المعرف بملفه؟

Viewed 0

كيف يمكن منع حفظ فاتورة مبيعات إذا كانت ستؤدي إلى تخطي العميل لحد الائتمان المعرف بملفه؟


Originally posted at https://answers.namasoft.com/question/338/ on 2018-09-13.

1 Answers

يمكن ذلك من خلال آلية التحقق بناء على معايير، حيث تقوم بوضع الاستعلام التالي في استعلام "عندما" (When)، ويمكن تعديله إذا تطلب الأمر:

select case when {customer.limitValue} > 0 and
(COALESCE(SUM(l.debitLocalAmount-l.creditLocalAmount),0)+{money.remaining}>{customer.limitValue}) 
then 1 else 0 end      	from Customer c  
left join  ledgertransline l on l.subsidiaryId = c.id and c.mainAccount_id = l.account_id and l.originId <> {id} 
where c.id = {customer.id}

وإذا أردت أن تجعل النظام يتحقق من رصيد الحساب الرئيسي وحساب 1 معًا مثلًا، فاستعمل الاستعلام التالي:

select case when {customer.limitValue} > 0 and
(COALESCE(SUM(l.debitLocalAmount-l.creditLocalAmount),0)+{money.remaining}>{customer.limitValue}) 
then 1 else 0 end      	from Customer c  
left join  ledgertransline l on l.subsidiaryId = c.id 
and l.account_id in (coalesce(c.mainAccount_id,0x1),coalesce(c.account1_id,0x1)) and l.originId <> 
{id} where c.id = {customer.id}

Originally posted at https://answers.namasoft.com/question/338/ on 2018-09-13.

Related