Hello,
the requirement is that Voucher format on Vendor invoice journal should be according whether the line (LedgerJournalTrans) is a Debit or Credit.
For this, we have created new /Continious/ number sequence myCred for Credits and myDeb for debit lines.
myDeb is added to the Journal Names parameters as a /Voucher series/ field value and we have also added new field on Journal Names where we select the myCred num seq.
So.. now, when we create journal and go to Lines, journal lines is created automatically with the voucher based on myDeb. Let's say the value is myDeb-001. If we delete the line and create again the voucher number is still the same myDeb-001, which is correct.
Our desire is that, if we type a value in Credit field, Voucher number must be changed from myDeb to myCred.
For this I have created extension class of LedgerJournalTrans table and with CoC doing the below logic in modifiedField method.
public void modifiedField(FieldId _fieldId) { next modifiedField(_fieldId); LedgerJournalName journalName = LedgerJournalName::find(this.ledgerJournalTable().JournalName); switch (_fieldId) { case fieldNum(LedgerJournalTrans, AmountCurCredit): if (this.AmountCurCredit) { ttsbegin; this.Voucher = NumberSeq::newGetVoucherFromCode(NumberSequenceTable::find( journalName.XXXNumberSequenceTableRefId).NumberSequence).voucher(); ttscommit; } break; case fieldNum(LedgerJournalTrans, AmountCurDebit): if (this.AmountCurDebit) { ttsbegin; this.Voucher = NumberSeq::newGetVoucherFromCode(NumberSequenceTable::find( journalName.NumberSequenceTable).NumberSequence).voucher(); ttscommit; } break; } }
This is kinda working, but not really as desired, because it will generate new voucher number after each modification of value.
Goal is to get previously generated voucher number.
For example, if I change the Credit value to 1 and new Voucher number is generated as myCred-001 and then if I change Credit again it must not generate new Voucher (With the code above it will generate new myCred-002). Or if after I already changed the Credit value and then typed something in Debit and then again in Credit, it should not give me a new voucher and rather assign previously created number again.
I hope the goal is understandable :)
How can I achieve it?
Thanks.