periodenddate() and create_salesinvoice() plpgsql function for salesinvoice generation