mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
fix: added erp item visibility
This commit is contained in:
@@ -40,6 +40,9 @@ export class ERPNextSyncSettings extends Doc {
|
||||
batchSyncType: () => {
|
||||
return !this.fyo.singles.InventorySettings?.enableBatches;
|
||||
},
|
||||
// syncDataFromServer: () => {
|
||||
// return !this.deviceID;
|
||||
// },
|
||||
};
|
||||
|
||||
async change(ch: ChangeArg) {
|
||||
|
||||
@@ -19,8 +19,13 @@ import { Item } from '../Item/Item';
|
||||
import { StockTransfer } from 'models/inventory/StockTransfer';
|
||||
import { isPesa } from 'fyo/utils';
|
||||
import { PricingRule } from '../PricingRule/PricingRule';
|
||||
import { getItemRateFromPriceList, getPricingRule } from 'models/helpers';
|
||||
import {
|
||||
getItemRateFromPriceList,
|
||||
getPricingRule,
|
||||
getItemVisibility,
|
||||
} from 'models/helpers';
|
||||
import { SalesInvoice } from '../SalesInvoice/SalesInvoice';
|
||||
import { QueryFilter } from 'utils/db/types';
|
||||
|
||||
export abstract class InvoiceItem extends Doc {
|
||||
item?: string;
|
||||
@@ -646,13 +651,28 @@ export abstract class InvoiceItem extends Doc {
|
||||
};
|
||||
|
||||
static filters: FiltersMap = {
|
||||
item: (doc: Doc) => {
|
||||
item: async (doc: Doc): Promise<QueryFilter> => {
|
||||
let itemNotFor = 'Sales';
|
||||
if (doc.isSales) {
|
||||
itemNotFor = 'Purchases';
|
||||
}
|
||||
|
||||
return { for: ['not in', [itemNotFor]] };
|
||||
const filters: QueryFilter = {
|
||||
for: ['not in', [itemNotFor]],
|
||||
};
|
||||
|
||||
const enableERPNextSync =
|
||||
doc.fyo.singles.AccountingSettings?.enableERPNextSync;
|
||||
|
||||
if (enableERPNextSync) {
|
||||
const itemVisibility = await getItemVisibility(doc.fyo);
|
||||
|
||||
if (itemVisibility === 'ERP Sync Items') {
|
||||
filters.datafromErp = true;
|
||||
}
|
||||
}
|
||||
|
||||
return filters;
|
||||
},
|
||||
batch: async (doc: Doc) => {
|
||||
const batches = await doc.fyo.db.getAll(ModelNameEnum.Batch, {
|
||||
|
||||
@@ -30,6 +30,7 @@ export class Item extends Doc {
|
||||
hsnCode?: number;
|
||||
hasSerialNumber?: boolean;
|
||||
serialNumberSeries?: string;
|
||||
datafromErp?: boolean;
|
||||
uomConversions: UOMConversionItem[] = [];
|
||||
|
||||
formulas: FormulaMap = {
|
||||
@@ -237,5 +238,6 @@ export class Item extends Doc {
|
||||
trackItem: () => this.inserted,
|
||||
hasBatch: () => this.inserted,
|
||||
hasSerialNumber: () => this.inserted,
|
||||
datafromErp: () => true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -116,6 +116,12 @@ export async function getItemQtyMap(doc: SalesInvoice): Promise<ItemQtyMap> {
|
||||
|
||||
export async function getItemVisibility(fyo: Fyo): Promise<ItemVisibility> {
|
||||
const posProfileName = fyo.singles.POSSettings?.posProfile as string;
|
||||
const enableERPNextSync = fyo.singles.AccountingSettings?.enableERPNextSync;
|
||||
|
||||
if (enableERPNextSync) {
|
||||
// When ERP sync is enabled, use itemVisibilityERP from POSSettings
|
||||
return fyo.singles.POSSettings?.itemVisibilityERP as ItemVisibility;
|
||||
}
|
||||
|
||||
if (posProfileName) {
|
||||
const posProfile = await fyo.doc.getDoc(
|
||||
|
||||
@@ -16,6 +16,7 @@ export class POSSettings extends Doc {
|
||||
itemWeightDigits?: number;
|
||||
defaultAccount?: string;
|
||||
itemVisibility?: string;
|
||||
itemVisibilityERP?: 'ERP Sync Items';
|
||||
posUI?: 'Classic' | 'Modern';
|
||||
canChangeRate?: boolean;
|
||||
canEditDiscount?: boolean;
|
||||
@@ -46,6 +47,8 @@ export class POSSettings extends Doc {
|
||||
!this.fyo.singles.InventorySettings?.enableBarcodes ||
|
||||
!this.weightEnabledBarcode,
|
||||
itemVisibility: () =>
|
||||
!this.fyo.singles.AccountingSettings?.enablePointOfSaleWithOutInventory,
|
||||
!!this.fyo.singles.AccountingSettings?.enableERPNextSync,
|
||||
itemVisibilityERP: () =>
|
||||
!this.fyo.singles.AccountingSettings?.enableERPNextSync,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user