Commit Graph

60635 Commits

Author SHA1 Message Date
Suhas Bharadwaj
e0b9351d49 fix: condition check with empty object for falsy case 2026-08-06 16:38:46 +05:30
rohitwaghchaure
a49fcfe888 fix: purchase return of batchwise valuation batch valued at original receipt rate instead of batch avg rate (#57835)
* fix: use current batch avg rate for outward returns of batchwise valuation batches

* fix: honor zero batch average and avoid duplicate batch classification query
2026-08-06 15:21:44 +05:30
Diptanil Saha
12359c36bc Merge pull request #57825 from diptanilsaha/st/72599/arpbmd/pinv
refactor(accounts)!: rework Purchase Invoice hold actions and enforce them on Journal Entry
2026-08-06 13:11:51 +05:30
diptanilsaha
1a8d438b21 test(journal_entry): added test cases for blocked purchase invoices 2026-08-06 12:31:00 +05:30
diptanilsaha
cbafa16fbc fix(journal_entry): validate blocked purchase invoices 2026-08-06 11:56:58 +05:30
diptanilsaha
6c33ede45c refactor(purchase_invoice): expose invoice hold actions as document methods 2026-08-06 11:18:46 +05:30
rohitwaghchaure
742e0e16cf fix: XSS through unescaped work order name in shop floor view (#57826) 2026-08-06 08:53:46 +05:30
MochaMind
1ffcfeb11b fix: sync translations from crowdin (#57743) 2026-08-05 15:13:07 +02:00
Henil Maru
8e8ef1602e fix(sales-invoice): respect Customize Form hidden setting on Update Stock (#57818)
set_dynamic_labels() unconditionally forced update_stock's hidden
property based only on is_debit_note/has_subcontracted, overwriting
whatever Customize Form had set on every refresh. OR it with the
field's original (property-setter-driven) hidden value instead.
2026-08-05 18:00:26 +05:30
rohitwaghchaure
d71fc3b774 feat: validate stock value and stock closing entry before period closing (#57811)
* feat: validate stock value and stock closing entry before period closing

* fix: do not accept scoped stock closing entries as period closing prerequisite

* feat: seed batch valuation from stock closing balance and freeze closed-period stock
2026-08-05 15:45:16 +05:30
Mihir Kandoi
8aadffa73c Merge pull request #57810 from aerele/fix/blanket-order-mapped-naming-series
fix: do not copy Blanket Order naming series to the mapped order
2026-08-05 14:12:11 +05:30
pandiyan
7620553418 test: assert mapped order keeps its own naming series 2026-08-05 13:03:10 +05:30
pandiyan
fe7128f02f fix: do not copy blanket order naming series to the mapped order
get_mapped_doc copies every same-named field that is not no_copy, so the
Sales Order / Purchase Order / Quotation created from a Blanket Order
inherited MFG-BLR-.YYYY.- and was named MFG-BLR-2026-00003 instead of
SAL-ORD-2026-00001.

exclude naming_series from the mapping, same as job card does when it
maps to a Purchase Order.
2026-08-05 13:03:10 +05:30
Mihir Kandoi
1f42eb1a3c Merge pull request #57793 from aerele/fix/blanket-order-zero-qty-validation
fix: validate Blanket Order item quantity is greater than zero
2026-08-05 12:11:48 +05:30
rohitwaghchaure
d3a8c329dd fix: incorrect batch-wise valuation rate for entries with same posting datetime (#57803)
fix: incorrect batch-wise valuation rate for entries with same posting datetime (#57794)

* fix: incorrect batch-wise valuation rate for entries with same posting datetime

The tie-breaker in get_batch_no_ledgers compared the bundle's creation
against the SLE's creation. These are different timelines - a bundle can
be created (drafted) much before its SLE (created at submission). For
entries sharing a posting datetime (backdated / amended vouchers), this
mis-ordered the entries against the ledger's replay order (SLE creation),
causing double counting or omission of batch qty / value and runaway
outgoing rates that no repost could heal.

Now the tie is broken using the creation of the bundle's own SLE (same
timeline on both sides). When the valuation runs through the bundle
before its SLE exists, the entry is by definition last in its timestamp
group, so all same-timestamp entries already in the ledger precede it.



* test: batch-wise valuation ordering for same posting datetime entries

Covers both tie-breaking branches of get_batch_no_ledgers:
- submission (pre-insertion) branch: same-timestamp inward at a different
  rate plus a multi-row outward voucher (same item and warehouse), at
  submission and after a backdated repost
- existing-SLE branch: a bundle created after its sibling's SLE, the
  ordering must follow the SLE creation and not the bundle creation

Both tests fail with the previous parent.creation < sle.creation
tie-breaker and pass with the fix.



---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 11:06:30 +05:30
Diptanil Saha
4d511a1521 chore(CODEOWNERS): add @nikkothari22 for banking (#57801) 2026-08-04 19:53:54 +00:00
Diptanil Saha
fc8e2e8627 Merge pull request #57734 from aerele/fix/payment-reconciliation-supplier-gain-loss-sign
fix(payment reconciliation): correct supplier gain/loss posting
2026-08-04 23:55:38 +05:30
Sudharsanan Ashok
0dbe410414 fix(stock): handle multi-item opening balance in Stock Ledger report (#57591)
* fix(stock): handle multi-item opening balance in Stock

* test(stock): add unit test for multi-item Stock Ledger report

---------

Co-authored-by: Afsal Syed <afsalsyed12@gmail.com>
2026-08-04 22:14:16 +05:30
R-Jayaraman
d80b0f67cc test: add regression test for zero quantity Blanket Order 2026-08-04 19:06:25 +05:30
R-Jayaraman
e897c4d82d fix: validate Blanket Order item quantity is greater than zero 2026-08-04 19:05:51 +05:30
Shllokkk
b9dafafeee Merge pull request #57790 from Shllokkk/warehouse-account-override-value-comparison
test: child warehouse account override in stock vs account value comparison
2026-08-04 17:30:28 +05:30
Shllokkk
ef7a3cb4c8 test: child warehouse account override excluded in stock vs account value comparison 2026-08-04 17:03:25 +05:30
Mihir Kandoi
afdb951eb4 Merge pull request #57757 from aerele/fix/opportunity-qty-validation
fix(opportunity): add validation for positive item quantities
2026-08-04 16:52:55 +05:30
R-Jayaraman
69de8f2d62 chore: use flt() in qty check 2026-08-04 16:38:49 +05:30
Mihir Kandoi
8b710ddbf1 Merge pull request #57772 from aerele/fix/party-dashboard-doctype-permission
fix(accounts): skip party dashboard without invoice permission
2026-08-04 16:33:30 +05:30
Jatin3128
0f428ed854 fix(subscription): don't reactivate a cancelled subscription (#57774)
* fix(subscription): don't reactivate a cancelled subscription

set_subscription_status() unconditionally set status to Active once
there was no outstanding invoice, even if the subscription had been
intentionally cancelled. Paying off an invoice issued before
cancellation (directly, or via the Payment Entry -> refresh hook)
flipped a Cancelled subscription back to Active while cancelation_date
stayed set.

process()'s cancel_at_period_end check compared posting_date against
getdate(self.end_date), and getdate(None) returns today, so an empty
end_date was silently treated as "cancel now" on every scheduler run.
Combined with the reactivation bug, this let a cancelled subscription
toggle Cancelled -> Active on each run and generate another invoice at
the next period boundary.

Fixes #57761

* fix(test): compare normalized dates in subscription cancellation test

cancelation_date read straight off an unsaved in-memory doc is a
string from nowdate(), but the same field comes back as a
datetime.date after reload(). Wrap both sides in getdate() so the
comparison isn't type-sensitive.
2026-08-04 15:59:44 +05:30
Mihir Kandoi
3dd01e5120 Merge pull request #57777 from mihir-kandoi/fix/bom-creator-toolbar-actions
fix(manufacturing): reach the whole configurator from tree toolbar actions
2026-08-04 15:38:28 +05:30
Mihir Kandoi
097ce0f348 fix(manufacturing): reach the whole configurator from tree toolbar actions
The toolbar handlers were copied onto view.events as unbound functions, so
`this` inside them was that object literal rather than the BOMConfigurator.
They worked only because the literal also carried `frm`, and broke as soon as
a handler called a method the literal did not list: get_item_code, added when
the tree started keying nodes on the row name, threw
"this.get_item_code is not a function" and killed Add Raw Material, Add Sub
Assembly and Convert to Sub Assembly.

Assign the instance instead of a hand-maintained whitelist. Every method is
reachable, `this.frm` keeps working, and no future method can be forgotten.

Fixes #57773
2026-08-04 15:34:59 +05:30
Diptanil Saha
9ce32fc1da fix(sales_invoice): enable repost on account change of account in payments (#57775) 2026-08-04 09:52:28 +00:00
Sudharsanan11
ed78dd37be fix(accounts): skip party dashboard without invoice permission 2026-08-04 14:10:55 +05:30
Jatin3128
c1717d8689 fix: keep source rate on re-fetch when maintain same rate is enabled (#57479)
* fix: keep source rate on re-fetch when maintain same rate is enabled

With "maintain same rate" on, re-fetching item details on a row mapped from a
source document (e.g. a Purchase Order) pulled the latest Item Price, giving a
rate the document can never be saved with. Skip the price list fetch for such
rows and keep the source rate.

Fixes frappe/erpnext#57436

* fix: keep source rate on bulk apply_price_list when maintain same rate is on

The single-row re-fetch guard skipped the bulk apply_price_list path, so
changing the price list, party, or conversion rate on a mapped transaction
re-fetched current Item Prices and overwrote the mapped rates, breaking the
maintain-same-rate check on save.

Guard apply_price_list_on_item with the same source-row lookup, and resolve the
parent doctype via ctx.parenttype since the bulk path carries the child doctype
in ctx.doctype.

* fix: preserve full source pricing on rate-locked rows

Restoring only price_list_rate on a mapped row dropped any manual discount or
margin, so re-running pricing produced a rate that differed from the source and
still failed the maintain-same-rate check on save.

Copy the source row's whole pricing block (rate, discount, margin) and skip
pricing rules for locked rows, in both get_item_details and the bulk
apply_price_list path.

* fix: pass child_docname in server bulk price apply so the rate lock is reachable

The server-side _apply_price_list builds its item ctx from as_dict(), which omits
the child_docname key the desk (JS) callers add, so the maintain-same-rate lock in
apply_price_list could not match rows in that path. Pass child_docname for
consistency with the desk callers.

* test: cover maintain-same-rate preservation on re-fetch of a discounted row

Reproduces the end-to-end symptom: a mapped Purchase Receipt row with a source
discount (rate != price_list_rate) keeps its rate after a re-fetch, so the
document saves under maintain-same-rate. Covers percentage and amount discounts
via process_item_selection, the server recompute the desk mirrors.

* fix: read the locked rate from the persisted source row

get_rate_locked_source_row returned the mutable target row, so an unsaved rate or
discount edit on a mapped row was preserved on re-fetch instead of the source
pricing, and the document still failed maintain-same-rate on save. Read the
pricing straight from the linked source row in the database, and cover the
edit-then-refresh case with a test.

* fix: permission-check the source row before returning its rate

The rate lock reads the linked source row with a direct db.get_value, which
bypasses permissions on a whitelisted endpoint. Only return the source pricing
when the caller can read the source document, so a crafted request cannot
disclose another document's rate. Covered by a test.

* fix: import make_purchase_receipt from its current mapper module

make_purchase_receipt moved from purchase_order.py to
purchase_order/mapper.py in a develop refactor pulled in by this
branch's merge commit. Two tests added afterwards still imported it
from the old path, failing CI with an ImportError.

* fix: Simplify source retrieval logic in get_item_details

Removed permission check for source parent in get_item_details.py.

* Revert "fix: Simplify source retrieval logic in get_item_details"

This reverts commit 58863805bd.
2026-08-04 13:28:57 +05:30
Khushi Rawat
8cefaa355c Merge pull request #57539 from harisansari008/fix/dunning-timestamp-mismatch-multi-installment
fix: prevent TimestampMismatchError resolving Dunning with multiple overdue installments
2026-08-04 13:02:44 +05:30
Diptanil Saha
4255df05cd Merge pull request #57742 from diptanilsaha/fix/escape_data_in_templates
fix: escape data in multiple templates
2026-08-04 12:11:43 +05:30
ruthra kumar
bca3889f97 Merge pull request #57719 from krishna-254/fix/reversal-journal-entry-custom-remark
Fix/reversal journal entry custom remark
2026-08-04 10:59:46 +05:30
Krishna Shirsath
5e0e9ba668 fix: allow custom remark on reversal journal entry 2026-08-03 17:16:09 +05:30
Mihir Kandoi
e8b16a4228 Merge pull request #57754 from mihir-kandoi/fix/isolate-disabled-attribute-test-fixtures
test: isolate the disabled item attribute test fixtures
2026-08-03 17:01:24 +05:30
Mihir Kandoi
ae6749470f test(stock): isolate the disabled attribute fixtures
The test disabled the shared `Test Size` Item Attribute. On version-15
`FrappeTestCase` rolls back once per class instead of once per test, so the
flag stayed visible for the rest of `TestItem` and broke the seven tests that
build a variant from that attribute.

Build a dedicated attribute and template instead. Nothing the test writes is
reachable from another test, on either branch, so no cleanup is needed.
2026-08-03 16:43:07 +05:30
R-Jayaraman
c47cc37441 fix(opportunity): add validation for positive item quantities 2026-08-03 16:41:43 +05:30
Mihir Kandoi
8db8c6a83d fix(stock): allocate secondary item cost from the consumption entry (#57738)
* fix(stock): allocate secondary item cost from the consumption entry

A secondary item's rate is its BOM share of the cost of the consumed
rows. With Get RM Cost From Consumption Entry enabled the consumption
happens in a separate document, so the Manufacture entry carries no
consumed rows and that cost is zero. The share evaluated to zero, and the
row fell through to the item's own valuation rate.

Only the finished good substituted the consumption entry's cost. Against
a consumption entry of 1000 and a BOM allocating 75% to the finished good
and 25% to scrap, the finished good took its 750 while the scrap took an
unrelated valuation of 100, booking 850 for 1000 consumed.

Derive the allocation base once and use it for both sides.

* test(stock): cover secondary allocation against a consumption entry

A consumption entry of 1000 splits into 750 and 250 by the BOM's shares.
2026-08-03 10:58:23 +00:00
Mihir Kandoi
aef69202ea Merge pull request #57747 from mihir-kandoi/fix/disabled-attribute-blocks-variant-edits
fix: disabled item attribute blocks unrelated edits to existing variants
2026-08-03 16:16:24 +05:30
diptanilsaha
3df596d84e fix: escape data on stock_summary_template 2026-08-03 16:16:07 +05:30
diptanilsaha
10c439ff01 fix: escape item name and item title on item_selector 2026-08-03 16:16:07 +05:30
diptanilsaha
2d387002d9 fix(workstation): escape data on get_workstations 2026-08-03 16:15:59 +05:30
Mihir Kandoi
7d901ed92c fix(stock): treat a 0% BOM cost allocation as no cost (#57736)
* fix(stock): treat a 0% BOM cost allocation as no cost

A BOM splits its raw material cost between the finished good and its
secondary items, and validate_total_cost_allocation holds the two to
100%. An allocation of 0% therefore means the finished good takes
everything and the secondary item carries no cost.

The code read it as no allocation at all. A cost_allocation_per of 0 is
falsy, so the branch was skipped, the row kept a rate of zero, and the
fallback below handed it the item's own valuation rate. Producing 1000 of
raw material into a finished good at 100% and scrap at 0% booked 1000 to
the finished good and another 100 to the scrap.

Apply the BOM's share whatever it is, and mark the rate as derived so the
valuation fallback leaves a deliberate zero alone. rate_derived_from_consumption
becomes has_derived_rate, since it now guards more than the consumption case.

* test(stock): cover a secondary item allocated 0% of the cost

The finished good takes the full 1000 and the scrap row is worth nothing.
2026-08-03 10:42:24 +00:00
Mihir Kandoi
8d5326196e test(stock): cover editing a variant whose attribute is disabled
Assert that a variant saves after its attribute is disabled when the edit
leaves the attribute rows alone, and that changing an attribute value still
throws.
2026-08-03 16:00:27 +05:30
Mihir Kandoi
25cd793617 fix(stock): validate only the variant attributes that changed
Disabling an Item Attribute writes `disabled = 1` into every Item Variant
Attribute row, including the rows on the template. `validate_variant` runs
on every save and walks the whole attribute table, so any later save of an
existing variant re-checked its untouched rows against the now-disabled
template row and threw. `update_variants` hit the same wall, which made a
single template save fail once an attribute was disabled.

The flag exists to keep an attribute out of new variants, not to freeze the
variants that already use it. item.js only reads it to drop the attribute
from the variant creation dialog.

Skip rows that are unchanged since the last save. New and edited rows are
still checked, so a disabled attribute cannot be added to an existing
variant, and the same guard covers the sibling checks for attributes and
values that the template no longer offers.
2026-08-03 15:57:35 +05:30
Mihir Kandoi
7886bd2cab fix(stock): stop treating a Repack secondary item as a finished good (#57735)
* fix(stock): stop treating a Repack secondary item as a finished good

mark_finished_and_secondary_items flagged every incoming Repack row as a
finished item, secondary rows included. Two things followed from that.
The row never reached the secondary-item branch in _set_incoming_item_rate,
so its own cost_allocation_per was never applied, and the BOM's
finished-good percentage was applied to every incoming row rather than
to the finished good alone.

Value was destroyed as a result. Repacking 1000 of raw material under a
BOM that allocates 75% to the finished good and 25% to scrap booked 500
to the finished good and 250 to the scrap: 750 in against 1000 out.

Leave secondary rows unflagged so each side takes the share the BOM
declares.

* test(stock): cover cost allocation for a Repack secondary item

A BOM allocating 75% to the finished good and 25% to scrap must split
1000 of raw material into 750 and 250, leaving no difference.
2026-08-03 10:19:09 +00:00
Mihir Kandoi
be3df759f1 Merge pull request #57732 from mihir-kandoi/fix/secondary-item-without-bom-balances-manufacture
fix(stock): cost a BOM-less secondary item out of the finished good
2026-08-03 15:22:16 +05:30
Mihir Kandoi
7f47361ebd test(stock): cover a secondary item added without a BOM
A Manufacture entry with a raw material worth 1000, a finished good and a
Scrap row typed in the UI must value the scrap at its own rate and take
that value out of the finished good, leaving no difference.
2026-08-03 15:01:08 +05:30
Mihir Kandoi
5e81cd1540 fix(stock): cost a BOM-less secondary item out of the finished good
The legacy scrap checkbox deducted the scrap row's value from the
finished good, so a Manufacture entry balanced. Its replacement, the
Secondary Item Type dropdown, only balances when the row carries a BOM
Secondary Item link, because the cost allocation percentage lives there.
A row typed as Scrap in the UI has no such link, so its value was added
on top of a finished good that already absorbed the whole raw material
cost, and the entry closed with a non-zero difference.

Treat a secondary row with no BOM link the way the legacy scrap item was
treated: deduct its value from the finished good.

The finished good's rate is derived from the other incoming rows, so
those rows must be rated first. Previously the finished good was rated
in row order, ahead of the secondary rows, and picked up their amounts
only on a later validate pass. Rate the finished goods last so a single
pass is correct.
2026-08-03 15:00:41 +05:30