+
+# If a 'custom' discount is applied to existing cust_pkg,
+# also add that option to the selectbox
+my $pkgnum = $cgi ? $cgi->param('pkgnum') : undef;
+if ($pkgnum) {
+
+ # Does pkgnum have a custom discount?
+ my $cust_pkg_discount = qsearchs(cust_pkg_discount => {
+ disabled => '',
+ pkgnum => $pkgnum,
+ });
+
+ if ($cust_pkg_discount) {
+ my $discount = qsearchs(discount => {
+ discountnum => $cust_pkg_discount->discountnum,
+ disabled => 'Y',
+ });
+ if ($discount) {
+ my $descr = $opt{carry_value} eq $discount->discountnum
+ ? $discount->description.' [Continue existing discount]'
+ : $discount->description;
+ push @$post_options, $discount->discountnum, $descr;
+ }
+ }
+}
+