2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 06:44:06 +00:00

fix: allow location to be common

This commit is contained in:
18alantom 2022-11-01 18:51:21 +05:30
parent d394db817e
commit 6805ebcaba
5 changed files with 17 additions and 13 deletions

View File

@ -484,6 +484,14 @@ export default class DatabaseCore extends DatabaseBase {
if (operator === '=') { if (operator === '=') {
builder.where(field, comparisonValue); builder.where(field, comparisonValue);
} else if (
operator === 'in' &&
(comparisonValue as (string | null)[]).includes(null)
) {
const nonNulls = (comparisonValue as (string | null)[]).filter(
Boolean
) as string[];
builder.where(field, operator, nonNulls).orWhere(field, null);
} else { } else {
builder.where(field, operator as string, comparisonValue as string); builder.where(field, operator as string, comparisonValue as string);
} }

View File

@ -13,10 +13,10 @@ import { StockMovement } from './StockMovement';
const locationFilter: FilterFunction = (doc: Doc) => { const locationFilter: FilterFunction = (doc: Doc) => {
const item = doc.item; const item = doc.item;
if (!doc.item) { if (!doc.item) {
return {}; return { item: null };
} }
return { item } as QueryFilter; return { item: ['in', [null, item]] } as QueryFilter;
}; };
export class StockMovementItem extends Doc { export class StockMovementItem extends Doc {
@ -38,7 +38,6 @@ export class StockMovementItem extends Doc {
formulas: FormulaMap = { formulas: FormulaMap = {
rate: { rate: {
formula: async () => { formula: async () => {
console.log('called', this.item);
if (!this.item) { if (!this.item) {
return this.rate; return this.rate;
} }

View File

@ -1,9 +1,10 @@
import { Money } from 'pesa'; import { Money } from 'pesa';
export type MovementType = export enum MovementType {
| 'MaterialIssue' 'MaterialIssue' = 'MaterialIssue',
| 'MaterialReceipt' 'MaterialReceipt' = 'MaterialReceipt',
| 'MaterialTransfer'; 'MaterialTransfer' = 'MaterialTransfer',
}
export interface SMDetails { export interface SMDetails {
date: Date; date: Date;
@ -20,5 +21,3 @@ export interface SMTransferDetails {
} }
export interface SMIDetails extends SMDetails, SMTransferDetails {} export interface SMIDetails extends SMDetails, SMTransferDetails {}

View File

@ -15,9 +15,7 @@
"fieldname": "item", "fieldname": "item",
"label": "Item", "label": "Item",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Item", "target": "Item"
"required": true,
"readOnly": true
} }
], ],
"quickEditFields": ["item"] "quickEditFields": ["item"]

View File

@ -64,7 +64,7 @@ export interface GetAllOptions {
export type QueryFilter = Record< export type QueryFilter = Record<
string, string,
boolean | string | (string | number | (string | number)[])[] boolean | string | null | (string | number | (string | number | null)[])[]
>; >;
/** /**