Merge pull request #1338 from Gadha2311/add-uom-batch-filter-stock-movement

fix : uom-batch filter
This commit is contained in:
Able k Saju
2025-09-12 14:38:12 +05:30
committed by GitHub
5 changed files with 55 additions and 7 deletions
+10 -1
View File
@@ -659,8 +659,17 @@ export abstract class InvoiceItem extends Doc {
);
const conversionUoms = conversionItems.map((i) => i.uom) as string[];
const baseUnit = await doc.fyo.getValue(
ModelNameEnum.Item,
doc.item as string,
'unit'
);
const validUoms = [...conversionUoms, baseUnit].filter(
Boolean
) as string[];
return {
name: ['in', conversionUoms],
name: ['in', validUoms],
};
},
};
+34
View File
@@ -15,6 +15,7 @@ import { safeParseFloat } from 'utils/index';
import { StockMovement } from './StockMovement';
import { TransferItem } from './TransferItem';
import { MovementTypeEnum } from './types';
import { Doc } from 'fyo/model/doc';
export class StockMovementItem extends TransferItem {
name?: string;
@@ -54,6 +55,39 @@ export class StockMovementItem extends TransferItem {
static filters: FiltersMap = {
item: () => ({ trackItem: true }),
transferUnit: async (doc: Doc) => {
const conversionItems = await doc.fyo.db.getAll(
ModelNameEnum.UOMConversionItem,
{
fields: ['uom'],
filters: { parent: doc.item as string },
}
);
const conversionUoms = conversionItems.map((i) => i.uom) as string[];
const baseUnit = await doc.fyo.getValue(
ModelNameEnum.Item,
doc.item as string,
'unit'
);
const validUoms = [...conversionUoms, baseUnit].filter(
Boolean
) as string[];
return {
name: ['in', validUoms],
};
},
batch: async (doc: Doc) => {
const batches = await doc.fyo.db.getAll(ModelNameEnum.Batch, {
fields: ['name'],
filters: { item: doc.item as string },
});
const batchName = batches.map((b) => b.name) as string[];
return {
name: ['in', batchName],
};
},
};
async validate() {
@@ -486,7 +486,6 @@ export default defineComponent({
this.row.set('setItemDiscountAmount', false);
this.row.set('itemDiscountPercent', 0);
}
this.row.set('rate', this.fyo.pesa(0));
if (hasManualDiscount) {
this.row.set('setItemDiscountAmount', true);
+3
View File
@@ -102,6 +102,7 @@
:border="true"
:value="sinvDoc?.party"
:df="sinvDoc?.fieldMap.party"
:show-clear-button="true"
@change="(value:string) => $emit('setCustomer',value)"
/>
@@ -309,6 +310,7 @@
}"
:border="true"
:value="itemSearchTerm"
:show-clear-button="true"
@keyup.enter="(item) =>
emitEvent('handleItemSearch', item.target.value as string, true)
"
@@ -324,6 +326,7 @@
target: 'ItemGroup',
}"
:border="true"
:show-clear-button="true"
:value="selectedItemGroup"
@change="(group: string) => emitEvent('setItemGroup',group)"
/>
+8 -5
View File
@@ -304,13 +304,16 @@
>
<svg
xmlns="http://www.w3.org/2000/svg"
height="23px"
viewBox="0 -960 960 960"
width="24px"
fill="#000"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="1.5"
class="w-6 h-6 text-black"
>
<path
d="M180.31-164q-27.01 0-45.66-18.65Q116-201.3 116-228.31v-503.38q0-27.01 18.65-45.66Q153.3-796 180.31-796h599.38q27.01 0 45.66 18.65Q844-758.7 844-731.69v503.38q0 27.01-18.65 45.66Q806.7-164 779.69-164H180.31Zm0-52h599.38q4.62 0 8.46-3.85 3.85-3.84 3.85-8.46v-503.38q0-4.62-3.85-8.46-3.84-3.85-8.46-3.85H180.31q-4.62 0-8.46 3.85-3.85 3.84-3.85 8.46v503.38q0 4.62 3.85 8.46 3.84 3.85 8.46 3.85ZM221-297h172v-52H221v52Zm361-77.23L737.77-530 701-566.77l-119 119-51-51L494.23-462 582-374.23ZM221-454h172v-52H221v52Zm0-156h172v-52H221v52Zm-53 394v-528 528Z"
stroke-linecap="round"
stroke-linejoin="round"
d="M16.862 4.487l1.686 1.686a1.25 1.25 0 010 1.768L10.06 16.43a.75.75 0 01-.49.219l-2.563.128a.75.75 0 01-.791-.79l.128-2.564a.75.75 0 01.218-.49l8.488-8.489a1.25 1.25 0 011.768 0zM19.5 13.25v4.75a2 2 0 01-2 2h-11a2 2 0 01-2-2v-11a2 2 0 012-2h4.75"
/>
</svg>
</div>