mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
incr: add stock indicator text
- move inventory reports to Inventory
This commit is contained in:
parent
bea9d86b91
commit
a879f04ad5
@ -24,6 +24,14 @@ export function format(
|
||||
|
||||
const field: Field = getField(df);
|
||||
|
||||
if (field.fieldtype === FieldTypeEnum.Float) {
|
||||
return Number(value).toFixed(fyo.singles.SystemSettings?.displayPrecision);
|
||||
}
|
||||
|
||||
if (field.fieldtype === FieldTypeEnum.Int) {
|
||||
return Math.trunc(Number(value)).toString();
|
||||
}
|
||||
|
||||
if (field.fieldtype === FieldTypeEnum.Currency) {
|
||||
return formatCurrency(value, field, doc, fyo);
|
||||
}
|
||||
@ -60,7 +68,9 @@ function toDatetime(value: DocValue) {
|
||||
function formatDatetime(value: DocValue, fyo: Fyo): string {
|
||||
const dateFormat =
|
||||
(fyo.singles.SystemSettings?.dateFormat as string) ?? DEFAULT_DATE_FORMAT;
|
||||
const formattedDatetime = toDatetime(value).toFormat(`${dateFormat} HH:mm:ss`);
|
||||
const formattedDatetime = toDatetime(value).toFormat(
|
||||
`${dateFormat} HH:mm:ss`
|
||||
);
|
||||
|
||||
if (value === 'Invalid DateTime') {
|
||||
return '';
|
||||
|
@ -7,14 +7,14 @@ import {
|
||||
DefaultMap,
|
||||
FiltersMap,
|
||||
FormulaMap,
|
||||
HiddenMap
|
||||
HiddenMap,
|
||||
} from 'fyo/model/types';
|
||||
import { DEFAULT_CURRENCY } from 'fyo/utils/consts';
|
||||
import { ValidationError } from 'fyo/utils/errors';
|
||||
import {
|
||||
getExchangeRate,
|
||||
getInvoiceActions,
|
||||
getNumberSeries
|
||||
getNumberSeries,
|
||||
} from 'models/helpers';
|
||||
import { InventorySettings } from 'models/inventory/InventorySettings';
|
||||
import { StockTransfer } from 'models/inventory/StockTransfer';
|
||||
@ -22,10 +22,7 @@ import { Transactional } from 'models/Transactional/Transactional';
|
||||
import { ModelNameEnum } from 'models/types';
|
||||
import { Money } from 'pesa';
|
||||
import { FieldTypeEnum, Schema } from 'schemas/types';
|
||||
import {
|
||||
getIsNullOrUndef, joinMapLists,
|
||||
safeParseFloat
|
||||
} from 'utils';
|
||||
import { getIsNullOrUndef, joinMapLists, safeParseFloat } from 'utils';
|
||||
import { Defaults } from '../Defaults/Defaults';
|
||||
import { InvoiceItem } from '../InvoiceItem/InvoiceItem';
|
||||
import { Item } from '../Item/Item';
|
||||
@ -396,6 +393,13 @@ export abstract class Invoice extends Transactional {
|
||||
);
|
||||
}
|
||||
|
||||
getTotalQuantity() {
|
||||
return (this.items ?? []).reduce(
|
||||
(acc, item) => acc + (item.quantity ?? 0),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
getStockNotTransferred() {
|
||||
return (this.items ?? []).reduce(
|
||||
(acc, item) => (item.stockNotTransferred ?? 0) + acc,
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
DefaultMap,
|
||||
FiltersMap,
|
||||
FormulaMap,
|
||||
ListViewSettings
|
||||
ListViewSettings,
|
||||
} from 'fyo/model/types';
|
||||
import { getDocStatusListColumn, getLedgerLinkAction } from 'models/helpers';
|
||||
import { LedgerPosting } from 'models/Transactional/LedgerPosting';
|
||||
@ -50,9 +50,32 @@ export class StockMovement extends Transfer {
|
||||
date: () => new Date(),
|
||||
};
|
||||
|
||||
static getListViewSettings(): ListViewSettings {
|
||||
static getListViewSettings(fyo: Fyo): ListViewSettings {
|
||||
return {
|
||||
columns: ['name', getDocStatusListColumn(), 'date', 'movementType'],
|
||||
columns: [
|
||||
'name',
|
||||
getDocStatusListColumn(),
|
||||
'date',
|
||||
{
|
||||
label: fyo.t`Movement Type`,
|
||||
fieldname: 'movementType',
|
||||
fieldtype: 'Select',
|
||||
size: 'small',
|
||||
render(doc) {
|
||||
const movementType = doc.movementType as MovementType;
|
||||
const label =
|
||||
{
|
||||
[MovementType.MaterialIssue]: fyo.t`Material Issue`,
|
||||
[MovementType.MaterialReceipt]: fyo.t`Material Receipt`,
|
||||
[MovementType.MaterialTransfer]: fyo.t`Material Transfer`,
|
||||
}[movementType] ?? '';
|
||||
|
||||
return {
|
||||
template: `<span>${label}</span>`,
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -130,10 +130,15 @@
|
||||
<hr />
|
||||
<div class="flex justify-between text-base m-4 gap-12">
|
||||
<div class="w-1/2 flex flex-col justify-between">
|
||||
<!-- Discount Note -->
|
||||
<!-- Info Note -->
|
||||
<p v-if="discountNote?.length" class="text-gray-600 text-sm">
|
||||
{{ discountNote }}
|
||||
</p>
|
||||
|
||||
<p v-if="stockTransferText?.length" class="text-gray-600 text-sm">
|
||||
{{ stockTransferText }}
|
||||
</p>
|
||||
|
||||
<!-- Form Terms-->
|
||||
<FormControl
|
||||
:border="true"
|
||||
@ -309,7 +314,6 @@ import { docsPathMap } from 'src/utils/misc';
|
||||
import {
|
||||
docsPath,
|
||||
getGroupedActionsForDoc,
|
||||
getStatus,
|
||||
routeTo,
|
||||
showMessageDialog,
|
||||
} from 'src/utils/ui';
|
||||
@ -355,6 +359,27 @@ export default {
|
||||
this.chstatus = !this.chstatus;
|
||||
},
|
||||
computed: {
|
||||
stockTransferText() {
|
||||
if (!this.fyo.singles.AccountingSettings.enableInventory) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!this.doc.submitted) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const totalQuantity = this.doc.getTotalQuantity();
|
||||
const stockNotTransferred = this.doc.stockNotTransferred;
|
||||
|
||||
if (stockNotTransferred === 0) {
|
||||
return this.t`Stock has been transferred`;
|
||||
}
|
||||
|
||||
const stn = this.fyo.format(stockNotTransferred, 'Float');
|
||||
const tq = this.fyo.format(totalQuantity, 'Float');
|
||||
|
||||
return this.t`Stock qty. ${stn} out of ${tq} left to transfer`;
|
||||
},
|
||||
groupedActions() {
|
||||
const actions = getGroupedActionsForDoc(this.doc);
|
||||
const group = this.t`View`;
|
||||
|
@ -46,7 +46,7 @@ import PageHeader from 'src/components/PageHeader.vue';
|
||||
import { fyo } from 'src/initFyo';
|
||||
import { docsPathMap } from 'src/utils/misc';
|
||||
import { docsPath, routeTo } from 'src/utils/ui';
|
||||
import List from './List';
|
||||
import List from './List.vue';
|
||||
|
||||
export default {
|
||||
name: 'ListView',
|
||||
|
@ -85,13 +85,23 @@ async function getInventorySidebar(): Promise<SidebarRoot[]> {
|
||||
route: '/list/PurchaseReceipt',
|
||||
schemaName: 'PurchaseReceipt',
|
||||
},
|
||||
{
|
||||
label: t`Stock Ledger`,
|
||||
name: 'stock-ledger',
|
||||
route: '/report/StockLedger',
|
||||
},
|
||||
{
|
||||
label: t`Stock Balance`,
|
||||
name: 'stock-balance',
|
||||
route: '/report/StockBalance',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async function getReportSidebar() {
|
||||
const reports = {
|
||||
return {
|
||||
label: t`Reports`,
|
||||
name: 'reports',
|
||||
icon: 'reports',
|
||||
@ -119,24 +129,6 @@ async function getReportSidebar() {
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const hasInventory = !!fyo.singles.AccountingSettings?.enableInventory;
|
||||
if (hasInventory) {
|
||||
reports.items.push(
|
||||
{
|
||||
label: t`Stock Ledger`,
|
||||
name: 'stock-ledger',
|
||||
route: '/report/StockLedger',
|
||||
},
|
||||
{
|
||||
label: t`Stock Balance`,
|
||||
name: 'stock-balance',
|
||||
route: '/report/StockBalance',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return reports;
|
||||
}
|
||||
|
||||
async function getCompleteSidebar(): Promise<SidebarConfig> {
|
||||
|
Loading…
Reference in New Issue
Block a user