$mgr->editor->update_acq_lineitem_detail($lid) or return 0;
my $query = { "select" => {
- "acqlid" => [
- "lineitem", {
- "column" => "lineitem",
- "transform" => "count",
- "alias" => "lineitem_count",
- "aggregate" => "true"
- }]
- },
- "from" => { "jub" => "acqlid" },
- "where" => [{
- "+acqlid" => { "lineitem" => $lid->lineitem->id, "cancel_reason" => null }
- },
- {"purchase_order" => $lid->lineitem->purchase_order}
- ]};
+ "acqlid" => [
+ "lineitem", {
+ "column" => "lineitem",
+ "transform" => "count",
+ "alias" => "lineitem_count",
+ "aggregate" => "true"
+ }]
+ },
+ "from" => {
+ "jub" => {
+ "acqlid" => {
+ "join" => { "acqcr" => {} }
+ }
+ }
+ },
+ "where" => [{
+ "+acqlid" => {
+ "lineitem" => $lid->lineitem->id,
+ "cancel_reason" => null
+ }
+ }, {
+ "purchase_order" => $lid->lineitem->purchase_order
+ }, {
+ "-or" => [{
+ "+acqlid" => {
+ "lineitem" => $lid->lineitem->id,
+ "cancel_reason" => { "!=" => null }
+ }
+ }, {
+ "+acqcr" => "keep_debits"
+ }, {
+ "purchase_order" => $lid->lineitem->purchase_order
+ }]
+ }
+ ]};
+
my $lineitem_query = $e->json_query($query);
if ($lineitem_query->lineitem_count == 0) {