Add a new UserGroupRight to control access to open/close months.
[capital-apms-progress.git] / trigger / wrcrdtor.p
blob3041788eae724815cb3cd685aa2fefd2492ee0c4
1 TRIGGER PROCEDURE FOR WRITE OF Creditor OLD BUFFER OldCr.
3 IF OldCr.CreditorCode <> 0 AND OldCr.CreditorCode <> Creditor.CreditorCode THEN DO:
4 MESSAGE "Creditor codes cannot be re-assigned."
5 VIEW-AS ALERT-BOX ERROR TITLE "Error Writing Creditor".
6 RETURN ERROR.
7 END.
8 IF OldCr.Active AND NOT Creditor.Active THEN DO:
9 IF CAN-FIND( FIRST Voucher OF Creditor WHERE Voucher.VoucherStatus = "U"
10 OR Voucher.VoucherStatus = "A")
11 THEN DO:
12 MESSAGE "Cannot de-activate a creditor with unpaid vouchers."
13 VIEW-AS ALERT-BOX ERROR TITLE "Error Writing Creditor".
14 RETURN ERROR.
15 END.
16 FIND Office WHERE ThisOffice NO-LOCK.
17 FIND OfficeControlAccount OF Office WHERE OfficeControlAccount.Name = "CREDITORS" NO-LOCK.
18 IF CAN-FIND( AccountSummary WHERE AccountSummary.EntityType = "C"
19 AND AccountSummary.EntityCode = Creditor.CreditorCode
20 AND AccountSummary.AccountCode = OfficeControlAccount.AccountCode)
21 THEN DO:
22 MESSAGE "Cannot de-activate a creditor with non-zero balance."
23 VIEW-AS ALERT-BOX ERROR TITLE "Error Writing Creditor".
24 RETURN ERROR.
25 END.
26 END.